diff options
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/button.c | 100 |
1 files changed, 98 insertions, 2 deletions
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index 1e3cbcbf32..7537cb5e7d 100644 --- a/firmware/drivers/button.c +++ b/firmware/drivers/button.c | |||
@@ -211,6 +211,13 @@ void button_init(void) | |||
211 | /* Set GPIO33, GPIO37, GPIO38 and GPIO52 as general purpose inputs */ | 211 | /* Set GPIO33, GPIO37, GPIO38 and GPIO52 as general purpose inputs */ |
212 | GPIO1_FUNCTION |= 0x00100062; | 212 | GPIO1_FUNCTION |= 0x00100062; |
213 | GPIO1_ENABLE &= ~0x00100062; | 213 | GPIO1_ENABLE &= ~0x00100062; |
214 | #elif CONFIG_KEYPAD == IRIVER_H300_PAD | ||
215 | /* Set GPIO9 and GPIO15 as general purpose inputs */ | ||
216 | GPIO_ENABLE &= ~0x00008200; | ||
217 | GPIO_FUNCTION |= 0x00008200; | ||
218 | /* Set GPIO33, GPIO37, GPIO38 and GPIO52 as general purpose inputs */ | ||
219 | GPIO1_ENABLE &= ~0x00100062; | ||
220 | GPIO1_FUNCTION |= 0x00100062; | ||
214 | #elif CONFIG_KEYPAD == RECORDER_PAD | 221 | #elif CONFIG_KEYPAD == RECORDER_PAD |
215 | /* Set PB4 and PB8 as input pins */ | 222 | /* Set PB4 and PB8 as input pins */ |
216 | PBCR1 &= 0xfffc; /* PB8MD = 00 */ | 223 | PBCR1 &= 0xfffc; /* PB8MD = 00 */ |
@@ -367,7 +374,7 @@ static int button_read(void) | |||
367 | 374 | ||
368 | int data; | 375 | int data; |
369 | 376 | ||
370 | #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) | 377 | #if CONFIG_KEYPAD == IRIVER_H100_PAD |
371 | 378 | ||
372 | static bool hold_button = false; | 379 | static bool hold_button = false; |
373 | static bool remote_hold_button = false; | 380 | static bool remote_hold_button = false; |
@@ -449,7 +456,7 @@ static int button_read(void) | |||
449 | if (data < 0xf0) | 456 | if (data < 0xf0) |
450 | btn = BUTTON_RC_REW; | 457 | btn = BUTTON_RC_REW; |
451 | } | 458 | } |
452 | 459 | ||
453 | /* special buttons */ | 460 | /* special buttons */ |
454 | data = GPIO1_READ; | 461 | data = GPIO1_READ; |
455 | if (!button_hold() && ((data & 0x20) == 0)) | 462 | if (!button_hold() && ((data & 0x20) == 0)) |
@@ -457,6 +464,95 @@ static int button_read(void) | |||
457 | if (!remote_button_hold() && ((data & 0x40) == 0)) | 464 | if (!remote_button_hold() && ((data & 0x40) == 0)) |
458 | btn |= BUTTON_RC_ON; | 465 | btn |= BUTTON_RC_ON; |
459 | 466 | ||
467 | #elif CONFIG_KEYPAD == IRIVER_H300_PAD | ||
468 | |||
469 | static bool hold_button = false; | ||
470 | static bool remote_hold_button = false; | ||
471 | |||
472 | /* light handling */ | ||
473 | if (hold_button && !button_hold()) | ||
474 | { | ||
475 | backlight_on(); | ||
476 | } | ||
477 | if (remote_hold_button && !remote_button_hold()) | ||
478 | { | ||
479 | remote_backlight_on(); | ||
480 | } | ||
481 | hold_button = button_hold(); | ||
482 | remote_hold_button = remote_button_hold(); | ||
483 | |||
484 | /* normal buttons */ | ||
485 | if (!button_hold()) | ||
486 | { | ||
487 | data = adc_scan(ADC_BUTTONS); | ||
488 | |||
489 | if (data < 0x50) | ||
490 | if (data < 0x30) | ||
491 | if (data < 0x10) | ||
492 | btn = BUTTON_SELECT; | ||
493 | else | ||
494 | btn = BUTTON_UP; | ||
495 | else | ||
496 | btn = BUTTON_LEFT; | ||
497 | else | ||
498 | if (data < 0x90) | ||
499 | if (data < 0x70) | ||
500 | btn = BUTTON_DOWN; | ||
501 | else | ||
502 | btn = BUTTON_RIGHT; | ||
503 | else | ||
504 | if(data < 0xc0) | ||
505 | btn = BUTTON_OFF; | ||
506 | } | ||
507 | |||
508 | /* remote buttons */ | ||
509 | if (!remote_button_hold()) | ||
510 | { | ||
511 | data = adc_scan(ADC_REMOTE); | ||
512 | |||
513 | if (data < 0x74) | ||
514 | if (data < 0x40) | ||
515 | if (data < 0x20) | ||
516 | if(data < 0x10) | ||
517 | btn = BUTTON_RC_STOP; | ||
518 | else | ||
519 | btn = BUTTON_RC_VOL_DOWN; | ||
520 | else | ||
521 | btn = BUTTON_RC_MODE; | ||
522 | else | ||
523 | if (data < 0x58) | ||
524 | btn = BUTTON_RC_VOL_UP; | ||
525 | else | ||
526 | btn = BUTTON_RC_BITRATE; | ||
527 | else | ||
528 | if (data < 0xb0) | ||
529 | if (data < 0x88) | ||
530 | btn = BUTTON_RC_REC; | ||
531 | else | ||
532 | btn = BUTTON_RC_SOURCE; | ||
533 | else | ||
534 | if (data < 0xd8) | ||
535 | if(data < 0xc0) | ||
536 | btn = BUTTON_RC_FF; | ||
537 | else | ||
538 | btn = BUTTON_RC_MENU; | ||
539 | else | ||
540 | if (data < 0xf0) | ||
541 | btn = BUTTON_RC_REW; | ||
542 | } | ||
543 | |||
544 | /* special buttons */ | ||
545 | data = GPIO_READ; | ||
546 | if (!button_hold() && ((data & 0x200) == 0)) | ||
547 | btn |= BUTTON_MODE; | ||
548 | if (!button_hold() && ((data & 0x8000) == 0)) | ||
549 | btn |= BUTTON_REC; | ||
550 | |||
551 | data = GPIO1_READ; | ||
552 | if (!button_hold() && ((data & 0x20) == 0)) | ||
553 | btn |= BUTTON_ON; | ||
554 | if (!remote_button_hold() && ((data & 0x40) == 0)) | ||
555 | btn |= BUTTON_RC_ON; | ||
460 | 556 | ||
461 | #elif CONFIG_KEYPAD == RECORDER_PAD | 557 | #elif CONFIG_KEYPAD == RECORDER_PAD |
462 | 558 | ||