summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorBertrik Sikken <bertrik@sikken.nl>2009-06-06 21:05:54 +0000
committerBertrik Sikken <bertrik@sikken.nl>2009-06-06 21:05:54 +0000
commit9f7b0b9d1ea1f649d809f7a9f8b9ace8a079e1cc (patch)
tree6e372551c31bf6040da2b8e5026a5951e24aea75 /firmware
parent1d97a380e279694a93855921f02b3a93ac5b97e9 (diff)
downloadrockbox-9f7b0b9d1ea1f649d809f7a9f8b9ace8a079e1cc.tar.gz
rockbox-9f7b0b9d1ea1f649d809f7a9f8b9ace8a079e1cc.zip
Fix some delays in generic_i2c
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21200 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/generic_i2c.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/firmware/drivers/generic_i2c.c b/firmware/drivers/generic_i2c.c
index 62d442b1d2..31a6e580ff 100644
--- a/firmware/drivers/generic_i2c.c
+++ b/firmware/drivers/generic_i2c.c
@@ -40,6 +40,7 @@ static void i2c_start(const struct i2c_interface *iface)
40 iface->sda_lo(); 40 iface->sda_lo();
41 iface->delay_hd_sta(); 41 iface->delay_hd_sta();
42 iface->scl_lo(); 42 iface->scl_lo();
43 iface->delay_hd_dat();
43} 44}
44 45
45static void i2c_stop(const struct i2c_interface *iface) 46static void i2c_stop(const struct i2c_interface *iface)
@@ -47,6 +48,7 @@ static void i2c_stop(const struct i2c_interface *iface)
47 iface->sda_output(); 48 iface->sda_output();
48 49
49 iface->sda_lo(); 50 iface->sda_lo();
51 iface->delay_su_dat();
50 iface->scl_hi(); 52 iface->scl_hi();
51 iface->delay_su_sto(); 53 iface->delay_su_sto();
52 iface->sda_hi(); 54 iface->sda_hi();
@@ -55,7 +57,6 @@ static void i2c_stop(const struct i2c_interface *iface)
55static void i2c_ack(const struct i2c_interface *iface, bool ack) 57static void i2c_ack(const struct i2c_interface *iface, bool ack)
56{ 58{
57 iface->sda_output(); 59 iface->sda_output();
58 iface->scl_lo();
59 if ( ack ) 60 if ( ack )
60 iface->sda_lo(); 61 iface->sda_lo();
61 else 62 else
@@ -65,6 +66,7 @@ static void i2c_ack(const struct i2c_interface *iface, bool ack)
65 iface->scl_hi(); 66 iface->scl_hi();
66 iface->delay_thigh(); 67 iface->delay_thigh();
67 iface->scl_lo(); 68 iface->scl_lo();
69 iface->delay_hd_dat();
68} 70}
69 71
70static int i2c_getack(const struct i2c_interface *iface) 72static int i2c_getack(const struct i2c_interface *iface)
@@ -74,14 +76,10 @@ static int i2c_getack(const struct i2c_interface *iface)
74 iface->sda_input(); 76 iface->sda_input();
75 iface->delay_su_dat(); 77 iface->delay_su_dat();
76 iface->scl_hi(); 78 iface->scl_hi();
77 79 iface->delay_thigh();
78 if (iface->sda()) 80 if (iface->sda())
79 ret = 0; /* ack failed */ 81 ret = 0; /* ack failed */
80
81 iface->delay_thigh();
82 iface->scl_lo(); 82 iface->scl_lo();
83 iface->sda_hi();
84 iface->sda_output();
85 iface->delay_hd_dat(); 83 iface->delay_hd_dat();
86 return ret; 84 return ret;
87} 85}
@@ -93,6 +91,7 @@ static unsigned char i2c_inb(const struct i2c_interface *iface, bool ack)
93 91
94 iface->sda_input(); 92 iface->sda_input();
95 93
94 iface->delay_su_dat();
96 /* clock in each bit, MSB first */ 95 /* clock in each bit, MSB first */
97 for ( i=0x80; i; i>>=1 ) { 96 for ( i=0x80; i; i>>=1 ) {
98 iface->scl_hi(); 97 iface->scl_hi();
@@ -127,8 +126,6 @@ static int i2c_outb(const struct i2c_interface *iface, unsigned char byte)
127 iface->delay_hd_dat(); 126 iface->delay_hd_dat();
128 } 127 }
129 128
130 iface->sda_hi();
131
132 return i2c_getack(iface); 129 return i2c_getack(iface);
133} 130}
134 131