
Hi, I noticed a bug in soft_i2c.c (or in the README depending on how you think about it).
If CONFIG_SOFT_I2C is defined and using open-collector I/O, then the README says that I2C_TRISTATE can be defined as null. If this is the case, then doing:
imd 29 0.0 2
will cause the following chain of calls in soft_i2c.c:
send_start() write_byte() read_byte() read_byte() send_stop()
The first read_byte() calls send_ack(0). send_ack(0) drives the data line low without releasing it. The following call to read_byte() calls I2C_TRISTATE, but in this case it is defined as NULL per the README. This leaves the data line driven low during the read of the 2nd byte causing data^h^h^h^hhair loss that I can ill afford :-)
I propose the following fix - modify the README to make say that I2C_TRISTATE should be defined even for open-collector setups, and add code to soft_i2c.c to explictly tristate the data at the end of send_ack(0)
Signed-off-by: Andrew Dyer amdyer@gmail.com