summaryrefslogtreecommitdiff
path: root/firmware/target/arm
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-01-20 14:26:58 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-01-20 14:26:58 +0000
commit5f52f6ee01fdd060fab9b72736daf06b3dbda212 (patch)
tree940b56b9e46845c8283a9c2285a4447599d90f04 /firmware/target/arm
parentee6ea59c764e023c4cf63e1ca9eac8a62cf4a2b4 (diff)
downloadrockbox-5f52f6ee01fdd060fab9b72736daf06b3dbda212.tar.gz
rockbox-5f52f6ee01fdd060fab9b72736daf06b3dbda212.zip
Fuze V2: Fix hold switch behavior. Add a GPIOx_PIN_MASK macro to AS3525.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29096 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm')
-rw-r--r--firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c32
1 files changed, 11 insertions, 21 deletions
diff --git a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
index 7920bff80e..4907de11f3 100644
--- a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
+++ b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
@@ -196,31 +196,26 @@ void button_init_device(void)
196#endif 196#endif
197} 197}
198 198
199 /* read the 2 bits at the same time */
200#define GPIOA_PIN76_offset ((1<<(6+2)) | (1<<(7+2)))
201#define GPIOA_PIN76 (*(volatile unsigned char*)(GPIOA_BASE+GPIOA_PIN76_offset))
202
203void button_gpioa_isr(void) 199void button_gpioa_isr(void)
204{ 200{
205#if defined(HAVE_SCROLLWHEEL) 201#if defined(HAVE_SCROLLWHEEL)
206 /* scroll wheel handling */ 202 /* scroll wheel handling */
207 if (GPIOA_MIS & SCROLLWHEEL_BITS) 203 if (GPIOA_MIS & SCROLLWHEEL_BITS)
208 scrollwheel(GPIOA_PIN76 >> 6); 204 scrollwheel(GPIOA_PIN_MASK(0xc0) >> 6);
209 205
210 /* ack interrupt */ 206 /* ack interrupt */
211 GPIOA_IC = SCROLLWHEEL_BITS; 207 GPIOA_IC = SCROLLWHEEL_BITS;
212#endif 208#endif
213} 209}
214 210
215
216/* 211/*
217 * Get button pressed from hardware 212 * Get button pressed from hardware
218 */ 213 */
219int button_read_device(void) 214int button_read_device(void)
220{ 215{
221 int btn = 0; 216 int btn = 0;
222 static bool hold_button_old = false;
223 static long power_counter = 0; 217 static long power_counter = 0;
218 bool hold = false;
224 unsigned gpiod6; 219 unsigned gpiod6;
225 220
226 /* if we don't wait for the fifo to empty, we'll see screen corruption 221 /* if we don't wait for the fifo to empty, we'll see screen corruption
@@ -264,14 +259,9 @@ int button_read_device(void)
264 { /* power/hold is on the same pin. we know it's hold if the bit isn't 259 { /* power/hold is on the same pin. we know it's hold if the bit isn't
265 * set now anymore */ 260 * set now anymore */
266 if (GPIOD_PIN(6) & 1<<6) 261 if (GPIOD_PIN(6) & 1<<6)
267 {
268 hold_button = false;
269 btn |= BUTTON_POWER; 262 btn |= BUTTON_POWER;
270 }
271 else 263 else
272 { 264 hold = true;
273 hold_button = true;
274 }
275 } 265 }
276 266
277 if(gpiob_pin0_dir) 267 if(gpiob_pin0_dir)
@@ -283,21 +273,21 @@ int button_read_device(void)
283#ifdef HAS_BUTTON_HOLD 273#ifdef HAS_BUTTON_HOLD
284#ifndef BOOTLOADER 274#ifndef BOOTLOADER
285 /* light handling */ 275 /* light handling */
286 if (hold_button != hold_button_old) 276 if (hold != hold_button)
287 { 277 {
288 hold_button_old = hold_button; 278 hold_button = hold;
289 backlight_hold_changed(hold_button); 279 backlight_hold_changed(hold);
290 /* mask scrollwheel irq so we don't need to check for 280 /* mask scrollwheel irq so we don't need to check for
291 * the hold button in the isr */ 281 * the hold button in the isr */
292 if (hold_button) 282 if (hold)
293 GPIOA_IE &= ~SCROLLWHEEL_BITS; 283 GPIOA_IE &= ~SCROLLWHEEL_BITS;
294 else 284 else
295 GPIOA_IE |= SCROLLWHEEL_BITS; 285 GPIOA_IE |= SCROLLWHEEL_BITS;
296 } 286 }
297#else 287#else
298 (void)hold_button_old; 288 hold_button = hold;
299#endif 289#endif /* BOOTLOADER */
300 if (hold_button) 290 if (hold)
301 { 291 {
302 power_counter = HZ; 292 power_counter = HZ;
303 return 0; 293 return 0;
@@ -311,7 +301,7 @@ int button_read_device(void)
311 power_counter--; 301 power_counter--;
312 btn &= ~BUTTON_POWER; 302 btn &= ~BUTTON_POWER;
313 } 303 }
314#endif 304#endif /* HAS_BUTTON_HOLD */
315 return btn; 305 return btn;
316} 306}
317 307