summaryrefslogtreecommitdiffstats
path: root/firmware
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
parentf16c1f341a479a61e2cdf1f54de7106ac8d5fc36 (diff)
downloadrockbox-568ac3eb2130eb3c8075d6e1de5402647b5c2ebc.tar.gz
rockbox-568ac3eb2130eb3c8075d6e1de5402647b5c2ebc.tar.bz2
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')
-rw-r--r--firmware/drivers/button.c45
-rw-r--r--firmware/export/adc.h3
-rw-r--r--firmware/export/button.h6
3 files changed, 49 insertions, 5 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 */
(CONFIG_KEYPAD == IRIVER_IFP7XX_PAD)
#define POWEROFF_BUTTON BUTTON_PLAY
#define POWEROFF_COUNT 40
+#elif (CONFIG_KEYPAD == IAUDIO_X5_PAD)
+#define POWEROFF_BUTTON BUTTON_POWER
+#define POWEROFF_COUNT 10
#else
#define POWEROFF_BUTTON BUTTON_OFF
#define POWEROFF_COUNT 10
@@ -530,6 +533,11 @@ void button_init(void)
/* Set GPIO33, GPIO37, GPIO38 and GPIO52 as general purpose inputs */
GPIO1_ENABLE &= ~0x00100060;
GPIO1_FUNCTION |= 0x00100062;
+#elif CONFIG_KEYPAD == IAUDIO_X5_PAD
+ /* Hold switch */
+ GPIO_FUNCTION |= 0x08000000;
+ GPIO_ENABLE &= ~0x08000000;
+
#elif CONFIG_KEYPAD == RECORDER_PAD
/* Set PB4 and PB8 as input pins */
PBCR1 &= 0xfffc; /* PB8MD = 00 */
@@ -698,6 +706,7 @@ void button_set_flip(bool flip)
#endif /* CONFIG_KEYPAD */
+int counter;
/*
* Get button pressed from hardware
*/
@@ -1039,6 +1048,40 @@ static int button_read(void)
(void)data;
/* The int_btn variable is set in the button interrupt handler */
btn = int_btn;
+#elif (CONFIG_KEYPAD == IAUDIO_X5_PAD)
+ static bool hold_button = false;
+ static bool remote_hold_button = false;
+
+ counter ++;
+
+ hold_button = button_hold();
+ remote_hold_button = remote_button_hold();
+
+ /* normal buttons */
+ if (!hold_button)
+ {
+ data = adc_scan(ADC_BUTTONS);
+ if(data < 0x7c)
+ if(data < 0x42)
+ btn = BUTTON_LEFT;
+ else
+ if(data < 0x62)
+ btn = BUTTON_RIGHT;
+ else
+ btn = BUTTON_SELECT;
+ else
+ if(data < 0xb6)
+ if(data < 0x98)
+ btn = BUTTON_PLAY;
+ else
+ btn = BUTTON_REC;
+ else
+ if(data < 0xd3)
+ btn = BUTTON_DOWN;
+ else
+ if(data < 0xf0)
+ btn = BUTTON_UP;
+ }
#endif /* CONFIG_KEYPAD */
@@ -1100,7 +1143,7 @@ bool button_hold(void)
#if (CONFIG_KEYPAD == IAUDIO_X5_PAD)
bool button_hold(void)
{
- return (GPIO_READ & 0x08000000)?true:false;
+ return (GPIO_READ & 0x08000000)?false:true;
}
bool remote_button_hold(void)
diff --git a/firmware/export/adc.h b/firmware/export/adc.h
index 027c7154f0..454c102403 100644
--- a/firmware/export/adc.h
+++ b/firmware/export/adc.h
@@ -92,7 +92,8 @@
unsigned short adc_read(int channel);
void adc_init(void);
-#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
+#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)\
+ || defined(IAUDIO_X5)
unsigned char adc_scan(int channel);
#endif
diff --git a/firmware/export/button.h b/firmware/export/button.h
index 1d6acfa275..484698e492 100644
--- a/firmware/export/button.h
+++ b/firmware/export/button.h
@@ -23,7 +23,8 @@
#include <stdbool.h>
#include "config.h"
#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
- (CONFIG_KEYPAD == IRIVER_H300_PAD)
+ (CONFIG_KEYPAD == IRIVER_H300_PAD) || \
+ (CONFIG_KEYPAD == IAUDIO_X5_PAD)
#define HAS_BUTTON_HOLD
#define HAS_REMOTE_BUTTON_HOLD
#elif (CONFIG_KEYPAD == IPOD_4G_PAD)
@@ -192,8 +193,7 @@ bool button_hold(void);
#define BUTTON_POWER 0x0004
#define BUTTON_UP 0x0008
#define BUTTON_DOWN 0x0010
-#define BUTTON_MENU 0x0020
-#define BUTTON_OFF 0x0040 /* DOES NOT EXIST!!! */
+#define BUTTON_SELECT 0x0020
#define BUTTON_RC_REC (BUTTON_REMOTE | 0x00400000)