raspberrypi / pico-sdk

BSD 3-Clause "New" or "Revised" License
3.8k stars 953 forks source link

i2c bus clear #1595

Open PepperoniPingu opened 11 months ago

PepperoniPingu commented 11 months ago

Hi!

I have some software that is using i2c for the rp2040. Over a couple of months of continuous running there have been some failed transactions. Since these are rare, and, our i2c waveform is not too pretty when looked at with an oscilloscope, I presume my hardware implementation is at fault. Nevertheless it would be nice to try to properly recover from these crashes with an i2c bus clear sequence (a.k.a. software reset). To do this you simply send 10 negative pulses on scl. The purpose is to clock out potential data that is stuck in the output register of peripherals.

I suggest adding a standard method to do this, e.g. i2c_clear_bus();

The datasheet states in 4.3.13 that the i2c hardware block has a bus clear feature. But this seems not to be the case as discussed here.

I see two ways of solving this:

Thoughts?

lurch commented 11 months ago

The datasheet states in 4.3.13 that the i2c hardware block has a bus clear feature. But this seems not to be the case as discussed here.

Also discussed in https://github.com/raspberrypi/pico-feedback/issues/199