summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2008-04-24 20:18:41 +0000
committerMichael Sevakis <jethead71@rockbox.org>2008-04-24 20:18:41 +0000
commit45786ca7fdfd58f9b3fa1233e5521b9d2c207a85 (patch)
tree63cbf86e7e08ae0d6d3c3dbf16ffbfaf5a8bb481
parent95167e01773dcfe8e5c1b356cfa1ea4b3a55441b (diff)
Make Gigabeat S keypad correctly detect multiple key down events in a row. Properly exclude BUTTON_POWER in interrupt enable decision. Shorten delays in KPP_HANDLER and hopefully get away with it.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17242 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/button-imx31.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/button-imx31.c b/firmware/target/arm/imx31/gigabeat-s/button-imx31.c
index c85fe5e37e..682c79f80a 100644
--- a/firmware/target/arm/imx31/gigabeat-s/button-imx31.c
+++ b/firmware/target/arm/imx31/gigabeat-s/button-imx31.c
@@ -52,6 +52,8 @@ static __attribute__((interrupt("IRQ"))) void KPP_HANDLER(void)
/* Power button is handled separately on PMIC */
int button = int_btn & BUTTON_POWER;
+ int oldlevel = disable_irq_save();
+
/* 1. Disable both (depress and release) keypad interrupts. */
KPP_KPSR &= ~(KPP_KPSR_KRIE | KPP_KPSR_KDIE);
@@ -65,7 +67,7 @@ static __attribute__((interrupt("IRQ"))) void KPP_HANDLER(void)
KPP_KPCR &= ~(0x7 << 8);
/* Give the columns time to discharge */
- for (i = 0; i < 256; i++)
+ for (i = 0; i < 128; i++) /* TODO: find minimum safe delay */
asm volatile ("");
/* 4. Configure columns as open-drain */
@@ -81,7 +83,7 @@ static __attribute__((interrupt("IRQ"))) void KPP_HANDLER(void)
/* Delay added to avoid propagating the 0 from column to row
* when scanning. */
- for (i = 0; i < 256; i++)
+ for (i = 0; i < 128; i++) /* TODO: find minimum safe delay */
asm volatile ("");
/* Read row input */
@@ -104,11 +106,13 @@ static __attribute__((interrupt("IRQ"))) void KPP_HANDLER(void)
/* 10. Re-enable the appropriate keypad interrupt(s) so that the KDIE
* detects a key hold condition, or the KRIE detects a key-release
* event. */
- if (button != BUTTON_NONE)
+ if ((button & ~BUTTON_POWER) != BUTTON_NONE)
KPP_KPSR |= KPP_KPSR_KRIE;
else
KPP_KPSR |= KPP_KPSR_KDIE;
+ restore_irq(oldlevel);
+
int_btn = button;
}
@@ -160,6 +164,12 @@ int button_read_device(void)
backlight_hold_changed(hold_button);
}
+ /* Enable the keypad interrupt to cause it to fire if a key is down.
+ * KPP_HANDLER will clear and disable it after the scan. If no key
+ * is depressed then this bit will already be set in waiting for the
+ * first key down event. */
+ KPP_KPSR |= KPP_KPSR_KDIE;
+
/* If hold, ignore any pressed button */
return hold_button ? BUTTON_NONE : int_btn;
}