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 | |
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
-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 @@ | |||
27 | #include "string.h" | 27 | #include "string.h" |
28 | #include "generic_i2c.h" | 28 | #include "generic_i2c.h" |
29 | 29 | ||
30 | void i2c_sda_output(void) | 30 | static void i2c_sda_output(void) |
31 | { | 31 | { |
32 | GPECON |= (1 << 30); | 32 | GPECON |= (1 << 30); |
33 | } | 33 | } |
34 | 34 | ||
35 | void i2c_sda_input(void) | 35 | static void i2c_sda_input(void) |
36 | { | 36 | { |
37 | GPECON &= ~(3 << 30); | 37 | GPECON &= ~(3 << 30); |
38 | } | 38 | } |
39 | 39 | ||
40 | void i2c_sda_lo(void) | 40 | static void i2c_sda_lo(void) |
41 | { | 41 | { |
42 | GPEDAT &= ~(1 << 15); | 42 | GPEDAT &= ~(1 << 15); |
43 | } | 43 | } |
44 | 44 | ||
45 | void i2c_sda_hi(void) | 45 | static void i2c_sda_hi(void) |
46 | { | 46 | { |
47 | GPEDAT |= (1 << 15); | 47 | GPEDAT |= (1 << 15); |
48 | } | 48 | } |
49 | 49 | ||
50 | int i2c_sda(void) | 50 | static int i2c_sda(void) |
51 | { | 51 | { |
52 | return GPEDAT & (1 << 15); | 52 | return GPEDAT & (1 << 15); |
53 | } | 53 | } |
54 | 54 | ||
55 | void i2c_scl_output(void) | 55 | static void i2c_scl_output(void) |
56 | { | 56 | { |
57 | GPECON |= (1 << 28); | 57 | GPECON |= (1 << 28); |
58 | } | 58 | } |
59 | 59 | ||
60 | void i2c_scl_input(void) | 60 | static void i2c_scl_input(void) |
61 | { | 61 | { |
62 | GPECON &= ~(3 << 28); | 62 | GPECON &= ~(3 << 28); |
63 | } | 63 | } |
64 | 64 | ||
65 | void i2c_scl_lo(void) | 65 | static void i2c_scl_lo(void) |
66 | { | 66 | { |
67 | GPEDAT &= ~(1 << 14); | 67 | GPEDAT &= ~(1 << 14); |
68 | } | 68 | } |
69 | 69 | ||
70 | int i2c_scl(void) | 70 | static int i2c_scl(void) |
71 | { | 71 | { |
72 | return GPEDAT & (1 << 14); | 72 | return GPEDAT & (1 << 14); |
73 | } | 73 | } |
74 | 74 | ||
75 | void i2c_scl_hi(void) | 75 | static void i2c_scl_hi(void) |
76 | { | 76 | { |
77 | i2c_scl_input(); | 77 | i2c_scl_input(); |
78 | while(!i2c_scl()); | 78 | while(!i2c_scl()); |
@@ -80,9 +80,17 @@ void i2c_scl_hi(void) | |||
80 | i2c_scl_output(); | 80 | i2c_scl_output(); |
81 | } | 81 | } |
82 | 82 | ||
83 | void i2c_delay(void) | 83 | |
84 | static void i2c_delay(void) | ||
84 | { | 85 | { |
85 | do { int _x; for(_x=0;_x<2000;_x++);} while (0); | 86 | volatile int _x; |
87 | |||
88 | /* The i2c can clock at 500KHz: 2uS period -> 1uS half period */ | ||
89 | /* At 300Mhz - if loop takes 10 cycles @ 3.3nS each -> 1uS / 33nS -> 30 */ | ||
90 | for (_x=0; _x<30; _x++) | ||
91 | { | ||
92 | /* burn CPU cycles */ | ||
93 | } | ||
86 | } | 94 | } |
87 | 95 | ||
88 | struct i2c_interface s3c2440_i2c = { | 96 | struct i2c_interface s3c2440_i2c = { |