1
0
Fork 0
forked from len0rd/rockbox

e200: Finally use GPIO IRQs for the buttons...it's IRQ enable bit 33 afterall and verified independently. There shouldn't now be a need to add tick tasks to monitor GPIO level status in other code.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13538 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sevakis 2007-06-03 14:31:42 +00:00
parent 20a8a9a3c8
commit 5c32faad43
3 changed files with 27 additions and 34 deletions

View file

@ -20,11 +20,11 @@
****************************************************************************/ ****************************************************************************/
/* We believe is this quite similar to the 5020 and for how we just use that /* We believe is this quite similar to the 5020 and for how we just use that
completely */ completely and redifine any minor differences */
#include "pp5020.h" #include "pp5020.h"
#undef GPIO_IRQ #undef GPIO_IRQ
#define GPIO_IRQ (32+6) #define GPIO_IRQ (32+1)
#undef GPIO_MASK #undef GPIO_MASK
#define GPIO_MASK (1 << (GPIO_IRQ-32)) #define GPIO_MASK (1 << (GPIO_IRQ-32))

View file

@ -39,6 +39,9 @@ static unsigned long next_backlight_on = 0;
/* Buttons */ /* Buttons */
static bool hold_button = false; static bool hold_button = false;
static bool hold_button_old = false; static bool hold_button_old = false;
#define _button_hold() hold_button
#else
#define _button_hold() ((GPIOF_INPUT_VAL & 0x80) != 0)
#endif /* BOOTLOADER */ #endif /* BOOTLOADER */
static int int_btn = BUTTON_NONE; static int int_btn = BUTTON_NONE;
@ -47,22 +50,19 @@ void button_init_device(void)
/* Enable all buttons */ /* Enable all buttons */
GPIOF_OUTPUT_EN &= ~0xff; GPIOF_OUTPUT_EN &= ~0xff;
GPIOF_ENABLE |= 0xff; GPIOF_ENABLE |= 0xff;
/* Scrollwheel light - enable control through GPIOG pin 7 and set timeout */ /* Scrollwheel light - enable control through GPIOG pin 7 and set timeout */
GPIOG_OUTPUT_EN |= 0x80; GPIOG_OUTPUT_EN |= 0x80;
GPIOG_ENABLE = 0x80; GPIOG_ENABLE = 0x80;
#ifndef BOOTLOADER #ifndef BOOTLOADER
/* Get current tick before enabling button interrupts */
last_wheel_tick = current_tick;
last_wheel_post = current_tick;
GPIOH_ENABLE |= 0xc0; GPIOH_ENABLE |= 0xc0;
GPIOH_OUTPUT_EN &= ~0xc0; GPIOH_OUTPUT_EN &= ~0xc0;
#if 0
CPU_INT_PRIORITY &= ~HI_MASK;
CPU_HI_INT_PRIORITY &= ~GPIO_MASK;
CPU_INT_CLR = HI_MASK;
CPU_HI_INT_CLR = GPIO_MASK;
#endif
GPIOF_INT_CLR = 0xff; GPIOF_INT_CLR = 0xff;
GPIOH_INT_CLR = 0xc0; GPIOH_INT_CLR = 0xc0;
@ -75,25 +75,18 @@ void button_init_device(void)
old_wheel_value = GPIOH_INPUT_VAL & 0xc0; old_wheel_value = GPIOH_INPUT_VAL & 0xc0;
GPIOH_INT_LEV = (GPIOH_INT_LEV & ~0xc0) | (old_wheel_value ^ 0xc0); GPIOH_INT_LEV = (GPIOH_INT_LEV & ~0xc0) | (old_wheel_value ^ 0xc0);
/* Enable button interrupts */
GPIOF_INT_EN = 0xff; GPIOF_INT_EN = 0xff;
GPIOH_INT_EN = 0xc0; GPIOH_INT_EN = 0xc0;
#if 0
CPU_HI_INT_EN = GPIO_MASK;
CPU_INT_EN = HI_MASK;
#endif
last_wheel_tick = current_tick; CPU_INT_EN = HI_MASK;
last_wheel_post = current_tick; CPU_HI_INT_EN = GPIO_MASK;
#endif /* BOOTLOADER */ #endif /* BOOTLOADER */
} }
bool button_hold(void) bool button_hold(void)
{ {
#ifdef BOOTLOADER return _button_hold();
return (GPIOF_INPUT_VAL & 0x80) != 0;
#else
return hold_button;
#endif /* BOOTLOADER */
} }
/* clickwheel */ /* clickwheel */
@ -118,10 +111,9 @@ void clickwheel_int(void)
unsigned int wheel_value; unsigned int wheel_value;
GPIOH_INT_CLR = GPIOH_INT_STAT & 0xc0;
wheel_value = GPIOH_INPUT_VAL & 0xc0; wheel_value = GPIOH_INPUT_VAL & 0xc0;
GPIOH_INT_LEV = (GPIOH_INT_LEV & ~0xc0) | (wheel_value ^ 0xc0); GPIOH_INT_LEV = (GPIOH_INT_LEV & ~0xc0) | (wheel_value ^ 0xc0);
GPIOH_INT_CLR = GPIOH_INT_STAT & 0xc0;
if (!hold_button) if (!hold_button)
{ {
@ -202,15 +194,13 @@ void button_int(void)
state = GPIOF_INPUT_VAL & 0xff; state = GPIOF_INPUT_VAL & 0xff;
#ifndef BOOTLOADER #ifndef BOOTLOADER
GPIOF_INT_CLR = GPIOF_INT_STAT;
GPIOF_INT_LEV = (GPIOF_INT_LEV & ~0xff) | (state ^ 0xff); GPIOF_INT_LEV = (GPIOF_INT_LEV & ~0xff) | (state ^ 0xff);
GPIOF_INT_CLR = GPIOF_INT_STAT;
hold_button = (state & 0x80) != 0; hold_button = (state & 0x80) != 0;
#endif
if (!hold_button) if (!_button_hold())
#else
if (button_hold())
#endif /* BOOTLOADER */
{ {
/* Read normal buttons */ /* Read normal buttons */
if ((state & 0x01) == 0) int_btn |= BUTTON_REC; if ((state & 0x01) == 0) int_btn |= BUTTON_REC;

View file

@ -63,16 +63,19 @@ void irq(void)
{ {
if(CURRENT_CORE == CPU) { if(CURRENT_CORE == CPU) {
if (CPU_INT_STAT & TIMER1_MASK) { if (CPU_INT_STAT & TIMER1_MASK) {
#ifdef SANSA_E200
if (GPIOF_INT_STAT & 0xff)
button_int();
if (GPIOH_INT_STAT & 0xc0)
clickwheel_int();
#endif
TIMER1(); TIMER1();
} }
else if (CPU_INT_STAT & TIMER2_MASK) else if (CPU_INT_STAT & TIMER2_MASK)
TIMER2(); TIMER2();
#ifdef SANSA_E200
else if (CPU_HI_INT_STAT & GPIO_MASK)
{
if (GPIOF_INT_STAT & 0xff)
button_int();
if (GPIOH_INT_STAT & 0xc0)
clickwheel_int();
}
#endif
} else { } else {
if (COP_INT_STAT & TIMER1_MASK) if (COP_INT_STAT & TIMER1_MASK)
TIMER1(); TIMER1();