rust-embedded-community / tm4c-hal

An Embedded HAL and general chip support for the TM4C123/LM4F120. Replaces the old lm4f120 crate.
Apache License 2.0
40 stars 27 forks source link

Read/write operation can stall indefinitely if slave holds clock low #25

Closed thejpster closed 4 years ago

thejpster commented 4 years ago

We need to set the MCLKOCNT (I2C Master Clock Low Timeout Count) to a sensible value, then check for the interrupt flag being set in the raw interrupt status register. This will indicate the slave has pulled clock low for too long, and we can then abort the transaction.

Currently we will not spot this an spin indefinitely. This can occur if the slave goes wrong and clock stretches for too long, or if the bus is pulled low instead of high.