summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-01-20 17:11:23 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-01-20 17:11:23 +0000
commit2da0f9bcfdf056255b298c0e61f0f4f0f950f869 (patch)
tree4bb8e4de0f500f73b6e81ce347c0b36ab763e4bf /firmware
parent5f52f6ee01fdd060fab9b72736daf06b3dbda212 (diff)
downloadrockbox-2da0f9bcfdf056255b298c0e61f0f4f0f950f869.tar.gz
rockbox-2da0f9bcfdf056255b298c0e61f0f4f0f950f869.zip
Fuze v2: Do button reading more efficiently by mapping button codes directly to the GPIO pin states where possible (all but 'home' and hold). This makes plugins incompatible; up the min version and sort things.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29097 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c24
-rw-r--r--firmware/target/arm/as3525/sansa-fuzev2/button-target.h9
2 files changed, 10 insertions, 23 deletions
diff --git a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
index 4907de11f3..30f2c0df16 100644
--- a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
+++ b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
@@ -213,9 +213,9 @@ void button_gpioa_isr(void)
213 */ 213 */
214int button_read_device(void) 214int button_read_device(void)
215{ 215{
216 int btn = 0;
217 static long power_counter = 0; 216 static long power_counter = 0;
218 bool hold = false; 217 bool hold = false;
218 int btn;
219 unsigned gpiod6; 219 unsigned gpiod6;
220 220
221 /* if we don't wait for the fifo to empty, we'll see screen corruption 221 /* if we don't wait for the fifo to empty, we'll see screen corruption
@@ -240,28 +240,16 @@ int button_read_device(void)
240 GPIOB_PIN(0) = 0; 240 GPIOB_PIN(0) = 0;
241 udelay(2); 241 udelay(2);
242 242
243 if (GPIOC_PIN(1) & 1<<1) 243 btn = GPIOC_PIN_MASK(0x3e) | (GPIOB_PIN(1) >> 1);
244 btn |= BUTTON_DOWN; 244
245 if (GPIOC_PIN(2) & 1<<2)
246 btn |= BUTTON_UP;
247 if (GPIOC_PIN(3) & 1<<3)
248 btn |= BUTTON_LEFT;
249 if (GPIOC_PIN(4) & 1<<4)
250 btn |= BUTTON_SELECT;
251 if (GPIOC_PIN(5) & 1<<5)
252 btn |= BUTTON_RIGHT;
253 if (GPIOB_PIN(1) & 1<<1)
254 btn |= BUTTON_HOME;
255 if (amsv2_variant == 1) 245 if (amsv2_variant == 1)
256 btn ^= BUTTON_HOME; 246 btn ^= BUTTON_HOME;
257 247
258 if (gpiod6 & 1<<6) 248 if (gpiod6)
259 { /* power/hold is on the same pin. we know it's hold if the bit isn't 249 { /* power/hold is on the same pin. we know it's hold if the bit isn't
260 * set now anymore */ 250 * set now anymore */
261 if (GPIOD_PIN(6) & 1<<6) 251 btn |= GPIOD_PIN(6);
262 btn |= BUTTON_POWER; 252 hold = !(btn & BUTTON_POWER);
263 else
264 hold = true;
265 } 253 }
266 254
267 if(gpiob_pin0_dir) 255 if(gpiob_pin0_dir)
diff --git a/firmware/target/arm/as3525/sansa-fuzev2/button-target.h b/firmware/target/arm/as3525/sansa-fuzev2/button-target.h
index c64c68f951..596ac01262 100644
--- a/firmware/target/arm/as3525/sansa-fuzev2/button-target.h
+++ b/firmware/target/arm/as3525/sansa-fuzev2/button-target.h
@@ -32,15 +32,14 @@ bool button_hold(void);
32int button_read_device(void); 32int button_read_device(void);
33/* Sandisk Sansa Fuze button codes */ 33/* Sandisk Sansa Fuze button codes */
34 34
35/* Main unit's buttons */ 35/* Main unit's buttons - mapped for optimal reading */
36#define BUTTON_HOME 0x00000001 36#define BUTTON_HOME 0x00000001
37
38#define BUTTON_DOWN 0x00000002 37#define BUTTON_DOWN 0x00000002
39#define BUTTON_RIGHT 0x00000004 38#define BUTTON_UP 0x00000004
40
41#define BUTTON_LEFT 0x00000008 39#define BUTTON_LEFT 0x00000008
42#define BUTTON_SELECT 0x00000010 40#define BUTTON_SELECT 0x00000010
43#define BUTTON_UP 0x00000020 41#define BUTTON_RIGHT 0x00000020
42
44#define BUTTON_POWER 0x00000040 43#define BUTTON_POWER 0x00000040
45 44
46#define BUTTON_SCROLL_BACK 0x00000080 45#define BUTTON_SCROLL_BACK 0x00000080