diff options
-rw-r--r-- | firmware/target/arm/as3525/sansa-clipplus/button-clip.c | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/firmware/target/arm/as3525/sansa-clipplus/button-clip.c b/firmware/target/arm/as3525/sansa-clipplus/button-clip.c index 9365c4a940..5b4af70c80 100644 --- a/firmware/target/arm/as3525/sansa-clipplus/button-clip.c +++ b/firmware/target/arm/as3525/sansa-clipplus/button-clip.c | |||
@@ -25,6 +25,12 @@ | |||
25 | 25 | ||
26 | void button_init_device(void) | 26 | void button_init_device(void) |
27 | { | 27 | { |
28 | /* Set pins to input for reading buttons */ | ||
29 | GPIOC_DIR = 0; /* All C pins input */ | ||
30 | GPIOA_DIR &= ~(1<<1|1<<6|1<<7); /* Pins A1,A6,A7 input */ | ||
31 | /* OF does not set D6 to input */ | ||
32 | GPIOB_DIR |= (1<<6); /* Pin B6 output */ | ||
33 | GPIOB_DIR |= (1<<0); /* Pin B0 set output */ | ||
28 | } | 34 | } |
29 | 35 | ||
30 | bool button_hold(void) | 36 | bool button_hold(void) |
@@ -35,12 +41,7 @@ bool button_hold(void) | |||
35 | 41 | ||
36 | int button_read_device(void) | 42 | int button_read_device(void) |
37 | { | 43 | { |
38 | static int buttons = 0; | 44 | int buttons = 0; |
39 | |||
40 | /* Set pins to input for reading buttons */ | ||
41 | GPIOC_DIR = 0; /* All C pins input */ | ||
42 | GPIOA_DIR &= ~(1<<1|1<<6|1<<7); /* Pins A1,A6,A7 input */ | ||
43 | /* OF does not set D6 to input */ | ||
44 | 45 | ||
45 | /* TODO No hold button Hold toggled by long home(A1) press in OF */ | 46 | /* TODO No hold button Hold toggled by long home(A1) press in OF */ |
46 | if(button_hold()) | 47 | if(button_hold()) |
@@ -50,7 +51,6 @@ int button_read_device(void) | |||
50 | /* Buttons do not appear to need reset */ | 51 | /* Buttons do not appear to need reset */ |
51 | /* D6 needs special handling though */ | 52 | /* D6 needs special handling though */ |
52 | 53 | ||
53 | GPIOB_DIR |= (1<<0); /* Pin B0 set output */ | ||
54 | GPIOB_PIN(0) = 1; /* set B0 */ | 54 | GPIOB_PIN(0) = 1; /* set B0 */ |
55 | 55 | ||
56 | int delay = 500; | 56 | int delay = 500; |
@@ -85,21 +85,5 @@ int button_read_device(void) | |||
85 | if GPIOC_PIN(1) | 85 | if GPIOC_PIN(1) |
86 | buttons |= BUTTON_DOWN; | 86 | buttons |= BUTTON_DOWN; |
87 | 87 | ||
88 | /* TODO figure out why OF does this */ | ||
89 | if (buttons & BUTTON_POWER) | ||
90 | { | ||
91 | GPIOB_DIR |= (1<<6); /* Pin B6 output */ | ||
92 | |||
93 | delay = 8; | ||
94 | do { | ||
95 | asm volatile("nop\n"); | ||
96 | } while (delay--); | ||
97 | |||
98 | if GPIOD_PIN(6) | ||
99 | buttons |= BUTTON_POWER; /* OF sets a different flag than PWR */ | ||
100 | } | ||
101 | |||
102 | return buttons; | 88 | return buttons; |
103 | } | 89 | } |
104 | |||
105 | |||