diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2006-10-29 10:26:41 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2006-10-29 10:26:41 +0000 |
commit | cad563b00f1013ad0c56746140ff3b30e8402b70 (patch) | |
tree | faf32a85a37e86ebaf0a0ccd2791d7a76d97cfb6 | |
parent | 3b54ab32242c3cbde346ab5a0693a9eabb4ab4f3 (diff) | |
download | rockbox-cad563b00f1013ad0c56746140ff3b30e8402b70.tar.gz rockbox-cad563b00f1013ad0c56746140ff3b30e8402b70.zip |
move the iriver h1x0/h3x0 button driver to target tree
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11380 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/drivers/button.c | 253 | ||||
-rw-r--r-- | firmware/export/button.h | 46 | ||||
-rw-r--r-- | firmware/target/coldfire/iriver/button-target.h | 81 | ||||
-rw-r--r-- | firmware/target/coldfire/iriver/h100/button-h100.c | 240 | ||||
-rw-r--r-- | firmware/target/coldfire/iriver/h300/button-h300.c | 246 | ||||
-rwxr-xr-x | tools/configure | 9 |
6 files changed, 590 insertions, 285 deletions
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index cc9f0fa18d..c4e013afdc 100644 --- a/firmware/drivers/button.c +++ b/firmware/drivers/button.c | |||
@@ -46,6 +46,9 @@ | |||
46 | 46 | ||
47 | #ifdef TARGET_TREE | 47 | #ifdef TARGET_TREE |
48 | #include "button-target.h" | 48 | #include "button-target.h" |
49 | #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) \ | ||
50 | || (CONFIG_KEYPAD == IRIVER_H300_PAD) | ||
51 | #include "button-target.h" | ||
49 | #endif | 52 | #endif |
50 | 53 | ||
51 | struct event_queue button_queue; | 54 | struct event_queue button_queue; |
@@ -82,10 +85,6 @@ static bool remote_filter_first_keypress; | |||
82 | 85 | ||
83 | static int button_read(void); | 86 | static int button_read(void); |
84 | 87 | ||
85 | #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) | ||
86 | static bool remote_button_hold_only(void); | ||
87 | #endif | ||
88 | |||
89 | #ifdef HAVE_HEADPHONE_DETECTION | 88 | #ifdef HAVE_HEADPHONE_DETECTION |
90 | bool phones_present = false; | 89 | bool phones_present = false; |
91 | #endif | 90 | #endif |
@@ -309,17 +308,9 @@ void button_init(void) | |||
309 | #ifdef TARGET_TREE | 308 | #ifdef TARGET_TREE |
310 | button_init_device(); | 309 | button_init_device(); |
311 | 310 | ||
312 | #elif CONFIG_KEYPAD == IRIVER_H100_PAD | 311 | #elif CONFIG_KEYPAD == IRIVER_H100_PAD \ |
313 | /* Set GPIO33, GPIO37, GPIO38 and GPIO52 as general purpose inputs */ | 312 | || CONFIG_KEYPAD == IRIVER_H300_PAD |
314 | GPIO1_FUNCTION |= 0x00100062; | 313 | button_init_device(); /* temp untill TARGET_TREE is defined */ |
315 | GPIO1_ENABLE &= ~0x00100060; | ||
316 | #elif CONFIG_KEYPAD == IRIVER_H300_PAD | ||
317 | /* Set GPIO9 and GPIO15 as general purpose inputs */ | ||
318 | GPIO_ENABLE &= ~0x00008200; | ||
319 | GPIO_FUNCTION |= 0x00008200; | ||
320 | /* Set GPIO33, GPIO37, GPIO38 and GPIO52 as general purpose inputs */ | ||
321 | GPIO1_ENABLE &= ~0x00100060; | ||
322 | GPIO1_FUNCTION |= 0x00100062; | ||
323 | #elif CONFIG_KEYPAD == RECORDER_PAD | 314 | #elif CONFIG_KEYPAD == RECORDER_PAD |
324 | /* Set PB4 and PB8 as input pins */ | 315 | /* Set PB4 and PB8 as input pins */ |
325 | PBCR1 &= 0xfffc; /* PB8MD = 00 */ | 316 | PBCR1 &= 0xfffc; /* PB8MD = 00 */ |
@@ -505,214 +496,19 @@ static int button_read(void) | |||
505 | int btn = BUTTON_NONE; | 496 | int btn = BUTTON_NONE; |
506 | int retval; | 497 | int retval; |
507 | #ifndef TARGET_TREE | 498 | #ifndef TARGET_TREE |
499 | #if (CONFIG_KEYPAD != IRIVER_H100_PAD) \ | ||
500 | && (CONFIG_KEYPAD != IRIVER_H300_PAD) | ||
508 | int data; | 501 | int data; |
509 | #endif | 502 | #endif |
503 | #endif | ||
510 | 504 | ||
511 | #ifdef TARGET_TREE | 505 | #ifdef TARGET_TREE |
512 | btn = button_read_device(); | 506 | btn = button_read_device(); |
513 | 507 | ||
514 | #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) | 508 | #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) \ |
515 | static bool hold_button = false; | 509 | || (CONFIG_KEYPAD == IRIVER_H300_PAD) |
516 | static bool remote_hold_button = false; | 510 | btn = button_read_device(); /* temp untill TARGET_TREE is defined */ |
517 | static int prev_data = 0xff; | ||
518 | static int last_valid = 0xff; | ||
519 | bool hold_button_old; | ||
520 | bool remote_hold_button_old; | ||
521 | |||
522 | /* normal buttons */ | ||
523 | hold_button_old = hold_button; | ||
524 | hold_button = button_hold(); | ||
525 | |||
526 | #ifndef BOOTLOADER | ||
527 | if (hold_button != hold_button_old) | ||
528 | backlight_hold_changed(hold_button); | ||
529 | #endif | ||
530 | |||
531 | if (!hold_button) | ||
532 | { | ||
533 | data = adc_scan(ADC_BUTTONS); | ||
534 | |||
535 | /* ADC debouncing: Only accept new reading if it's | ||
536 | * stable (+/-1). Use latest stable value otherwise. */ | ||
537 | if ((unsigned)(data - prev_data + 1) <= 2) | ||
538 | last_valid = data; | ||
539 | prev_data = data; | ||
540 | data = last_valid; | ||
541 | |||
542 | #if CONFIG_KEYPAD == IRIVER_H100_PAD | ||
543 | if (data < 0xf0) | ||
544 | { | ||
545 | if (data < 0x80) | ||
546 | if (data < 0x30) | ||
547 | if (data < 0x18) | ||
548 | btn = BUTTON_SELECT; | ||
549 | else | ||
550 | btn = BUTTON_UP; | ||
551 | else | ||
552 | if (data < 0x50) | ||
553 | btn = BUTTON_LEFT; | ||
554 | else | ||
555 | btn = BUTTON_DOWN; | ||
556 | else | ||
557 | if (data < 0xb0) | ||
558 | if (data < 0xa0) | ||
559 | btn = BUTTON_RIGHT; | ||
560 | else | ||
561 | btn = BUTTON_OFF; | ||
562 | else | ||
563 | if (data < 0xd0) | ||
564 | btn = BUTTON_MODE; | ||
565 | else | ||
566 | btn = BUTTON_REC; | ||
567 | } | ||
568 | #else /* H300 */ | ||
569 | if (data < 0xba) | ||
570 | { | ||
571 | if (data < 0x54) | ||
572 | if (data < 0x30) | ||
573 | if (data < 0x10) | ||
574 | btn = BUTTON_SELECT; | ||
575 | else | ||
576 | btn = BUTTON_UP; | ||
577 | else | ||
578 | btn = BUTTON_LEFT; | ||
579 | else | ||
580 | if (data < 0x98) | ||
581 | if (data < 0x76) | ||
582 | btn = BUTTON_DOWN; | ||
583 | else | ||
584 | btn = BUTTON_RIGHT; | ||
585 | else | ||
586 | btn = BUTTON_OFF; | ||
587 | } | ||
588 | #endif | ||
589 | } | ||
590 | |||
591 | /* remote buttons */ | ||
592 | remote_hold_button_old = remote_hold_button; | ||
593 | remote_hold_button = remote_button_hold_only(); | ||
594 | |||
595 | #ifndef BOOTLOADER | ||
596 | if (remote_hold_button != remote_hold_button_old) | ||
597 | remote_backlight_hold_changed(remote_hold_button); | ||
598 | #endif | ||
599 | 511 | ||
600 | if (!remote_hold_button) | ||
601 | { | ||
602 | data = adc_scan(ADC_REMOTE); | ||
603 | switch (remote_type()) | ||
604 | { | ||
605 | case REMOTETYPE_H100_LCD: | ||
606 | if (data < 0xf5) | ||
607 | { | ||
608 | if (data < 0x73) | ||
609 | if (data < 0x3f) | ||
610 | if (data < 0x25) | ||
611 | if(data < 0x0c) | ||
612 | btn |= BUTTON_RC_STOP; | ||
613 | else | ||
614 | btn |= BUTTON_RC_VOL_DOWN; | ||
615 | else | ||
616 | btn |= BUTTON_RC_MODE; | ||
617 | else | ||
618 | if (data < 0x5a) | ||
619 | btn |= BUTTON_RC_VOL_UP; | ||
620 | else | ||
621 | btn |= BUTTON_RC_BITRATE; | ||
622 | else | ||
623 | if (data < 0xa8) | ||
624 | if (data < 0x8c) | ||
625 | btn |= BUTTON_RC_REC; | ||
626 | else | ||
627 | btn |= BUTTON_RC_SOURCE; | ||
628 | else | ||
629 | if (data < 0xdf) | ||
630 | if(data < 0xc5) | ||
631 | btn |= BUTTON_RC_FF; | ||
632 | else | ||
633 | btn |= BUTTON_RC_MENU; | ||
634 | else | ||
635 | btn |= BUTTON_RC_REW; | ||
636 | } | ||
637 | break; | ||
638 | case REMOTETYPE_H300_LCD: | ||
639 | if (data < 0xf5) | ||
640 | { | ||
641 | if (data < 0x73) | ||
642 | if (data < 0x42) | ||
643 | if (data < 0x27) | ||
644 | if(data < 0x0c) | ||
645 | btn |= BUTTON_RC_VOL_DOWN; | ||
646 | else | ||
647 | btn |= BUTTON_RC_FF; | ||
648 | else | ||
649 | btn |= BUTTON_RC_STOP; | ||
650 | else | ||
651 | if (data < 0x5b) | ||
652 | btn |= BUTTON_RC_MODE; | ||
653 | else | ||
654 | btn |= BUTTON_RC_REC; | ||
655 | else | ||
656 | if (data < 0xab) | ||
657 | if (data < 0x8e) | ||
658 | btn |= BUTTON_RC_ON; | ||
659 | else | ||
660 | btn |= BUTTON_RC_BITRATE; | ||
661 | else | ||
662 | if (data < 0xde) | ||
663 | if(data < 0xc5) | ||
664 | btn |= BUTTON_RC_SOURCE; | ||
665 | else | ||
666 | btn |= BUTTON_RC_VOL_UP; | ||
667 | else | ||
668 | btn |= BUTTON_RC_REW; | ||
669 | } | ||
670 | break; | ||
671 | case REMOTETYPE_H300_NONLCD: | ||
672 | if (data < 0xf1) | ||
673 | { | ||
674 | if (data < 0x7d) | ||
675 | if (data < 0x25) | ||
676 | btn |= BUTTON_RC_FF; | ||
677 | else | ||
678 | btn |= BUTTON_RC_REW; | ||
679 | else | ||
680 | if (data < 0xd5) | ||
681 | btn |= BUTTON_RC_VOL_DOWN; | ||
682 | else | ||
683 | btn |= BUTTON_RC_VOL_UP; | ||
684 | } | ||
685 | break; | ||
686 | } | ||
687 | } | ||
688 | |||
689 | /* special buttons */ | ||
690 | #if CONFIG_KEYPAD == IRIVER_H300_PAD | ||
691 | if (!hold_button) | ||
692 | { | ||
693 | data = GPIO_READ; | ||
694 | if ((data & 0x0200) == 0) | ||
695 | btn |= BUTTON_MODE; | ||
696 | if ((data & 0x8000) == 0) | ||
697 | btn |= BUTTON_REC; | ||
698 | } | ||
699 | #endif | ||
700 | |||
701 | data = GPIO1_READ; | ||
702 | if (!hold_button && ((data & 0x20) == 0)) | ||
703 | btn |= BUTTON_ON; | ||
704 | if (!remote_hold_button && ((data & 0x40) == 0)) | ||
705 | switch(remote_type()) | ||
706 | { | ||
707 | case REMOTETYPE_H100_LCD: | ||
708 | case REMOTETYPE_H300_NONLCD: | ||
709 | btn |= BUTTON_RC_ON; | ||
710 | break; | ||
711 | case REMOTETYPE_H300_LCD: | ||
712 | btn |= BUTTON_RC_MENU; | ||
713 | break; | ||
714 | } | ||
715 | |||
716 | #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD | 512 | #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD |
717 | static bool hold_button = false; | 513 | static bool hold_button = false; |
718 | bool hold_button_old; | 514 | bool hold_button_old; |
@@ -910,31 +706,6 @@ static int button_read(void) | |||
910 | return retval; | 706 | return retval; |
911 | } | 707 | } |
912 | 708 | ||
913 | #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) | ||
914 | bool button_hold(void) | ||
915 | { | ||
916 | return (GPIO1_READ & 0x00000002)?true:false; | ||
917 | } | ||
918 | |||
919 | static bool remote_button_hold_only(void) | ||
920 | { | ||
921 | if(remote_type() == REMOTETYPE_H300_NONLCD) | ||
922 | return adc_scan(ADC_REMOTE)<0x0d; /* hold should be 0x00 */ | ||
923 | else | ||
924 | return (GPIO1_READ & 0x00100000)?true:false; | ||
925 | } | ||
926 | |||
927 | /* returns true only if there is remote present */ | ||
928 | bool remote_button_hold(void) | ||
929 | { | ||
930 | /* H300's NON-LCD remote doesn't set the "remote present" bit */ | ||
931 | if(remote_type() == REMOTETYPE_H300_NONLCD) | ||
932 | return remote_button_hold_only(); | ||
933 | else | ||
934 | return ((GPIO_READ & 0x40000000) == 0)?remote_button_hold_only():false; | ||
935 | } | ||
936 | #endif | ||
937 | |||
938 | #if CONFIG_KEYPAD == IRIVER_IFP7XX_PAD | 709 | #if CONFIG_KEYPAD == IRIVER_IFP7XX_PAD |
939 | bool button_hold(void) | 710 | bool button_hold(void) |
940 | { | 711 | { |
diff --git a/firmware/export/button.h b/firmware/export/button.h index 686fe79937..18da59e13a 100644 --- a/firmware/export/button.h +++ b/firmware/export/button.h | |||
@@ -72,51 +72,9 @@ void wheel_send_events(bool send); | |||
72 | #else | 72 | #else |
73 | 73 | ||
74 | /* Target specific button codes */ | 74 | /* Target specific button codes */ |
75 | 75 | #if (CONFIG_KEYPAD == IRIVER_H100_PAD) \ | |
76 | #if (CONFIG_KEYPAD == IRIVER_H100_PAD)\ | ||
77 | || (CONFIG_KEYPAD == IRIVER_H300_PAD) | 76 | || (CONFIG_KEYPAD == IRIVER_H300_PAD) |
78 | 77 | #include "button-target.h" | |
79 | /* iRiver H100/H300 specific button codes */ | ||
80 | |||
81 | /* Main unit's buttons */ | ||
82 | #define BUTTON_ON 0x00000001 | ||
83 | #define BUTTON_OFF 0x00000002 | ||
84 | |||
85 | #define BUTTON_LEFT 0x00000004 | ||
86 | #define BUTTON_RIGHT 0x00000008 | ||
87 | #define BUTTON_UP 0x00000010 | ||
88 | #define BUTTON_DOWN 0x00000020 | ||
89 | |||
90 | #define BUTTON_REC 0x00000040 | ||
91 | #define BUTTON_MODE 0x00000080 | ||
92 | |||
93 | #define BUTTON_SELECT 0x00000100 | ||
94 | |||
95 | #define BUTTON_MAIN (BUTTON_ON|BUTTON_OFF|BUTTON_LEFT|BUTTON_RIGHT|\ | ||
96 | BUTTON_UP|BUTTON_DOWN|BUTTON_REC|BUTTON_MODE|BUTTON_SELECT) | ||
97 | |||
98 | /* Remote control's buttons */ | ||
99 | #define BUTTON_RC_ON 0x00100000 | ||
100 | #define BUTTON_RC_STOP 0x00080000 | ||
101 | |||
102 | #define BUTTON_RC_REW 0x00040000 | ||
103 | #define BUTTON_RC_FF 0x00020000 | ||
104 | #define BUTTON_RC_VOL_UP 0x00010000 | ||
105 | #define BUTTON_RC_VOL_DOWN 0x00008000 | ||
106 | |||
107 | #define BUTTON_RC_REC 0x00004000 | ||
108 | #define BUTTON_RC_MODE 0x00002000 | ||
109 | |||
110 | #define BUTTON_RC_MENU 0x00001000 | ||
111 | |||
112 | #define BUTTON_RC_BITRATE 0x00000800 | ||
113 | #define BUTTON_RC_SOURCE 0x00000400 | ||
114 | |||
115 | #define BUTTON_REMOTE (BUTTON_RC_ON|BUTTON_RC_STOP|BUTTON_RC_REW|BUTTON_RC_FF\ | ||
116 | |BUTTON_RC_VOL_UP|BUTTON_RC_VOL_DOWN|BUTTON_RC_REC\ | ||
117 | |BUTTON_RC_MODE|BUTTON_RC_MENU|BUTTON_RC_BITRATE\ | ||
118 | |BUTTON_RC_SOURCE) | ||
119 | |||
120 | #elif CONFIG_KEYPAD == RECORDER_PAD | 78 | #elif CONFIG_KEYPAD == RECORDER_PAD |
121 | 79 | ||
122 | /* Recorder specific button codes */ | 80 | /* Recorder specific button codes */ |
diff --git a/firmware/target/coldfire/iriver/button-target.h b/firmware/target/coldfire/iriver/button-target.h new file mode 100644 index 0000000000..b89761b317 --- /dev/null +++ b/firmware/target/coldfire/iriver/button-target.h | |||
@@ -0,0 +1,81 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Jonathan Gordon | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | /* Custom written for the Hxxx */ | ||
21 | |||
22 | #ifndef _BUTTON_TARGET_H_ | ||
23 | #define _BUTTON_TARGET_H_ | ||
24 | |||
25 | #include <stdbool.h> | ||
26 | #include "config.h" | ||
27 | |||
28 | #define HAS_BUTTON_HOLD | ||
29 | #define HAS_REMOTE_BUTTON_HOLD | ||
30 | |||
31 | bool button_hold(void); | ||
32 | bool remote_button_hold(void); | ||
33 | bool remote_button_hold_only(void); | ||
34 | void button_init_device(void); | ||
35 | int button_read_device(void); | ||
36 | |||
37 | /* iRiver H100/H300 specific button codes */ | ||
38 | |||
39 | /* Main unit's buttons */ | ||
40 | #define BUTTON_ON 0x00000001 | ||
41 | #define BUTTON_OFF 0x00000002 | ||
42 | |||
43 | #define BUTTON_LEFT 0x00000004 | ||
44 | #define BUTTON_RIGHT 0x00000008 | ||
45 | #define BUTTON_UP 0x00000010 | ||
46 | #define BUTTON_DOWN 0x00000020 | ||
47 | |||
48 | #define BUTTON_REC 0x00000040 | ||
49 | #define BUTTON_MODE 0x00000080 | ||
50 | |||
51 | #define BUTTON_SELECT 0x00000100 | ||
52 | |||
53 | #define BUTTON_MAIN (BUTTON_ON|BUTTON_OFF|BUTTON_LEFT|BUTTON_RIGHT|\ | ||
54 | BUTTON_UP|BUTTON_DOWN|BUTTON_REC|BUTTON_MODE|BUTTON_SELECT) | ||
55 | |||
56 | /* Remote control's buttons */ | ||
57 | #define BUTTON_RC_ON 0x00100000 | ||
58 | #define BUTTON_RC_STOP 0x00080000 | ||
59 | |||
60 | #define BUTTON_RC_REW 0x00040000 | ||
61 | #define BUTTON_RC_FF 0x00020000 | ||
62 | #define BUTTON_RC_VOL_UP 0x00010000 | ||
63 | #define BUTTON_RC_VOL_DOWN 0x00008000 | ||
64 | |||
65 | #define BUTTON_RC_REC 0x00004000 | ||
66 | #define BUTTON_RC_MODE 0x00002000 | ||
67 | |||
68 | #define BUTTON_RC_MENU 0x00001000 | ||
69 | |||
70 | #define BUTTON_RC_BITRATE 0x00000800 | ||
71 | #define BUTTON_RC_SOURCE 0x00000400 | ||
72 | |||
73 | #define BUTTON_REMOTE (BUTTON_RC_ON|BUTTON_RC_STOP|BUTTON_RC_REW|BUTTON_RC_FF\ | ||
74 | |BUTTON_RC_VOL_UP|BUTTON_RC_VOL_DOWN|BUTTON_RC_REC\ | ||
75 | |BUTTON_RC_MODE|BUTTON_RC_MENU|BUTTON_RC_BITRATE\ | ||
76 | |BUTTON_RC_SOURCE) | ||
77 | |||
78 | #define POWEROFF_BUTTON BUTTON_OFF | ||
79 | #define POWEROFF_COUNT 10 | ||
80 | |||
81 | #endif /* _BUTTON_TARGET_H_ */ | ||
diff --git a/firmware/target/coldfire/iriver/h100/button-h100.c b/firmware/target/coldfire/iriver/h100/button-h100.c new file mode 100644 index 0000000000..caf7cfdaca --- /dev/null +++ b/firmware/target/coldfire/iriver/h100/button-h100.c | |||
@@ -0,0 +1,240 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Jonathan Gordon | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | |||
21 | #include <stdlib.h> | ||
22 | #include "config.h" | ||
23 | #include "cpu.h" | ||
24 | #include "system.h" | ||
25 | #include "button.h" | ||
26 | #include "kernel.h" | ||
27 | #include "backlight.h" | ||
28 | #include "adc.h" | ||
29 | #include "system.h" | ||
30 | #ifdef HAVE_REMOTE_LCD | ||
31 | #include "lcd-remote.h" | ||
32 | #endif | ||
33 | |||
34 | void button_init_device(void) | ||
35 | { | ||
36 | /* Set GPIO33, GPIO37, GPIO38 and GPIO52 as general purpose inputs */ | ||
37 | GPIO1_FUNCTION |= 0x00100062; | ||
38 | GPIO1_ENABLE &= ~0x00100060; | ||
39 | } | ||
40 | |||
41 | bool button_hold(void) | ||
42 | { | ||
43 | return (GPIO1_READ & 0x00000002)?true:false; | ||
44 | } | ||
45 | |||
46 | bool remote_button_hold_only(void) | ||
47 | { | ||
48 | if(remote_type() == REMOTETYPE_H300_NONLCD) | ||
49 | return adc_scan(ADC_REMOTE)<0x0d; /* hold should be 0x00 */ | ||
50 | else | ||
51 | return (GPIO1_READ & 0x00100000)?true:false; | ||
52 | } | ||
53 | |||
54 | /* returns true only if there is remote present */ | ||
55 | bool remote_button_hold(void) | ||
56 | { | ||
57 | /* H300's NON-LCD remote doesn't set the "remote present" bit */ | ||
58 | if(remote_type() == REMOTETYPE_H300_NONLCD) | ||
59 | return remote_button_hold_only(); | ||
60 | else | ||
61 | return ((GPIO_READ & 0x40000000) == 0)?remote_button_hold_only():false; | ||
62 | } | ||
63 | |||
64 | /* | ||
65 | * Get button pressed from hardware | ||
66 | */ | ||
67 | int button_read_device(void) | ||
68 | { | ||
69 | int btn = BUTTON_NONE; | ||
70 | int data; | ||
71 | static bool hold_button = false; | ||
72 | static bool remote_hold_button = false; | ||
73 | static int prev_data = 0xff; | ||
74 | static int last_valid = 0xff; | ||
75 | bool hold_button_old; | ||
76 | bool remote_hold_button_old; | ||
77 | |||
78 | /* normal buttons */ | ||
79 | hold_button_old = hold_button; | ||
80 | hold_button = button_hold(); | ||
81 | |||
82 | |||
83 | #ifndef BOOTLOADER | ||
84 | if (hold_button != hold_button_old) | ||
85 | backlight_hold_changed(hold_button); | ||
86 | #endif | ||
87 | |||
88 | if (!hold_button) | ||
89 | { | ||
90 | data = adc_scan(ADC_BUTTONS); | ||
91 | |||
92 | /* ADC debouncing: Only accept new reading if it's | ||
93 | * stable (+/-1). Use latest stable value otherwise. */ | ||
94 | if ((unsigned)(data - prev_data + 1) <= 2) | ||
95 | last_valid = data; | ||
96 | prev_data = data; | ||
97 | data = last_valid; | ||
98 | |||
99 | if (data < 0xf0) | ||
100 | { | ||
101 | if (data < 0x80) | ||
102 | if (data < 0x30) | ||
103 | if (data < 0x18) | ||
104 | btn = BUTTON_SELECT; | ||
105 | else | ||
106 | btn = BUTTON_UP; | ||
107 | else | ||
108 | if (data < 0x50) | ||
109 | btn = BUTTON_LEFT; | ||
110 | else | ||
111 | btn = BUTTON_DOWN; | ||
112 | else | ||
113 | if (data < 0xb0) | ||
114 | if (data < 0xa0) | ||
115 | btn = BUTTON_RIGHT; | ||
116 | else | ||
117 | btn = BUTTON_OFF; | ||
118 | else | ||
119 | if (data < 0xd0) | ||
120 | btn = BUTTON_MODE; | ||
121 | else | ||
122 | btn = BUTTON_REC; | ||
123 | } | ||
124 | } | ||
125 | |||
126 | /* remote buttons */ | ||
127 | remote_hold_button_old = remote_hold_button; | ||
128 | remote_hold_button = remote_button_hold_only(); | ||
129 | |||
130 | #ifndef BOOTLOADER | ||
131 | if (remote_hold_button != remote_hold_button_old) | ||
132 | remote_backlight_hold_changed(remote_hold_button); | ||
133 | #endif | ||
134 | |||
135 | if (!remote_hold_button) | ||
136 | { | ||
137 | data = adc_scan(ADC_REMOTE); | ||
138 | switch (remote_type()) | ||
139 | { | ||
140 | case REMOTETYPE_H100_LCD: | ||
141 | if (data < 0xf5) | ||
142 | { | ||
143 | if (data < 0x73) | ||
144 | if (data < 0x3f) | ||
145 | if (data < 0x25) | ||
146 | if(data < 0x0c) | ||
147 | btn |= BUTTON_RC_STOP; | ||
148 | else | ||
149 | btn |= BUTTON_RC_VOL_DOWN; | ||
150 | else | ||
151 | btn |= BUTTON_RC_MODE; | ||
152 | else | ||
153 | if (data < 0x5a) | ||
154 | btn |= BUTTON_RC_VOL_UP; | ||
155 | else | ||
156 | btn |= BUTTON_RC_BITRATE; | ||
157 | else | ||
158 | if (data < 0xa8) | ||
159 | if (data < 0x8c) | ||
160 | btn |= BUTTON_RC_REC; | ||
161 | else | ||
162 | btn |= BUTTON_RC_SOURCE; | ||
163 | else | ||
164 | if (data < 0xdf) | ||
165 | if(data < 0xc5) | ||
166 | btn |= BUTTON_RC_FF; | ||
167 | else | ||
168 | btn |= BUTTON_RC_MENU; | ||
169 | else | ||
170 | btn |= BUTTON_RC_REW; | ||
171 | } | ||
172 | break; | ||
173 | case REMOTETYPE_H300_LCD: | ||
174 | if (data < 0xf5) | ||
175 | { | ||
176 | if (data < 0x73) | ||
177 | if (data < 0x42) | ||
178 | if (data < 0x27) | ||
179 | if(data < 0x0c) | ||
180 | btn |= BUTTON_RC_VOL_DOWN; | ||
181 | else | ||
182 | btn |= BUTTON_RC_FF; | ||
183 | else | ||
184 | btn |= BUTTON_RC_STOP; | ||
185 | else | ||
186 | if (data < 0x5b) | ||
187 | btn |= BUTTON_RC_MODE; | ||
188 | else | ||
189 | btn |= BUTTON_RC_REC; | ||
190 | else | ||
191 | if (data < 0xab) | ||
192 | if (data < 0x8e) | ||
193 | btn |= BUTTON_RC_ON; | ||
194 | else | ||
195 | btn |= BUTTON_RC_BITRATE; | ||
196 | else | ||
197 | if (data < 0xde) | ||
198 | if(data < 0xc5) | ||
199 | btn |= BUTTON_RC_SOURCE; | ||
200 | else | ||
201 | btn |= BUTTON_RC_VOL_UP; | ||
202 | else | ||
203 | btn |= BUTTON_RC_REW; | ||
204 | } | ||
205 | break; | ||
206 | case REMOTETYPE_H300_NONLCD: | ||
207 | if (data < 0xf1) | ||
208 | { | ||
209 | if (data < 0x7d) | ||
210 | if (data < 0x25) | ||
211 | btn |= BUTTON_RC_FF; | ||
212 | else | ||
213 | btn |= BUTTON_RC_REW; | ||
214 | else | ||
215 | if (data < 0xd5) | ||
216 | btn |= BUTTON_RC_VOL_DOWN; | ||
217 | else | ||
218 | btn |= BUTTON_RC_VOL_UP; | ||
219 | } | ||
220 | break; | ||
221 | } | ||
222 | } | ||
223 | |||
224 | data = GPIO1_READ; | ||
225 | if (!hold_button && ((data & 0x20) == 0)) | ||
226 | btn |= BUTTON_ON; | ||
227 | if (!remote_hold_button && ((data & 0x40) == 0)) | ||
228 | switch(remote_type()) | ||
229 | { | ||
230 | case REMOTETYPE_H100_LCD: | ||
231 | case REMOTETYPE_H300_NONLCD: | ||
232 | btn |= BUTTON_RC_ON; | ||
233 | break; | ||
234 | case REMOTETYPE_H300_LCD: | ||
235 | btn |= BUTTON_RC_MENU; | ||
236 | break; | ||
237 | } | ||
238 | |||
239 | return btn; | ||
240 | } | ||
diff --git a/firmware/target/coldfire/iriver/h300/button-h300.c b/firmware/target/coldfire/iriver/h300/button-h300.c new file mode 100644 index 0000000000..80210b6c19 --- /dev/null +++ b/firmware/target/coldfire/iriver/h300/button-h300.c | |||
@@ -0,0 +1,246 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Jonathan Gordon | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | |||
21 | #include <stdlib.h> | ||
22 | #include "config.h" | ||
23 | #include "cpu.h" | ||
24 | #include "system.h" | ||
25 | #include "button.h" | ||
26 | #include "kernel.h" | ||
27 | #include "backlight.h" | ||
28 | #include "adc.h" | ||
29 | #include "system.h" | ||
30 | #ifdef HAVE_REMOTE_LCD | ||
31 | #include "lcd-remote.h" | ||
32 | #endif | ||
33 | |||
34 | void button_init_device(void) | ||
35 | { | ||
36 | /* Set GPIO9 and GPIO15 as general purpose inputs */ | ||
37 | GPIO_ENABLE &= ~0x00008200; | ||
38 | GPIO_FUNCTION |= 0x00008200; | ||
39 | /* Set GPIO33, GPIO37, GPIO38 and GPIO52 as general purpose inputs */ | ||
40 | GPIO1_ENABLE &= ~0x00100060; | ||
41 | GPIO1_FUNCTION |= 0x00100062; | ||
42 | } | ||
43 | |||
44 | bool button_hold(void) | ||
45 | { | ||
46 | return (GPIO1_READ & 0x00000002)?true:false; | ||
47 | } | ||
48 | |||
49 | bool remote_button_hold_only(void) | ||
50 | { | ||
51 | if(remote_type() == REMOTETYPE_H300_NONLCD) | ||
52 | return adc_scan(ADC_REMOTE)<0x0d; /* hold should be 0x00 */ | ||
53 | else | ||
54 | return (GPIO1_READ & 0x00100000)?true:false; | ||
55 | } | ||
56 | |||
57 | /* returns true only if there is remote present */ | ||
58 | bool remote_button_hold(void) | ||
59 | { | ||
60 | /* H300's NON-LCD remote doesn't set the "remote present" bit */ | ||
61 | if(remote_type() == REMOTETYPE_H300_NONLCD) | ||
62 | return remote_button_hold_only(); | ||
63 | else | ||
64 | return ((GPIO_READ & 0x40000000) == 0)?remote_button_hold_only():false; | ||
65 | } | ||
66 | |||
67 | /* | ||
68 | * Get button pressed from hardware | ||
69 | */ | ||
70 | int button_read_device(void) | ||
71 | { | ||
72 | int btn = BUTTON_NONE; | ||
73 | int data; | ||
74 | static bool hold_button = false; | ||
75 | static bool remote_hold_button = false; | ||
76 | static int prev_data = 0xff; | ||
77 | static int last_valid = 0xff; | ||
78 | bool hold_button_old; | ||
79 | bool remote_hold_button_old; | ||
80 | |||
81 | /* normal buttons */ | ||
82 | hold_button_old = hold_button; | ||
83 | hold_button = button_hold(); | ||
84 | |||
85 | |||
86 | #ifndef BOOTLOADER | ||
87 | if (hold_button != hold_button_old) | ||
88 | backlight_hold_changed(hold_button); | ||
89 | #endif | ||
90 | |||
91 | if (!hold_button) | ||
92 | { | ||
93 | data = adc_scan(ADC_BUTTONS); | ||
94 | |||
95 | /* ADC debouncing: Only accept new reading if it's | ||
96 | * stable (+/-1). Use latest stable value otherwise. */ | ||
97 | if ((unsigned)(data - prev_data + 1) <= 2) | ||
98 | last_valid = data; | ||
99 | prev_data = data; | ||
100 | data = last_valid; | ||
101 | |||
102 | if (data < 0xba) | ||
103 | { | ||
104 | if (data < 0x54) | ||
105 | if (data < 0x30) | ||
106 | if (data < 0x10) | ||
107 | btn = BUTTON_SELECT; | ||
108 | else | ||
109 | btn = BUTTON_UP; | ||
110 | else | ||
111 | btn = BUTTON_LEFT; | ||
112 | else | ||
113 | if (data < 0x98) | ||
114 | if (data < 0x76) | ||
115 | btn = BUTTON_DOWN; | ||
116 | else | ||
117 | btn = BUTTON_RIGHT; | ||
118 | else | ||
119 | btn = BUTTON_OFF; | ||
120 | } | ||
121 | } | ||
122 | |||
123 | /* remote buttons */ | ||
124 | remote_hold_button_old = remote_hold_button; | ||
125 | remote_hold_button = remote_button_hold_only(); | ||
126 | |||
127 | #ifndef BOOTLOADER | ||
128 | if (remote_hold_button != remote_hold_button_old) | ||
129 | remote_backlight_hold_changed(remote_hold_button); | ||
130 | #endif | ||
131 | |||
132 | if (!remote_hold_button) | ||
133 | { | ||
134 | data = adc_scan(ADC_REMOTE); | ||
135 | switch (remote_type()) | ||
136 | { | ||
137 | case REMOTETYPE_H100_LCD: | ||
138 | if (data < 0xf5) | ||
139 | { | ||
140 | if (data < 0x73) | ||
141 | if (data < 0x3f) | ||
142 | if (data < 0x25) | ||
143 | if(data < 0x0c) | ||
144 | btn |= BUTTON_RC_STOP; | ||
145 | else | ||
146 | btn |= BUTTON_RC_VOL_DOWN; | ||
147 | else | ||
148 | btn |= BUTTON_RC_MODE; | ||
149 | else | ||
150 | if (data < 0x5a) | ||
151 | btn |= BUTTON_RC_VOL_UP; | ||
152 | else | ||
153 | btn |= BUTTON_RC_BITRATE; | ||
154 | else | ||
155 | if (data < 0xa8) | ||
156 | if (data < 0x8c) | ||
157 | btn |= BUTTON_RC_REC; | ||
158 | else | ||
159 | btn |= BUTTON_RC_SOURCE; | ||
160 | else | ||
161 | if (data < 0xdf) | ||
162 | if(data < 0xc5) | ||
163 | btn |= BUTTON_RC_FF; | ||
164 | else | ||
165 | btn |= BUTTON_RC_MENU; | ||
166 | else | ||
167 | btn |= BUTTON_RC_REW; | ||
168 | } | ||
169 | break; | ||
170 | case REMOTETYPE_H300_LCD: | ||
171 | if (data < 0xf5) | ||
172 | { | ||
173 | if (data < 0x73) | ||
174 | if (data < 0x42) | ||
175 | if (data < 0x27) | ||
176 | if(data < 0x0c) | ||
177 | btn |= BUTTON_RC_VOL_DOWN; | ||
178 | else | ||
179 | btn |= BUTTON_RC_FF; | ||
180 | else | ||
181 | btn |= BUTTON_RC_STOP; | ||
182 | else | ||
183 | if (data < 0x5b) | ||
184 | btn |= BUTTON_RC_MODE; | ||
185 | else | ||
186 | btn |= BUTTON_RC_REC; | ||
187 | else | ||
188 | if (data < 0xab) | ||
189 | if (data < 0x8e) | ||
190 | btn |= BUTTON_RC_ON; | ||
191 | else | ||
192 | btn |= BUTTON_RC_BITRATE; | ||
193 | else | ||
194 | if (data < 0xde) | ||
195 | if(data < 0xc5) | ||
196 | btn |= BUTTON_RC_SOURCE; | ||
197 | else | ||
198 | btn |= BUTTON_RC_VOL_UP; | ||
199 | else | ||
200 | btn |= BUTTON_RC_REW; | ||
201 | } | ||
202 | break; | ||
203 | case REMOTETYPE_H300_NONLCD: | ||
204 | if (data < 0xf1) | ||
205 | { | ||
206 | if (data < 0x7d) | ||
207 | if (data < 0x25) | ||
208 | btn |= BUTTON_RC_FF; | ||
209 | else | ||
210 | btn |= BUTTON_RC_REW; | ||
211 | else | ||
212 | if (data < 0xd5) | ||
213 | btn |= BUTTON_RC_VOL_DOWN; | ||
214 | else | ||
215 | btn |= BUTTON_RC_VOL_UP; | ||
216 | } | ||
217 | break; | ||
218 | } | ||
219 | } | ||
220 | |||
221 | if (!hold_button) | ||
222 | { | ||
223 | data = GPIO_READ; | ||
224 | if ((data & 0x0200) == 0) | ||
225 | btn |= BUTTON_MODE; | ||
226 | if ((data & 0x8000) == 0) | ||
227 | btn |= BUTTON_REC; | ||
228 | } | ||
229 | |||
230 | data = GPIO1_READ; | ||
231 | if (!hold_button && ((data & 0x20) == 0)) | ||
232 | btn |= BUTTON_ON; | ||
233 | if (!remote_hold_button && ((data & 0x40) == 0)) | ||
234 | switch(remote_type()) | ||
235 | { | ||
236 | case REMOTETYPE_H100_LCD: | ||
237 | case REMOTETYPE_H300_NONLCD: | ||
238 | btn |= BUTTON_RC_ON; | ||
239 | break; | ||
240 | case REMOTETYPE_H300_LCD: | ||
241 | btn |= BUTTON_RC_MENU; | ||
242 | break; | ||
243 | } | ||
244 | |||
245 | return btn; | ||
246 | } | ||
diff --git a/tools/configure b/tools/configure index 2f9e2db528..e7562f824b 100755 --- a/tools/configure +++ b/tools/configure | |||
@@ -685,6 +685,9 @@ EOF | |||
685 | # toolset is the tools within the tools directory that we build for | 685 | # toolset is the tools within the tools directory that we build for |
686 | # this particular target. | 686 | # this particular target. |
687 | toolset=$iriverbitmaptools | 687 | toolset=$iriverbitmaptools |
688 | t_cpu="coldfire" | ||
689 | t_manufacturer="iriver" | ||
690 | t_model="h100" | ||
688 | ;; | 691 | ;; |
689 | 692 | ||
690 | 11|h300) | 693 | 11|h300) |
@@ -707,6 +710,9 @@ EOF | |||
707 | # toolset is the tools within the tools directory that we build for | 710 | # toolset is the tools within the tools directory that we build for |
708 | # this particular target. | 711 | # this particular target. |
709 | toolset=$iriverbitmaptools | 712 | toolset=$iriverbitmaptools |
713 | t_cpu="coldfire" | ||
714 | t_manufacturer="iriver" | ||
715 | t_model="h300" | ||
710 | ;; | 716 | ;; |
711 | 717 | ||
712 | 12|h100) | 718 | 12|h100) |
@@ -729,6 +735,9 @@ EOF | |||
729 | # toolset is the tools within the tools directory that we build for | 735 | # toolset is the tools within the tools directory that we build for |
730 | # this particular target. | 736 | # this particular target. |
731 | toolset=$iriverbitmaptools | 737 | toolset=$iriverbitmaptools |
738 | t_cpu="coldfire" | ||
739 | t_manufacturer="iriver" | ||
740 | t_model="h100" | ||
732 | ;; | 741 | ;; |
733 | 742 | ||
734 | 30|x5) | 743 | 30|x5) |