summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-06-03 14:31:42 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-06-03 14:31:42 +0000
commit5c32faad432e74f9ccb7a6d0632492fe2dba5aab (patch)
tree8b94a3d5961e01b07d7e44b94d90c3d802c8d66a
parent20a8a9a3c8fefb38ba533e3a2a7e21d02e5b737b (diff)
downloadrockbox-5c32faad432e74f9ccb7a6d0632492fe2dba5aab.tar.gz
rockbox-5c32faad432e74f9ccb7a6d0632492fe2dba5aab.zip
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
-rw-r--r--firmware/export/pp5024.h4
-rw-r--r--firmware/target/arm/sandisk/sansa-e200/button-e200.c42
-rw-r--r--firmware/target/arm/system-pp502x.c11
3 files changed, 25 insertions, 32 deletions
diff --git a/firmware/export/pp5024.h b/firmware/export/pp5024.h
index b9238ae98d..59c003613b 100644
--- a/firmware/export/pp5024.h
+++ b/firmware/export/pp5024.h
@@ -20,11 +20,11 @@
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22/* We believe is this quite similar to the 5020 and for how we just use that 22/* We believe is this quite similar to the 5020 and for how we just use that
23 completely */ 23 completely and redifine any minor differences */
24#include "pp5020.h" 24#include "pp5020.h"
25 25
26#undef GPIO_IRQ 26#undef GPIO_IRQ
27#define GPIO_IRQ (32+6) 27#define GPIO_IRQ (32+1)
28 28
29#undef GPIO_MASK 29#undef GPIO_MASK
30#define GPIO_MASK (1 << (GPIO_IRQ-32)) 30#define GPIO_MASK (1 << (GPIO_IRQ-32))
diff --git a/firmware/target/arm/sandisk/sansa-e200/button-e200.c b/firmware/target/arm/sandisk/sansa-e200/button-e200.c
index 56bce816e4..f1d5981a18 100644
--- a/firmware/target/arm/sandisk/sansa-e200/button-e200.c
+++ b/firmware/target/arm/sandisk/sansa-e200/button-e200.c
@@ -39,6 +39,9 @@ static unsigned long next_backlight_on = 0;
39/* Buttons */ 39/* Buttons */
40static bool hold_button = false; 40static bool hold_button = false;
41static bool hold_button_old = false; 41static bool hold_button_old = false;
42#define _button_hold() hold_button
43#else
44#define _button_hold() ((GPIOF_INPUT_VAL & 0x80) != 0)
42#endif /* BOOTLOADER */ 45#endif /* BOOTLOADER */
43static int int_btn = BUTTON_NONE; 46static int int_btn = BUTTON_NONE;
44 47
@@ -47,22 +50,19 @@ void button_init_device(void)
47 /* Enable all buttons */ 50 /* Enable all buttons */
48 GPIOF_OUTPUT_EN &= ~0xff; 51 GPIOF_OUTPUT_EN &= ~0xff;
49 GPIOF_ENABLE |= 0xff; 52 GPIOF_ENABLE |= 0xff;
50 53
51 /* Scrollwheel light - enable control through GPIOG pin 7 and set timeout */ 54 /* Scrollwheel light - enable control through GPIOG pin 7 and set timeout */
52 GPIOG_OUTPUT_EN |= 0x80; 55 GPIOG_OUTPUT_EN |= 0x80;
53 GPIOG_ENABLE = 0x80; 56 GPIOG_ENABLE = 0x80;
54 57
55#ifndef BOOTLOADER 58#ifndef BOOTLOADER
59 /* Get current tick before enabling button interrupts */
60 last_wheel_tick = current_tick;
61 last_wheel_post = current_tick;
62
56 GPIOH_ENABLE |= 0xc0; 63 GPIOH_ENABLE |= 0xc0;
57 GPIOH_OUTPUT_EN &= ~0xc0; 64 GPIOH_OUTPUT_EN &= ~0xc0;
58 65
59#if 0
60 CPU_INT_PRIORITY &= ~HI_MASK;
61 CPU_HI_INT_PRIORITY &= ~GPIO_MASK;
62
63 CPU_INT_CLR = HI_MASK;
64 CPU_HI_INT_CLR = GPIO_MASK;
65#endif
66 GPIOF_INT_CLR = 0xff; 66 GPIOF_INT_CLR = 0xff;
67 GPIOH_INT_CLR = 0xc0; 67 GPIOH_INT_CLR = 0xc0;
68 68
@@ -75,25 +75,18 @@ void button_init_device(void)
75 old_wheel_value = GPIOH_INPUT_VAL & 0xc0; 75 old_wheel_value = GPIOH_INPUT_VAL & 0xc0;
76 GPIOH_INT_LEV = (GPIOH_INT_LEV & ~0xc0) | (old_wheel_value ^ 0xc0); 76 GPIOH_INT_LEV = (GPIOH_INT_LEV & ~0xc0) | (old_wheel_value ^ 0xc0);
77 77
78 /* Enable button interrupts */
78 GPIOF_INT_EN = 0xff; 79 GPIOF_INT_EN = 0xff;
79 GPIOH_INT_EN = 0xc0; 80 GPIOH_INT_EN = 0xc0;
80#if 0
81 CPU_HI_INT_EN = GPIO_MASK;
82 CPU_INT_EN = HI_MASK;
83#endif
84 81
85 last_wheel_tick = current_tick; 82 CPU_INT_EN = HI_MASK;
86 last_wheel_post = current_tick; 83 CPU_HI_INT_EN = GPIO_MASK;
87#endif /* BOOTLOADER */ 84#endif /* BOOTLOADER */
88} 85}
89 86
90bool button_hold(void) 87bool button_hold(void)
91{ 88{
92#ifdef BOOTLOADER 89 return _button_hold();
93 return (GPIOF_INPUT_VAL & 0x80) != 0;
94#else
95 return hold_button;
96#endif /* BOOTLOADER */
97} 90}
98 91
99/* clickwheel */ 92/* clickwheel */
@@ -118,10 +111,9 @@ void clickwheel_int(void)
118 111
119 unsigned int wheel_value; 112 unsigned int wheel_value;
120 113
121 GPIOH_INT_CLR = GPIOH_INT_STAT & 0xc0;
122
123 wheel_value = GPIOH_INPUT_VAL & 0xc0; 114 wheel_value = GPIOH_INPUT_VAL & 0xc0;
124 GPIOH_INT_LEV = (GPIOH_INT_LEV & ~0xc0) | (wheel_value ^ 0xc0); 115 GPIOH_INT_LEV = (GPIOH_INT_LEV & ~0xc0) | (wheel_value ^ 0xc0);
116 GPIOH_INT_CLR = GPIOH_INT_STAT & 0xc0;
125 117
126 if (!hold_button) 118 if (!hold_button)
127 { 119 {
@@ -202,15 +194,13 @@ void button_int(void)
202 state = GPIOF_INPUT_VAL & 0xff; 194 state = GPIOF_INPUT_VAL & 0xff;
203 195
204#ifndef BOOTLOADER 196#ifndef BOOTLOADER
205 GPIOF_INT_CLR = GPIOF_INT_STAT;
206 GPIOF_INT_LEV = (GPIOF_INT_LEV & ~0xff) | (state ^ 0xff); 197 GPIOF_INT_LEV = (GPIOF_INT_LEV & ~0xff) | (state ^ 0xff);
198 GPIOF_INT_CLR = GPIOF_INT_STAT;
207 199
208 hold_button = (state & 0x80) != 0; 200 hold_button = (state & 0x80) != 0;
201#endif
209 202
210 if (!hold_button) 203 if (!_button_hold())
211#else
212 if (button_hold())
213#endif /* BOOTLOADER */
214 { 204 {
215 /* Read normal buttons */ 205 /* Read normal buttons */
216 if ((state & 0x01) == 0) int_btn |= BUTTON_REC; 206 if ((state & 0x01) == 0) int_btn |= BUTTON_REC;
diff --git a/firmware/target/arm/system-pp502x.c b/firmware/target/arm/system-pp502x.c
index a03d479444..2b6a801128 100644
--- a/firmware/target/arm/system-pp502x.c
+++ b/firmware/target/arm/system-pp502x.c
@@ -63,16 +63,19 @@ void irq(void)
63{ 63{
64 if(CURRENT_CORE == CPU) { 64 if(CURRENT_CORE == CPU) {
65 if (CPU_INT_STAT & TIMER1_MASK) { 65 if (CPU_INT_STAT & TIMER1_MASK) {
66 TIMER1();
67 }
68 else if (CPU_INT_STAT & TIMER2_MASK)
69 TIMER2();
66#ifdef SANSA_E200 70#ifdef SANSA_E200
71 else if (CPU_HI_INT_STAT & GPIO_MASK)
72 {
67 if (GPIOF_INT_STAT & 0xff) 73 if (GPIOF_INT_STAT & 0xff)
68 button_int(); 74 button_int();
69 if (GPIOH_INT_STAT & 0xc0) 75 if (GPIOH_INT_STAT & 0xc0)
70 clickwheel_int(); 76 clickwheel_int();
71#endif
72 TIMER1();
73 } 77 }
74 else if (CPU_INT_STAT & TIMER2_MASK) 78#endif
75 TIMER2();
76 } else { 79 } else {
77 if (COP_INT_STAT & TIMER1_MASK) 80 if (COP_INT_STAT & TIMER1_MASK)
78 TIMER1(); 81 TIMER1();