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:
parent
a137733d10
commit
30b888cb58
2 changed files with 30 additions and 31 deletions
|
@ -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
|
||||||
|
|
|
@ -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 */
|
||||||
|
@ -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;
|
||||||
|
@ -188,21 +187,19 @@ static short read_dbop(void)
|
||||||
/* 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_01 = 0xe167e167; //11100001011001111110000101100111
|
DBOP_TIMPOL_23 = 0xe167006e; /* Set Timing & Polarity regs 2 & 3 */
|
||||||
DBOP_TIMPOL_23 = 0xe167006e; //11100001011001110000000001101110
|
|
||||||
|
|
||||||
DBOP_CTRL |= (1<<15); /* start read */
|
DBOP_CTRL |= (1<<15); /* start read */
|
||||||
while (!(DBOP_STAT & (1<<16))); /* wait for valid 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*/
|
_dbop_din = DBOP_DIN; /* Read dbop data*/
|
||||||
|
|
||||||
DBOP_TIMPOL_01 = 0x6e167;
|
/* Reset dbop for output */
|
||||||
DBOP_TIMPOL_23 = 0xa167e06f;
|
DBOP_TIMPOL_01 = 0x6e167; /* Set Timing & Polarity regs 0 & 1 */
|
||||||
DBOP_CTRL |= (1<<16);
|
DBOP_TIMPOL_23 = 0xa167e06f; /* Set Timing & Polarity regs 2 & 3 */
|
||||||
|
DBOP_CTRL |= (1<<16); /* Enable output (0:write disable) */
|
||||||
DBOP_CTRL &= ~(1<<19);
|
DBOP_CTRL &= ~(1<<19);
|
||||||
|
|
||||||
return _dbop_din;
|
return _dbop_din;
|
||||||
|
@ -235,6 +232,7 @@ int button_read_device(void)
|
||||||
|
|
||||||
if (dbop & (1<<8))
|
if (dbop & (1<<8))
|
||||||
btn |= BUTTON_POWER;
|
btn |= BUTTON_POWER;
|
||||||
|
|
||||||
if (!(dbop & (1<<15)))
|
if (!(dbop & (1<<15)))
|
||||||
btn |= BUTTON_REC;
|
btn |= BUTTON_REC;
|
||||||
|
|
||||||
|
@ -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 */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue