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)
downloadrockbox-45786ca7fdfd58f9b3fa1233e5521b9d2c207a85.tar.gz
rockbox-45786ca7fdfd58f9b3fa1233e5521b9d2c207a85.zip
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)
52 /* Power button is handled separately on PMIC */ 52 /* Power button is handled separately on PMIC */
53 int button = int_btn & BUTTON_POWER; 53 int button = int_btn & BUTTON_POWER;
54 54
55 int oldlevel = disable_irq_save();
56
55 /* 1. Disable both (depress and release) keypad interrupts. */ 57 /* 1. Disable both (depress and release) keypad interrupts. */
56 KPP_KPSR &= ~(KPP_KPSR_KRIE | KPP_KPSR_KDIE); 58 KPP_KPSR &= ~(KPP_KPSR_KRIE | KPP_KPSR_KDIE);
57 59
@@ -65,7 +67,7 @@ static __attribute__((interrupt("IRQ"))) void KPP_HANDLER(void)
65 KPP_KPCR &= ~(0x7 << 8); 67 KPP_KPCR &= ~(0x7 << 8);
66 68
67 /* Give the columns time to discharge */ 69 /* Give the columns time to discharge */
68 for (i = 0; i < 256; i++) 70 for (i = 0; i < 128; i++) /* TODO: find minimum safe delay */
69 asm volatile (""); 71 asm volatile ("");
70 72
71 /* 4. Configure columns as open-drain */ 73 /* 4. Configure columns as open-drain */
@@ -81,7 +83,7 @@ static __attribute__((interrupt("IRQ"))) void KPP_HANDLER(void)
81 83
82 /* Delay added to avoid propagating the 0 from column to row 84 /* Delay added to avoid propagating the 0 from column to row
83 * when scanning. */ 85 * when scanning. */
84 for (i = 0; i < 256; i++) 86 for (i = 0; i < 128; i++) /* TODO: find minimum safe delay */
85 asm volatile (""); 87 asm volatile ("");
86 88
87 /* Read row input */ 89 /* Read row input */
@@ -104,11 +106,13 @@ static __attribute__((interrupt("IRQ"))) void KPP_HANDLER(void)
104 /* 10. Re-enable the appropriate keypad interrupt(s) so that the KDIE 106 /* 10. Re-enable the appropriate keypad interrupt(s) so that the KDIE
105 * detects a key hold condition, or the KRIE detects a key-release 107 * detects a key hold condition, or the KRIE detects a key-release
106 * event. */ 108 * event. */
107 if (button != BUTTON_NONE) 109 if ((button & ~BUTTON_POWER) != BUTTON_NONE)
108 KPP_KPSR |= KPP_KPSR_KRIE; 110 KPP_KPSR |= KPP_KPSR_KRIE;
109 else 111 else
110 KPP_KPSR |= KPP_KPSR_KDIE; 112 KPP_KPSR |= KPP_KPSR_KDIE;
111 113
114 restore_irq(oldlevel);
115
112 int_btn = button; 116 int_btn = button;
113} 117}
114 118
@@ -160,6 +164,12 @@ int button_read_device(void)
160 backlight_hold_changed(hold_button); 164 backlight_hold_changed(hold_button);
161 } 165 }
162 166
167 /* Enable the keypad interrupt to cause it to fire if a key is down.
168 * KPP_HANDLER will clear and disable it after the scan. If no key
169 * is depressed then this bit will already be set in waiting for the
170 * first key down event. */
171 KPP_KPSR |= KPP_KPSR_KDIE;
172
163 /* If hold, ignore any pressed button */ 173 /* If hold, ignore any pressed button */
164 return hold_button ? BUTTON_NONE : int_btn; 174 return hold_button ? BUTTON_NONE : int_btn;
165} 175}