summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Gotthardt <gotthardt@rockbox.org>2007-01-04 03:31:03 +0000
committerSteve Gotthardt <gotthardt@rockbox.org>2007-01-04 03:31:03 +0000
commit2aa3e3f63c096b2b57981f39f5c8f9213794c9ac (patch)
tree745dc1e0144158896fa92fb66e5c6dd36a3b48ab
parent23b722d4a9f8620f804f7ea8e5a190fdf236ffef (diff)
downloadrockbox-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.c32
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
30void i2c_sda_output(void) 30static void i2c_sda_output(void)
31{ 31{
32 GPECON |= (1 << 30); 32 GPECON |= (1 << 30);
33} 33}
34 34
35void i2c_sda_input(void) 35static void i2c_sda_input(void)
36{ 36{
37 GPECON &= ~(3 << 30); 37 GPECON &= ~(3 << 30);
38} 38}
39 39
40void i2c_sda_lo(void) 40static void i2c_sda_lo(void)
41{ 41{
42 GPEDAT &= ~(1 << 15); 42 GPEDAT &= ~(1 << 15);
43} 43}
44 44
45void i2c_sda_hi(void) 45static void i2c_sda_hi(void)
46{ 46{
47 GPEDAT |= (1 << 15); 47 GPEDAT |= (1 << 15);
48} 48}
49 49
50int i2c_sda(void) 50static int i2c_sda(void)
51{ 51{
52 return GPEDAT & (1 << 15); 52 return GPEDAT & (1 << 15);
53} 53}
54 54
55void i2c_scl_output(void) 55static void i2c_scl_output(void)
56{ 56{
57 GPECON |= (1 << 28); 57 GPECON |= (1 << 28);
58} 58}
59 59
60void i2c_scl_input(void) 60static void i2c_scl_input(void)
61{ 61{
62 GPECON &= ~(3 << 28); 62 GPECON &= ~(3 << 28);
63} 63}
64 64
65void i2c_scl_lo(void) 65static void i2c_scl_lo(void)
66{ 66{
67 GPEDAT &= ~(1 << 14); 67 GPEDAT &= ~(1 << 14);
68} 68}
69 69
70int i2c_scl(void) 70static int i2c_scl(void)
71{ 71{
72 return GPEDAT & (1 << 14); 72 return GPEDAT & (1 << 14);
73} 73}
74 74
75void i2c_scl_hi(void) 75static 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
83void i2c_delay(void) 83
84static 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
88struct i2c_interface s3c2440_i2c = { 96struct i2c_interface s3c2440_i2c = {