summaryrefslogtreecommitdiffstats
path: root/firmware/target
diff options
context:
space:
mode:
authorVitja Makarov <vitja.makarov@gmail.com>2008-09-19 05:55:11 +0000
committerVitja Makarov <vitja.makarov@gmail.com>2008-09-19 05:55:11 +0000
commiteab54984840ecb9b0e55622f73260c84847f07be (patch)
tree514d8b432de9f764592b1c469d92384ab895d1cb /firmware/target
parentafe32ef15d85327e77037a4385bc798cc6c4e159 (diff)
downloadrockbox-eab54984840ecb9b0e55622f73260c84847f07be.tar.gz
rockbox-eab54984840ecb9b0e55622f73260c84847f07be.zip
Fix ata2501 serial reading
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18550 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/ata2501.c41
1 files changed, 14 insertions, 27 deletions
diff --git a/firmware/target/arm/tcc77x/iaudio7/ata2501.c b/firmware/target/arm/tcc77x/iaudio7/ata2501.c
index bc39872de6..3d78599ff9 100644
--- a/firmware/target/arm/tcc77x/iaudio7/ata2501.c
+++ b/firmware/target/arm/tcc77x/iaudio7/ata2501.c
@@ -20,6 +20,7 @@
****************************************************************************/
#include "config.h"
+#include "system.h"
#include "cpu.h"
#include "button.h"
@@ -31,39 +32,27 @@
#define SIFMD (1<<7)
#define STB_DELAY 200
-#define udelay _udelay
-
-/* do we really need it? */
-static void _udelay(int cycles)
+static inline void ndelay(unsigned long nsecs)
{
- cycles /= 8;
- while (cycles--) {
- asm("nop;nop;");
- }
+ nsecs /= 8;
+ while (nsecs)
+ nsecs--;
}
/*
- TODO: sensitivity using GPIOS
+ TODO: sensitivity
*/
void ata2501_init(void)
{
GPIOD_DIR |= (RESET | STB | SIFMD | (1 << 8) | (1 << 9));
- GPIOD_DIR &= ~(SDATA);
-
- GPIOD &= ~RESET;
- udelay(1000);
-
- GPIOD |= RESET;
+ GPIOD_DIR &= ~SDATA;
GPIOD &= ~STB;
+ GPIOD |= (1 << 8) | SIFMD | (1 << 9);
-#if 1
- GPIOD &= ~((1 << 9) | (1 << 8));
- GPIOD |= ((1 << 8) | SIFMD) | (1 << 9);
-#else
- GPIOD |= ((1 << 9) | (1 << 8));
- GPIOD &= ~(SIFMD);
-#endif
+ GPIOD &= ~RESET;
+ ndelay(1000);
+ GPIOD |= RESET;
}
unsigned short ata2501_read(void)
@@ -73,14 +62,12 @@ unsigned short ata2501_read(void)
for (i = 0; i < 12; i++) {
GPIOD |= STB;
- udelay(50);
-
+ ndelay(100);
ret <<= 1;
if (GPIOD & SDATA)
ret |= 1;
- udelay(50);
GPIOD &= ~STB;
- udelay(100);
+ ndelay(100);
}
return ret;
@@ -118,7 +105,7 @@ void ata2501_test(void)
lcd_puts(0, line++, buf);
lcd_update();
- udelay(2000);
+ sleep(HZ/10);
}
}
#endif