diff options
Diffstat (limited to 'firmware/target/arm/tcc77x/iaudio7')
-rw-r--r-- | firmware/target/arm/tcc77x/iaudio7/ata2501.c | 41 |
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 @@ | |||
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | #include "config.h" | 22 | #include "config.h" |
23 | #include "system.h" | ||
23 | #include "cpu.h" | 24 | #include "cpu.h" |
24 | #include "button.h" | 25 | #include "button.h" |
25 | 26 | ||
@@ -31,39 +32,27 @@ | |||
31 | #define SIFMD (1<<7) | 32 | #define SIFMD (1<<7) |
32 | #define STB_DELAY 200 | 33 | #define STB_DELAY 200 |
33 | 34 | ||
34 | #define udelay _udelay | 35 | static inline void ndelay(unsigned long nsecs) |
35 | |||
36 | /* do we really need it? */ | ||
37 | static void _udelay(int cycles) | ||
38 | { | 36 | { |
39 | cycles /= 8; | 37 | nsecs /= 8; |
40 | while (cycles--) { | 38 | while (nsecs) |
41 | asm("nop;nop;"); | 39 | nsecs--; |
42 | } | ||
43 | } | 40 | } |
44 | 41 | ||
45 | /* | 42 | /* |
46 | TODO: sensitivity using GPIOS | 43 | TODO: sensitivity |
47 | */ | 44 | */ |
48 | void ata2501_init(void) | 45 | void ata2501_init(void) |
49 | { | 46 | { |
50 | GPIOD_DIR |= (RESET | STB | SIFMD | (1 << 8) | (1 << 9)); | 47 | GPIOD_DIR |= (RESET | STB | SIFMD | (1 << 8) | (1 << 9)); |
51 | GPIOD_DIR &= ~(SDATA); | 48 | GPIOD_DIR &= ~SDATA; |
52 | |||
53 | GPIOD &= ~RESET; | ||
54 | udelay(1000); | ||
55 | |||
56 | GPIOD |= RESET; | ||
57 | 49 | ||
58 | GPIOD &= ~STB; | 50 | GPIOD &= ~STB; |
51 | GPIOD |= (1 << 8) | SIFMD | (1 << 9); | ||
59 | 52 | ||
60 | #if 1 | 53 | GPIOD &= ~RESET; |
61 | GPIOD &= ~((1 << 9) | (1 << 8)); | 54 | ndelay(1000); |
62 | GPIOD |= ((1 << 8) | SIFMD) | (1 << 9); | 55 | GPIOD |= RESET; |
63 | #else | ||
64 | GPIOD |= ((1 << 9) | (1 << 8)); | ||
65 | GPIOD &= ~(SIFMD); | ||
66 | #endif | ||
67 | } | 56 | } |
68 | 57 | ||
69 | unsigned short ata2501_read(void) | 58 | unsigned short ata2501_read(void) |
@@ -73,14 +62,12 @@ unsigned short ata2501_read(void) | |||
73 | 62 | ||
74 | for (i = 0; i < 12; i++) { | 63 | for (i = 0; i < 12; i++) { |
75 | GPIOD |= STB; | 64 | GPIOD |= STB; |
76 | udelay(50); | 65 | ndelay(100); |
77 | |||
78 | ret <<= 1; | 66 | ret <<= 1; |
79 | if (GPIOD & SDATA) | 67 | if (GPIOD & SDATA) |
80 | ret |= 1; | 68 | ret |= 1; |
81 | udelay(50); | ||
82 | GPIOD &= ~STB; | 69 | GPIOD &= ~STB; |
83 | udelay(100); | 70 | ndelay(100); |
84 | } | 71 | } |
85 | 72 | ||
86 | return ret; | 73 | return ret; |
@@ -118,7 +105,7 @@ void ata2501_test(void) | |||
118 | lcd_puts(0, line++, buf); | 105 | lcd_puts(0, line++, buf); |
119 | 106 | ||
120 | lcd_update(); | 107 | lcd_update(); |
121 | udelay(2000); | 108 | sleep(HZ/10); |
122 | } | 109 | } |
123 | } | 110 | } |
124 | #endif | 111 | #endif |