forked from len0rd/rockbox
Fix ata2501 serial reading
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18550 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
afe32ef15d
commit
eab5498484
1 changed files with 14 additions and 27 deletions
|
|
@ -20,6 +20,7 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "system.h"
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
|
|
||||||
|
|
@ -31,39 +32,27 @@
|
||||||
#define SIFMD (1<<7)
|
#define SIFMD (1<<7)
|
||||||
#define STB_DELAY 200
|
#define STB_DELAY 200
|
||||||
|
|
||||||
#define udelay _udelay
|
static inline void ndelay(unsigned long nsecs)
|
||||||
|
|
||||||
/* do we really need it? */
|
|
||||||
static void _udelay(int cycles)
|
|
||||||
{
|
{
|
||||||
cycles /= 8;
|
nsecs /= 8;
|
||||||
while (cycles--) {
|
while (nsecs)
|
||||||
asm("nop;nop;");
|
nsecs--;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO: sensitivity using GPIOS
|
TODO: sensitivity
|
||||||
*/
|
*/
|
||||||
void ata2501_init(void)
|
void ata2501_init(void)
|
||||||
{
|
{
|
||||||
GPIOD_DIR |= (RESET | STB | SIFMD | (1 << 8) | (1 << 9));
|
GPIOD_DIR |= (RESET | STB | SIFMD | (1 << 8) | (1 << 9));
|
||||||
GPIOD_DIR &= ~(SDATA);
|
GPIOD_DIR &= ~SDATA;
|
||||||
|
|
||||||
GPIOD &= ~RESET;
|
|
||||||
udelay(1000);
|
|
||||||
|
|
||||||
GPIOD |= RESET;
|
|
||||||
|
|
||||||
GPIOD &= ~STB;
|
GPIOD &= ~STB;
|
||||||
|
GPIOD |= (1 << 8) | SIFMD | (1 << 9);
|
||||||
|
|
||||||
#if 1
|
GPIOD &= ~RESET;
|
||||||
GPIOD &= ~((1 << 9) | (1 << 8));
|
ndelay(1000);
|
||||||
GPIOD |= ((1 << 8) | SIFMD) | (1 << 9);
|
GPIOD |= RESET;
|
||||||
#else
|
|
||||||
GPIOD |= ((1 << 9) | (1 << 8));
|
|
||||||
GPIOD &= ~(SIFMD);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short ata2501_read(void)
|
unsigned short ata2501_read(void)
|
||||||
|
|
@ -73,14 +62,12 @@ unsigned short ata2501_read(void)
|
||||||
|
|
||||||
for (i = 0; i < 12; i++) {
|
for (i = 0; i < 12; i++) {
|
||||||
GPIOD |= STB;
|
GPIOD |= STB;
|
||||||
udelay(50);
|
ndelay(100);
|
||||||
|
|
||||||
ret <<= 1;
|
ret <<= 1;
|
||||||
if (GPIOD & SDATA)
|
if (GPIOD & SDATA)
|
||||||
ret |= 1;
|
ret |= 1;
|
||||||
udelay(50);
|
|
||||||
GPIOD &= ~STB;
|
GPIOD &= ~STB;
|
||||||
udelay(100);
|
ndelay(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -118,7 +105,7 @@ void ata2501_test(void)
|
||||||
lcd_puts(0, line++, buf);
|
lcd_puts(0, line++, buf);
|
||||||
|
|
||||||
lcd_update();
|
lcd_update();
|
||||||
udelay(2000);
|
sleep(HZ/10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue