diff options
Diffstat (limited to 'firmware/target/arm/sandisk')
-rw-r--r-- | firmware/target/arm/sandisk/sansa-e200/button-e200.c | 42 |
1 files changed, 16 insertions, 26 deletions
diff --git a/firmware/target/arm/sandisk/sansa-e200/button-e200.c b/firmware/target/arm/sandisk/sansa-e200/button-e200.c index 56bce816e4..f1d5981a18 100644 --- a/firmware/target/arm/sandisk/sansa-e200/button-e200.c +++ b/firmware/target/arm/sandisk/sansa-e200/button-e200.c | |||
@@ -39,6 +39,9 @@ static unsigned long next_backlight_on = 0; | |||
39 | /* Buttons */ | 39 | /* Buttons */ |
40 | static bool hold_button = false; | 40 | static bool hold_button = false; |
41 | static bool hold_button_old = false; | 41 | static bool hold_button_old = false; |
42 | #define _button_hold() hold_button | ||
43 | #else | ||
44 | #define _button_hold() ((GPIOF_INPUT_VAL & 0x80) != 0) | ||
42 | #endif /* BOOTLOADER */ | 45 | #endif /* BOOTLOADER */ |
43 | static int int_btn = BUTTON_NONE; | 46 | static int int_btn = BUTTON_NONE; |
44 | 47 | ||
@@ -47,22 +50,19 @@ void button_init_device(void) | |||
47 | /* Enable all buttons */ | 50 | /* Enable all buttons */ |
48 | GPIOF_OUTPUT_EN &= ~0xff; | 51 | GPIOF_OUTPUT_EN &= ~0xff; |
49 | GPIOF_ENABLE |= 0xff; | 52 | GPIOF_ENABLE |= 0xff; |
50 | 53 | ||
51 | /* Scrollwheel light - enable control through GPIOG pin 7 and set timeout */ | 54 | /* Scrollwheel light - enable control through GPIOG pin 7 and set timeout */ |
52 | GPIOG_OUTPUT_EN |= 0x80; | 55 | GPIOG_OUTPUT_EN |= 0x80; |
53 | GPIOG_ENABLE = 0x80; | 56 | GPIOG_ENABLE = 0x80; |
54 | 57 | ||
55 | #ifndef BOOTLOADER | 58 | #ifndef BOOTLOADER |
59 | /* Get current tick before enabling button interrupts */ | ||
60 | last_wheel_tick = current_tick; | ||
61 | last_wheel_post = current_tick; | ||
62 | |||
56 | GPIOH_ENABLE |= 0xc0; | 63 | GPIOH_ENABLE |= 0xc0; |
57 | GPIOH_OUTPUT_EN &= ~0xc0; | 64 | GPIOH_OUTPUT_EN &= ~0xc0; |
58 | 65 | ||
59 | #if 0 | ||
60 | CPU_INT_PRIORITY &= ~HI_MASK; | ||
61 | CPU_HI_INT_PRIORITY &= ~GPIO_MASK; | ||
62 | |||
63 | CPU_INT_CLR = HI_MASK; | ||
64 | CPU_HI_INT_CLR = GPIO_MASK; | ||
65 | #endif | ||
66 | GPIOF_INT_CLR = 0xff; | 66 | GPIOF_INT_CLR = 0xff; |
67 | GPIOH_INT_CLR = 0xc0; | 67 | GPIOH_INT_CLR = 0xc0; |
68 | 68 | ||
@@ -75,25 +75,18 @@ void button_init_device(void) | |||
75 | old_wheel_value = GPIOH_INPUT_VAL & 0xc0; | 75 | old_wheel_value = GPIOH_INPUT_VAL & 0xc0; |
76 | GPIOH_INT_LEV = (GPIOH_INT_LEV & ~0xc0) | (old_wheel_value ^ 0xc0); | 76 | GPIOH_INT_LEV = (GPIOH_INT_LEV & ~0xc0) | (old_wheel_value ^ 0xc0); |
77 | 77 | ||
78 | /* Enable button interrupts */ | ||
78 | GPIOF_INT_EN = 0xff; | 79 | GPIOF_INT_EN = 0xff; |
79 | GPIOH_INT_EN = 0xc0; | 80 | GPIOH_INT_EN = 0xc0; |
80 | #if 0 | ||
81 | CPU_HI_INT_EN = GPIO_MASK; | ||
82 | CPU_INT_EN = HI_MASK; | ||
83 | #endif | ||
84 | 81 | ||
85 | last_wheel_tick = current_tick; | 82 | CPU_INT_EN = HI_MASK; |
86 | last_wheel_post = current_tick; | 83 | CPU_HI_INT_EN = GPIO_MASK; |
87 | #endif /* BOOTLOADER */ | 84 | #endif /* BOOTLOADER */ |
88 | } | 85 | } |
89 | 86 | ||
90 | bool button_hold(void) | 87 | bool button_hold(void) |
91 | { | 88 | { |
92 | #ifdef BOOTLOADER | 89 | return _button_hold(); |
93 | return (GPIOF_INPUT_VAL & 0x80) != 0; | ||
94 | #else | ||
95 | return hold_button; | ||
96 | #endif /* BOOTLOADER */ | ||
97 | } | 90 | } |
98 | 91 | ||
99 | /* clickwheel */ | 92 | /* clickwheel */ |
@@ -118,10 +111,9 @@ void clickwheel_int(void) | |||
118 | 111 | ||
119 | unsigned int wheel_value; | 112 | unsigned int wheel_value; |
120 | 113 | ||
121 | GPIOH_INT_CLR = GPIOH_INT_STAT & 0xc0; | ||
122 | |||
123 | wheel_value = GPIOH_INPUT_VAL & 0xc0; | 114 | wheel_value = GPIOH_INPUT_VAL & 0xc0; |
124 | GPIOH_INT_LEV = (GPIOH_INT_LEV & ~0xc0) | (wheel_value ^ 0xc0); | 115 | GPIOH_INT_LEV = (GPIOH_INT_LEV & ~0xc0) | (wheel_value ^ 0xc0); |
116 | GPIOH_INT_CLR = GPIOH_INT_STAT & 0xc0; | ||
125 | 117 | ||
126 | if (!hold_button) | 118 | if (!hold_button) |
127 | { | 119 | { |
@@ -202,15 +194,13 @@ void button_int(void) | |||
202 | state = GPIOF_INPUT_VAL & 0xff; | 194 | state = GPIOF_INPUT_VAL & 0xff; |
203 | 195 | ||
204 | #ifndef BOOTLOADER | 196 | #ifndef BOOTLOADER |
205 | GPIOF_INT_CLR = GPIOF_INT_STAT; | ||
206 | GPIOF_INT_LEV = (GPIOF_INT_LEV & ~0xff) | (state ^ 0xff); | 197 | GPIOF_INT_LEV = (GPIOF_INT_LEV & ~0xff) | (state ^ 0xff); |
198 | GPIOF_INT_CLR = GPIOF_INT_STAT; | ||
207 | 199 | ||
208 | hold_button = (state & 0x80) != 0; | 200 | hold_button = (state & 0x80) != 0; |
201 | #endif | ||
209 | 202 | ||
210 | if (!hold_button) | 203 | if (!_button_hold()) |
211 | #else | ||
212 | if (button_hold()) | ||
213 | #endif /* BOOTLOADER */ | ||
214 | { | 204 | { |
215 | /* Read normal buttons */ | 205 | /* Read normal buttons */ |
216 | if ((state & 0x01) == 0) int_btn |= BUTTON_REC; | 206 | if ((state & 0x01) == 0) int_btn |= BUTTON_REC; |