summaryrefslogtreecommitdiff
path: root/firmware/target
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/arm/as3525/sansa-m200v2/backlight-target.h3
-rw-r--r--firmware/target/arm/as3525/sansa-m200v2/button-m200v2.c60
-rw-r--r--firmware/target/arm/as3525/sansa-m200v2/button-target.h3
3 files changed, 60 insertions, 6 deletions
diff --git a/firmware/target/arm/as3525/sansa-m200v2/backlight-target.h b/firmware/target/arm/as3525/sansa-m200v2/backlight-target.h
index 9533d0a6b5..50404f7090 100644
--- a/firmware/target/arm/as3525/sansa-m200v2/backlight-target.h
+++ b/firmware/target/arm/as3525/sansa-m200v2/backlight-target.h
@@ -23,15 +23,18 @@
23 23
24static inline bool _backlight_init(void) 24static inline bool _backlight_init(void)
25{ 25{
26 GPIOD_DIR |= (1<<1);
26 return true; 27 return true;
27} 28}
28 29
29static inline void _backlight_on(void) 30static inline void _backlight_on(void)
30{ 31{
32 GPIOD_PIN(1) = (1<<1);
31} 33}
32 34
33static inline void _backlight_off(void) 35static inline void _backlight_off(void)
34{ 36{
37 GPIOD_PIN(1) = 0x00;
35} 38}
36 39
37#endif 40#endif
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}
diff --git a/firmware/target/arm/as3525/sansa-m200v2/button-target.h b/firmware/target/arm/as3525/sansa-m200v2/button-target.h
index acf80b2ed7..779f7400bb 100644
--- a/firmware/target/arm/as3525/sansa-m200v2/button-target.h
+++ b/firmware/target/arm/as3525/sansa-m200v2/button-target.h
@@ -40,10 +40,11 @@ bool button_hold(void);
40#define BUTTON_LEFT 0x00000020 40#define BUTTON_LEFT 0x00000020
41#define BUTTON_RIGHT 0x00000040 41#define BUTTON_RIGHT 0x00000040
42#define BUTTON_SELECT 0x00000080 42#define BUTTON_SELECT 0x00000080
43#define BUTTON_HOLD 0x00000100
43 44
44#define BUTTON_MAIN (BUTTON_MENU|BUTTON_VOLUP|BUTTON_VOLDOWN\ 45#define BUTTON_MAIN (BUTTON_MENU|BUTTON_VOLUP|BUTTON_VOLDOWN\
45 |BUTTON_PLAYPAUSE|BUTTON_REPEATAB|BUTTON_LEFT\ 46 |BUTTON_PLAYPAUSE|BUTTON_REPEATAB|BUTTON_LEFT\
46 |BUTTON_RIGHT|BUTTON_SELECT) 47 |BUTTON_RIGHT|BUTTON_SELECT|BUTTON_HOLD)
47 48
48#define BUTTON_REMOTE 0 49#define BUTTON_REMOTE 0
49 50