summaryrefslogtreecommitdiff
path: root/firmware/target/arm/sandisk/sansa-e200/button-e200.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-06-03 15:17:01 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-06-03 15:17:01 +0000
commitebe67b28e3b0876560bee94ad0413010cd266e03 (patch)
tree976d0e6748071a25d5accdf04087725df701e8d0 /firmware/target/arm/sandisk/sansa-e200/button-e200.c
parent5c32faad432e74f9ccb7a6d0632492fe2dba5aab (diff)
e200: Update the button init code to be more correct for using GPIO IRQs.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13539 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/sandisk/sansa-e200/button-e200.c')
-rw-r--r--firmware/target/arm/sandisk/sansa-e200/button-e200.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/firmware/target/arm/sandisk/sansa-e200/button-e200.c b/firmware/target/arm/sandisk/sansa-e200/button-e200.c
index f1d5981a18..6365a3f4d4 100644
--- a/firmware/target/arm/sandisk/sansa-e200/button-e200.c
+++ b/firmware/target/arm/sandisk/sansa-e200/button-e200.c
@@ -45,6 +45,8 @@ static bool hold_button_old = false;
#endif /* BOOTLOADER */
static int int_btn = BUTTON_NONE;
+void button_int(void);
+
void button_init_device(void)
{
/* Enable all buttons */
@@ -56,6 +58,11 @@ void button_init_device(void)
GPIOG_ENABLE = 0x80;
#ifndef BOOTLOADER
+ /* Mask these before performing init ... because init has possibly
+ occurred before */
+ GPIOF_INT_EN &= ~0xff;
+ GPIOH_INT_EN &= ~0xc0;
+
/* Get current tick before enabling button interrupts */
last_wheel_tick = current_tick;
last_wheel_post = current_tick;
@@ -63,21 +70,18 @@ void button_init_device(void)
GPIOH_ENABLE |= 0xc0;
GPIOH_OUTPUT_EN &= ~0xc0;
- GPIOF_INT_CLR = 0xff;
- GPIOH_INT_CLR = 0xc0;
-
/* Read initial buttons */
- old_wheel_value = GPIOF_INPUT_VAL & 0xff;
- GPIOF_INT_LEV = (GPIOF_INT_LEV & ~0xff) | (old_wheel_value ^ 0xff);
- hold_button = (GPIOF_INPUT_VAL & 0x80) != 0;
+ button_int();
+ GPIOF_INT_CLR = 0xff;
/* Read initial wheel value (bit 6-7 of GPIOH) */
old_wheel_value = GPIOH_INPUT_VAL & 0xc0;
GPIOH_INT_LEV = (GPIOH_INT_LEV & ~0xc0) | (old_wheel_value ^ 0xc0);
+ GPIOH_INT_CLR = 0xc0;
/* Enable button interrupts */
- GPIOF_INT_EN = 0xff;
- GPIOH_INT_EN = 0xc0;
+ GPIOF_INT_EN |= 0xff;
+ GPIOH_INT_EN |= 0xc0;
CPU_INT_EN = HI_MASK;
CPU_HI_INT_EN = GPIO_MASK;