Hi i was thinking of good way to enumerate devices in an I2C Bus System with an unkown number of participants. To me it sounds like a problem which is done already.
So my setup is that I will have a random number (n) of slave devices(ATtiny1626) which will be connected in a random order. Connected via the TWI bus. All devices will have an unknown but unique 16bit identifier which has to be enumerated by the master. My approach to enumerate the devices would be connected via the identifier to a response time with 1us time slots.
So that a device A with the identifier 15 would wait 15us to claim the bus and a device B with the identifier 325 would wait 325 us. And the master would have to wait a maximum time of n*65536-sum(ni) us to get all devices.
- First the master would send a broad message to request the first device.
- After 15 us our device A would respond and get the unique I2C Address 1.
- The master would send again a request for devices. Device A has already an I2C Address and wouldn't respond to that request.
- But after 325us our Device B will respond to that request and will be enumerated with the I2C address 2.
- Untill the master waits one time for 65536us in which no device responds and the master can be sure that there are no devices left.