Description
lib_i2c/lib_i2c/src/i2c_master.xc
Line 181 in 648351b
Both I2C bus lines should only ever be driven in open drain mode i.e. either drive low or drive high-z (input). This is the case for SCL but not the case for SDA when driving data on to the bus - it is driven high if the data is high. This is contrary to the specification and could lead to multiple hardware issues. (driving current into pullup supply voltage, multi voltage compatibility issues etc.)
Instead of:
p_sda <: data & 0x1;
Correct function here would be:
if (data & 1)
p_sda :> void;
else
p_sda <: 0;
I have made this change and done quick testing with success.
A similar change would be needed to the other i2c sources e.g. i2c_slave.xc and i2c_master_async.xc etc.