diff options
-rw-r--r-- | firmware/SOURCES | 1 | ||||
-rw-r--r-- | firmware/export/config-cowond2.h | 10 | ||||
-rw-r--r-- | firmware/target/arm/tcc780x/cowond2/backlight-cowond2.c | 56 | ||||
-rw-r--r-- | firmware/target/arm/tcc780x/cowond2/backlight-target.h | 21 | ||||
-rw-r--r-- | firmware/target/arm/tcc780x/cowond2/lcd-cowond2.c | 26 |
5 files changed, 69 insertions, 45 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES index fa2222e7d0..3864a3478b 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -911,6 +911,7 @@ target/arm/tcc780x/cowond2/lcd-cowond2.c | |||
911 | target/arm/tcc780x/cowond2/power-cowond2.c | 911 | target/arm/tcc780x/cowond2/power-cowond2.c |
912 | target/arm/tcc780x/cowond2/powermgmt-cowond2.c | 912 | target/arm/tcc780x/cowond2/powermgmt-cowond2.c |
913 | target/arm/tcc780x/cowond2/usb-cowond2.c | 913 | target/arm/tcc780x/cowond2/usb-cowond2.c |
914 | target/arm/tcc780x/cowond2/backlight-cowond2.c | ||
914 | #ifndef BOOTLOADER | 915 | #ifndef BOOTLOADER |
915 | target/arm/tcc780x/kernel-tcc780x.c | 916 | target/arm/tcc780x/kernel-tcc780x.c |
916 | target/arm/tcc780x/timer-tcc780x.c | 917 | target/arm/tcc780x/timer-tcc780x.c |
diff --git a/firmware/export/config-cowond2.h b/firmware/export/config-cowond2.h index a2a1775500..1eef8f8ee5 100644 --- a/firmware/export/config-cowond2.h +++ b/firmware/export/config-cowond2.h | |||
@@ -89,13 +89,13 @@ | |||
89 | /* Define this for LCD backlight available */ | 89 | /* Define this for LCD backlight available */ |
90 | #define HAVE_BACKLIGHT | 90 | #define HAVE_BACKLIGHT |
91 | 91 | ||
92 | /* TODO: Enable LCD brightness control */ | 92 | /* Enable LCD brightness control */ |
93 | //#define HAVE_BACKLIGHT_BRIGHTNESS | 93 | #define HAVE_BACKLIGHT_BRIGHTNESS |
94 | 94 | ||
95 | /* Main LCD backlight brightness range and defaults */ | 95 | /* Main LCD backlight brightness range and defaults */ |
96 | //#define MIN_BRIGHTNESS_SETTING 1 | 96 | #define MIN_BRIGHTNESS_SETTING 1 |
97 | //#define MAX_BRIGHTNESS_SETTING 10 | 97 | #define MAX_BRIGHTNESS_SETTING 14 |
98 | //#define DEFAULT_BRIGHTNESS_SETTING 8 | 98 | #define DEFAULT_BRIGHTNESS_SETTING 8 |
99 | 99 | ||
100 | #define CONFIG_I2C I2C_TCC780X | 100 | #define CONFIG_I2C I2C_TCC780X |
101 | 101 | ||
diff --git a/firmware/target/arm/tcc780x/cowond2/backlight-cowond2.c b/firmware/target/arm/tcc780x/cowond2/backlight-cowond2.c new file mode 100644 index 0000000000..07286bdd09 --- /dev/null +++ b/firmware/target/arm/tcc780x/cowond2/backlight-cowond2.c | |||
@@ -0,0 +1,56 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 by Rob Purchase | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "backlight-target.h" | ||
20 | #include "system.h" | ||
21 | #include "backlight.h" | ||
22 | #include "pcf50606.h" | ||
23 | #include "tcc780x.h" | ||
24 | |||
25 | static unsigned short backlight_brightness = DEFAULT_BRIGHTNESS_SETTING; | ||
26 | |||
27 | int _backlight_init(void) | ||
28 | { | ||
29 | _backlight_set_brightness(DEFAULT_BRIGHTNESS_SETTING); | ||
30 | return true; | ||
31 | } | ||
32 | |||
33 | void _backlight_set_brightness(int brightness) | ||
34 | { | ||
35 | backlight_brightness = brightness; | ||
36 | |||
37 | int level = disable_irq_save(); | ||
38 | pcf50606_write(PCF5060X_PWMC1, 0xe1 | (14-backlight_brightness)<<1); | ||
39 | pcf50606_write(PCF5060X_GPOC1, 0x3); | ||
40 | restore_irq(level); | ||
41 | |||
42 | if (brightness > 0) | ||
43 | _backlight_on(); | ||
44 | else | ||
45 | _backlight_off(); | ||
46 | } | ||
47 | |||
48 | void _backlight_on(void) | ||
49 | { | ||
50 | GPIOA_SET = (1<<6); | ||
51 | } | ||
52 | |||
53 | void _backlight_off(void) | ||
54 | { | ||
55 | GPIOA_CLEAR = (1<<6); | ||
56 | } | ||
diff --git a/firmware/target/arm/tcc780x/cowond2/backlight-target.h b/firmware/target/arm/tcc780x/cowond2/backlight-target.h index 0563fc20f5..0ddff85544 100644 --- a/firmware/target/arm/tcc780x/cowond2/backlight-target.h +++ b/firmware/target/arm/tcc780x/cowond2/backlight-target.h | |||
@@ -19,22 +19,9 @@ | |||
19 | #ifndef BACKLIGHT_TARGET_H | 19 | #ifndef BACKLIGHT_TARGET_H |
20 | #define BACKLIGHT_TARGET_H | 20 | #define BACKLIGHT_TARGET_H |
21 | 21 | ||
22 | #include "tcc780x.h" | 22 | int _backlight_init(void); |
23 | 23 | void _backlight_on(void); | |
24 | #define _backlight_init() true | 24 | void _backlight_off(void); |
25 | 25 | void _backlight_set_brightness(int brightness); | |
26 | /* nb: we can set the backlight intensity using PCF50606 register 0x35 */ | ||
27 | |||
28 | static inline void _backlight_on(void) | ||
29 | { | ||
30 | /* Enable backlight */ | ||
31 | GPIOA_SET = (1<<6); | ||
32 | } | ||
33 | |||
34 | static inline void _backlight_off(void) | ||
35 | { | ||
36 | /* Disable backlight */ | ||
37 | GPIOA_CLEAR = (1<<6); | ||
38 | } | ||
39 | 26 | ||
40 | #endif | 27 | #endif |
diff --git a/firmware/target/arm/tcc780x/cowond2/lcd-cowond2.c b/firmware/target/arm/tcc780x/cowond2/lcd-cowond2.c index 54466f428b..8a268db4cc 100644 --- a/firmware/target/arm/tcc780x/cowond2/lcd-cowond2.c +++ b/firmware/target/arm/tcc780x/cowond2/lcd-cowond2.c | |||
@@ -23,7 +23,6 @@ | |||
23 | #include "lcd.h" | 23 | #include "lcd.h" |
24 | #include "system.h" | 24 | #include "system.h" |
25 | #include "cpu.h" | 25 | #include "cpu.h" |
26 | #include "i2c.h" | ||
27 | 26 | ||
28 | /* GPIO A pins for LCD panel SDI interface */ | 27 | /* GPIO A pins for LCD panel SDI interface */ |
29 | 28 | ||
@@ -100,16 +99,6 @@ static void lcd_write_reg(unsigned char reg, unsigned short val) | |||
100 | } | 99 | } |
101 | 100 | ||
102 | 101 | ||
103 | /* TODO: The existing pcf50606 drivers are target-specific, so the following | ||
104 | lonely function exists until a D2 driver exists. */ | ||
105 | |||
106 | void pcf50606_write_reg(unsigned char reg, unsigned char val) | ||
107 | { | ||
108 | unsigned char data[] = { reg, val }; | ||
109 | i2c_write(0x10, data, 2); | ||
110 | } | ||
111 | |||
112 | |||
113 | /* | 102 | /* |
114 | TEMP: Rough millisecond delay routine used by the LCD panel init sequence. | 103 | TEMP: Rough millisecond delay routine used by the LCD panel init sequence. |
115 | PCK_TCT must first have been initialised to 2Mhz by calling clock_init(). | 104 | PCK_TCT must first have been initialised to 2Mhz by calling clock_init(). |
@@ -190,9 +179,6 @@ static void lcd_display_on(void) | |||
190 | lcd_write_reg(10, 0x111F); | 179 | lcd_write_reg(10, 0x111F); |
191 | sleep_ms(10); | 180 | sleep_ms(10); |
192 | 181 | ||
193 | pcf50606_write_reg(0x35, 0xe9); /* PWMC1 - backlight power (intensity) */ | ||
194 | pcf50606_write_reg(0x38, 0x3); /* GPOC1 - ? */ | ||
195 | |||
196 | /* tell that we're on now */ | 182 | /* tell that we're on now */ |
197 | display_on = true; | 183 | display_on = true; |
198 | } | 184 | } |
@@ -213,9 +199,6 @@ static void lcd_display_off(void) | |||
213 | 199 | ||
214 | /* kill power to LCD panel (unconfirmed) */ | 200 | /* kill power to LCD panel (unconfirmed) */ |
215 | GPIOA_CLEAR = (1<<16); | 201 | GPIOA_CLEAR = (1<<16); |
216 | |||
217 | /* also kill the backlight, otherwise LCD fade is visible on screen */ | ||
218 | GPIOA_CLEAR = (1<<6); | ||
219 | } | 202 | } |
220 | 203 | ||
221 | 204 | ||
@@ -226,14 +209,14 @@ void lcd_enable(bool on) | |||
226 | 209 | ||
227 | if (on) | 210 | if (on) |
228 | { | 211 | { |
212 | lcd_display_on(); | ||
229 | LCDC_CTRL |= 1; /* controller enable */ | 213 | LCDC_CTRL |= 1; /* controller enable */ |
230 | GPIOA_SET = (1<<6); /* backlight enable - not visible otherwise */ | ||
231 | lcd_update(); /* Resync display */ | 214 | lcd_update(); /* Resync display */ |
232 | } | 215 | } |
233 | else | 216 | else |
234 | { | 217 | { |
235 | LCDC_CTRL &= ~1; /* controller disable */ | 218 | LCDC_CTRL &= ~1; /* controller disable */ |
236 | GPIOA_CLEAR = (1<<6); /* backlight off */ | 219 | lcd_display_off(); |
237 | } | 220 | } |
238 | } | 221 | } |
239 | 222 | ||
@@ -290,9 +273,6 @@ void lcd_init_device(void) | |||
290 | 273 | ||
291 | /* enable LTV250QV panel */ | 274 | /* enable LTV250QV panel */ |
292 | lcd_display_on(); | 275 | lcd_display_on(); |
293 | |||
294 | /* turn on the backlight, without it the LCD is not visible at all */ | ||
295 | GPIOA_SET = (1<<6); | ||
296 | } | 276 | } |
297 | 277 | ||
298 | 278 | ||