1
0
Fork 0
forked from len0rd/rockbox

Fix some delays in generic_i2c

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21200 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Bertrik Sikken 2009-06-06 21:05:54 +00:00
parent 1d97a380e2
commit 9f7b0b9d1e

View file

@ -40,6 +40,7 @@ static void i2c_start(const struct i2c_interface *iface)
iface->sda_lo(); iface->sda_lo();
iface->delay_hd_sta(); iface->delay_hd_sta();
iface->scl_lo(); iface->scl_lo();
iface->delay_hd_dat();
} }
static void i2c_stop(const struct i2c_interface *iface) static void i2c_stop(const struct i2c_interface *iface)
@ -47,6 +48,7 @@ static void i2c_stop(const struct i2c_interface *iface)
iface->sda_output(); iface->sda_output();
iface->sda_lo(); iface->sda_lo();
iface->delay_su_dat();
iface->scl_hi(); iface->scl_hi();
iface->delay_su_sto(); iface->delay_su_sto();
iface->sda_hi(); iface->sda_hi();
@ -55,7 +57,6 @@ static void i2c_stop(const struct i2c_interface *iface)
static void i2c_ack(const struct i2c_interface *iface, bool ack) static void i2c_ack(const struct i2c_interface *iface, bool ack)
{ {
iface->sda_output(); iface->sda_output();
iface->scl_lo();
if ( ack ) if ( ack )
iface->sda_lo(); iface->sda_lo();
else else
@ -65,6 +66,7 @@ static void i2c_ack(const struct i2c_interface *iface, bool ack)
iface->scl_hi(); iface->scl_hi();
iface->delay_thigh(); iface->delay_thigh();
iface->scl_lo(); iface->scl_lo();
iface->delay_hd_dat();
} }
static int i2c_getack(const struct i2c_interface *iface) static int i2c_getack(const struct i2c_interface *iface)
@ -74,14 +76,10 @@ static int i2c_getack(const struct i2c_interface *iface)
iface->sda_input(); iface->sda_input();
iface->delay_su_dat(); iface->delay_su_dat();
iface->scl_hi(); iface->scl_hi();
iface->delay_thigh();
if (iface->sda()) if (iface->sda())
ret = 0; /* ack failed */ ret = 0; /* ack failed */
iface->delay_thigh();
iface->scl_lo(); iface->scl_lo();
iface->sda_hi();
iface->sda_output();
iface->delay_hd_dat(); iface->delay_hd_dat();
return ret; return ret;
} }
@ -93,6 +91,7 @@ static unsigned char i2c_inb(const struct i2c_interface *iface, bool ack)
iface->sda_input(); iface->sda_input();
iface->delay_su_dat();
/* clock in each bit, MSB first */ /* clock in each bit, MSB first */
for ( i=0x80; i; i>>=1 ) { for ( i=0x80; i; i>>=1 ) {
iface->scl_hi(); iface->scl_hi();
@ -127,8 +126,6 @@ static int i2c_outb(const struct i2c_interface *iface, unsigned char byte)
iface->delay_hd_dat(); iface->delay_hd_dat();
} }
iface->sda_hi();
return i2c_getack(iface); return i2c_getack(iface);
} }