mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-26 03:38:25 +08:00
runtime/i2c: more conservative timings
This commit is contained in:
parent
2bb4ad189a
commit
799c2c77c4
@ -139,6 +139,7 @@ int i2c_write(int busno, int b)
|
|||||||
for(i=7;i>=0;i--) {
|
for(i=7;i>=0;i--) {
|
||||||
/* Set SCL low and set our bit on SDA */
|
/* Set SCL low and set our bit on SDA */
|
||||||
i2c_scl_o(busno, 0);
|
i2c_scl_o(busno, 0);
|
||||||
|
i2c_halfperiod(); /* make sure SCL has settled low */
|
||||||
i2c_sda_oe(busno, b & (1 << i) ? 0 : 1);
|
i2c_sda_oe(busno, b & (1 << i) ? 0 : 1);
|
||||||
i2c_halfperiod();
|
i2c_halfperiod();
|
||||||
/* Set SCL high ; data is shifted on the rising edge of SCL */
|
/* Set SCL high ; data is shifted on the rising edge of SCL */
|
||||||
@ -148,8 +149,9 @@ int i2c_write(int busno, int b)
|
|||||||
/* Check ack */
|
/* Check ack */
|
||||||
/* Set SCL low, then release SDA so that the I2C target can respond */
|
/* Set SCL low, then release SDA so that the I2C target can respond */
|
||||||
i2c_scl_o(busno, 0);
|
i2c_scl_o(busno, 0);
|
||||||
i2c_halfperiod();
|
i2c_halfperiod(); /* make sure SCL has settled low */
|
||||||
i2c_sda_oe(busno, 0);
|
i2c_sda_oe(busno, 0);
|
||||||
|
i2c_halfperiod();
|
||||||
/* Set SCL high and check for ack */
|
/* Set SCL high and check for ack */
|
||||||
i2c_scl_o(busno, 1);
|
i2c_scl_o(busno, 1);
|
||||||
i2c_halfperiod();
|
i2c_halfperiod();
|
||||||
@ -182,6 +184,7 @@ int i2c_read(int busno, int ack)
|
|||||||
/* Send ack */
|
/* Send ack */
|
||||||
/* Set SCL low and pull SDA low when acking */
|
/* Set SCL low and pull SDA low when acking */
|
||||||
i2c_scl_o(busno, 0);
|
i2c_scl_o(busno, 0);
|
||||||
|
i2c_halfperiod(); /* make sure SCL has settled low */
|
||||||
if(ack)
|
if(ack)
|
||||||
i2c_sda_oe(busno, 1);
|
i2c_sda_oe(busno, 1);
|
||||||
i2c_halfperiod();
|
i2c_halfperiod();
|
||||||
|
Loading…
Reference in New Issue
Block a user