summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2012-01-08 22:29:25 +0000
committerMichael Sevakis <jethead71@rockbox.org>2012-01-08 22:29:25 +0000
commit307cb049485cc20140b85aa78f8e2677e8df5851 (patch)
treeeaadfd7266e4e97e69bccd68655140dd9f1ef061 /firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
parent5e21bbf5757163725f4bd2909fc7aaa548f61fc3 (diff)
downloadrockbox-307cb049485cc20140b85aa78f8e2677e8df5851.tar.gz
rockbox-307cb049485cc20140b85aa78f8e2677e8df5851.zip
AS3525v1/2: Enable nested handling of interrupts
Mostly for the sake of reducing latency for audio servicing where other service routines can take a long time to complete, leading to occasional drops of a few samples, especially in recording, where they are fairly frequent. One mystery that remains is GPIOA IRQ being interrupted causes strange undefined instruction exceptions, most easily produced on my Fuze V2 with a scrollwheel. Making GPIOA the top ISR for now, thus not interruptible, cures it. SVC mode is used during the actual calls. Hopefully the SVC stack size is sufficient. Prologue and epilogue code only uses the IRQ stack and is large enough. Any routine code that should not be interrupted should disable IRQ itself from here on in. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31642 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c')
-rw-r--r--firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
index 7f82b692c7..8244c475fa 100644
--- a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
+++ b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
@@ -30,6 +30,7 @@ static bool hold_button = false;
#ifdef HAVE_SCROLLWHEEL
#define SCROLLWHEEL_BITS (1<<7|1<<6)
+#define SCROLLWHEEL_BITS_POS 6
/* TIMER units */
#define TIMER_TICK (KERNEL_TIMER_FREQ/HZ)/* how long a tick lasts */
#define TIMER_MS (TIMER_TICK/(1000/HZ))/* how long a ms lasts */
@@ -78,10 +79,17 @@ static void scrollwheel(unsigned int wheel_value)
unsigned int btn = BUTTON_NONE;
- if (old_wheel_value == wheel_tbl[0][wheel_value])
+ if (hold_button)
+ {
+ }
+ else if (old_wheel_value == wheel_tbl[0][wheel_value])
+ {
btn = BUTTON_SCROLL_FWD;
+ }
else if (old_wheel_value == wheel_tbl[1][wheel_value])
+ {
btn = BUTTON_SCROLL_BACK;
+ }
if (btn == BUTTON_NONE)
{
@@ -200,11 +208,13 @@ void button_gpioa_isr(void)
{
#if defined(HAVE_SCROLLWHEEL)
/* scroll wheel handling */
- if (GPIOA_MIS & SCROLLWHEEL_BITS)
- scrollwheel(GPIOA_PIN_MASK(0xc0) >> 6);
+ unsigned long bits = GPIOA_MIS & SCROLLWHEEL_BITS;
- /* ack interrupt */
- GPIOA_IC = SCROLLWHEEL_BITS;
+ if (bits)
+ {
+ scrollwheel(GPIOA_PIN_MASK(SCROLLWHEEL_BITS) >> SCROLLWHEEL_BITS_POS);
+ GPIOA_IC = bits; /* ack interrupt */
+ }
#endif
}
@@ -225,8 +235,10 @@ int button_read_device(void)
int delay = 30;
while(delay--) nop;
+ disable_irq();
+
bool ccu_io_bit12 = CCU_IO & (1<<12);
- bitclr32(&CCU_IO, 1<<12);
+ CCU_IO &= ~(1<<12);
/* B1 is shared with FM i2c */
bool gpiob_pin0_dir = GPIOB_DIR & (1<<1);
@@ -256,7 +268,9 @@ int button_read_device(void)
GPIOB_DIR |= 1<<1;
if(ccu_io_bit12)
- bitset32(&CCU_IO, 1<<12);
+ CCU_IO |= (1<<12);
+
+ enable_irq();
#ifdef HAS_BUTTON_HOLD
#ifndef BOOTLOADER
@@ -265,12 +279,6 @@ int button_read_device(void)
{
hold_button = hold;
backlight_hold_changed(hold);
- /* mask scrollwheel irq so we don't need to check for
- * the hold button in the isr */
- if (hold)
- GPIOA_IE &= ~SCROLLWHEEL_BITS;
- else
- GPIOA_IE |= SCROLLWHEEL_BITS;
}
#else
hold_button = hold;