summaryrefslogtreecommitdiff
path: root/firmware/target/arm/as3525/sansa-fuzev2
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/as3525/sansa-fuzev2')
-rw-r--r--firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c38
-rw-r--r--firmware/target/arm/as3525/sansa-fuzev2/button-target.h6
2 files changed, 40 insertions, 4 deletions
diff --git a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
index 0a6d2c919c..4848d9e7d9 100644
--- a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
+++ b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
@@ -24,21 +24,50 @@
24#include "button.h" 24#include "button.h"
25#include "backlight.h" 25#include "backlight.h"
26 26
27/* 27extern void scrollwheel(unsigned wheel_value);
28 * TODO: Scrollwheel! 28
29 */
30
31#ifdef HAS_BUTTON_HOLD 29#ifdef HAS_BUTTON_HOLD
32static bool hold_button = false; 30static bool hold_button = false;
33#endif 31#endif
34void button_init_device(void) 32void button_init_device(void)
33{ /* activate the wheel */
34 volatile int i;
35 GPIOB_DIR |= 1<<4;
36 for(i = 20; i; i--) nop;
37 GPIOB_PIN(4) = 0x10;
38}
39
40unsigned read_GPIOA_67(void)
35{ 41{
42 unsigned ret = 0;
43 volatile int i;
44 DBOP_CTRL |= 1<<19;
45 for(i = 20; i; i--) nop;
46 GPIOA_DIR &= ~0xc0;
47 for(i = 20; i; i--) nop;
48 if (GPIOA_PIN(6) != 0)
49 ret = 1<<0;
50 for(i = 20; i; i--) nop;
51 if (GPIOA_PIN(7) != 0)
52 ret |= 1<<1;
53 DBOP_CTRL &= ~(1<<19);
54 for(i = 20; i; i--) nop;
55 return ret;
56}
57
58void get_scrollwheel(void)
59{
60#if defined(HAVE_SCROLLWHEEL) && !defined(BOOTLOADER)
61 /* scroll wheel handling */
62 scrollwheel(read_GPIOA_67());
63#endif
36} 64}
37 65
38/* 66/*
39 * Get button pressed from hardware 67 * Get button pressed from hardware
40 */ 68 */
41 69
70
42int button_read_device(void) 71int button_read_device(void)
43{ 72{
44 int btn = 0; 73 int btn = 0;
@@ -48,6 +77,7 @@ int button_read_device(void)
48 unsigned gpiod = GPIOD_DATA; 77 unsigned gpiod = GPIOD_DATA;
49 unsigned gpioa_dir = GPIOA_DIR; 78 unsigned gpioa_dir = GPIOA_DIR;
50 unsigned gpiod6; 79 unsigned gpiod6;
80 get_scrollwheel();
51 for(delay = 500; delay; delay--) nop; 81 for(delay = 500; delay; delay--) nop;
52 CCU_IO &= ~(1<<12); 82 CCU_IO &= ~(1<<12);
53 for(delay=8;delay;delay--) nop; 83 for(delay=8;delay;delay--) nop;
diff --git a/firmware/target/arm/as3525/sansa-fuzev2/button-target.h b/firmware/target/arm/as3525/sansa-fuzev2/button-target.h
index 6dcd37460a..14f3db18f7 100644
--- a/firmware/target/arm/as3525/sansa-fuzev2/button-target.h
+++ b/firmware/target/arm/as3525/sansa-fuzev2/button-target.h
@@ -31,6 +31,12 @@ void button_init_device(void);
31bool button_hold(void); 31bool button_hold(void);
32int button_read_device(void); 32int button_read_device(void);
33unsigned short button_read_dbop(void); 33unsigned short button_read_dbop(void);
34void get_scrollwheel(void);
35
36#define WHEEL_REPEAT_INTERVAL (HZ/5)
37#define WHEEL_COUNTER_DIV 4
38#define ACCEL_INCREMENT 2
39#define ACCEL_SHIFT 2
34/* Sandisk Sansa Fuze button codes */ 40/* Sandisk Sansa Fuze button codes */
35 41
36/* Main unit's buttons */ 42/* Main unit's buttons */