Skip to content

Commit 52eef65

Browse files
committed
Combine Si470x reset with display reset
1 parent a91c611 commit 52eef65

14 files changed

+41
-79
lines changed

Diff for: Makefile

-5
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ ifeq "$(findstring LC72131, $(TUNER_LIST))" "LC72131"
9191
endif
9292
ifeq "$(findstring SI470X, $(TUNER_LIST))" "SI470X"
9393
SRCS += tuner/si470x.c
94-
HARDWARE_RST = "YES"
9594
endif
9695
DEFINES += $(addprefix -D_, $(TUNER_LIST))
9796

@@ -116,10 +115,6 @@ ifeq "$(findstring YES, $(SOFTWARE_SPI))" "YES"
116115
DEFINES += -D_SPISW
117116
endif
118117

119-
ifeq "$(findstring YES, $(HARDWARE_RST))" "YES"
120-
DEFINES += -D_HARDWARE_RST
121-
endif
122-
123118
# Build directory
124119
BUILDDIR = build
125120

Diff for: ampcontrol-m32.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@
2323
#define _TEMPCONTROL
2424
#define _UARTCONTROL
2525
#define _RDS
26-
#define _HARDWARE_RST
2726
#define _ALARM
27+
#define _SPISW

Diff for: display/ks0066.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@
7979
#define KS0066_MAX_BRIGHTNESS 32
8080

8181
// Functions
82-
void ks0066Clear();
83-
void ks0066Init();
82+
void ks0066Clear(void);
83+
void ks0066Init(void);
8484

8585
void ks0066SelectSymbol(uint8_t num);
8686
void ks0066SetXY(uint8_t x, uint8_t y);

Diff for: display/ks0108.c

-9
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,6 @@ void ks0108Init()
189189
CLR(KS0108_DI);
190190
CLR(KS0108_E);
191191

192-
// Hardware reset
193-
#ifdef _atmega32
194-
OUT(KS0108_RES);
195-
CLR(KS0108_RES);
196-
_delay_us(1);
197-
SET(KS0108_RES);
198-
_delay_us(1);
199-
#endif
200-
201192
// Init first controller
202193
KS0108_SET_CS1();
203194
ks0108WriteCmd(KS0108_DISPLAY_START_LINE);

Diff for: display/ks0108.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434

3535
void ks0108SetBrightness(uint8_t br);
3636

37-
void ks0108Init();
38-
void ks0108Clear();
37+
void ks0108Init(void);
38+
void ks0108Clear(void);
3939

4040
void ks0108DrawPixel(uint8_t x, uint8_t y, uint8_t color);
4141

42-
uint8_t ks0108GetPins();
42+
uint8_t ks0108GetPins(void);
4343

4444
#endif // KS0108_H

Diff for: display/ls020.c

-7
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,6 @@ void ls020Init()
178178
SPCR = (1 << SPE) | (1 << MSTR);
179179
SPSR = (1 << SPI2X);
180180

181-
CLR(LS020_CS);
182-
183-
// Reset display
184-
CLR(LS020_RES);
185-
_delay_ms(5);
186-
SET(LS020_RES);
187-
188181
// Set command mode
189182
SET(LS020_RS);
190183

Diff for: display/ls020.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ enum {
5353

5454
void ls020SetBrightness(uint8_t br);
5555

56-
void ls020Init();
56+
void ls020Init(void);
5757

58-
void ls020PowerOff ();
58+
void ls020PowerOff(void);
5959

6060
void ls020DrawRect(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t color);
6161
void ls020DrawFrame(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t color);
6262
#define ls020DrawVertLine(x, y1 ,y2, color) ls020DrawRect(x, y1, x, y2, color)
6363
#define ls020DrawHorizLine(x1, y, x2, color) ls020DrawRect(x1, y, x2, y, color)
6464
#define ls020DrawPixel(x, y,color) ls020DrawRect(x, y, x, y, color)
6565

66-
void ls020Clear();
66+
void ls020Clear(void);
6767

6868
void ls020SetXY(uint8_t x, uint8_t y);
6969
uint8_t ls020GetX();

Diff for: display/ssd1306.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@
115115
#define SSD1306_MIN_BRIGHTNESS 0
116116
#define SSD1306_MAX_BRIGHTNESS 32
117117

118-
uint8_t ssd1306GetPins();
118+
uint8_t ssd1306GetPins(void);
119119

120-
void ssd1306UpdateFb();
120+
void ssd1306UpdateFb(void);
121121

122-
void ssd1306Init();
122+
void ssd1306Init(void);
123123
void ssd1306DrawPixel(uint8_t x, uint8_t y, uint8_t color);
124-
void ssd1306Clear();
124+
void ssd1306Clear(void);
125125

126126
void ssd1306SetBrightness(uint8_t br);
127127

Diff for: display/st7920.c

-8
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,6 @@ void st7920Init()
161161
// Switch display to parallel mode
162162
SET(ST7920_PSB);
163163

164-
// Hardware reset
165-
#ifdef _atmega32
166-
OUT(ST7920_RST);
167-
CLR(ST7920_RST);
168-
_delay_us(1);
169-
SET(ST7920_RST);
170-
#endif
171-
172164
// Init display in graphics mode
173165
_delay_ms(40);
174166
st7920WriteCmd(ST7920_FUNCTION | ST7920_8BIT);

Diff for: display/st7920.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@
5050

5151
void st7920SetBrightness(uint8_t br);
5252

53-
void st7920Init();
54-
void st7920Clear();
53+
void st7920Init(void);
54+
void st7920Clear(void);
5555

5656
void st7920DrawPixel(uint8_t x, uint8_t y, uint8_t color);
5757

58-
uint8_t st7920GetPins();
58+
uint8_t st7920GetPins(void);
5959

6060
#endif // ST7920_H

Diff for: main.c

+19-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <avr/interrupt.h>
22
#include <avr/eeprom.h>
3+
#include <util/delay.h>
34

45
#include "eeprom.h"
56
#include "adc.h"
@@ -24,9 +25,27 @@
2425
#include "spisw.h"
2526
#endif
2627

28+
void hwReset()
29+
{
30+
OUT(DISP_RESET);
31+
IN(I2C_SCL);
32+
SET(I2C_SCL);
33+
_delay_ms(1);
34+
OUT(I2C_SDA);
35+
36+
CLR(I2C_SDA);
37+
CLR(DISP_RESET);
38+
_delay_ms(5);
39+
SET(DISP_RESET);
40+
IN(I2C_SDA);
41+
_delay_ms(1);
42+
}
43+
2744
// Hardware initialization
2845
static void hwInit(uint8_t extFunc)
2946
{
47+
hwReset();
48+
3049
#ifdef _TEMPCONTROL
3150
loadTempParams();
3251
#endif
@@ -43,11 +62,6 @@ static void hwInit(uint8_t extFunc)
4362
}
4463
#endif
4564
}
46-
#ifdef _HARDWARE_RST
47-
#ifdef _SI470X
48-
si470xReset();
49-
#endif
50-
#endif
5165

5266
I2CInit(); // I2C bus
5367
displayInit(); // Load params and text labels before fb scan started

Diff for: pins.h

+3-8
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
#define DISP_CTRL1_LINE (1<<4)
7979
#define DISP_CTRL2 D
8080
#define DISP_CTRL2_LINE (1<<3)
81-
#define DISP_RESET C
81+
#define DISP_RESET D
8282
#define DISP_RESET_LINE (1<<1)
8383
// Display backlight port
8484
#define DISP_BCKL D
@@ -286,13 +286,8 @@ enum {
286286
#define SI470X_B_SDIO_LINE I2C_SDA_LINE
287287
#define SI470X_B_SCLK I2C_SCL
288288
#define SI470X_B_SCLK_LINE I2C_SCL_LINE
289-
#if defined(_atmega32)
290-
#define SI470X_B_RST EXT_2
291-
#define SI470X_B_RST_LINE EXT_2_LINE
292-
#elif defined(_atmega328p)
293-
#define SI470X_B_RST D
294-
#define SI470X_B_RST_LINE (1<<1)
295-
#endif
289+
#define SI470X_B_RST DISP_RESET
290+
#define SI470X_B_RST_LINE DISP_RESET_LINE
296291

297292
// SSD1306 port
298293
#define SSD1306_SCK DISP_STROB

Diff for: tuner/si470x.c

-16
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,6 @@ static void initRegs()
3636
I2CStop();
3737
}
3838

39-
void si470xReset()
40-
{
41-
OUT(SI470X_B_RST);
42-
IN(SI470X_B_SCLK);
43-
SET(SI470X_B_SCLK);
44-
_delay_ms(1);
45-
OUT(SI470X_B_SDIO);
46-
47-
CLR(SI470X_B_SDIO);
48-
CLR(SI470X_B_RST);
49-
_delay_ms(1);
50-
SET(SI470X_B_RST);
51-
IN(SI470X_B_SDIO);
52-
_delay_ms(1);
53-
}
54-
5539
void si470xInit()
5640
{
5741
initRegs();

Diff for: tuner/si470x.h

+3-5
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,11 @@
130130
#define SI470X_VOL_MIN 0
131131
#define SI470X_VOL_MAX 15
132132

133-
void si470xReset();
133+
void si470xInit(void);
134134

135-
void si470xInit();
135+
void si470xSetFreq(void);
136136

137-
void si470xSetFreq();
138-
139-
void si470xReadStatus();
137+
void si470xReadStatus(void);
140138

141139
void si470xSetVolume(int8_t value);
142140
void si470xSetMute(uint8_t value);

0 commit comments

Comments
 (0)