diff options
Diffstat (limited to 'firmware/target/arm/as3525/sansa-fuze/button-fuze.c')
-rw-r--r-- | firmware/target/arm/as3525/sansa-fuze/button-fuze.c | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/firmware/target/arm/as3525/sansa-fuze/button-fuze.c b/firmware/target/arm/as3525/sansa-fuze/button-fuze.c index f32776f6eb..f532a96431 100644 --- a/firmware/target/arm/as3525/sansa-fuze/button-fuze.c +++ b/firmware/target/arm/as3525/sansa-fuze/button-fuze.c | |||
@@ -49,7 +49,7 @@ void button_init_device(void) | |||
49 | } | 49 | } |
50 | 50 | ||
51 | #if !defined(BOOTLOADER) && defined(HAVE_SCROLLWHEEL) | 51 | #if !defined(BOOTLOADER) && defined(HAVE_SCROLLWHEEL) |
52 | static void scrollwheel(short dbop) | 52 | static void scrollwheel(short dbop_din) |
53 | { | 53 | { |
54 | /* current wheel values, parsed from dbop and the resulting button */ | 54 | /* current wheel values, parsed from dbop and the resulting button */ |
55 | unsigned wheel_value = 0; | 55 | unsigned wheel_value = 0; |
@@ -76,7 +76,7 @@ static void scrollwheel(short dbop) | |||
76 | { 2, 0, 3, 1 }, /* Clockwise rotation */ | 76 | { 2, 0, 3, 1 }, /* Clockwise rotation */ |
77 | { 1, 3, 0, 2 }, /* Counter-clockwise */ | 77 | { 1, 3, 0, 2 }, /* Counter-clockwise */ |
78 | }; | 78 | }; |
79 | wheel_value = dbop & (1<<13|1<<14); | 79 | wheel_value = dbop_din & (1<<13|1<<14); |
80 | wheel_value >>= 13; | 80 | wheel_value >>= 13; |
81 | 81 | ||
82 | if (old_wheel_value == wheel_tbl[0][wheel_value]) | 82 | if (old_wheel_value == wheel_tbl[0][wheel_value]) |
@@ -90,7 +90,7 @@ static void scrollwheel(short dbop) | |||
90 | { | 90 | { |
91 | /* direction reversals nullify repeats */ | 91 | /* direction reversals nullify repeats */ |
92 | wheel_repeat = btn; | 92 | wheel_repeat = btn; |
93 | repeat = 0; | 93 | repeat = counter = 0; |
94 | } | 94 | } |
95 | if (btn != BUTTON_NONE) | 95 | if (btn != BUTTON_NONE) |
96 | { | 96 | { |
@@ -139,7 +139,7 @@ static void button_delay(void) | |||
139 | while(i--); | 139 | while(i--); |
140 | } | 140 | } |
141 | 141 | ||
142 | static short button_dbop(void) | 142 | short button_read_dbop(void) |
143 | { | 143 | { |
144 | /* skip home and power reading if lcd_button_support was blocked, | 144 | /* skip home and power reading if lcd_button_support was blocked, |
145 | * since the dbop bit 15 is invalid then, and use the old value instead */ | 145 | * since the dbop bit 15 is invalid then, and use the old value instead */ |
@@ -150,27 +150,24 @@ static short button_dbop(void) | |||
150 | old_home_power = (_dbop_din & (1<<15|1<<8)); | 150 | old_home_power = (_dbop_din & (1<<15|1<<8)); |
151 | } | 151 | } |
152 | 152 | ||
153 | /* Wait for fifo to empty */ | 153 | /* Set up dbop for input */ |
154 | while ((DBOP_STAT & (1<<10)) == 0); | 154 | while (!(DBOP_STAT & (1<<10))); /* Wait for fifo to empty */ |
155 | 155 | DBOP_CTRL |= (1<<19); /* Tri-state DBOP on read cycle */ | |
156 | DBOP_CTRL |= (1<<19); | 156 | DBOP_CTRL &= ~(1<<16); /* disable output (1:write enabled) */ |
157 | DBOP_CTRL &= ~(1<<16); /* disable output */ | 157 | DBOP_TIMPOL_01 = 0xe167e167; /* Set Timing & Polarity regs 0 & 1 */ |
158 | 158 | DBOP_TIMPOL_23 = 0xe167006e; /* Set Timing & Polarity regs 2 & 3 */ | |
159 | DBOP_TIMPOL_01 = 0xe167e167; | ||
160 | DBOP_TIMPOL_23 = 0xe167006e; | ||
161 | 159 | ||
162 | button_delay(); | 160 | button_delay(); |
161 | DBOP_CTRL |= (1<<15); /* start read */ | ||
162 | while (!(DBOP_STAT & (1<<16))); /* wait for valid data */ | ||
163 | 163 | ||
164 | DBOP_CTRL |= (1<<15); /* start read */ | 164 | _dbop_din = DBOP_DIN; /* Read dbop data*/ |
165 | while((DBOP_STAT & (1<<16)) == 0); /* wait for valid data */ | ||
166 | |||
167 | _dbop_din = DBOP_DIN; /* now read */ | ||
168 | 165 | ||
169 | DBOP_TIMPOL_01 = 0x6e167; | 166 | /* Reset dbop for output */ |
170 | DBOP_TIMPOL_23 = 0xa167e06f; | 167 | DBOP_TIMPOL_01 = 0x6e167; /* Set Timing & Polarity regs 0 & 1 */ |
171 | 168 | DBOP_TIMPOL_23 = 0xa167e06f; /* Set Timing & Polarity regs 2 & 3 */ | |
172 | DBOP_CTRL |= (1<<16); | 169 | DBOP_CTRL |= (1<<16); /* Enable output (0:write disable) */ |
173 | DBOP_CTRL &= ~(1<<19); | 170 | DBOP_CTRL &= ~(1<<19); /* Tri-state when no active write */ |
174 | 171 | ||
175 | /* write back old values if blocked */ | 172 | /* write back old values if blocked */ |
176 | if (old_home_power != -20) | 173 | if (old_home_power != -20) |
@@ -178,6 +175,10 @@ static short button_dbop(void) | |||
178 | _dbop_din |= old_home_power & 1<<15; | 175 | _dbop_din |= old_home_power & 1<<15; |
179 | _dbop_din &= 0xfeff|(old_home_power & 1<<8); | 176 | _dbop_din &= 0xfeff|(old_home_power & 1<<8); |
180 | } | 177 | } |
178 | #if defined(HAVE_SCROLLWHEEL) && !defined(BOOTLOADER) | ||
179 | /* read wheel on bit 13 & 14, but sent to the button queue seperately */ | ||
180 | scrollwheel(_dbop_din); | ||
181 | #endif | ||
181 | return _dbop_din; | 182 | return _dbop_din; |
182 | } | 183 | } |
183 | 184 | ||
@@ -233,7 +234,7 @@ static int button_gpio(void) | |||
233 | int button_read_device(void) | 234 | int button_read_device(void) |
234 | { | 235 | { |
235 | int btn = BUTTON_NONE; | 236 | int btn = BUTTON_NONE; |
236 | short dbop = button_dbop(); | 237 | short dbop = button_read_dbop(); |
237 | static unsigned power_counter = 0; | 238 | static unsigned power_counter = 0; |
238 | /* hold button */ | 239 | /* hold button */ |
239 | if(dbop & (1<<12)) | 240 | if(dbop & (1<<12)) |
@@ -244,10 +245,6 @@ int button_read_device(void) | |||
244 | else | 245 | else |
245 | { | 246 | { |
246 | hold_button = false; | 247 | hold_button = false; |
247 | #if defined(HAVE_SCROLLWHEEL) && !defined(BOOTLOADER) | ||
248 | /* read wheel on bit 13 & 14, but sent to the button queue seperately */ | ||
249 | scrollwheel(dbop); | ||
250 | #endif | ||
251 | /* read power on bit 8, but not if hold button was just released, since | 248 | /* read power on bit 8, but not if hold button was just released, since |
252 | * you basically always hit power due to the slider mechanism after releasing | 249 | * you basically always hit power due to the slider mechanism after releasing |
253 | * hold (wait ~1 sec) */ | 250 | * hold (wait ~1 sec) */ |