summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/arm/gigabeat/meg-fx/sc606-meg-fx.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/firmware/target/arm/gigabeat/meg-fx/sc606-meg-fx.c b/firmware/target/arm/gigabeat/meg-fx/sc606-meg-fx.c
index 39718a4ec6..9e9fcb3547 100644
--- a/firmware/target/arm/gigabeat/meg-fx/sc606-meg-fx.c
+++ b/firmware/target/arm/gigabeat/meg-fx/sc606-meg-fx.c
@@ -25,8 +25,8 @@
25#define SCL_SDA_HI GPHDAT |= (3 << 9) 25#define SCL_SDA_HI GPHDAT |= (3 << 9)
26 26
27/* The SC606 can clock at 400KHz: 2.5uS period -> 1.25uS half period */ 27/* The SC606 can clock at 400KHz: 2.5uS period -> 1.25uS half period */
28/* At 300Mhz - if loop takes 6 cycles @ 3.3nS each -> 1.25uS / 20nS -> 63 */ 28/* At 300Mhz - if loop takes 10 cycles @ 3.3nS each -> 1.25uS / 30nS -> 40 */
29#define DELAY do { volatile int _x; for(_x=0;_x<63;_x++);} while (0) 29#define DELAY do { volatile int _x; for(_x=0;_x<40;_x++);} while (0)
30 30
31static void sc606_i2c_start(void) 31static void sc606_i2c_start(void)
32{ 32{
@@ -164,6 +164,8 @@ int sc606_read(unsigned char reg, unsigned char* data)
164 164
165void sc606_init(void) 165void sc606_init(void)
166{ 166{
167 volatile int i;
168
167 /* Set GPB2 (EN) to 1 */ 169 /* Set GPB2 (EN) to 1 */
168 GPBCON = (GPBCON & ~(3<<4)) | 1<<4; 170 GPBCON = (GPBCON & ~(3<<4)) | 1<<4;
169 171
@@ -172,11 +174,10 @@ void sc606_init(void)
172 /* OFF GPBDAT &= ~(1 << 2); */ 174 /* OFF GPBDAT &= ~(1 << 2); */
173 175
174 /* About 400us - needs 350us */ 176 /* About 400us - needs 350us */
175 DELAY; 177 for (i = 200; i; i--)
176 DELAY; 178 {
177 DELAY; 179 DELAY;
178 DELAY; 180 }
179 DELAY;
180 181
181 /* Set GPH9 (SDA) and GPH10 (SCL) to 1 */ 182 /* Set GPH9 (SDA) and GPH10 (SCL) to 1 */
182 GPHUP &= ~(3<<9); 183 GPHUP &= ~(3<<9);