On 16 February 2017 at 07:48, H. Nikolaus Schaller <hns@goldelico.com> wrote:
So you leave the existing inputs as inputs while changing the other settings and
only make them outputs *after* this sequence.
Yes, I make sure that if pins are requested to be inputs that they do high-Z before the output data register is written, and more importantly if pins are requested to be outputs I do this only after the output data register has been written.
Previously all pins configured as "output low" would transition as "high-Z -> output high -> output low" during init, which of course is asking for trouble.
And while I look at it, we could suggest to optimize out the i2c_read() if mask = 0xff in tca642x_reg_write()...
The whole code is really weird, I just decided to touch it as little as possible. He creates wrappers but doesn't use them during init. Pointlessly reads when all you want to do is write. Performs i2c transactions per byte even though you can do all three bytes at once (hence expose them effectively just as 24-bit registers).