summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-05-25 22:41:44 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-05-25 22:41:44 +0000
commit31df21c4f97b71c86dea1171b8623aa0cd14944f (patch)
treef71676449021d36a2fc148c080504e6cf43f3578
parente1374b053601b0461bddfe95123a3ae908a0dbf1 (diff)
downloadrockbox-31df21c4f97b71c86dea1171b8623aa0cd14944f.tar.gz
rockbox-31df21c4f97b71c86dea1171b8623aa0cd14944f.zip
Bring buttons back to the e200 bootloader?
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13493 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/arm/sandisk/sansa-e200/button-e200.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/firmware/target/arm/sandisk/sansa-e200/button-e200.c b/firmware/target/arm/sandisk/sansa-e200/button-e200.c
index 630162ef78..56bce816e4 100644
--- a/firmware/target/arm/sandisk/sansa-e200/button-e200.c
+++ b/firmware/target/arm/sandisk/sansa-e200/button-e200.c
@@ -28,20 +28,18 @@
28#define WHEEL_FAST_OFF_INTERVAL 6 28#define WHEEL_FAST_OFF_INTERVAL 6
29 29
30/* Clickwheel */ 30/* Clickwheel */
31#ifndef BOOTLOADER
31static unsigned int old_wheel_value = 0; 32static unsigned int old_wheel_value = 0;
32static unsigned int wheel_repeat = BUTTON_NONE; 33static unsigned int wheel_repeat = BUTTON_NONE;
33static unsigned int wheel_click_count = 0; 34static unsigned int wheel_click_count = 0;
34static int wheel_fast_mode = 0; 35static int wheel_fast_mode = 0;
35static unsigned long last_wheel_tick = 0; 36static unsigned long last_wheel_tick = 0;
36static unsigned long last_wheel_post = 0; 37static unsigned long last_wheel_post = 0;
37#ifndef BOOTLOADER
38static unsigned long next_backlight_on = 0; 38static unsigned long next_backlight_on = 0;
39#endif
40/* Buttons */ 39/* Buttons */
41static bool hold_button = false; 40static bool hold_button = false;
42#ifndef BOOTLOADER
43static bool hold_button_old = false; 41static bool hold_button_old = false;
44#endif 42#endif /* BOOTLOADER */
45static int int_btn = BUTTON_NONE; 43static int int_btn = BUTTON_NONE;
46 44
47void button_init_device(void) 45void button_init_device(void)
@@ -54,6 +52,7 @@ void button_init_device(void)
54 GPIOG_OUTPUT_EN |= 0x80; 52 GPIOG_OUTPUT_EN |= 0x80;
55 GPIOG_ENABLE = 0x80; 53 GPIOG_ENABLE = 0x80;
56 54
55#ifndef BOOTLOADER
57 GPIOH_ENABLE |= 0xc0; 56 GPIOH_ENABLE |= 0xc0;
58 GPIOH_OUTPUT_EN &= ~0xc0; 57 GPIOH_OUTPUT_EN &= ~0xc0;
59 58
@@ -85,13 +84,20 @@ void button_init_device(void)
85 84
86 last_wheel_tick = current_tick; 85 last_wheel_tick = current_tick;
87 last_wheel_post = current_tick; 86 last_wheel_post = current_tick;
87#endif /* BOOTLOADER */
88} 88}
89 89
90bool button_hold(void) 90bool button_hold(void)
91{ 91{
92#ifdef BOOTLOADER
93 return (GPIOF_INPUT_VAL & 0x80) != 0;
94#else
92 return hold_button; 95 return hold_button;
96#endif /* BOOTLOADER */
93} 97}
94 98
99/* clickwheel */
100#ifndef BOOTLOADER
95void clickwheel_int(void) 101void clickwheel_int(void)
96{ 102{
97 /* Read wheel 103 /* Read wheel
@@ -157,14 +163,13 @@ void clickwheel_int(void)
157 btn = BUTTON_NONE; 163 btn = BUTTON_NONE;
158 } 164 }
159 165
160#ifndef BOOTLOADER
161 if (TIME_AFTER(current_tick, next_backlight_on)) 166 if (TIME_AFTER(current_tick, next_backlight_on))
162 { 167 {
163 next_backlight_on = current_tick + HZ/4; 168 next_backlight_on = current_tick + HZ/4;
164 backlight_on(); 169 backlight_on();
165 button_backlight_on(); 170 button_backlight_on();
166 } 171 }
167#endif 172
168 if (btn != BUTTON_NONE) 173 if (btn != BUTTON_NONE)
169 { 174 {
170 wheel_click_count = 0; 175 wheel_click_count = 0;
@@ -185,23 +190,27 @@ void clickwheel_int(void)
185 190
186 old_wheel_value = wheel_value; 191 old_wheel_value = wheel_value;
187} 192}
193#endif /* BOOTLOADER */
188 194
195/* device buttons */
189void button_int(void) 196void button_int(void)
190{ 197{
191 unsigned char state; 198 unsigned char state;
192 199
193 GPIOF_INT_CLR = GPIOF_INT_STAT; 200 int_btn = BUTTON_NONE;
194 201
195 state = GPIOF_INPUT_VAL & 0xff; 202 state = GPIOF_INPUT_VAL & 0xff;
196 203
204#ifndef BOOTLOADER
205 GPIOF_INT_CLR = GPIOF_INT_STAT;
197 GPIOF_INT_LEV = (GPIOF_INT_LEV & ~0xff) | (state ^ 0xff); 206 GPIOF_INT_LEV = (GPIOF_INT_LEV & ~0xff) | (state ^ 0xff);
198 207
199 int_btn = BUTTON_NONE;
200
201 hold_button = (state & 0x80) != 0; 208 hold_button = (state & 0x80) != 0;
202 209
203 /* device buttons */
204 if (!hold_button) 210 if (!hold_button)
211#else
212 if (button_hold())
213#endif /* BOOTLOADER */
205 { 214 {
206 /* Read normal buttons */ 215 /* Read normal buttons */
207 if ((state & 0x01) == 0) int_btn |= BUTTON_REC; 216 if ((state & 0x01) == 0) int_btn |= BUTTON_REC;
@@ -219,15 +228,17 @@ void button_int(void)
219 */ 228 */
220int button_read_device(void) 229int button_read_device(void)
221{ 230{
222 /* Hold */ 231#ifdef BOOTLOADER
223#ifndef BOOTLOADER 232 /* Read buttons directly in the bootloader */
233 button_int();
234#else
224 /* light handling */ 235 /* light handling */
225 if (hold_button != hold_button_old) 236 if (hold_button != hold_button_old)
226 { 237 {
227 hold_button_old = hold_button; 238 hold_button_old = hold_button;
228 backlight_hold_changed(hold_button); 239 backlight_hold_changed(hold_button);
229 } 240 }
230#endif 241#endif /* BOOTLOADER */
231 242
232 /* The int_btn variable is set in the button interrupt handler */ 243 /* The int_btn variable is set in the button interrupt handler */
233 return int_btn; 244 return int_btn;