summaryrefslogtreecommitdiff
path: root/firmware/drivers/button.c
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2006-02-24 15:06:25 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2006-02-24 15:06:25 +0000
commit568ac3eb2130eb3c8075d6e1de5402647b5c2ebc (patch)
tree15c3a6a31d51a648a62408a7556c04f7ded04186 /firmware/drivers/button.c
parentf16c1f341a479a61e2cdf1f54de7106ac8d5fc36 (diff)
downloadrockbox-568ac3eb2130eb3c8075d6e1de5402647b5c2ebc.tar.gz
rockbox-568ac3eb2130eb3c8075d6e1de5402647b5c2ebc.zip
Button driver for iAudio X5
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8828 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/button.c')
-rw-r--r--firmware/drivers/button.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index 3d14eb147c..f47df82e8c 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -70,6 +70,9 @@ static bool flipped; /* buttons can be flipped to match the LCD flip */
70 (CONFIG_KEYPAD == IRIVER_IFP7XX_PAD) 70 (CONFIG_KEYPAD == IRIVER_IFP7XX_PAD)
71#define POWEROFF_BUTTON BUTTON_PLAY 71#define POWEROFF_BUTTON BUTTON_PLAY
72#define POWEROFF_COUNT 40 72#define POWEROFF_COUNT 40
73#elif (CONFIG_KEYPAD == IAUDIO_X5_PAD)
74#define POWEROFF_BUTTON BUTTON_POWER
75#define POWEROFF_COUNT 10
73#else 76#else
74#define POWEROFF_BUTTON BUTTON_OFF 77#define POWEROFF_BUTTON BUTTON_OFF
75#define POWEROFF_COUNT 10 78#define POWEROFF_COUNT 10
@@ -530,6 +533,11 @@ void button_init(void)
530 /* Set GPIO33, GPIO37, GPIO38 and GPIO52 as general purpose inputs */ 533 /* Set GPIO33, GPIO37, GPIO38 and GPIO52 as general purpose inputs */
531 GPIO1_ENABLE &= ~0x00100060; 534 GPIO1_ENABLE &= ~0x00100060;
532 GPIO1_FUNCTION |= 0x00100062; 535 GPIO1_FUNCTION |= 0x00100062;
536#elif CONFIG_KEYPAD == IAUDIO_X5_PAD
537 /* Hold switch */
538 GPIO_FUNCTION |= 0x08000000;
539 GPIO_ENABLE &= ~0x08000000;
540
533#elif CONFIG_KEYPAD == RECORDER_PAD 541#elif CONFIG_KEYPAD == RECORDER_PAD
534 /* Set PB4 and PB8 as input pins */ 542 /* Set PB4 and PB8 as input pins */
535 PBCR1 &= 0xfffc; /* PB8MD = 00 */ 543 PBCR1 &= 0xfffc; /* PB8MD = 00 */
@@ -698,6 +706,7 @@ void button_set_flip(bool flip)
698 706
699#endif /* CONFIG_KEYPAD */ 707#endif /* CONFIG_KEYPAD */
700 708
709int counter;
701/* 710/*
702 * Get button pressed from hardware 711 * Get button pressed from hardware
703 */ 712 */
@@ -1039,6 +1048,40 @@ static int button_read(void)
1039 (void)data; 1048 (void)data;
1040 /* The int_btn variable is set in the button interrupt handler */ 1049 /* The int_btn variable is set in the button interrupt handler */
1041 btn = int_btn; 1050 btn = int_btn;
1051#elif (CONFIG_KEYPAD == IAUDIO_X5_PAD)
1052 static bool hold_button = false;
1053 static bool remote_hold_button = false;
1054
1055 counter ++;
1056
1057 hold_button = button_hold();
1058 remote_hold_button = remote_button_hold();
1059
1060 /* normal buttons */
1061 if (!hold_button)
1062 {
1063 data = adc_scan(ADC_BUTTONS);
1064 if(data < 0x7c)
1065 if(data < 0x42)
1066 btn = BUTTON_LEFT;
1067 else
1068 if(data < 0x62)
1069 btn = BUTTON_RIGHT;
1070 else
1071 btn = BUTTON_SELECT;
1072 else
1073 if(data < 0xb6)
1074 if(data < 0x98)
1075 btn = BUTTON_PLAY;
1076 else
1077 btn = BUTTON_REC;
1078 else
1079 if(data < 0xd3)
1080 btn = BUTTON_DOWN;
1081 else
1082 if(data < 0xf0)
1083 btn = BUTTON_UP;
1084 }
1042#endif /* CONFIG_KEYPAD */ 1085#endif /* CONFIG_KEYPAD */
1043 1086
1044 1087
@@ -1100,7 +1143,7 @@ bool button_hold(void)
1100#if (CONFIG_KEYPAD == IAUDIO_X5_PAD) 1143#if (CONFIG_KEYPAD == IAUDIO_X5_PAD)
1101bool button_hold(void) 1144bool button_hold(void)
1102{ 1145{
1103 return (GPIO_READ & 0x08000000)?true:false; 1146 return (GPIO_READ & 0x08000000)?false:true;
1104} 1147}
1105 1148
1106bool remote_button_hold(void) 1149bool remote_button_hold(void)