I2C: Bitbang driver and clock stretching

Turbo J


while playing with an BQ27421YZFR battery gauge, I noticed that the I²C
bitbang driver does not support clock stretching.

Easy enough to fix: https://github.com/zephyrproject-rtos/zephyr/pull/16849

The code in i2c_gpio_set_scl() just waits until SCL actually reads back
as high.

There is currently no timeout - misbehaving slave would cause a deadlock.

I also noticed that reading a bit from the SDA line was done a bit too
early - it is supposed to be done when SCL is high.
Slaves w/o clock stretching would not have noticed this bug, as these
would set up SDA line early enough.

Yours sincerely,

Jörg Fischer

Join devel@lists.zephyrproject.org to automatically receive all group messages.