Richard-Gemmell / teensy4_i2c

An I2C library for the Teensy 4. Provides slave and master mode.
MIT License
92 stars 19 forks source link

Multi Master Bus ( One Teensy Slave >> Two Teensies Master ) #28

Open 8JupiterMoll8 opened 1 year ago

8JupiterMoll8 commented 1 year ago

Hi Richard ,

i have a teensy 4.1 (slave ) that sends sensor data to the an other Teensy 4.1 reciver(master) using your wire library. That works. Now I want to add another Teensy 4.1 reciver (master) to get this sensor data. I wire sda and scl in parallel. But I think this is not going to work. Is there an example for Multi Master ? thx

Richard-Gemmell commented 1 year ago

Hi, The I2C specification does support multi-master setups and I wrote the driver to with this in mind. I never tested it though. I don't have any sample code. As I understand it, you don't need to do anything special. You just wire up the extra master in the way you said. The masters should sort of work round each other. Whichever one starts sending a message first gets control. The other master is blocked until the first transaction finishes. You might get arbitration_lost errors when this happens. I might try it out later this week and see what happens. cheers, Richard