xmos / lib_i2c

I²C library
Other
3 stars 25 forks source link

Mask off all but lowest bit of SDA port sample #39

Closed xross closed 6 years ago

xross commented 6 years ago

Mask off all but lowest bit of input from SDA port - allows use of bit[0] of multibit port

chrisc-xmos commented 6 years ago

Correct me if I'm wrong but I think.. Reading the multi-bit port will make it an input so the other bits on the port would float. Also, since the library is not in control of port allocation it could incorrectly be used with an output that actively pulls high as well as low and the tx8 function could end up writing the other pins in the port both high and low. If this is correct, we should be advising that all other pins in the multi-bit port be pulled low through a resistor if this option is used. Tying high/low or leaving the pin open could cause excessive pin driver current flow.

xross commented 6 years ago

This commit was not intended to add full-multi-bit port support.

Reading the multi-bit port will make it an input so the other bits on the port would float

Correct

high as well as low and the tx8 function could end up writing the other pins in the port both high and low. If this is correct, we should be advising that all other pins in the multi-bit port be pulled low through a resistor if this option is used.

No, the port drives low and high-z (internal pull up enabled) so you would. Adding a pull down against this would not be a good idea. The board in question (xmos originated) leaves them disconnected

Regarding SDA, if you want to use a multi-bit port for SDA there is a pinseq() that would require a change (either with pulls or a poll and mask). Since this would effect power I suppose the code could check the resource ID and use the relevant code. Incidentally, we do have a board that requires this change (again, xmos originated) - the Audio8 slice.