diff options
author | Steve Gotthardt <gotthardt@rockbox.org> | 2007-01-04 03:31:03 +0000 |
---|---|---|
committer | Steve Gotthardt <gotthardt@rockbox.org> | 2007-01-04 03:31:03 +0000 |
commit | 2aa3e3f63c096b2b57981f39f5c8f9213794c9ac (patch) | |
tree | 745dc1e0144158896fa92fb66e5c6dd36a3b48ab /firmware | |
parent | 23b722d4a9f8620f804f7ea8e5a190fdf236ffef (diff) | |
download | rockbox-2aa3e3f63c096b2b57981f39f5c8f9213794c9ac.tar.gz rockbox-2aa3e3f63c096b2b57981f39f5c8f9213794c9ac.zip |
Changed the delay loop to run faster and more accurate. Made the internal functions 'static'.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11894 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/target/arm/gigabeat/meg-fx/i2c-meg-fx.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/firmware/target/arm/gigabeat/meg-fx/i2c-meg-fx.c b/firmware/target/arm/gigabeat/meg-fx/i2c-meg-fx.c index c0e9fb4fc3..7667c03e38 100644 --- a/firmware/target/arm/gigabeat/meg-fx/i2c-meg-fx.c +++ b/firmware/target/arm/gigabeat/meg-fx/i2c-meg-fx.c @@ -27,52 +27,52 @@ #include "string.h" #include "generic_i2c.h" -void i2c_sda_output(void) +static void i2c_sda_output(void) { GPECON |= (1 << 30); } -void i2c_sda_input(void) +static void i2c_sda_input(void) { GPECON &= ~(3 << 30); } -void i2c_sda_lo(void) +static void i2c_sda_lo(void) { GPEDAT &= ~(1 << 15); } -void i2c_sda_hi(void) +static void i2c_sda_hi(void) { GPEDAT |= (1 << 15); } -int i2c_sda(void) +static int i2c_sda(void) { return GPEDAT & (1 << 15); } -void i2c_scl_output(void) +static void i2c_scl_output(void) { GPECON |= (1 << 28); } -void i2c_scl_input(void) +static void i2c_scl_input(void) { GPECON &= ~(3 << 28); } -void i2c_scl_lo(void) +static void i2c_scl_lo(void) { GPEDAT &= ~(1 << 14); } -int i2c_scl(void) +static int i2c_scl(void) { return GPEDAT & (1 << 14); } -void i2c_scl_hi(void) +static void i2c_scl_hi(void) { i2c_scl_input(); while(!i2c_scl()); @@ -80,9 +80,17 @@ void i2c_scl_hi(void) i2c_scl_output(); } -void i2c_delay(void) + +static void i2c_delay(void) { - do { int _x; for(_x=0;_x<2000;_x++);} while (0); + volatile int _x; + + /* The i2c can clock at 500KHz: 2uS period -> 1uS half period */ + /* At 300Mhz - if loop takes 10 cycles @ 3.3nS each -> 1uS / 33nS -> 30 */ + for (_x=0; _x<30; _x++) + { + /* burn CPU cycles */ + } } struct i2c_interface s3c2440_i2c = { |