diff options
-rw-r--r-- | firmware/export/as3525.h | 5 | ||||
-rw-r--r-- | firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c | 32 |
2 files changed, 15 insertions, 22 deletions
diff --git a/firmware/export/as3525.h b/firmware/export/as3525.h index e44b4ed693..87e3fc43d7 100644 --- a/firmware/export/as3525.h +++ b/firmware/export/as3525.h | |||
@@ -343,7 +343,6 @@ CE lines | |||
343 | 343 | ||
344 | 344 | ||
345 | /* GPIO registers */ | 345 | /* GPIO registers */ |
346 | |||
347 | #define GPIOA_DIR (*(volatile unsigned char*)(GPIOA_BASE+0x400)) | 346 | #define GPIOA_DIR (*(volatile unsigned char*)(GPIOA_BASE+0x400)) |
348 | #define GPIOA_IS (*(volatile unsigned char*)(GPIOA_BASE+0x404)) | 347 | #define GPIOA_IS (*(volatile unsigned char*)(GPIOA_BASE+0x404)) |
349 | #define GPIOA_IBE (*(volatile unsigned char*)(GPIOA_BASE+0x408)) | 348 | #define GPIOA_IBE (*(volatile unsigned char*)(GPIOA_BASE+0x408)) |
@@ -354,6 +353,7 @@ CE lines | |||
354 | #define GPIOA_IC (*(volatile unsigned char*)(GPIOA_BASE+0x41C)) | 353 | #define GPIOA_IC (*(volatile unsigned char*)(GPIOA_BASE+0x41C)) |
355 | #define GPIOA_AFSEL (*(volatile unsigned char*)(GPIOA_BASE+0x420)) | 354 | #define GPIOA_AFSEL (*(volatile unsigned char*)(GPIOA_BASE+0x420)) |
356 | #define GPIOA_PIN(a) (*(volatile unsigned char*)(GPIOA_BASE+(1<<((a)+2)))) | 355 | #define GPIOA_PIN(a) (*(volatile unsigned char*)(GPIOA_BASE+(1<<((a)+2)))) |
356 | #define GPIOA_PIN_MASK(m) (*(volatile unsigned char *)(GPIOA_BASE+(((m)&0xff)<<2))) | ||
357 | #define GPIOA_DATA (*(volatile unsigned char*)(GPIOA_BASE+(0xff<<2))) | 357 | #define GPIOA_DATA (*(volatile unsigned char*)(GPIOA_BASE+(0xff<<2))) |
358 | 358 | ||
359 | 359 | ||
@@ -367,6 +367,7 @@ CE lines | |||
367 | #define GPIOB_IC (*(volatile unsigned char*)(GPIOB_BASE+0x41C)) | 367 | #define GPIOB_IC (*(volatile unsigned char*)(GPIOB_BASE+0x41C)) |
368 | #define GPIOB_AFSEL (*(volatile unsigned char*)(GPIOB_BASE+0x420)) | 368 | #define GPIOB_AFSEL (*(volatile unsigned char*)(GPIOB_BASE+0x420)) |
369 | #define GPIOB_PIN(a) (*(volatile unsigned char*)(GPIOB_BASE+(1<<((a)+2)))) | 369 | #define GPIOB_PIN(a) (*(volatile unsigned char*)(GPIOB_BASE+(1<<((a)+2)))) |
370 | #define GPIOB_PIN_MASK(m) (*(volatile unsigned char *)(GPIOB_BASE+(((m)&0xff)<<2))) | ||
370 | #define GPIOB_DATA (*(volatile unsigned char*)(GPIOB_BASE+(0xff<<2))) | 371 | #define GPIOB_DATA (*(volatile unsigned char*)(GPIOB_BASE+(0xff<<2))) |
371 | 372 | ||
372 | #define GPIOC_DIR (*(volatile unsigned char*)(GPIOC_BASE+0x400)) | 373 | #define GPIOC_DIR (*(volatile unsigned char*)(GPIOC_BASE+0x400)) |
@@ -379,6 +380,7 @@ CE lines | |||
379 | #define GPIOC_IC (*(volatile unsigned char*)(GPIOC_BASE+0x41C)) | 380 | #define GPIOC_IC (*(volatile unsigned char*)(GPIOC_BASE+0x41C)) |
380 | #define GPIOC_AFSEL (*(volatile unsigned char*)(GPIOC_BASE+0x420)) | 381 | #define GPIOC_AFSEL (*(volatile unsigned char*)(GPIOC_BASE+0x420)) |
381 | #define GPIOC_PIN(a) (*(volatile unsigned char*)(GPIOC_BASE+(1<<((a)+2)))) | 382 | #define GPIOC_PIN(a) (*(volatile unsigned char*)(GPIOC_BASE+(1<<((a)+2)))) |
383 | #define GPIOC_PIN_MASK(m) (*(volatile unsigned char *)(GPIOC_BASE+(((m)&0xff)<<2))) | ||
382 | #define GPIOC_DATA (*(volatile unsigned char*)(GPIOC_BASE+(0xff<<2))) | 384 | #define GPIOC_DATA (*(volatile unsigned char*)(GPIOC_BASE+(0xff<<2))) |
383 | 385 | ||
384 | #define GPIOD_DIR (*(volatile unsigned char*)(GPIOD_BASE+0x400)) | 386 | #define GPIOD_DIR (*(volatile unsigned char*)(GPIOD_BASE+0x400)) |
@@ -391,6 +393,7 @@ CE lines | |||
391 | #define GPIOD_IC (*(volatile unsigned char*)(GPIOD_BASE+0x41C)) | 393 | #define GPIOD_IC (*(volatile unsigned char*)(GPIOD_BASE+0x41C)) |
392 | #define GPIOD_AFSEL (*(volatile unsigned char*)(GPIOD_BASE+0x420)) | 394 | #define GPIOD_AFSEL (*(volatile unsigned char*)(GPIOD_BASE+0x420)) |
393 | #define GPIOD_PIN(a) (*(volatile unsigned char*)(GPIOD_BASE+(1<<((a)+2)))) | 395 | #define GPIOD_PIN(a) (*(volatile unsigned char*)(GPIOD_BASE+(1<<((a)+2)))) |
396 | #define GPIOD_PIN_MASK(m) (*(volatile unsigned char *)(GPIOD_BASE+(((m)&0xff)<<2))) | ||
394 | #define GPIOD_DATA (*(volatile unsigned char*)(GPIOD_BASE+(0xff<<2))) | 397 | #define GPIOD_DATA (*(volatile unsigned char*)(GPIOD_BASE+(0xff<<2))) |
395 | 398 | ||
396 | /* ARM PL172 Memory Controller registers */ | 399 | /* ARM PL172 Memory Controller registers */ |
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 | |||
203 | void button_gpioa_isr(void) | 199 | void 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 | */ |
219 | int button_read_device(void) | 214 | int 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 | ||