From 26496ce72fae7f5243f6fb2bd81a87528a256995 Mon Sep 17 00:00:00 2001 From: Steve Gotthardt Date: Thu, 4 Jan 2007 09:26:32 +0000 Subject: Optimized the timing for the delay and changed the startup delay. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11896 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/gigabeat/meg-fx/sc606-meg-fx.c | 15 ++++++++------- 1 file 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 @@ #define SCL_SDA_HI GPHDAT |= (3 << 9) /* The SC606 can clock at 400KHz: 2.5uS period -> 1.25uS half period */ -/* At 300Mhz - if loop takes 6 cycles @ 3.3nS each -> 1.25uS / 20nS -> 63 */ -#define DELAY do { volatile int _x; for(_x=0;_x<63;_x++);} while (0) +/* At 300Mhz - if loop takes 10 cycles @ 3.3nS each -> 1.25uS / 30nS -> 40 */ +#define DELAY do { volatile int _x; for(_x=0;_x<40;_x++);} while (0) static void sc606_i2c_start(void) { @@ -164,6 +164,8 @@ int sc606_read(unsigned char reg, unsigned char* data) void sc606_init(void) { + volatile int i; + /* Set GPB2 (EN) to 1 */ GPBCON = (GPBCON & ~(3<<4)) | 1<<4; @@ -172,11 +174,10 @@ void sc606_init(void) /* OFF GPBDAT &= ~(1 << 2); */ /* About 400us - needs 350us */ - DELAY; - DELAY; - DELAY; - DELAY; - DELAY; + for (i = 200; i; i--) + { + DELAY; + } /* Set GPH9 (SDA) and GPH10 (SCL) to 1 */ GPHUP &= ~(3<<9); -- cgit v1.2.3