summaryrefslogtreecommitdiff
path: root/firmware/target/arm/as3525/sansa-m200v2/button-m200v2.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/as3525/sansa-m200v2/button-m200v2.c')
-rw-r--r--firmware/target/arm/as3525/sansa-m200v2/button-m200v2.c60
1 files changed, 55 insertions, 5 deletions
diff --git a/firmware/target/arm/as3525/sansa-m200v2/button-m200v2.c b/firmware/target/arm/as3525/sansa-m200v2/button-m200v2.c
index cd31d06720..c5d6c4941d 100644
--- a/firmware/target/arm/as3525/sansa-m200v2/button-m200v2.c
+++ b/firmware/target/arm/as3525/sansa-m200v2/button-m200v2.c
@@ -26,18 +26,68 @@
26 26
27void button_init_device(void) 27void button_init_device(void)
28{ 28{
29 29 GPIOA_DIR &= ~((1<<3) | (1<<2) | (1<<1) | (1<<0)); /* A3-A0 is input */
30 GPIOA_DIR |= ((1<<6) | (1<<5) | (1<<4)); /* A4-A6 row outputs */
30} 31}
31 32
32int button_read_device(void) 33int button_read_device(void)
33{ 34{
34 int btn = BUTTON_NONE; 35 int result = BUTTON_NONE;
36
37 /* direct GPIO connections */
38 if (GPIOA_PIN(3))
39 result |= BUTTON_MENU;
40
41 /* This is a keypad using A4-A6 as columns and A0-A2 as rows */
42 GPIOA_PIN(4) = (1<<4);
43
44 /* A4A0 is unused */
45
46 if (GPIOA_PIN(1))
47 result |= BUTTON_VOLDOWN;
48
49 if (GPIOA_PIN(2))
50 result |= BUTTON_PLAYPAUSE;
51
52 GPIOA_PIN(4) = 0x00;
53
54 GPIOA_PIN(5) = (1<<5);
55
56 if (GPIOA_PIN(0))
57 result |= BUTTON_LEFT;
58
59 if (GPIOA_PIN(1))
60 result |= BUTTON_SELECT;
61
62 if (GPIOA_PIN(2))
63 result |= BUTTON_RIGHT;
64
65 GPIOA_PIN(5) = 0x00;
66
67
68 GPIOA_PIN(6) = (1<<6);
69
70 if (GPIOA_PIN(0))
71 result |= BUTTON_REPEATAB;
72
73 if (GPIOA_PIN(1))
74 result |= BUTTON_VOLUP;
75
76 if (GPIOA_PIN(2))
77 result |= BUTTON_HOLD;
78 GPIOA_PIN(6) = 0x00;
35 79
36 return btn; 80 return result;
37} 81}
38 82
39bool button_hold(void) 83bool button_hold(void)
40{ 84{
41 /* TODO */ 85 bool ret = false;
42 return false; 86
87 GPIOA_PIN(6) = (1<<6);
88 if (GPIOA_PIN(2))
89 ret = true;
90 GPIOA_PIN(6) = 0x00;
91
92 return ret;
43} 93}