1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Michael Sevakis 2008-04-24 20:18:41 +00:00
parent 95167e0177
commit 45786ca7fd

View file

@ -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;
}