forked from M-Labs/artiq
1
0
Fork 0

firmware: try to unstuck the I2C bus if it gets stuck.

Fixes #957.
This commit is contained in:
whitequark 2018-03-19 06:23:12 +00:00
parent f39b7b33e8
commit c86df8e13e
1 changed files with 13 additions and 1 deletions

View File

@ -59,7 +59,19 @@ mod imp {
half_period(); half_period();
half_period(); half_period();
if !sda_i(busno) { if !sda_i(busno) {
error!("SDA is stuck low on bus #{}", busno) warn!("SDA is stuck low on bus #{}, trying to unstuck", busno);
// Try toggling SCL a few times
for bit in 0..8 {
scl_o(busno, false);
half_period();
scl_o(busno, true);
half_period();
}
}
if !sda_i(busno) {
error!("SDA is stuck low on bus #{} and doesn't get unstuck", busno);
} }
} }
} }