forked from M-Labs/zynq-rs
1
0
Fork 0

i2c: conservative timing, avoid SCL/SDA races. Closes #83

This commit is contained in:
Sebastien Bourdeauducq 2021-06-25 16:26:04 +08:00
parent d18c77c0eb
commit 4159aab6c8
1 changed files with 3 additions and 0 deletions

View File

@ -150,6 +150,7 @@ impl I2c {
self.sda_oe(true); self.sda_oe(true);
self.half_period(); self.half_period();
self.scl_oe(true); self.scl_oe(true);
self.half_period();
// postcondition: SCL and SDA low // postcondition: SCL and SDA low
Ok(()) Ok(())
} }
@ -188,6 +189,7 @@ impl I2c {
self.scl_oe(false); self.scl_oe(false);
self.half_period(); self.half_period();
self.scl_oe(true); self.scl_oe(true);
self.half_period();
} }
self.sda_oe(false); self.sda_oe(false);
self.half_period(); self.half_period();
@ -196,6 +198,7 @@ impl I2c {
// Read ack/nack // Read ack/nack
let ack = !self.sda_i(); let ack = !self.sda_i();
self.scl_oe(true); self.scl_oe(true);
self.half_period();
self.sda_oe(true); self.sda_oe(true);
// postcondition: SCL and SDA low // postcondition: SCL and SDA low