1
0
Fork 0
forked from len0rd/rockbox

Commit fs#9959 by Jack Halpin. Removes delays from the Sansa e200v2 button driver and cleans up the code.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20676 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Giacomelli 2009-04-10 15:19:59 +00:00
parent a137733d10
commit 30b888cb58
2 changed files with 30 additions and 31 deletions

View file

@ -458,6 +458,7 @@ Johannes Linke
Michaël Burtin Michaël Burtin
Sasha Khamkov Sasha Khamkov
Kai Posadowsky Kai Posadowsky
Jack Halpin
The libmad team The libmad team
The wavpack team The wavpack team

View file

@ -73,7 +73,7 @@ void clickwheel(unsigned int wheel_value)
* Counter-clockwise 00 -> 10 -> 11 -> 01 -> 00 * Counter-clockwise 00 -> 10 -> 11 -> 01 -> 00
*/ */
/* did the wheel value change? */ /* did the wheel value change? */
unsigned int btn = BUTTON_NONE; unsigned int btn = BUTTON_NONE;
if (old_wheel_value == wheel_tbl[0][wheel_value]) if (old_wheel_value == wheel_tbl[0][wheel_value])
btn = BUTTON_SCROLL_FWD; btn = BUTTON_SCROLL_FWD;
@ -83,7 +83,7 @@ void clickwheel(unsigned int wheel_value)
if (btn != BUTTON_NONE) if (btn != BUTTON_NONE)
{ {
int repeat = 1; /* assume repeat */ int repeat = 1; /* assume repeat */
unsigned long usec = TIMER1_VALUE; /* WAG!!! and it works!!*/ unsigned long usec = TIMER1_VALUE;
unsigned v = (usec - last_wheel_usec) & 0x7fffffff; unsigned v = (usec - last_wheel_usec) & 0x7fffffff;
v = (v>0) ? 1000000 / v : 0; /* clicks/sec = 1000000 * +clicks/usec */ v = (v>0) ? 1000000 / v : 0; /* clicks/sec = 1000000 * +clicks/usec */
@ -162,7 +162,7 @@ void clickwheel(unsigned int wheel_value)
{ {
queue_post(&button_queue, btn, wheel_fast_mode | queue_post(&button_queue, btn, wheel_fast_mode |
(wheel_delta << 24) | (wheel_delta << 24) |
wheel_velocity*360/WHEELCLICKS_PER_ROTATION); wheel_velocity*360/WHEELCLICKS_PER_ROTATION);
/* message posted - reset delta */ /* message posted - reset delta */
wheel_delta = 1; wheel_delta = 1;
} }
@ -173,7 +173,6 @@ void clickwheel(unsigned int wheel_value)
wheel_delta = 0x7f; wheel_delta = 0x7f;
} }
} }
last_wheel_usec = usec; last_wheel_usec = usec;
} }
old_wheel_value = wheel_value; old_wheel_value = wheel_value;
@ -183,26 +182,24 @@ static short read_dbop(void)
{ {
/*write a red pixel */ /*write a red pixel */
if (!lcd_button_support()) if (!lcd_button_support())
return _dbop_din; return _dbop_din;
/* Set up dbop for input */ /* Set up dbop for input */
while (!(DBOP_STAT & (1<<10))); /* Wait for fifo to empty */ while (!(DBOP_STAT & (1<<10))); /* Wait for fifo to empty */
DBOP_CTRL |= (1<<19); DBOP_CTRL |= (1<<19);
DBOP_CTRL &= ~(1<<16); /* disable output */ DBOP_CTRL &= ~(1<<16); /* disable output (1:write enabled) */
DBOP_TIMPOL_01 = 0xe167e167; /* Set Timing & Polarity regs 0 & 1 */
DBOP_TIMPOL_23 = 0xe167006e; /* Set Timing & Polarity regs 2 & 3 */
DBOP_TIMPOL_01 = 0xe167e167; //11100001011001111110000101100111 DBOP_CTRL |= (1<<15); /* start read */
DBOP_TIMPOL_23 = 0xe167006e; //11100001011001110000000001101110 while (!(DBOP_STAT & (1<<16))); /* wait for valid data */
DBOP_CTRL |= (1<<15); /* start read */ _dbop_din = DBOP_DIN; /* Read dbop data*/
while (!(DBOP_STAT & (1<<16))); /* wait for valid data */
int delay = 50;
while(delay--); /* small delay to set up read */
_dbop_din = DBOP_DIN; /* now read dbop & store info*/ /* Reset dbop for output */
DBOP_TIMPOL_01 = 0x6e167; /* Set Timing & Polarity regs 0 & 1 */
DBOP_TIMPOL_01 = 0x6e167; DBOP_TIMPOL_23 = 0xa167e06f; /* Set Timing & Polarity regs 2 & 3 */
DBOP_TIMPOL_23 = 0xa167e06f; DBOP_CTRL |= (1<<16); /* Enable output (0:write disable) */
DBOP_CTRL |= (1<<16);
DBOP_CTRL &= ~(1<<19); DBOP_CTRL &= ~(1<<19);
return _dbop_din; return _dbop_din;
@ -235,8 +232,9 @@ int button_read_device(void)
if (dbop & (1<<8)) if (dbop & (1<<8))
btn |= BUTTON_POWER; btn |= BUTTON_POWER;
if (!(dbop & (1<<15)))
btn |= BUTTON_REC; if (!(dbop & (1<<15)))
btn |= BUTTON_REC;
/* handle wheel */ /* handle wheel */
int wheel_value = dbop & (1<<13|1<<14); int wheel_value = dbop & (1<<13|1<<14);
@ -256,7 +254,7 @@ int button_read_device(void)
GPIOC_DIR &= ~(1<<2|1<<3|1<<4|1<<5|1<<6); GPIOC_DIR &= ~(1<<2|1<<3|1<<4|1<<5|1<<6);
int delay = 50; /* small delay needed to read buttons correctly */ int delay = 2; /* small delay needed to read buttons correctly */
while(delay--); while(delay--);
/* direct GPIO connections */ /* direct GPIO connections */
@ -268,8 +266,8 @@ int button_read_device(void)
btn |= BUTTON_SELECT; btn |= BUTTON_SELECT;
if (!GPIOC_PIN(5)) if (!GPIOC_PIN(5))
btn |= BUTTON_RIGHT; btn |= BUTTON_RIGHT;
if (!GPIOC_PIN(6)) if (!GPIOC_PIN(6))
btn |= BUTTON_DOWN; btn |= BUTTON_DOWN;
/* return to settings needed for lcd */ /* return to settings needed for lcd */
GPIOC_DIR |= (1<<2|1<<3|1<<4|1<<5|1<<6); GPIOC_DIR |= (1<<2|1<<3|1<<4|1<<5|1<<6);