summaryrefslogtreecommitdiff
path: root/firmware/target/arm/as3525/sansa-e200v2/button-e200v2.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/as3525/sansa-e200v2/button-e200v2.c')
-rw-r--r--firmware/target/arm/as3525/sansa-e200v2/button-e200v2.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/firmware/target/arm/as3525/sansa-e200v2/button-e200v2.c b/firmware/target/arm/as3525/sansa-e200v2/button-e200v2.c
index 54e46f4a12..85288d2cc1 100644
--- a/firmware/target/arm/as3525/sansa-e200v2/button-e200v2.c
+++ b/firmware/target/arm/as3525/sansa-e200v2/button-e200v2.c
@@ -60,7 +60,7 @@ bool button_hold(void)
60 return hold_button; 60 return hold_button;
61} 61}
62 62
63void clickwheel(unsigned int wheel_value) 63static void scrollwheel(short dbop_din)
64{ 64{
65 static const unsigned char wheel_tbl[2][4] = 65 static const unsigned char wheel_tbl[2][4] =
66 { 66 {
@@ -75,6 +75,10 @@ void clickwheel(unsigned int wheel_value)
75 75
76 /* did the wheel value change? */ 76 /* did the wheel value change? */
77 unsigned int btn = BUTTON_NONE; 77 unsigned int btn = BUTTON_NONE;
78
79 unsigned wheel_value = dbop_din & (1<<13|1<<14);
80 wheel_value >>= 13;
81
78 if (old_wheel_value == wheel_tbl[0][wheel_value]) 82 if (old_wheel_value == wheel_tbl[0][wheel_value])
79 btn = BUTTON_SCROLL_FWD; 83 btn = BUTTON_SCROLL_FWD;
80 else if (old_wheel_value == wheel_tbl[1][wheel_value]) 84 else if (old_wheel_value == wheel_tbl[1][wheel_value])
@@ -178,7 +182,7 @@ void clickwheel(unsigned int wheel_value)
178 old_wheel_value = wheel_value; 182 old_wheel_value = wheel_value;
179} 183}
180 184
181static short read_dbop(void) 185short button_read_dbop(void)
182{ 186{
183 /*write a red pixel */ 187 /*write a red pixel */
184 if (!lcd_button_support()) 188 if (!lcd_button_support())
@@ -186,7 +190,7 @@ static short read_dbop(void)
186 190
187 /* Set up dbop for input */ 191 /* Set up dbop for input */
188 while (!(DBOP_STAT & (1<<10))); /* Wait for fifo to empty */ 192 while (!(DBOP_STAT & (1<<10))); /* Wait for fifo to empty */
189 DBOP_CTRL |= (1<<19); 193 DBOP_CTRL |= (1<<19); /* Tri-state DBOP on read cycle */
190 DBOP_CTRL &= ~(1<<16); /* disable output (1:write enabled) */ 194 DBOP_CTRL &= ~(1<<16); /* disable output (1:write enabled) */
191 DBOP_TIMPOL_01 = 0xe167e167; /* Set Timing & Polarity regs 0 & 1 */ 195 DBOP_TIMPOL_01 = 0xe167e167; /* Set Timing & Polarity regs 0 & 1 */
192 DBOP_TIMPOL_23 = 0xe167006e; /* Set Timing & Polarity regs 2 & 3 */ 196 DBOP_TIMPOL_23 = 0xe167006e; /* Set Timing & Polarity regs 2 & 3 */
@@ -200,8 +204,9 @@ static short read_dbop(void)
200 DBOP_TIMPOL_01 = 0x6e167; /* Set Timing & Polarity regs 0 & 1 */ 204 DBOP_TIMPOL_01 = 0x6e167; /* Set Timing & Polarity regs 0 & 1 */
201 DBOP_TIMPOL_23 = 0xa167e06f; /* Set Timing & Polarity regs 2 & 3 */ 205 DBOP_TIMPOL_23 = 0xa167e06f; /* Set Timing & Polarity regs 2 & 3 */
202 DBOP_CTRL |= (1<<16); /* Enable output (0:write disable) */ 206 DBOP_CTRL |= (1<<16); /* Enable output (0:write disable) */
203 DBOP_CTRL &= ~(1<<19); 207 DBOP_CTRL &= ~(1<<19); /* Tri-state when no active write */
204 208
209 scrollwheel(_dbop_din);
205 return _dbop_din; 210 return _dbop_din;
206} 211}
207 212
@@ -217,7 +222,7 @@ int button_read_device(void)
217{ 222{
218 int btn = BUTTON_NONE; 223 int btn = BUTTON_NONE;
219 /* read buttons from dbop */ 224 /* read buttons from dbop */
220 short dbop = read_dbop(); 225 short dbop = button_read_dbop();
221 226
222 /* hold button */ 227 /* hold button */
223 if(dbop & (1<<12)) 228 if(dbop & (1<<12))
@@ -239,7 +244,6 @@ int button_read_device(void)
239 /* handle wheel */ 244 /* handle wheel */
240 int wheel_value = dbop & (1<<13|1<<14); 245 int wheel_value = dbop & (1<<13|1<<14);
241 wheel_value >>= 13; 246 wheel_value >>= 13;
242 clickwheel(wheel_value);
243 247
244 /* Set afsel, so that we can read our buttons */ 248 /* Set afsel, so that we can read our buttons */
245 GPIOC_AFSEL &= ~(1<<2|1<<3|1<<4|1<<5|1<<6); 249 GPIOC_AFSEL &= ~(1<<2|1<<3|1<<4|1<<5|1<<6);