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 26 forks source link

I2C not working anymore #34

Closed dkm closed 3 years ago

dkm commented 3 years ago

After last changes in I2C, it seems the logic of the busy_wait macro is not correct. I've been able to patch it locally and will push a clean proposal tomorrow (@thejpster asked me to file an issue).

Basically, checking for BusBusy everywhere is not correct as it will always be set between START and STOP, so during a transaction, we should not return an error (that's what I'm currently seeing).

Previous code was basically adapted from stm32f30x-hal and I see that the busy_wait macro has been changed (no more flag as parameter) and is not really busy_waiting on anything but the BUSY bit. The macro is now wrapped in loop{}. Was is not better to have the busy wait inside the macro ? Maybe there's something I'm not seeing here.

The original code was doing things like:

I see that previous code was wrongly looking at all mcs bits without waiting for busy to be clear, but maybe the cleaning went too far ? At least with my patch that reverts back the logic above, my application is working correctly again.

thejpster commented 3 years ago

@dtwood any thoughts on this one?

thejpster commented 3 years ago

@dtwood?