It happened to be that I run out of pins on ATmega48PA. So I have a pull-down buttons on the pins dedicated for I2C:
And now I need to add I2C bus to this device with as much backward compatibility as possibe.
The thing I'm going to implement is to keep buttons as it is with I2C devices on these ping as there are no buttons at all. And I hopefully will have both working.
By saying this I mean the following schematic:
Why am I so sure?
- Both I2C and buttons works as "pull low" logic. So there will be no conflicting outputs with excess currents.
- My controller will be I2C master. So I will be able to switch pins to GPIO mode, read the buttons ad go back again to I2C mode after that. Or do it vice versa: switch pins to I2C mode when I2C interaction will be needed.
The only thing I will not be able to avoid is that I2C bus become unusable while any button is pressed. I think I can deal with it.
The second thing I am afraiding of is that the button press can be treated by slave as I2C transmission and it will stuck with this wrong data. My only hope is that the slave will "forget" all wrong bits and it will not influence on the further communication.
So my questions is: does anyone experienced with such weird schematic? Did it work?