diff options
-rw-r--r-- | apps/debug_menu.c | 160 | ||||
-rw-r--r-- | apps/lang/english.lang | 6 | ||||
-rw-r--r-- | apps/settings_list.c | 2 | ||||
-rw-r--r-- | firmware/backlight.c | 3 | ||||
-rw-r--r-- | firmware/drivers/power.c | 14 | ||||
-rw-r--r-- | firmware/drivers/rtc/rtc_s3c2440.c | 12 | ||||
-rw-r--r-- | firmware/export/config-gigabeat.h | 4 | ||||
-rw-r--r-- | firmware/target/arm/s3c2440/gigabeat-fx/ata-meg-fx.c | 10 | ||||
-rw-r--r-- | firmware/target/arm/s3c2440/gigabeat-fx/backlight-meg-fx.c | 679 | ||||
-rw-r--r-- | firmware/target/arm/s3c2440/gigabeat-fx/backlight-target.h | 42 | ||||
-rw-r--r-- | firmware/target/arm/s3c2440/gigabeat-fx/button-meg-fx.c | 14 | ||||
-rw-r--r-- | firmware/target/arm/s3c2440/gigabeat-fx/sc606-meg-fx.c | 201 | ||||
-rw-r--r-- | firmware/target/arm/s3c2440/gigabeat-fx/system-meg-fx.c | 7 | ||||
-rw-r--r-- | firmware/target/arm/s3c2440/gigabeat-fx/usb-meg-fx.c | 12 |
14 files changed, 299 insertions, 867 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 0176b7405d..9e654b1d45 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -1132,7 +1132,7 @@ bool dbg_ports(void) | |||
1132 | return false; | 1132 | return false; |
1133 | } | 1133 | } |
1134 | #elif CONFIG_CPU == S3C2440 | 1134 | #elif CONFIG_CPU == S3C2440 |
1135 | char buf[128]; | 1135 | char buf[50]; |
1136 | int line; | 1136 | int line; |
1137 | 1137 | ||
1138 | lcd_setmargins(0, 0); | 1138 | lcd_setmargins(0, 0); |
@@ -1142,28 +1142,36 @@ bool dbg_ports(void) | |||
1142 | while(1) | 1142 | while(1) |
1143 | { | 1143 | { |
1144 | line = 0; | 1144 | line = 0; |
1145 | snprintf(buf, sizeof(buf), "GPACON: %08x GPBCON: %08x", GPACON, GPBCON); lcd_puts(0, line++, buf); | 1145 | snprintf(buf, sizeof(buf), "[Ports and Registers]"); lcd_puts(0, line++, buf); |
1146 | snprintf(buf, sizeof(buf), "GPADAT: %08x GPBDAT: %08x", GPADAT, GPBDAT); lcd_puts(0, line++, buf); | 1146 | |
1147 | snprintf(buf, sizeof(buf), "GPAUP: %08x GPBUP: %08x", 0, GPBUP); lcd_puts(0, line++, buf); | 1147 | snprintf(buf, sizeof(buf), "GPACON: %08x GPBCON: %08x", GPACON, GPBCON); lcd_puts(0, line++, buf); |
1148 | snprintf(buf, sizeof(buf), "GPCCON: %08x GPDCON: %08x", GPCCON, GPDCON); lcd_puts(0, line++, buf); | 1148 | snprintf(buf, sizeof(buf), "GPADAT: %08x GPBDAT: %08x", GPADAT, GPBDAT); lcd_puts(0, line++, buf); |
1149 | snprintf(buf, sizeof(buf), "GPCDAT: %08x GPDDAT: %08x", GPCDAT, GPDDAT); lcd_puts(0, line++, buf); | 1149 | snprintf(buf, sizeof(buf), "GPAUP: %08x GPBUP: %08x", 0, GPBUP); lcd_puts(0, line++, buf); |
1150 | snprintf(buf, sizeof(buf), "GPCUP: %08x GPDUP: %08x", GPCUP, GPDUP); lcd_puts(0, line++, buf); | 1150 | snprintf(buf, sizeof(buf), "GPCCON: %08x GPDCON: %08x", GPCCON, GPDCON); lcd_puts(0, line++, buf); |
1151 | 1151 | snprintf(buf, sizeof(buf), "GPCDAT: %08x GPDDAT: %08x", GPCDAT, GPDDAT); lcd_puts(0, line++, buf); | |
1152 | snprintf(buf, sizeof(buf), "GPCCON: %08x GPDCON: %08x", GPCCON, GPDCON); lcd_puts(0, line++, buf); | 1152 | snprintf(buf, sizeof(buf), "GPCUP: %08x GPDUP: %08x", GPCUP, GPDUP); lcd_puts(0, line++, buf); |
1153 | snprintf(buf, sizeof(buf), "GPCDAT: %08x GPDDAT: %08x", GPCDAT, GPDDAT); lcd_puts(0, line++, buf); | 1153 | |
1154 | snprintf(buf, sizeof(buf), "GPCUP: %08x GPDUP: %08x", GPCUP, GPDUP); lcd_puts(0, line++, buf); | 1154 | snprintf(buf, sizeof(buf), "GPCCON: %08x GPDCON: %08x", GPCCON, GPDCON); lcd_puts(0, line++, buf); |
1155 | 1155 | snprintf(buf, sizeof(buf), "GPCDAT: %08x GPDDAT: %08x", GPCDAT, GPDDAT); lcd_puts(0, line++, buf); | |
1156 | snprintf(buf, sizeof(buf), "GPECON: %08x GPFCON: %08x", GPECON, GPFCON); lcd_puts(0, line++, buf); | 1156 | snprintf(buf, sizeof(buf), "GPCUP: %08x GPDUP: %08x", GPCUP, GPDUP); lcd_puts(0, line++, buf); |
1157 | snprintf(buf, sizeof(buf), "GPEDAT: %08x GPFDAT: %08x", GPEDAT, GPFDAT); lcd_puts(0, line++, buf); | 1157 | |
1158 | snprintf(buf, sizeof(buf), "GPEUP: %08x GPFUP: %08x", GPEUP, GPFUP); lcd_puts(0, line++, buf); | 1158 | snprintf(buf, sizeof(buf), "GPECON: %08x GPFCON: %08x", GPECON, GPFCON); lcd_puts(0, line++, buf); |
1159 | 1159 | snprintf(buf, sizeof(buf), "GPEDAT: %08x GPFDAT: %08x", GPEDAT, GPFDAT); lcd_puts(0, line++, buf); | |
1160 | snprintf(buf, sizeof(buf), "GPGCON: %08x GPHCON: %08x", GPGCON, GPHCON); lcd_puts(0, line++, buf); | 1160 | snprintf(buf, sizeof(buf), "GPEUP: %08x GPFUP: %08x", GPEUP, GPFUP); lcd_puts(0, line++, buf); |
1161 | snprintf(buf, sizeof(buf), "GPGDAT: %08x GPHDAT: %08x", GPGDAT, GPHDAT); lcd_puts(0, line++, buf); | 1161 | |
1162 | snprintf(buf, sizeof(buf), "GPGUP: %08x GPHUP: %08x", GPGUP, GPHUP); lcd_puts(0, line++, buf); | 1162 | snprintf(buf, sizeof(buf), "GPGCON: %08x GPHCON: %08x", GPGCON, GPHCON); lcd_puts(0, line++, buf); |
1163 | snprintf(buf, sizeof(buf), "GPGDAT: %08x GPHDAT: %08x", GPGDAT, GPHDAT); lcd_puts(0, line++, buf); | ||
1164 | snprintf(buf, sizeof(buf), "GPGUP: %08x GPHUP: %08x", GPGUP, GPHUP); lcd_puts(0, line++, buf); | ||
1165 | |||
1166 | snprintf(buf, sizeof(buf), "GPJCON: %08x", GPJCON); lcd_puts(0, line++, buf); | ||
1167 | snprintf(buf, sizeof(buf), "GPJDAT: %08x", GPJDAT); lcd_puts(0, line++, buf); | ||
1168 | snprintf(buf, sizeof(buf), "GPJUP: %08x", GPJUP); lcd_puts(0, line++, buf); | ||
1163 | 1169 | ||
1164 | snprintf(buf, sizeof(buf), "GPJCON: %08x", GPJCON); lcd_puts(0, line++, buf); | 1170 | line++; |
1165 | snprintf(buf, sizeof(buf), "GPJDAT: %08x", GPJDAT); lcd_puts(0, line++, buf); | 1171 | |
1166 | snprintf(buf, sizeof(buf), "GPJUP: %08x", GPJUP); lcd_puts(0, line++, buf); | 1172 | snprintf(buf, sizeof(buf), "SRCPND: %08x INTMOD: %08x", SRCPND, INTMOD); lcd_puts(0, line++, buf); |
1173 | snprintf(buf, sizeof(buf), "INTMSK: %08x INTPND: %08x", INTMSK, INTPND); lcd_puts(0, line++, buf); | ||
1174 | snprintf(buf, sizeof(buf), "CLKCON: %08x CLKSLOW: %08x", CLKCON, CLKSLOW); lcd_puts(0, line++, buf); | ||
1167 | lcd_update(); | 1175 | lcd_update(); |
1168 | if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL)) | 1176 | if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL)) |
1169 | return false; | 1177 | return false; |
@@ -2093,112 +2101,6 @@ static bool dbg_lcd_power_off(void) | |||
2093 | } | 2101 | } |
2094 | return false; | 2102 | return false; |
2095 | } | 2103 | } |
2096 | |||
2097 | #include "backlight-target.h" | ||
2098 | |||
2099 | static bool dbg_buttonlights(void) | ||
2100 | { | ||
2101 | unsigned short mode_changed = 1, mode = 0; | ||
2102 | enum buttonlight_selection which_led = BUTTONLIGHT_LED_ALL; | ||
2103 | unsigned short brightness = DEFAULT_BRIGHTNESS_SETTING; | ||
2104 | |||
2105 | lcd_setmargins(0, 0); | ||
2106 | for (;;) | ||
2107 | { | ||
2108 | int button; | ||
2109 | |||
2110 | if (mode_changed) | ||
2111 | { | ||
2112 | lcd_clear_display(); | ||
2113 | lcd_puts(0, 0, "Button light support"); | ||
2114 | lcd_puts(0, 1, "Press UP for mode change"); | ||
2115 | lcd_puts(0, 2, "Press DOWN for buttonlight selection"); | ||
2116 | |||
2117 | switch (mode) | ||
2118 | { | ||
2119 | case 0: | ||
2120 | lcd_puts(1, 3, "Off"); | ||
2121 | __buttonlight_mode(BUTTONLIGHT_OFF, which_led, brightness); | ||
2122 | break; | ||
2123 | |||
2124 | case 1: | ||
2125 | lcd_puts(1, 3, "On - Set to brightness"); | ||
2126 | __buttonlight_mode(BUTTONLIGHT_ON, which_led, brightness); | ||
2127 | break; | ||
2128 | |||
2129 | case 2: | ||
2130 | lcd_puts(1, 3, "Faint - Always on at lowest brightness"); | ||
2131 | __buttonlight_mode(BUTTONLIGHT_FAINT, which_led, brightness); | ||
2132 | break; | ||
2133 | |||
2134 | case 3: | ||
2135 | lcd_puts(1, 3, "Flicker on disk access"); | ||
2136 | __buttonlight_mode(BUTTONLIGHT_FLICKER, which_led, brightness); | ||
2137 | break; | ||
2138 | |||
2139 | case 4: | ||
2140 | lcd_puts(1, 3, "Solid on disk access"); | ||
2141 | __buttonlight_mode(BUTTONLIGHT_SIGNAL, which_led, brightness); | ||
2142 | break; | ||
2143 | |||
2144 | case 5: | ||
2145 | lcd_puts(1, 3, "Follows backlight"); | ||
2146 | __buttonlight_mode(BUTTONLIGHT_FOLLOW, which_led, brightness); | ||
2147 | break; | ||
2148 | |||
2149 | case 6: | ||
2150 | lcd_puts(1, 3, "Shows 'battery charging'"); | ||
2151 | __buttonlight_mode(BUTTONLIGHT_CHARGING, which_led, brightness); | ||
2152 | break; | ||
2153 | |||
2154 | } | ||
2155 | mode_changed = 0; | ||
2156 | lcd_update(); | ||
2157 | } | ||
2158 | |||
2159 | |||
2160 | |||
2161 | /* does nothing unless in flicker mode */ | ||
2162 | /* the parameter sets the brightness */ | ||
2163 | __buttonlight_trigger(); | ||
2164 | button = get_action(CONTEXT_STD,HZ/5); | ||
2165 | switch(button) | ||
2166 | { | ||
2167 | case ACTION_STD_PREV: | ||
2168 | if (++mode > 6) mode = 0; | ||
2169 | mode_changed = 1; | ||
2170 | break; | ||
2171 | |||
2172 | case ACTION_STD_NEXT: | ||
2173 | if (which_led == BUTTONLIGHT_LED_ALL) | ||
2174 | { | ||
2175 | which_led = BUTTONLIGHT_LED_MENU; | ||
2176 | } | ||
2177 | else | ||
2178 | { | ||
2179 | which_led = BUTTONLIGHT_LED_ALL; | ||
2180 | } | ||
2181 | mode_changed = 1; | ||
2182 | |||
2183 | break; | ||
2184 | |||
2185 | |||
2186 | case ACTION_STD_OK: | ||
2187 | case ACTION_STD_CANCEL: | ||
2188 | action_signalscreenchange(); | ||
2189 | return false; | ||
2190 | |||
2191 | default: | ||
2192 | sleep(HZ/10); | ||
2193 | break; | ||
2194 | } | ||
2195 | } | ||
2196 | return false; | ||
2197 | } | ||
2198 | |||
2199 | |||
2200 | |||
2201 | |||
2202 | #endif | 2104 | #endif |
2203 | 2105 | ||
2204 | #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS) | 2106 | #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS) |
@@ -2302,8 +2204,6 @@ struct the_menu_item { | |||
2302 | static const struct the_menu_item menuitems[] = { | 2204 | static const struct the_menu_item menuitems[] = { |
2303 | #if defined(TOSHIBA_GIGABEAT_F) && !defined(SIMULATOR) | 2205 | #if defined(TOSHIBA_GIGABEAT_F) && !defined(SIMULATOR) |
2304 | { "LCD Power Off", dbg_lcd_power_off }, | 2206 | { "LCD Power Off", dbg_lcd_power_off }, |
2305 | { "Button Light modes", dbg_buttonlights }, | ||
2306 | |||
2307 | #endif | 2207 | #endif |
2308 | #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || \ | 2208 | #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || \ |
2309 | (defined(CPU_PP) && !defined(SANSA_E200)) | 2209 | (defined(CPU_PP) && !defined(SANSA_E200)) |
diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 35583e5ddd..8caad6eb9b 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang | |||
@@ -10760,15 +10760,15 @@ | |||
10760 | desc: in settings_menu | 10760 | desc: in settings_menu |
10761 | user: | 10761 | user: |
10762 | <source> | 10762 | <source> |
10763 | *: "" | 10763 | *: "Button Light Timeout" |
10764 | e200: "Wheel Light Timeout" | 10764 | e200: "Wheel Light Timeout" |
10765 | </source> | 10765 | </source> |
10766 | <dest> | 10766 | <dest> |
10767 | *: "" | 10767 | *: "Button Light Timeout" |
10768 | e200: "Wheel Light Timeout" | 10768 | e200: "Wheel Light Timeout" |
10769 | </dest> | 10769 | </dest> |
10770 | <voice> | 10770 | <voice> |
10771 | *: "" | 10771 | *: "Button Light Timeout" |
10772 | e200: "Wheel Light Timeout" | 10772 | e200: "Wheel Light Timeout" |
10773 | </voice> | 10773 | </voice> |
10774 | </phrase> | 10774 | </phrase> |
diff --git a/apps/settings_list.c b/apps/settings_list.c index dfb7c4ba08..e781c51be0 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c | |||
@@ -542,7 +542,7 @@ const struct settings_list settings[] = { | |||
542 | /* backlight fading */ | 542 | /* backlight fading */ |
543 | STRINGCHOICE_SETTING(0,backlight_fade_in, LANG_BACKLIGHT_FADE_IN, 1, | 543 | STRINGCHOICE_SETTING(0,backlight_fade_in, LANG_BACKLIGHT_FADE_IN, 1, |
544 | "backlight fade in","off,500ms,1s,2s", backlight_set_fade_in, 4, | 544 | "backlight fade in","off,500ms,1s,2s", backlight_set_fade_in, 4, |
545 | LANG_OFF, TALK_ID(500, UNIT_MS), | 545 | LANG_OFF, TALK_ID(500, UNIT_MS), |
546 | TALK_ID(1, UNIT_SEC), TALK_ID(2, UNIT_SEC)), | 546 | TALK_ID(1, UNIT_SEC), TALK_ID(2, UNIT_SEC)), |
547 | STRINGCHOICE_SETTING(0,backlight_fade_out, LANG_BACKLIGHT_FADE_OUT, 1, | 547 | STRINGCHOICE_SETTING(0,backlight_fade_out, LANG_BACKLIGHT_FADE_OUT, 1, |
548 | "backlight fade out","off,500ms,1s,2s,3s,5s,10s", backlight_set_fade_out, 7, | 548 | "backlight fade out","off,500ms,1s,2s,3s,5s,10s", backlight_set_fade_out, 7, |
diff --git a/firmware/backlight.c b/firmware/backlight.c index 2bdfe86c77..85e3d409b6 100644 --- a/firmware/backlight.c +++ b/firmware/backlight.c | |||
@@ -124,8 +124,7 @@ void button_backlight_set_timeout(int index) | |||
124 | else if (index == 1) /* on */ | 124 | else if (index == 1) /* on */ |
125 | button_backlight_on(); | 125 | button_backlight_on(); |
126 | 126 | ||
127 | if (button_backlight_timer) | 127 | button_backlight_timer = button_backlight_timeout; |
128 | button_backlight_timer = button_backlight_timeout; | ||
129 | } | 128 | } |
130 | 129 | ||
131 | /* internal interface */ | 130 | /* internal interface */ |
diff --git a/firmware/drivers/power.c b/firmware/drivers/power.c index 2a87cad2e1..eb69fcec27 100644 --- a/firmware/drivers/power.c +++ b/firmware/drivers/power.c | |||
@@ -91,8 +91,6 @@ bool charger_inserted(void) | |||
91 | #elif defined (HAVE_FMADC) | 91 | #elif defined (HAVE_FMADC) |
92 | /* FM or V2, can also charge from the USB port */ | 92 | /* FM or V2, can also charge from the USB port */ |
93 | return (adc_read(ADC_CHARGE_REGULATOR) < 0x1FF); | 93 | return (adc_read(ADC_CHARGE_REGULATOR) < 0x1FF); |
94 | #elif defined(TOSHIBA_GIGABEAT_F) | ||
95 | return false; | ||
96 | #else | 94 | #else |
97 | /* Player */ | 95 | /* Player */ |
98 | return (PADR & 1) == 0; | 96 | return (PADR & 1) == 0; |
@@ -136,9 +134,6 @@ void ide_power_enable(bool on) | |||
136 | { | 134 | { |
137 | (void)on; | 135 | (void)on; |
138 | 136 | ||
139 | #if defined(TOSHIBA_GIGABEAT_F) | ||
140 | /* Gigabeat TODO */ | ||
141 | #else /* SH1 based archos */ | ||
142 | bool touched = false; | 137 | bool touched = false; |
143 | #ifdef NEEDS_ATA_POWER_ON | 138 | #ifdef NEEDS_ATA_POWER_ON |
144 | if(on) | 139 | if(on) |
@@ -175,15 +170,11 @@ void ide_power_enable(bool on) | |||
175 | PACR2 &= 0xFBFF; /* GPIO for PA5 */ | 170 | PACR2 &= 0xFBFF; /* GPIO for PA5 */ |
176 | #endif | 171 | #endif |
177 | } | 172 | } |
178 | #endif /* SH1 based archos */ | ||
179 | } | 173 | } |
180 | 174 | ||
181 | 175 | ||
182 | bool ide_powered(void) | 176 | bool ide_powered(void) |
183 | { | 177 | { |
184 | #if defined(TOSHIBA_GIGABEAT_F) | ||
185 | return false; | ||
186 | #else /* SH1 based archos */ | ||
187 | #if defined(NEEDS_ATA_POWER_ON) || defined(HAVE_ATA_POWER_OFF) | 178 | #if defined(NEEDS_ATA_POWER_ON) || defined(HAVE_ATA_POWER_OFF) |
188 | #ifdef ATA_POWER_PLAYERSTYLE | 179 | #ifdef ATA_POWER_PLAYERSTYLE |
189 | /* This is not correct for very old players, since these are unable to | 180 | /* This is not correct for very old players, since these are unable to |
@@ -202,7 +193,6 @@ bool ide_powered(void) | |||
202 | #else /* !defined(NEEDS_ATA_POWER_ON) && !defined(HAVE_ATA_POWER_OFF) */ | 193 | #else /* !defined(NEEDS_ATA_POWER_ON) && !defined(HAVE_ATA_POWER_OFF) */ |
203 | return true; /* pretend always powered if not controlable */ | 194 | return true; /* pretend always powered if not controlable */ |
204 | #endif | 195 | #endif |
205 | #endif | ||
206 | } | 196 | } |
207 | #endif /* !HAVE_MMC */ | 197 | #endif /* !HAVE_MMC */ |
208 | 198 | ||
@@ -210,9 +200,6 @@ bool ide_powered(void) | |||
210 | void power_off(void) | 200 | void power_off(void) |
211 | { | 201 | { |
212 | set_irq_level(HIGHEST_IRQ_LEVEL); | 202 | set_irq_level(HIGHEST_IRQ_LEVEL); |
213 | #if defined(TOSHIBA_GIGABEAT_F) | ||
214 | /* FIXME: Can we turn the device off, or only enter sleep mode? */ | ||
215 | #else | ||
216 | #ifdef HAVE_POWEROFF_ON_PBDR | 203 | #ifdef HAVE_POWEROFF_ON_PBDR |
217 | and_b(~0x10, &PBDRL); | 204 | and_b(~0x10, &PBDRL); |
218 | or_b(0x10, &PBIORL); | 205 | or_b(0x10, &PBIORL); |
@@ -226,7 +213,6 @@ void power_off(void) | |||
226 | and_b(~0x08, &PADRH); | 213 | and_b(~0x08, &PADRH); |
227 | or_b(0x08, &PAIORH); | 214 | or_b(0x08, &PAIORH); |
228 | #endif | 215 | #endif |
229 | #endif | ||
230 | while(1) | 216 | while(1) |
231 | yield(); | 217 | yield(); |
232 | } | 218 | } |
diff --git a/firmware/drivers/rtc/rtc_s3c2440.c b/firmware/drivers/rtc/rtc_s3c2440.c index ae422ffc2d..b1bc622058 100644 --- a/firmware/drivers/rtc/rtc_s3c2440.c +++ b/firmware/drivers/rtc/rtc_s3c2440.c | |||
@@ -21,7 +21,6 @@ | |||
21 | #include "rtc.h" | 21 | #include "rtc.h" |
22 | #include "kernel.h" | 22 | #include "kernel.h" |
23 | #include "system.h" | 23 | #include "system.h" |
24 | #include <stdbool.h> | ||
25 | 24 | ||
26 | void rtc_init(void) | 25 | void rtc_init(void) |
27 | { | 26 | { |
@@ -55,7 +54,7 @@ int rtc_write_datetime(unsigned char* buf) | |||
55 | return 1; | 54 | return 1; |
56 | } | 55 | } |
57 | 56 | ||
58 | #ifdef HAVE_RTC_ALARM | 57 | #ifdef HAVE_RTC_ALARM |
59 | /* This alarm code works in that it at least triggers INT_RTC. I am guessing | 58 | /* This alarm code works in that it at least triggers INT_RTC. I am guessing |
60 | * that the OF bootloader for the Gigabeat detects the startup by alarm and shuts down. | 59 | * that the OF bootloader for the Gigabeat detects the startup by alarm and shuts down. |
61 | * This code is available for use once the OF bootloader is no longer required. | 60 | * This code is available for use once the OF bootloader is no longer required. |
@@ -110,13 +109,16 @@ void rtc_get_alarm(int *h, int *m) | |||
110 | */ | 109 | */ |
111 | bool rtc_enable_alarm(bool enable) | 110 | bool rtc_enable_alarm(bool enable) |
112 | { | 111 | { |
113 | /* Note: The interupt for the alarm is normally masked. May want to enable ( INTMSK&=~(1<<30); ) | ||
114 | * it here if an alarm handler is desired (while the unit is not in sleep). | ||
115 | */ | ||
116 | if (enable) | 112 | if (enable) |
113 | { | ||
117 | RTCALM=0x46; | 114 | RTCALM=0x46; |
115 | INTMSK&=~(1<<30); | ||
116 | } | ||
118 | else | 117 | else |
118 | { | ||
119 | RTCALM=0x00; | 119 | RTCALM=0x00; |
120 | INTMSK|=(1<<30); | ||
121 | } | ||
120 | 122 | ||
121 | return false; /* all ok */ | 123 | return false; /* all ok */ |
122 | } | 124 | } |
diff --git a/firmware/export/config-gigabeat.h b/firmware/export/config-gigabeat.h index 35b6175227..a83dc55fd8 100644 --- a/firmware/export/config-gigabeat.h +++ b/firmware/export/config-gigabeat.h | |||
@@ -32,7 +32,6 @@ | |||
32 | #define LCD_DEPTH 16 /* 65k colours */ | 32 | #define LCD_DEPTH 16 /* 65k colours */ |
33 | #define LCD_PIXELFORMAT RGB565 /* rgb565 */ | 33 | #define LCD_PIXELFORMAT RGB565 /* rgb565 */ |
34 | 34 | ||
35 | |||
36 | #define CONFIG_KEYPAD GIGABEAT_PAD | 35 | #define CONFIG_KEYPAD GIGABEAT_PAD |
37 | 36 | ||
38 | /* Define this if you do software codec */ | 37 | /* Define this if you do software codec */ |
@@ -44,13 +43,14 @@ | |||
44 | /* Define this for LCD backlight available */ | 43 | /* Define this for LCD backlight available */ |
45 | #define HAVE_BACKLIGHT | 44 | #define HAVE_BACKLIGHT |
46 | 45 | ||
46 | #define HAVE_BUTTON_LIGHT | ||
47 | |||
47 | #define HAVE_LCD_ENABLE | 48 | #define HAVE_LCD_ENABLE |
48 | 49 | ||
49 | #define HAVE_BACKLIGHT_BRIGHTNESS | 50 | #define HAVE_BACKLIGHT_BRIGHTNESS |
50 | 51 | ||
51 | /* Main LCD backlight brightness range and defaults */ | 52 | /* Main LCD backlight brightness range and defaults */ |
52 | #define MIN_BRIGHTNESS_SETTING 0 /* 0.5 mA */ | 53 | #define MIN_BRIGHTNESS_SETTING 0 /* 0.5 mA */ |
53 | #define MIN_ACTIVE_BRIGHTNESS_SETTING 16 /* lowest active brightness */ | ||
54 | #define MAX_DIM_BRIGHTNESS_SETTING 15 /* highest 'dimness' */ | 54 | #define MAX_DIM_BRIGHTNESS_SETTING 15 /* highest 'dimness' */ |
55 | #define MAX_BRIGHTNESS_SETTING 63 /* 32 mA */ | 55 | #define MAX_BRIGHTNESS_SETTING 63 /* 32 mA */ |
56 | #define DEFAULT_BRIGHTNESS_SETTING 39 /* 20 mA */ | 56 | #define DEFAULT_BRIGHTNESS_SETTING 39 /* 20 mA */ |
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/ata-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/ata-meg-fx.c index 2f28124edf..d33bcaaf6e 100644 --- a/firmware/target/arm/s3c2440/gigabeat-fx/ata-meg-fx.c +++ b/firmware/target/arm/s3c2440/gigabeat-fx/ata-meg-fx.c | |||
@@ -18,7 +18,6 @@ | |||
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #include "config.h" | 19 | #include "config.h" |
20 | #include "cpu.h" | 20 | #include "cpu.h" |
21 | #include <stdbool.h> | ||
22 | #include "kernel.h" | 21 | #include "kernel.h" |
23 | #include "thread.h" | 22 | #include "thread.h" |
24 | #include "system.h" | 23 | #include "system.h" |
@@ -48,13 +47,12 @@ void ata_reset(void) | |||
48 | /* This function is called before enabling the USB bus */ | 47 | /* This function is called before enabling the USB bus */ |
49 | void ata_enable(bool on) | 48 | void ata_enable(bool on) |
50 | { | 49 | { |
50 | GPBCON=( GPBCON&~(1<<11) ) | (1<<10); /* Make the pin an output */ | ||
51 | GPBUP|=1<<5; /* Disable pullup in SOC as we are now driving */ | ||
51 | if(on) | 52 | if(on) |
52 | USB_ATA_DISABLE; | 53 | USB_ATA_DISABLE; |
53 | else | 54 | else |
54 | USB_ATA_ENABLE; | 55 | USB_ATA_ENABLE; |
55 | |||
56 | GPBCON=( GPBCON&~(1<<11) ) | (1<<10); /* Make the pin an output */ | ||
57 | GPBUP|=1<<5; /* Disable pullup in SOC as we are now driving */ | ||
58 | } | 56 | } |
59 | 57 | ||
60 | bool ata_is_coldstart(void) | 58 | bool ata_is_coldstart(void) |
@@ -65,10 +63,10 @@ bool ata_is_coldstart(void) | |||
65 | 63 | ||
66 | void ata_device_init(void) | 64 | void ata_device_init(void) |
67 | { | 65 | { |
68 | /* ATA reset */ | ||
69 | ATA_RESET_DISABLE; /* Set the pin to disable an active low reset */ | ||
70 | GPGCON=( GPGCON&~(1<<21) ) | (1<<20); /* Make the pin an output */ | 66 | GPGCON=( GPGCON&~(1<<21) ) | (1<<20); /* Make the pin an output */ |
71 | GPGUP |= 1<<10; /* Disable pullup in SOC as we are now driving */ | 67 | GPGUP |= 1<<10; /* Disable pullup in SOC as we are now driving */ |
68 | /* ATA reset */ | ||
69 | ATA_RESET_DISABLE; /* Set the pin to disable an active low reset */ | ||
72 | } | 70 | } |
73 | 71 | ||
74 | #if !defined(BOOTLOADER) | 72 | #if !defined(BOOTLOADER) |
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/backlight-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/backlight-meg-fx.c index a1b6a8a583..a8f8ef5d85 100644 --- a/firmware/target/arm/s3c2440/gigabeat-fx/backlight-meg-fx.c +++ b/firmware/target/arm/s3c2440/gigabeat-fx/backlight-meg-fx.c | |||
@@ -25,19 +25,14 @@ | |||
25 | #include "sc606-meg-fx.h" | 25 | #include "sc606-meg-fx.h" |
26 | #include "power.h" | 26 | #include "power.h" |
27 | 27 | ||
28 | |||
29 | #define FLICKER_PERIOD 15 | 28 | #define FLICKER_PERIOD 15 |
30 | #define BUTTONLIGHT_MENU (SC606_LED_B1) | 29 | #define BUTTONLIGHT_MENU (SC606_LED_B1) |
31 | #define BUTTONLIGHT_ALL (SC606_LED_B1 | SC606_LED_B2 | SC606_LED_C1 | SC606_LED_C2) | 30 | #define BUTTONLIGHT_ALL (SC606_LED_B1 | SC606_LED_B2 | SC606_LED_C1 | SC606_LED_C2) |
32 | 31 | ||
33 | static void led_control_service(void); | 32 | static void led_control_service(void); |
34 | static unsigned short backlight_brightness; | 33 | static unsigned short backlight_brightness; |
35 | static unsigned short backlight_current; | ||
36 | static unsigned short backlight_target; | 34 | static unsigned short backlight_target; |
37 | static unsigned short time_til_fade; | 35 | static unsigned short buttonlight_target; |
38 | static unsigned short fade_interval; | ||
39 | static unsigned short initial_tick_delay; | ||
40 | static unsigned char backlight_leds; | ||
41 | 36 | ||
42 | static enum backlight_states | 37 | static enum backlight_states |
43 | { | 38 | { |
@@ -45,198 +40,95 @@ static enum backlight_states | |||
45 | BACKLIGHT_CONTROL_OFF, | 40 | BACKLIGHT_CONTROL_OFF, |
46 | BACKLIGHT_CONTROL_ON, | 41 | BACKLIGHT_CONTROL_ON, |
47 | BACKLIGHT_CONTROL_SET, | 42 | BACKLIGHT_CONTROL_SET, |
48 | BACKLIGHT_CONTROL_FADE_OFF, | 43 | BACKLIGHT_CONTROL_FADE |
49 | BACKLIGHT_CONTROL_FADE_ON, | ||
50 | BACKLIGHT_CONTROL_FADE_ON_FROM_OFF | ||
51 | } backlight_control; | 44 | } backlight_control; |
52 | 45 | ||
53 | 46 | static enum sc606_states | |
47 | { | ||
48 | SC606_CONTROL_IDLE, | ||
49 | SC606_CONTROL_A12, | ||
50 | SC606_CONTROL_B12, | ||
51 | SC606_CONTROL_C12, | ||
52 | SC606_CONTROL_CONF | ||
53 | } sc606_control; | ||
54 | 54 | ||
55 | enum buttonlight_states | 55 | enum buttonlight_states |
56 | { | 56 | { |
57 | BUTTONLIGHT_CONTROL_IDLE, | ||
58 | |||
57 | /* turn button lights off */ | 59 | /* turn button lights off */ |
58 | BUTTONLIGHT_MODE_OFF_ENTRY, | 60 | BUTTONLIGHT_CONTROL_OFF, |
59 | BUTTONLIGHT_MODE_OFF, | ||
60 | 61 | ||
61 | /* turns button lights on to setting */ | 62 | /* turns button lights on to setting */ |
62 | BUTTONLIGHT_MODE_ON_ENTRY, | 63 | BUTTONLIGHT_CONTROL_ON, |
63 | BUTTONLIGHT_MODE_ON, | 64 | |
64 | |||
65 | /* turns button lights on to minimum */ | ||
66 | BUTTONLIGHT_MODE_FAINT_ENTRY, | ||
67 | BUTTONLIGHT_MODE_FAINT, | ||
68 | |||
69 | /* allows button lights to flicker when triggered */ | ||
70 | BUTTONLIGHT_MODE_FLICKER_ENTRY, | ||
71 | BUTTONLIGHT_MODE_FLICKER, | ||
72 | BUTTONLIGHT_MODE_FLICKERING, | ||
73 | |||
74 | /* button lights solid */ | ||
75 | BUTTONLIGHT_MODE_SOLID_ENTRY, | ||
76 | BUTTONLIGHT_MODE_SOLID, | ||
77 | |||
78 | /* button light charing */ | ||
79 | BUTTONLIGHT_MODE_CHARGING_ENTRY, | ||
80 | BUTTONLIGHT_MODE_CHARGING, | ||
81 | BUTTONLIGHT_MODE_CHARGING_WAIT, | ||
82 | |||
83 | /* internal use only */ | ||
84 | BUTTONLIGHT_HELPER_SET, | ||
85 | BUTTONLIGHT_HELPER_SET_FINAL, | ||
86 | BUTTONLIGHT_MODE_STOP, | ||
87 | |||
88 | /* buttonlights follow the backlight settings */ | 65 | /* buttonlights follow the backlight settings */ |
89 | BUTTONLIGHT_MODE_FOLLOW_ENTRY, | 66 | BUTTONLIGHT_CONTROL_FADE, |
90 | BUTTONLIGHT_MODE_FOLLOW, | ||
91 | }; | ||
92 | |||
93 | |||
94 | 67 | ||
95 | static char buttonlight_leds; | 68 | } buttonlight_control; |
96 | static unsigned short buttonlight_setting; | ||
97 | static unsigned short buttonlight_current; | ||
98 | static unsigned char buttonlight_selected; | ||
99 | static enum buttonlight_states buttonlight_state; | ||
100 | static enum buttonlight_states buttonlight_saved_state; | ||
101 | static unsigned short buttonlight_flickering; | ||
102 | 69 | ||
103 | static unsigned short buttonlight_trigger_now; | 70 | static unsigned short buttonlight_trigger_now; |
104 | static unsigned short buttonlight_trigger_brightness; | ||
105 | |||
106 | |||
107 | |||
108 | static unsigned short charging_led_index; | ||
109 | static unsigned short buttonlight_charging_counter; | ||
110 | 71 | ||
111 | #define CHARGING_LED_COUNT 60 | 72 | #define CHARGING_LED_COUNT 60 |
112 | unsigned char charging_leds[] = { 0x00, 0x20, 0x38, 0x3C }; | 73 | unsigned char charging_leds[] = { 0x00, 0x20, 0x38, 0x3C }; |
113 | 74 | ||
114 | |||
115 | |||
116 | bool __backlight_init(void) | 75 | bool __backlight_init(void) |
117 | { | 76 | { |
77 | backlight_brightness=DEFAULT_BRIGHTNESS_SETTING; | ||
118 | backlight_control = BACKLIGHT_CONTROL_IDLE; | 78 | backlight_control = BACKLIGHT_CONTROL_IDLE; |
119 | 79 | ||
120 | backlight_current = DEFAULT_BRIGHTNESS_SETTING; | 80 | buttonlight_control = BUTTONLIGHT_CONTROL_IDLE; |
121 | |||
122 | buttonlight_state = BUTTONLIGHT_MODE_OFF; | ||
123 | 81 | ||
124 | buttonlight_selected = 0x04; | ||
125 | |||
126 | /* delay 4 seconds before any fading */ | ||
127 | initial_tick_delay = 400; | ||
128 | /* put the led control on the tick list */ | 82 | /* put the led control on the tick list */ |
129 | tick_add_task(led_control_service); | 83 | tick_add_task(led_control_service); |
130 | 84 | ||
131 | return true; | 85 | return true; |
132 | } | 86 | } |
133 | 87 | ||
134 | |||
135 | |||
136 | void __backlight_on(void) | 88 | void __backlight_on(void) |
137 | { | 89 | { |
138 | /* now go turn the backlight on */ | ||
139 | backlight_control = BACKLIGHT_CONTROL_ON; | 90 | backlight_control = BACKLIGHT_CONTROL_ON; |
140 | } | 91 | } |
141 | 92 | ||
142 | |||
143 | |||
144 | void __backlight_off(void) | 93 | void __backlight_off(void) |
145 | { | 94 | { |
146 | backlight_control = BACKLIGHT_CONTROL_OFF; | 95 | backlight_control = BACKLIGHT_CONTROL_OFF; |
147 | } | 96 | } |
148 | 97 | ||
149 | |||
150 | |||
151 | /* Assumes that the backlight has been initialized */ | 98 | /* Assumes that the backlight has been initialized */ |
152 | void __backlight_set_brightness(int brightness) | 99 | void __backlight_set_brightness(int brightness) |
153 | { | 100 | { |
154 | /* stop the interrupt from messing us up */ | 101 | /* stop the interrupt from messing us up */ |
155 | backlight_control = BACKLIGHT_CONTROL_IDLE; | 102 | backlight_control = BACKLIGHT_CONTROL_IDLE; |
156 | 103 | backlight_brightness = brightness; | |
157 | backlight_brightness = brightness + 1; | 104 | backlight_control = BACKLIGHT_CONTROL_SET; |
158 | |||
159 | /* only set the brightness if it is different from the current */ | ||
160 | if (backlight_brightness != backlight_current) | ||
161 | { | ||
162 | backlight_control = BACKLIGHT_CONTROL_SET; | ||
163 | } | ||
164 | } | 105 | } |
165 | 106 | ||
166 | |||
167 | |||
168 | /* only works if the buttonlight mode is set to triggered mode */ | 107 | /* only works if the buttonlight mode is set to triggered mode */ |
169 | void __buttonlight_trigger(void) | 108 | void __buttonlight_trigger(void) |
170 | { | 109 | { |
171 | buttonlight_trigger_now = 1; | 110 | buttonlight_trigger_now = 1; |
172 | } | 111 | } |
173 | 112 | ||
174 | |||
175 | |||
176 | |||
177 | /* map the mode from the command into the state machine entries */ | 113 | /* map the mode from the command into the state machine entries */ |
178 | void __buttonlight_mode(enum buttonlight_mode mode, | 114 | void __buttonlight_mode(enum buttonlight_mode mode) |
179 | enum buttonlight_selection selection, | ||
180 | unsigned short brightness) | ||
181 | { | 115 | { |
182 | /* choose stop to setup mode */ | 116 | /* choose stop to setup mode */ |
183 | buttonlight_state = BUTTONLIGHT_MODE_STOP; | 117 | buttonlight_control = BUTTONLIGHT_CONTROL_IDLE; |
184 | |||
185 | |||
186 | /* clip brightness */ | ||
187 | if (brightness > MAX_BRIGHTNESS_SETTING) | ||
188 | { | ||
189 | brightness = MAX_BRIGHTNESS_SETTING; | ||
190 | } | ||
191 | |||
192 | brightness++; | ||
193 | |||
194 | /* Select which LEDs to use */ | ||
195 | switch (selection) | ||
196 | { | ||
197 | case BUTTONLIGHT_LED_ALL: | ||
198 | buttonlight_selected = BUTTONLIGHT_ALL; | ||
199 | break; | ||
200 | |||
201 | case BUTTONLIGHT_LED_MENU: | ||
202 | buttonlight_selected = BUTTONLIGHT_MENU; | ||
203 | break; | ||
204 | } | ||
205 | 118 | ||
206 | /* which mode to use */ | 119 | /* which mode to use */ |
207 | switch (mode) | 120 | switch (mode) |
208 | { | 121 | { |
209 | case BUTTONLIGHT_OFF: | 122 | case BUTTONLIGHT_OFF: |
210 | buttonlight_state = BUTTONLIGHT_MODE_OFF_ENTRY; | 123 | buttonlight_control = BUTTONLIGHT_CONTROL_OFF; |
211 | break; | 124 | break; |
212 | 125 | ||
213 | case BUTTONLIGHT_ON: | 126 | case BUTTONLIGHT_ON: |
214 | buttonlight_trigger_brightness = brightness; | 127 | buttonlight_control = BUTTONLIGHT_CONTROL_ON; |
215 | buttonlight_state = BUTTONLIGHT_MODE_ON_ENTRY; | ||
216 | break; | 128 | break; |
217 | 129 | ||
218 | /* faint is just a quick way to set ON to 1 */ | ||
219 | case BUTTONLIGHT_FAINT: | ||
220 | buttonlight_trigger_brightness = 1; | ||
221 | buttonlight_state = BUTTONLIGHT_MODE_ON_ENTRY; | ||
222 | break; | ||
223 | |||
224 | case BUTTONLIGHT_FLICKER: | ||
225 | buttonlight_trigger_brightness = brightness; | ||
226 | buttonlight_state = BUTTONLIGHT_MODE_FLICKER_ENTRY; | ||
227 | break; | ||
228 | |||
229 | case BUTTONLIGHT_SIGNAL: | ||
230 | buttonlight_trigger_brightness = brightness; | ||
231 | buttonlight_state = BUTTONLIGHT_MODE_SOLID_ENTRY; | ||
232 | break; | ||
233 | |||
234 | case BUTTONLIGHT_FOLLOW: | 130 | case BUTTONLIGHT_FOLLOW: |
235 | buttonlight_state = BUTTONLIGHT_MODE_FOLLOW_ENTRY; | 131 | buttonlight_control = BUTTONLIGHT_CONTROL_FADE; |
236 | break; | ||
237 | |||
238 | case BUTTONLIGHT_CHARGING: | ||
239 | buttonlight_state = BUTTONLIGHT_MODE_CHARGING_ENTRY; | ||
240 | break; | 132 | break; |
241 | 133 | ||
242 | default: | 134 | default: |
@@ -246,16 +138,11 @@ void __buttonlight_mode(enum buttonlight_mode mode, | |||
246 | 138 | ||
247 | } | 139 | } |
248 | 140 | ||
249 | |||
250 | |||
251 | /* | 141 | /* |
252 | * The button lights have 'modes' of operation. Each mode must setup and | 142 | * The button lights have 'modes' of operation. Each mode must setup and |
253 | * execute its own operation - taking care that this is all done in an ISR. | 143 | * execute its own operation - taking care that this is all done in an ISR. |
254 | * | ||
255 | */ | 144 | */ |
256 | 145 | ||
257 | |||
258 | |||
259 | /* led_control_service runs in interrupt context - be brief! | 146 | /* led_control_service runs in interrupt context - be brief! |
260 | * This service is called once per interrupt timer tick - 100 times a second. | 147 | * This service is called once per interrupt timer tick - 100 times a second. |
261 | * | 148 | * |
@@ -265,428 +152,146 @@ void __buttonlight_mode(enum buttonlight_mode mode, | |||
265 | * Putting all led servicing in one thread means that we wont step on any | 152 | * Putting all led servicing in one thread means that we wont step on any |
266 | * i2c operations - they are all serialized here in the ISR tick. It also | 153 | * i2c operations - they are all serialized here in the ISR tick. It also |
267 | * insures that we get called at equal timing for good visual effect. | 154 | * insures that we get called at equal timing for good visual effect. |
268 | * | ||
269 | * The buttonlight service runs only after all backlight services have finished. | ||
270 | * Fading the buttonlights is possible, but not recommended because of the | ||
271 | * additional calls needed during the ISR | ||
272 | */ | 155 | */ |
273 | static void led_control_service(void) | 156 | static void led_control_service(void) |
274 | { | 157 | { |
275 | if(initial_tick_delay) { | 158 | static unsigned char |
276 | initial_tick_delay--; | 159 | sc606regAval=DEFAULT_BRIGHTNESS_SETTING, |
277 | return; | 160 | sc606regBval=DEFAULT_BRIGHTNESS_SETTING, |
278 | } | 161 | sc606regCval=DEFAULT_BRIGHTNESS_SETTING, |
279 | switch (backlight_control) | 162 | sc606regCONFval=3; |
163 | |||
164 | static bool sc606_changed=true; | ||
165 | |||
166 | if(sc606_changed==false) | ||
280 | { | 167 | { |
281 | case BACKLIGHT_CONTROL_IDLE: | 168 | switch (backlight_control) |
282 | switch (buttonlight_state) | ||
283 | { | 169 | { |
284 | case BUTTONLIGHT_MODE_STOP: break; | 170 | case BACKLIGHT_CONTROL_IDLE: |
285 | 171 | backlight_control = BACKLIGHT_CONTROL_IDLE; | |
286 | /* Buttonlight mode: OFF */ | 172 | break; |
287 | case BUTTONLIGHT_MODE_OFF_ENTRY: | 173 | case BACKLIGHT_CONTROL_OFF: |
288 | if (buttonlight_current) | 174 | sc606_changed=true; |
289 | { | 175 | sc606regCONFval &= ~0x03; |
290 | buttonlight_leds = 0x00; | 176 | backlight_control = BACKLIGHT_CONTROL_IDLE; |
291 | sc606_write(SC606_REG_CONF, backlight_leds); | 177 | break; |
292 | buttonlight_current = 0; | 178 | case BACKLIGHT_CONTROL_ON: |
293 | } | 179 | sc606_changed=true; |
294 | buttonlight_state = BUTTONLIGHT_MODE_OFF; | 180 | sc606regCONFval |= 0x03; |
295 | break; | 181 | backlight_control = BACKLIGHT_CONTROL_IDLE; |
296 | 182 | break; | |
297 | case BUTTONLIGHT_MODE_OFF: | 183 | case BACKLIGHT_CONTROL_SET: |
298 | break; | 184 | sc606regAval=backlight_brightness; |
299 | 185 | sc606_changed=true; | |
300 | 186 | backlight_control = BACKLIGHT_CONTROL_ON; | |
301 | /* button mode: CHARGING - show charging sequence */ | 187 | break; |
302 | case BUTTONLIGHT_MODE_CHARGING_ENTRY: | 188 | case BACKLIGHT_CONTROL_FADE: |
303 | /* start turned off */ | 189 | sc606_changed=true; |
304 | buttonlight_leds = 0x00; | 190 | sc606regCONFval |= 0x03; |
305 | sc606_write(SC606_REG_CONF, backlight_leds); | 191 | /* The SC606 LED driver can set the brightness in 64 steps */ |
306 | buttonlight_current = 0; | 192 | if(backlight_target==sc606regAval) |
307 | 193 | if(sc606regAval) | |
308 | /* temporary save for the next mode - then to do settings */ | 194 | backlight_control = BACKLIGHT_CONTROL_ON; |
309 | buttonlight_setting = DEFAULT_BRIGHTNESS_SETTING; | 195 | else |
310 | buttonlight_saved_state = BUTTONLIGHT_MODE_CHARGING_WAIT; | 196 | backlight_control = BACKLIGHT_CONTROL_OFF; |
311 | buttonlight_state = BUTTONLIGHT_HELPER_SET; | ||
312 | break; | ||
313 | |||
314 | |||
315 | case BUTTONLIGHT_MODE_CHARGING: | ||
316 | if (--buttonlight_charging_counter == 0) | ||
317 | { | ||
318 | /* change led */ | ||
319 | if (charging_state()) | ||
320 | { | ||
321 | buttonlight_leds = charging_leds[charging_led_index]; | ||
322 | if (++charging_led_index >= sizeof(charging_leds)) | ||
323 | { | ||
324 | charging_led_index = 0; | ||
325 | } | ||
326 | sc606_write(SC606_REG_CONF, backlight_leds | buttonlight_leds); | ||
327 | buttonlight_charging_counter = CHARGING_LED_COUNT; | ||
328 | } | ||
329 | else | 197 | else |
330 | { | 198 | if(backlight_target>sc606regAval) |
331 | buttonlight_state = BUTTONLIGHT_MODE_CHARGING_ENTRY; | 199 | sc606regAval++; |
332 | } | 200 | else |
333 | } | 201 | sc606regAval--; |
334 | break; | 202 | break; |
335 | 203 | default: | |
336 | /* wait for the charget to be plugged in */ | 204 | break; |
337 | case BUTTONLIGHT_MODE_CHARGING_WAIT: | 205 | } |
338 | if (charging_state()) | 206 | switch (buttonlight_control) |
339 | { | 207 | { |
340 | charging_led_index = 0; | 208 | case BUTTONLIGHT_CONTROL_IDLE: |
341 | buttonlight_charging_counter = CHARGING_LED_COUNT; | 209 | buttonlight_control=BUTTONLIGHT_CONTROL_IDLE; |
342 | buttonlight_state = BUTTONLIGHT_MODE_CHARGING; | 210 | break; |
343 | } | 211 | case BUTTONLIGHT_CONTROL_OFF: |
344 | break; | 212 | sc606_changed=true; |
345 | 213 | sc606regCONFval &= ~0x3C; | |
346 | 214 | buttonlight_control=BUTTONLIGHT_CONTROL_IDLE; | |
347 | /* Buttonlight mode: FOLLOW - try to stay current with backlight | 215 | break; |
348 | * since this runs in the idle of the backlight it will not really | 216 | case BUTTONLIGHT_CONTROL_ON: |
349 | * follow in real time | 217 | sc606_changed=true; |
350 | */ | 218 | sc606regBval=sc606regCval=backlight_brightness; |
351 | case BUTTONLIGHT_MODE_FOLLOW_ENTRY: | 219 | sc606regCONFval |= 0x3C; |
352 | /* case 1 - backlight on, but buttonlight is off */ | 220 | buttonlight_control=BUTTONLIGHT_CONTROL_IDLE; |
353 | if (backlight_current) | 221 | break; |
354 | { | 222 | case BUTTONLIGHT_CONTROL_FADE: |
355 | /* Turn the buttonlights on */ | 223 | sc606_changed=true; |
356 | buttonlight_leds = buttonlight_selected; | 224 | sc606regCONFval |= 0x3C; |
357 | sc606_write(SC606_REG_CONF, backlight_leds | buttonlight_leds); | 225 | if(buttonlight_target==sc606regBval) |
358 | 226 | if(sc606regBval) | |
359 | /* temporary save for the next mode - then to do settings */ | 227 | buttonlight_control = BUTTONLIGHT_CONTROL_ON; |
360 | buttonlight_setting = backlight_current; | 228 | else |
361 | buttonlight_saved_state = BUTTONLIGHT_MODE_FOLLOW; | 229 | buttonlight_control = BUTTONLIGHT_CONTROL_OFF; |
362 | buttonlight_state = BUTTONLIGHT_HELPER_SET; | ||
363 | } | ||
364 | /* case 2 - backlight off, but buttonlight is on */ | ||
365 | else | ||
366 | { | ||
367 | buttonlight_current = 0; | ||
368 | buttonlight_leds = 0x00; | ||
369 | sc606_write(SC606_REG_CONF, backlight_leds); | ||
370 | buttonlight_state = BUTTONLIGHT_MODE_FOLLOW; | ||
371 | } | ||
372 | break; | ||
373 | |||
374 | case BUTTONLIGHT_MODE_FOLLOW: | ||
375 | if (buttonlight_current != backlight_current) | ||
376 | { | ||
377 | /* case 1 - backlight on, but buttonlight is off */ | ||
378 | if (backlight_current) | ||
379 | { | ||
380 | if (0 == buttonlight_current) | ||
381 | { | ||
382 | /* Turn the buttonlights on */ | ||
383 | buttonlight_leds = buttonlight_selected; | ||
384 | sc606_write(SC606_REG_CONF, backlight_leds | buttonlight_leds); | ||
385 | } | ||
386 | |||
387 | /* temporary save for the next mode - then to do settings */ | ||
388 | buttonlight_setting = backlight_current; | ||
389 | buttonlight_saved_state = BUTTONLIGHT_MODE_FOLLOW; | ||
390 | buttonlight_state = BUTTONLIGHT_HELPER_SET; | ||
391 | } | ||
392 | |||
393 | /* case 2 - backlight off, but buttonlight is on */ | ||
394 | else | 230 | else |
395 | { | 231 | if(buttonlight_target>sc606regBval) |
396 | buttonlight_current = 0; | 232 | sc606regCval=++sc606regBval; |
397 | buttonlight_leds = 0x00; | 233 | else |
398 | sc606_write(SC606_REG_CONF, backlight_leds); | 234 | sc606regCval=--sc606regBval; |
399 | } | 235 | break; |
400 | 236 | default: | |
401 | } | 237 | break; |
402 | break; | 238 | } |
403 | 239 | } | |
404 | |||
405 | |||
406 | /* Buttonlight mode: ON - stays at the set brightness */ | ||
407 | case BUTTONLIGHT_MODE_ON_ENTRY: | ||
408 | buttonlight_leds = buttonlight_selected; | ||
409 | sc606_write(SC606_REG_CONF, backlight_leds | buttonlight_leds); | ||
410 | |||
411 | /* temporary save for the next mode - then to do settings */ | ||
412 | buttonlight_setting = buttonlight_trigger_brightness; | ||
413 | buttonlight_saved_state = BUTTONLIGHT_MODE_ON; | ||
414 | buttonlight_state = BUTTONLIGHT_HELPER_SET; | ||
415 | break; | ||
416 | |||
417 | case BUTTONLIGHT_MODE_ON: | ||
418 | break; | ||
419 | |||
420 | |||
421 | |||
422 | /* Buttonlight mode: FLICKER */ | ||
423 | case BUTTONLIGHT_MODE_FLICKER_ENTRY: | ||
424 | /* already on? turn it off */ | ||
425 | if (buttonlight_current) | ||
426 | { | ||
427 | buttonlight_leds = 0x00; | ||
428 | sc606_write(SC606_REG_CONF, backlight_leds); | ||
429 | buttonlight_current = 0; | ||
430 | } | ||
431 | |||
432 | /* set the brightness if not already set */ | ||
433 | if (buttonlight_current != buttonlight_trigger_brightness) | ||
434 | { | ||
435 | /* temporary save for the next mode - then to do settings */ | ||
436 | buttonlight_setting = buttonlight_trigger_brightness; | ||
437 | buttonlight_saved_state = BUTTONLIGHT_MODE_FLICKER; | ||
438 | buttonlight_state = BUTTONLIGHT_HELPER_SET; | ||
439 | } | ||
440 | else buttonlight_state = BUTTONLIGHT_MODE_FLICKER; | ||
441 | break; | ||
442 | |||
443 | |||
444 | case BUTTONLIGHT_MODE_FLICKER: | ||
445 | /* wait for the foreground to trigger flickering */ | ||
446 | if (buttonlight_trigger_now) | ||
447 | { | ||
448 | /* turn them on */ | ||
449 | buttonlight_leds = buttonlight_selected; | ||
450 | buttonlight_current = buttonlight_setting; | ||
451 | sc606_write(SC606_REG_CONF, backlight_leds | buttonlight_leds); | ||
452 | |||
453 | /* reset the trigger and go flicker the LEDs */ | ||
454 | buttonlight_trigger_now = 0; | ||
455 | buttonlight_flickering = FLICKER_PERIOD; | ||
456 | buttonlight_state = BUTTONLIGHT_MODE_FLICKERING; | ||
457 | } | ||
458 | break; | ||
459 | |||
460 | |||
461 | case BUTTONLIGHT_MODE_FLICKERING: | ||
462 | /* flicker the LEDs for as long as we get triggered */ | ||
463 | if (buttonlight_flickering) | ||
464 | { | ||
465 | /* turn the leds off if they are on */ | ||
466 | if (buttonlight_current) | ||
467 | { | ||
468 | buttonlight_leds = 0x00; | ||
469 | sc606_write(SC606_REG_CONF, backlight_leds); | ||
470 | buttonlight_current = 0; | ||
471 | } | ||
472 | 240 | ||
473 | buttonlight_flickering--; | 241 | switch (sc606_control) |
474 | } | 242 | { |
243 | case SC606_CONTROL_IDLE: | ||
244 | if(sc606_changed) | ||
245 | sc606_control=SC606_CONTROL_A12; | ||
475 | else | 246 | else |
476 | { | 247 | sc606_control=SC606_CONTROL_IDLE; |
477 | /* is flickering triggered again? */ | ||
478 | if (!buttonlight_trigger_now) | ||
479 | { | ||
480 | /* completed a cycle - no new triggers - go back and wait */ | ||
481 | buttonlight_state = BUTTONLIGHT_MODE_FLICKER; | ||
482 | } | ||
483 | else | ||
484 | { | ||
485 | /* reset flickering */ | ||
486 | buttonlight_trigger_now = 0; | ||
487 | buttonlight_flickering = FLICKER_PERIOD; | ||
488 | |||
489 | /* turn buttonlights on */ | ||
490 | buttonlight_leds = buttonlight_selected; | ||
491 | buttonlight_current = buttonlight_setting; | ||
492 | sc606_write(SC606_REG_CONF, backlight_leds | buttonlight_leds); | ||
493 | } | ||
494 | } | ||
495 | break; | 248 | break; |
496 | 249 | case SC606_CONTROL_A12: | |
497 | 250 | sc606_write(SC606_REG_A , sc606regAval); | |
498 | /* Buttonlight mode: SIGNAL / SOLID */ | 251 | sc606_control=SC606_CONTROL_B12; |
499 | case BUTTONLIGHT_MODE_SOLID_ENTRY: | ||
500 | /* already on? turn it off */ | ||
501 | if (buttonlight_current) | ||
502 | { | ||
503 | buttonlight_leds = 0x00; | ||
504 | sc606_write(SC606_REG_CONF, backlight_leds); | ||
505 | buttonlight_current = 0; | ||
506 | } | ||
507 | |||
508 | /* set the brightness if not already set */ | ||
509 | /* temporary save for the next mode - then to do settings */ | ||
510 | buttonlight_setting = buttonlight_trigger_brightness; | ||
511 | buttonlight_saved_state = BUTTONLIGHT_MODE_SOLID; | ||
512 | buttonlight_state = BUTTONLIGHT_HELPER_SET; | ||
513 | break; | 252 | break; |
514 | 253 | case SC606_CONTROL_B12: | |
515 | 254 | sc606_write(SC606_REG_B , sc606regBval); | |
516 | case BUTTONLIGHT_MODE_SOLID: | 255 | sc606_control=SC606_CONTROL_C12; |
517 | /* wait for the foreground to trigger */ | ||
518 | if (buttonlight_trigger_now) | ||
519 | { | ||
520 | /* turn them on if not already on */ | ||
521 | if (0 == buttonlight_current) | ||
522 | { | ||
523 | buttonlight_leds = buttonlight_selected; | ||
524 | buttonlight_current = buttonlight_setting; | ||
525 | sc606_write(SC606_REG_CONF, backlight_leds | buttonlight_leds); | ||
526 | } | ||
527 | |||
528 | /* reset the trigger */ | ||
529 | buttonlight_trigger_now = 0; | ||
530 | } | ||
531 | else | ||
532 | { | ||
533 | if (buttonlight_current) | ||
534 | { | ||
535 | buttonlight_leds = 0x00; | ||
536 | sc606_write(SC606_REG_CONF, backlight_leds); | ||
537 | buttonlight_current = 0; | ||
538 | } | ||
539 | } | ||
540 | break; | 256 | break; |
541 | 257 | case SC606_CONTROL_C12: | |
542 | 258 | sc606_write(SC606_REG_C , sc606regCval); | |
543 | /* set the brightness for the buttonlights - takes 2 passes */ | 259 | sc606_control=SC606_CONTROL_CONF; |
544 | case BUTTONLIGHT_HELPER_SET: | ||
545 | sc606_write(SC606_REG_B, buttonlight_setting-1); | ||
546 | buttonlight_state = BUTTONLIGHT_HELPER_SET_FINAL; | ||
547 | break; | 260 | break; |
548 | 261 | case SC606_CONTROL_CONF: | |
549 | case BUTTONLIGHT_HELPER_SET_FINAL: | 262 | sc606_write(SC606_REG_CONF , sc606regCONFval); |
550 | sc606_write(SC606_REG_C, buttonlight_setting-1); | 263 | sc606_changed=false; |
551 | buttonlight_current = buttonlight_setting; | 264 | sc606_control=SC606_CONTROL_IDLE; |
552 | buttonlight_state = buttonlight_saved_state; | ||
553 | break; | 265 | break; |
554 | 266 | default: | |
555 | default: | 267 | sc606_control=SC606_CONTROL_A12; |
556 | break; | 268 | break; |
557 | |||
558 | } | ||
559 | break; | ||
560 | |||
561 | |||
562 | case BACKLIGHT_CONTROL_FADE_ON_FROM_OFF: | ||
563 | backlight_leds = 0x03; | ||
564 | sc606_write(SC606_REG_CONF, 0x03 | buttonlight_leds); | ||
565 | backlight_control = BACKLIGHT_CONTROL_FADE_ON; | ||
566 | break; | ||
567 | |||
568 | |||
569 | case BACKLIGHT_CONTROL_OFF: | ||
570 | backlight_current = 0; | ||
571 | backlight_leds = 0x00; | ||
572 | sc606_write(SC606_REG_CONF, buttonlight_leds); | ||
573 | backlight_control = BACKLIGHT_CONTROL_IDLE; | ||
574 | |||
575 | break; | ||
576 | |||
577 | |||
578 | case BACKLIGHT_CONTROL_ON: | ||
579 | backlight_leds = 0x03; | ||
580 | sc606_write(SC606_REG_CONF, 0x03 | buttonlight_leds); | ||
581 | backlight_current = backlight_brightness; | ||
582 | backlight_control = BACKLIGHT_CONTROL_IDLE; | ||
583 | break; | ||
584 | |||
585 | |||
586 | case BACKLIGHT_CONTROL_SET: | ||
587 | /* The SC606 LED driver can set the brightness in 64 steps */ | ||
588 | sc606_write(SC606_REG_A, backlight_brightness-1); | ||
589 | |||
590 | /* if we were turned off - turn the backlight on */ | ||
591 | if (backlight_current) | ||
592 | { | ||
593 | backlight_current = backlight_brightness; | ||
594 | backlight_control = BACKLIGHT_CONTROL_IDLE; | ||
595 | } | ||
596 | else | ||
597 | { | ||
598 | backlight_control = BACKLIGHT_CONTROL_ON; | ||
599 | } | ||
600 | break; | ||
601 | |||
602 | |||
603 | case BACKLIGHT_CONTROL_FADE_ON: | ||
604 | if (--time_til_fade) return; | ||
605 | |||
606 | /* The SC606 LED driver can set the brightness in 64 steps */ | ||
607 | sc606_write(SC606_REG_A, backlight_current++); | ||
608 | |||
609 | /* have we hit the target? */ | ||
610 | if (backlight_current == backlight_target) | ||
611 | { | ||
612 | backlight_control = BACKLIGHT_CONTROL_IDLE; | ||
613 | } | ||
614 | else | ||
615 | { | ||
616 | time_til_fade = fade_interval; | ||
617 | } | ||
618 | break; | ||
619 | |||
620 | |||
621 | case BACKLIGHT_CONTROL_FADE_OFF: | ||
622 | if (--time_til_fade) return; | ||
623 | |||
624 | /* The SC606 LED driver can set the brightness in 64 steps */ | ||
625 | sc606_write(SC606_REG_A, --backlight_current); | ||
626 | |||
627 | /* have we hit the target? */ | ||
628 | if (backlight_current == backlight_target) | ||
629 | { | ||
630 | if (backlight_current) | ||
631 | { | ||
632 | backlight_control = BACKLIGHT_CONTROL_IDLE; | ||
633 | } | ||
634 | else | ||
635 | { | ||
636 | backlight_control = BACKLIGHT_CONTROL_OFF; | ||
637 | } | ||
638 | |||
639 | } | ||
640 | else | ||
641 | { | ||
642 | time_til_fade = fade_interval; | ||
643 | } | ||
644 | break; | ||
645 | } | 269 | } |
646 | 270 | ||
647 | if(backlight_current) | 271 | if(sc606regCONFval&0x03) |
648 | lcd_enable(true); | 272 | lcd_enable(true); |
649 | else | 273 | else |
650 | lcd_enable(false); | 274 | lcd_enable(false); |
651 | } | 275 | } |
652 | 276 | ||
277 | void __button_backlight_on(void) | ||
278 | { | ||
279 | buttonlight_control = BUTTONLIGHT_CONTROL_IDLE; | ||
280 | buttonlight_target = backlight_brightness; | ||
281 | buttonlight_control = BUTTONLIGHT_CONTROL_FADE; | ||
282 | } | ||
653 | 283 | ||
654 | 284 | void __button_backlight_off(void) | |
655 | 285 | { | |
286 | buttonlight_control = BUTTONLIGHT_CONTROL_IDLE; | ||
287 | buttonlight_target = 0; | ||
288 | buttonlight_control = BUTTONLIGHT_CONTROL_FADE; | ||
289 | } | ||
656 | 290 | ||
657 | void __backlight_dim(bool dim_now) | 291 | void __backlight_dim(bool dim_now) |
658 | { | 292 | { |
659 | unsigned short target; | ||
660 | |||
661 | /* dont let the interrupt tick happen */ | 293 | /* dont let the interrupt tick happen */ |
662 | backlight_control = BACKLIGHT_CONTROL_IDLE; | 294 | backlight_control = BACKLIGHT_CONTROL_IDLE; |
663 | 295 | backlight_target = (dim_now == true) ? 0 : backlight_brightness; | |
664 | target = (dim_now == true) ? 0 : backlight_brightness; | 296 | backlight_control = BACKLIGHT_CONTROL_FADE; |
665 | |||
666 | /* only try and fade if the target is different */ | ||
667 | if (backlight_current != target) | ||
668 | { | ||
669 | backlight_target = target; | ||
670 | |||
671 | if (backlight_current > backlight_target) | ||
672 | { | ||
673 | time_til_fade = fade_interval = 4; | ||
674 | backlight_control = BACKLIGHT_CONTROL_FADE_OFF; | ||
675 | } | ||
676 | else | ||
677 | { | ||
678 | time_til_fade = fade_interval = 1; | ||
679 | if (backlight_current) | ||
680 | { | ||
681 | backlight_control = BACKLIGHT_CONTROL_FADE_ON; | ||
682 | } | ||
683 | else | ||
684 | { | ||
685 | backlight_control = BACKLIGHT_CONTROL_FADE_ON_FROM_OFF; | ||
686 | } | ||
687 | } | ||
688 | } | ||
689 | |||
690 | } | 297 | } |
691 | |||
692 | |||
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/backlight-target.h b/firmware/target/arm/s3c2440/gigabeat-fx/backlight-target.h index 5f92cee935..401aa9c5e4 100644 --- a/firmware/target/arm/s3c2440/gigabeat-fx/backlight-target.h +++ b/firmware/target/arm/s3c2440/gigabeat-fx/backlight-target.h | |||
@@ -19,18 +19,6 @@ | |||
19 | #ifndef BACKLIGHT_TARGET_H | 19 | #ifndef BACKLIGHT_TARGET_H |
20 | #define BACKLIGHT_TARGET_H | 20 | #define BACKLIGHT_TARGET_H |
21 | 21 | ||
22 | |||
23 | /* select the led */ | ||
24 | enum buttonlight_selection | ||
25 | { | ||
26 | /* all leds */ | ||
27 | BUTTONLIGHT_LED_ALL, | ||
28 | |||
29 | /* only the menu/power led (two buttons for one LED) */ | ||
30 | BUTTONLIGHT_LED_MENU | ||
31 | }; | ||
32 | |||
33 | |||
34 | /* Use these to set the buttonlight mode */ | 22 | /* Use these to set the buttonlight mode */ |
35 | enum buttonlight_mode | 23 | enum buttonlight_mode |
36 | { | 24 | { |
@@ -40,47 +28,27 @@ enum buttonlight_mode | |||
40 | /* buttonlights always off */ | 28 | /* buttonlights always off */ |
41 | BUTTONLIGHT_OFF, | 29 | BUTTONLIGHT_OFF, |
42 | 30 | ||
43 | /* buttonlights always on but set at lowest brightness */ | ||
44 | BUTTONLIGHT_FAINT, | ||
45 | |||
46 | /* buttonlights flicker when triggered - continues to flicker | ||
47 | * even if the flicker is still asserted. | ||
48 | */ | ||
49 | BUTTONLIGHT_FLICKER, | ||
50 | |||
51 | /* buttonlights solid for as long as triggered */ | ||
52 | BUTTONLIGHT_SIGNAL, | ||
53 | |||
54 | /* buttonlights follow backlight */ | 31 | /* buttonlights follow backlight */ |
55 | BUTTONLIGHT_FOLLOW, | 32 | BUTTONLIGHT_FOLLOW |
56 | |||
57 | /* buttonlights show battery charging */ | ||
58 | BUTTONLIGHT_CHARGING, | ||
59 | }; | 33 | }; |
60 | 34 | ||
61 | |||
62 | /* Call this to flicker or signal the button lights. Only is effective for | 35 | /* Call this to flicker or signal the button lights. Only is effective for |
63 | * modes that take a trigger input. | 36 | * modes that take a trigger input. |
64 | */ | 37 | */ |
65 | void __buttonlight_trigger(void); | 38 | void __buttonlight_trigger(void); |
66 | 39 | ||
67 | |||
68 | /* select which led to use on the button lights. Other combinations are | ||
69 | * possible, but don't look very good. | ||
70 | */ | ||
71 | |||
72 | /* map the mode from the command into the state machine entries */ | 40 | /* map the mode from the command into the state machine entries */ |
73 | /* See enum buttonlight_mode for available functions */ | 41 | /* See enum buttonlight_mode for available functions */ |
74 | void __buttonlight_mode(enum buttonlight_mode mode, | 42 | void __buttonlight_mode(enum buttonlight_mode mode); |
75 | enum buttonlight_selection selection, | ||
76 | unsigned short brightness); | ||
77 | |||
78 | 43 | ||
79 | bool __backlight_init(void); | 44 | bool __backlight_init(void); |
80 | void __backlight_on(void); | 45 | void __backlight_on(void); |
81 | void __backlight_off(void); | 46 | void __backlight_off(void); |
82 | void __backlight_set_brightness(int val); | 47 | void __backlight_set_brightness(int val); |
83 | 48 | ||
49 | void __button_backlight_on(void); | ||
50 | void __button_backlight_off(void); | ||
51 | |||
84 | /* true: backlight fades off - false: backlight fades on */ | 52 | /* true: backlight fades off - false: backlight fades on */ |
85 | void __backlight_dim(bool dim); | 53 | void __backlight_dim(bool dim); |
86 | 54 | ||
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/button-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/button-meg-fx.c index 71d45c385c..25a69d7630 100644 --- a/firmware/target/arm/s3c2440/gigabeat-fx/button-meg-fx.c +++ b/firmware/target/arm/s3c2440/gigabeat-fx/button-meg-fx.c | |||
@@ -17,7 +17,6 @@ | |||
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | 19 | ||
20 | #include <stdlib.h> | ||
21 | #include "config.h" | 20 | #include "config.h" |
22 | #include "cpu.h" | 21 | #include "cpu.h" |
23 | #include "system.h" | 22 | #include "system.h" |
@@ -44,24 +43,16 @@ static int const remote_buttons[] = | |||
44 | BUTTON_NONE, /* Nothing in the headphone socket */ | 43 | BUTTON_NONE, /* Nothing in the headphone socket */ |
45 | }; | 44 | }; |
46 | 45 | ||
47 | |||
48 | |||
49 | |||
50 | |||
51 | void button_init_device(void) | 46 | void button_init_device(void) |
52 | { | 47 | { |
53 | /* Power, Remote Play & Hold switch */ | 48 | /* Power, Remote Play & Hold switch */ |
54 | } | 49 | } |
55 | 50 | ||
56 | |||
57 | |||
58 | inline bool button_hold(void) | 51 | inline bool button_hold(void) |
59 | { | 52 | { |
60 | return (GPGDAT & (1 << 15)); | 53 | return (GPGDAT & (1 << 15)); |
61 | } | 54 | } |
62 | 55 | ||
63 | |||
64 | |||
65 | int button_read_device(void) | 56 | int button_read_device(void) |
66 | { | 57 | { |
67 | int touchpad; | 58 | int touchpad; |
@@ -91,6 +82,7 @@ int button_read_device(void) | |||
91 | /* if the buttons dont agree twice in a row, then its none */ | 82 | /* if the buttons dont agree twice in a row, then its none */ |
92 | lastbutton = btn; | 83 | lastbutton = btn; |
93 | btn = BUTTON_NONE; | 84 | btn = BUTTON_NONE; |
85 | button_backlight_on(); | ||
94 | } | 86 | } |
95 | 87 | ||
96 | /* Check for hold first - exit if asserted with no button pressed */ | 88 | /* Check for hold first - exit if asserted with no button pressed */ |
@@ -115,6 +107,7 @@ int button_read_device(void) | |||
115 | 107 | ||
116 | if (buttons & (1 << 4)) | 108 | if (buttons & (1 << 4)) |
117 | btn |= BUTTON_A; | 109 | btn |= BUTTON_A; |
110 | button_backlight_on(); | ||
118 | } | 111 | } |
119 | 112 | ||
120 | /* the touchpad */ | 113 | /* the touchpad */ |
@@ -135,13 +128,12 @@ int button_read_device(void) | |||
135 | 128 | ||
136 | if (touchpad & (1 << 3)) | 129 | if (touchpad & (1 << 3)) |
137 | btn |= BUTTON_SELECT; | 130 | btn |= BUTTON_SELECT; |
131 | button_backlight_on(); | ||
138 | } | 132 | } |
139 | 133 | ||
140 | return btn; | 134 | return btn; |
141 | } | 135 | } |
142 | 136 | ||
143 | |||
144 | |||
145 | bool headphones_inserted(void) | 137 | bool headphones_inserted(void) |
146 | { | 138 | { |
147 | unsigned short remote_adc = adc_read(ADC_HPREMOTE); | 139 | unsigned short remote_adc = adc_read(ADC_HPREMOTE); |
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/sc606-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/sc606-meg-fx.c index e69eab432a..c207e310d9 100644 --- a/firmware/target/arm/s3c2440/gigabeat-fx/sc606-meg-fx.c +++ b/firmware/target/arm/s3c2440/gigabeat-fx/sc606-meg-fx.c | |||
@@ -1,6 +1,5 @@ | |||
1 | #include "config.h" | 1 | #include "config.h" |
2 | #include "cpu.h" | 2 | #include "cpu.h" |
3 | #include <stdbool.h> | ||
4 | #include "kernel.h" | 3 | #include "kernel.h" |
5 | #include "system.h" | 4 | #include "system.h" |
6 | #include "logf.h" | 5 | #include "logf.h" |
@@ -9,147 +8,132 @@ | |||
9 | 8 | ||
10 | #define SLAVE_ADDRESS 0xCC | 9 | #define SLAVE_ADDRESS 0xCC |
11 | 10 | ||
12 | #define SDA_LO (GPHDAT &= ~(1 << 9)) | 11 | #define USE_ASM |
13 | #define SDA_HI (GPHDAT |= (1 << 9)) | 12 | |
14 | #define SDA_INPUT (GPHCON &= ~(3 << 18)) | 13 | /* This I2C driver tristates the outputs instead of driving logic high's */ |
15 | #define SDA_OUTPUT (GPHCON |= (1 << 18)) | ||
16 | #define SDA (GPHDAT & (1 << 9)) | 14 | #define SDA (GPHDAT & (1 << 9)) |
15 | #define SDA_LO_OUT (GPHCON |= (1 << 18));(GPHDAT &= ~(1 << 9)); | ||
16 | #define SDA_HI_IN (GPHCON &= ~(3 << 18)) | ||
17 | 17 | ||
18 | #define SCL_LO (GPHDAT &= ~(1 << 10)) | ||
19 | #define SCL_HI (GPHDAT |= (1 << 10)) | ||
20 | #define SCL_INPUT (GPHCON &= ~(3 << 20)) | ||
21 | #define SCL_OUTPUT (GPHCON |= (1 << 20)) | ||
22 | #define SCL (GPHDAT & (1 << 10)) | 18 | #define SCL (GPHDAT & (1 << 10)) |
23 | 19 | #define SCL_LO_OUT (GPHCON |= (1 << 20));(GPHDAT &= ~(1 << 10)); | |
24 | #define SCL_SDA_HI (GPHDAT |= (3 << 9)) | 20 | #define SCL_HI_IN (GPHCON &= ~(3 << 20));while(!SCL); |
25 | 21 | ||
26 | /* The SC606 can clock at 400KHz: */ | 22 | /* The SC606 can clock at 400KHz: |
27 | /* Clock period high is 600nS and low is 1300nS */ | 23 | * Clock period high is 600nS and low is 1300nS |
28 | /* The high and low times are different enough to need different timings */ | 24 | * The high and low times are different enough to need different timings |
29 | /* cycles delayed = 30 + 7 * loops */ | 25 | * cycles delayed = 2 + 4 * loops |
30 | /* 100MHz = 10nS per cycle: LO:1300nS=130:14 HI:600nS=60:9 */ | 26 | * 100MHz = 10nS per cycle: LO:1300nS=130:33 HI:600nS=60:15 |
31 | /* 300MHz = 3.36nS per cycle: LO:1300nS=387:51 HI:600nS=179:21 */ | 27 | * 300MHz = 3.33nS per cycle: |
32 | #define DELAY_LO do{int x;for(x=51;x;x--);} while (0) | 28 | * LO:1300nS=394:99 |
33 | #define DELAY do{int x;for(x=35;x;x--);} while (0) | 29 | * HI:600nS=182:21 |
34 | #define DELAY_HI do{int x;for(x=21;x;x--);} while (0) | 30 | * MID(50/50):950(1900/2)ns=288:72 |
35 | 31 | */ | |
36 | 32 | ||
33 | #ifdef USE_ASM | ||
34 | |||
35 | #define DELAY_LO 99 | ||
36 | #define DELAY_MID 72 | ||
37 | #define DELAY_HI 46 | ||
38 | /* This delay loop takes 4 cycles/loop to execute plus 2 for setup */ | ||
39 | #define DELAY(dly) \ | ||
40 | asm volatile( "mov r0,%0 \n" \ | ||
41 | "1: \n" \ | ||
42 | "subs r0,r0,#1 \n" \ | ||
43 | "bhi 1b \n" \ | ||
44 | : : "r"((dly)) : "r0" ); | ||
45 | |||
46 | #else | ||
47 | |||
48 | #define DELAY_LO 51 | ||
49 | #define DELAY_MID 35 | ||
50 | #define DELAY_HI 21 | ||
51 | #define DELAY(dly) do{int x;for(x=(dly);x;x--);} while (0) | ||
52 | |||
53 | #endif | ||
37 | 54 | ||
38 | static void sc606_i2c_start(void) | 55 | static void sc606_i2c_start(void) |
39 | { | 56 | { |
40 | SCL_SDA_HI; | 57 | SDA_HI_IN; |
41 | DELAY; | 58 | SCL_HI_IN; |
42 | SDA_LO; | 59 | DELAY(DELAY_MID); |
43 | DELAY; | 60 | SDA_LO_OUT; |
44 | SCL_LO; | 61 | DELAY(DELAY_MID); |
45 | } | 62 | SCL_LO_OUT; |
46 | |||
47 | static void sc606_i2c_restart(void) | ||
48 | { | ||
49 | SCL_SDA_HI; | ||
50 | DELAY; | ||
51 | SDA_LO; | ||
52 | DELAY; | ||
53 | SCL_LO; | ||
54 | } | 63 | } |
55 | 64 | ||
56 | static void sc606_i2c_stop(void) | 65 | static void sc606_i2c_stop(void) |
57 | { | 66 | { |
58 | SDA_LO; | 67 | SDA_LO_OUT; |
59 | SCL_HI; | 68 | SCL_HI_IN; |
60 | DELAY_HI; | 69 | DELAY(DELAY_HI); |
61 | SDA_HI; | 70 | SDA_HI_IN; |
62 | } | 71 | } |
63 | 72 | ||
64 | static void sc606_i2c_ack(void) | 73 | static void sc606_i2c_ack(void) |
65 | { | 74 | { |
75 | SDA_HI_IN; | ||
76 | SCL_HI_IN; | ||
66 | 77 | ||
67 | SDA_LO; | 78 | DELAY(DELAY_HI); |
68 | SCL_HI; | 79 | SCL_LO_OUT; |
69 | DELAY_HI; | ||
70 | SCL_LO; | ||
71 | } | 80 | } |
72 | 81 | ||
73 | 82 | static bool sc606_i2c_getack(void) | |
74 | |||
75 | static int sc606_i2c_getack(void) | ||
76 | { | 83 | { |
77 | int ret; | 84 | bool ret; |
78 | |||
79 | /* Don't need a delay since follows a data bit with a delay on the end */ | ||
80 | SDA_INPUT; /* And set to input */ | ||
81 | DELAY; | ||
82 | SCL_HI; | ||
83 | 85 | ||
84 | ret = (SDA != 0); /* ack failed if SDA is not low */ | 86 | SDA_HI_IN; |
85 | DELAY_HI; | 87 | DELAY(DELAY_MID); |
88 | SCL_HI_IN; | ||
86 | 89 | ||
87 | SCL_LO; | 90 | ret = !SDA; |
88 | DELAY_LO; | ||
89 | 91 | ||
90 | SDA_HI; | 92 | SCL_LO_OUT; |
91 | SDA_OUTPUT; | 93 | DELAY(DELAY_LO); |
92 | DELAY_LO; | ||
93 | 94 | ||
94 | return ret; | 95 | return ret; |
95 | } | 96 | } |
96 | 97 | ||
97 | |||
98 | |||
99 | static void sc606_i2c_outb(unsigned char byte) | 98 | static void sc606_i2c_outb(unsigned char byte) |
100 | { | 99 | { |
101 | int i; | 100 | int i; |
102 | 101 | ||
103 | /* clock out each bit, MSB first */ | 102 | /* clock out each bit, MSB first */ |
104 | for (i = 0x80; i; i >>= 1) | 103 | for ( i=0x80; i; i>>=1 ) |
105 | { | 104 | { |
106 | if (i & byte) | 105 | if ( i & byte ) |
107 | { | 106 | SDA_HI_IN; |
108 | SDA_HI; | ||
109 | } | ||
110 | else | 107 | else |
111 | { | 108 | SDA_LO_OUT; |
112 | SDA_LO; | 109 | DELAY(DELAY_MID); |
113 | } | 110 | SCL_HI_IN; |
114 | DELAY; | 111 | DELAY(DELAY_HI); |
115 | 112 | SCL_LO_OUT; | |
116 | SCL_HI; | ||
117 | DELAY_HI; | ||
118 | |||
119 | SCL_LO; | ||
120 | DELAY_LO; | ||
121 | } | 113 | } |
122 | |||
123 | SDA_HI; | ||
124 | |||
125 | } | 114 | } |
126 | 115 | ||
127 | |||
128 | |||
129 | static unsigned char sc606_i2c_inb(void) | 116 | static unsigned char sc606_i2c_inb(void) |
130 | { | 117 | { |
131 | int i; | 118 | int i; |
132 | unsigned char byte = 0; | 119 | unsigned char byte = 0; |
133 | |||
134 | SDA_INPUT; /* And set to input */ | ||
135 | /* clock in each bit, MSB first */ | ||
136 | for (i = 0x80; i; i >>= 1) { | ||
137 | SCL_HI; | ||
138 | |||
139 | if (SDA) | ||
140 | byte |= i; | ||
141 | |||
142 | SCL_LO; | ||
143 | } | ||
144 | SDA_OUTPUT; | ||
145 | 120 | ||
146 | sc606_i2c_ack(); | 121 | /* clock in each bit, MSB first */ |
122 | SDA_HI_IN; | ||
123 | for ( i=0x80; i; i>>=1 ) | ||
124 | { | ||
125 | SCL_HI_IN; | ||
126 | DELAY(DELAY_HI); | ||
127 | if ( SDA ) | ||
128 | byte |= i; | ||
129 | SCL_LO_OUT; | ||
130 | DELAY(DELAY_LO); | ||
131 | } | ||
147 | 132 | ||
148 | return byte; | 133 | sc606_i2c_ack(); |
134 | return byte; | ||
149 | } | 135 | } |
150 | 136 | ||
151 | |||
152 | |||
153 | /* returns number of acks that were bad */ | 137 | /* returns number of acks that were bad */ |
154 | int sc606_write(unsigned char reg, unsigned char data) | 138 | int sc606_write(unsigned char reg, unsigned char data) |
155 | { | 139 | { |
@@ -163,7 +147,7 @@ int sc606_write(unsigned char reg, unsigned char data) | |||
163 | sc606_i2c_outb(reg); | 147 | sc606_i2c_outb(reg); |
164 | x += sc606_i2c_getack(); | 148 | x += sc606_i2c_getack(); |
165 | 149 | ||
166 | sc606_i2c_restart(); | 150 | sc606_i2c_start(); |
167 | 151 | ||
168 | sc606_i2c_outb(SLAVE_ADDRESS); | 152 | sc606_i2c_outb(SLAVE_ADDRESS); |
169 | x += sc606_i2c_getack(); | 153 | x += sc606_i2c_getack(); |
@@ -176,8 +160,6 @@ int sc606_write(unsigned char reg, unsigned char data) | |||
176 | return x; | 160 | return x; |
177 | } | 161 | } |
178 | 162 | ||
179 | |||
180 | |||
181 | int sc606_read(unsigned char reg, unsigned char* data) | 163 | int sc606_read(unsigned char reg, unsigned char* data) |
182 | { | 164 | { |
183 | int x; | 165 | int x; |
@@ -189,7 +171,7 @@ int sc606_read(unsigned char reg, unsigned char* data) | |||
189 | sc606_i2c_outb(reg); | 171 | sc606_i2c_outb(reg); |
190 | x += sc606_i2c_getack(); | 172 | x += sc606_i2c_getack(); |
191 | 173 | ||
192 | sc606_i2c_restart(); | 174 | sc606_i2c_start(); |
193 | sc606_i2c_outb(SLAVE_ADDRESS | 1); | 175 | sc606_i2c_outb(SLAVE_ADDRESS | 1); |
194 | x += sc606_i2c_getack(); | 176 | x += sc606_i2c_getack(); |
195 | 177 | ||
@@ -199,8 +181,6 @@ int sc606_read(unsigned char reg, unsigned char* data) | |||
199 | return x; | 181 | return x; |
200 | } | 182 | } |
201 | 183 | ||
202 | |||
203 | |||
204 | void sc606_init(void) | 184 | void sc606_init(void) |
205 | { | 185 | { |
206 | volatile int i; | 186 | volatile int i; |
@@ -214,12 +194,11 @@ void sc606_init(void) | |||
214 | 194 | ||
215 | /* About 400us - needs 350us */ | 195 | /* About 400us - needs 350us */ |
216 | for (i = 200; i; i--) | 196 | for (i = 200; i; i--) |
217 | { | 197 | DELAY(DELAY_LO); |
218 | DELAY_LO; | ||
219 | } | ||
220 | 198 | ||
221 | /* Set GPH9 (SDA) and GPH10 (SCL) to 1 */ | 199 | /* Set GPH9 (SDA) and GPH10 (SCL) to 1 */ |
222 | GPHUP &= ~(3<<9); | 200 | GPHUP &= ~(3<<9); |
223 | GPHCON = (GPHCON & ~(0xF<<18)) | 5<<18; | 201 | SCL_HI_IN; |
202 | SDA_HI_IN; | ||
224 | } | 203 | } |
225 | 204 | ||
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/system-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/system-meg-fx.c index 212b8facb2..3c9f77c5f9 100644 --- a/firmware/target/arm/s3c2440/gigabeat-fx/system-meg-fx.c +++ b/firmware/target/arm/s3c2440/gigabeat-fx/system-meg-fx.c | |||
@@ -4,7 +4,6 @@ | |||
4 | #include "mmu-meg-fx.h" | 4 | #include "mmu-meg-fx.h" |
5 | 5 | ||
6 | #include "lcd.h" | 6 | #include "lcd.h" |
7 | #include <stdio.h> | ||
8 | 7 | ||
9 | enum | 8 | enum |
10 | { | 9 | { |
@@ -65,9 +64,15 @@ void system_init(void) | |||
65 | 64 | ||
66 | /* Turn off USB host */ | 65 | /* Turn off USB host */ |
67 | CLKCON &= ~(1 << 6); | 66 | CLKCON &= ~(1 << 6); |
67 | |||
68 | /* Turn off USB device */ | ||
69 | CLKCON &= ~(1 << 7); | ||
68 | 70 | ||
69 | /* Turn off NAND flash controller */ | 71 | /* Turn off NAND flash controller */ |
70 | CLKCON &= ~(1 << 4); | 72 | CLKCON &= ~(1 << 4); |
73 | |||
74 | /* Turn off the USB PLL */ | ||
75 | CLKSLOW |= (1 << 7); | ||
71 | 76 | ||
72 | } | 77 | } |
73 | 78 | ||
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/usb-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/usb-meg-fx.c index af66e2a60c..374fb21136 100644 --- a/firmware/target/arm/s3c2440/gigabeat-fx/usb-meg-fx.c +++ b/firmware/target/arm/s3c2440/gigabeat-fx/usb-meg-fx.c | |||
@@ -17,7 +17,6 @@ | |||
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #include "config.h" | 19 | #include "config.h" |
20 | #include <stdbool.h> | ||
21 | #include "cpu.h" | 20 | #include "cpu.h" |
22 | #include "system.h" | 21 | #include "system.h" |
23 | #include "kernel.h" | 22 | #include "kernel.h" |
@@ -46,14 +45,14 @@ void usb_init_device(void) | |||
46 | /* Input is the default configuration, only pullups need to be disabled */ | 45 | /* Input is the default configuration, only pullups need to be disabled */ |
47 | /* GPFUP|=0x02; */ | 46 | /* GPFUP|=0x02; */ |
48 | 47 | ||
49 | USB_VPLUS_PWR_ASSERT; | ||
50 | GPBCON=( GPBCON&~(1<<13) ) | (1 << 12); | 48 | GPBCON=( GPBCON&~(1<<13) ) | (1 << 12); |
49 | USB_VPLUS_PWR_ASSERT; | ||
51 | 50 | ||
52 | sleep(HZ/20); | 51 | sleep(HZ/20); |
53 | 52 | ||
54 | /* Reset the usb port */ | 53 | /* Reset the usb port */ |
55 | USB_RST_ASSERT; | ||
56 | GPBCON = (GPBCON & ~0x200) | 0x100; /* Make sure reset line is an output */ | 54 | GPBCON = (GPBCON & ~0x200) | 0x100; /* Make sure reset line is an output */ |
55 | USB_RST_ASSERT; | ||
57 | 56 | ||
58 | sleep(HZ/25); | 57 | sleep(HZ/25); |
59 | USB_RST_DEASSERT; | 58 | USB_RST_DEASSERT; |
@@ -75,6 +74,9 @@ void usb_init_device(void) | |||
75 | 74 | ||
76 | void usb_enable(bool on) | 75 | void usb_enable(bool on) |
77 | { | 76 | { |
77 | GPHCON=( GPHCON&~(1<<17) ) | (1<<16); /* Make the pin an output */ | ||
78 | GPHUP|=1<<8; /* Disable pullup in SOC as we are now driving */ | ||
79 | |||
78 | if (on) | 80 | if (on) |
79 | { | 81 | { |
80 | USB_VPLUS_PWR_ASSERT; | 82 | USB_VPLUS_PWR_ASSERT; |
@@ -86,9 +88,5 @@ void usb_enable(bool on) | |||
86 | USB_VPLUS_PWR_DEASSERT; | 88 | USB_VPLUS_PWR_DEASSERT; |
87 | } | 89 | } |
88 | 90 | ||
89 | /* Make sure USB_CRADLE_BUS pin is an output */ | ||
90 | GPHCON=( GPHCON&~(1<<17) ) | (1<<16); /* Make the pin an output */ | ||
91 | GPHUP|=1<<8; /* Disable pullup in SOC as we are now driving */ | ||
92 | |||
93 | sleep(HZ/20); // > 50ms for detecting the enable state change | 91 | sleep(HZ/20); // > 50ms for detecting the enable state change |
94 | } | 92 | } |