1
0
Fork 0
forked from len0rd/rockbox

Sansa Connect: use udelay() in AVR spi_txrx().

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31377 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Tomasz Moń 2011-12-20 13:36:43 +00:00
parent 4aec001244
commit 44d1a26271
2 changed files with 7 additions and 9 deletions

View file

@ -229,8 +229,8 @@ static void spi_txrx(unsigned char *buf_tx, unsigned char *buf_rx, int n)
{ {
IO_SERIAL1_TX_DATA = buf_tx[i]; IO_SERIAL1_TX_DATA = buf_tx[i];
/* a short wait for AVR to process data */ /* 100 us wait for AVR */
sleep(0); udelay(100);
do do
{ {
@ -240,8 +240,8 @@ static void spi_txrx(unsigned char *buf_tx, unsigned char *buf_rx, int n)
if (buf_rx != NULL) if (buf_rx != NULL)
buf_rx[i] = rxdata & 0xFF; buf_rx[i] = rxdata & 0xFF;
/* seems to be unneccessary */ /* 100 us wait to give AVR time to process data */
//udelay(100); udelay(100);
} }
IO_SERIAL1_TX_ENABLE = 0; IO_SERIAL1_TX_ENABLE = 0;

View file

@ -426,7 +426,7 @@ void udelay(int usec) {
stop = count + usec*((tmp+1)/10000); stop = count + usec*((tmp+1)/10000);
stop += (unsigned short)(((unsigned long)(usec)*((tmp%10000)+1))/10000); stop += (unsigned short)(((unsigned long)(usec)*((tmp%10000)+1))/10000);
/* stop values over tmdiv won't ever be reached */ /* stop values over TMDIV won't ever be reached */
if (stop > tmp) if (stop > tmp)
{ {
stop -= tmp; stop -= tmp;
@ -435,15 +435,13 @@ void udelay(int usec) {
if (stop < count) if (stop < count)
{ {
/* udelay will end after counter reset (tick) */ /* udelay will end after counter reset (tick) */
while ((((tmp = IO_TIMER1_TMCNT) < stop) && while (((IO_TIMER1_TMCNT < stop) && (current_tick != prev_tick)) ||
(current_tick != prev_tick)) ||
(current_tick == prev_tick)); /* ensure new tick */ (current_tick == prev_tick)); /* ensure new tick */
} }
else else
{ {
/* udelay will end before counter reset (tick) */ /* udelay will end before counter reset (tick) */
while (((tmp = IO_TIMER1_TMCNT) < stop) && while ((IO_TIMER1_TMCNT < stop) && (current_tick == prev_tick));
(current_tick == prev_tick));
} }
} }