I'm working on a project that uses a simple microcontroller (I2C) master, and a component (I2C slave). When the microcontroller receives power the first thing it has to do is determine which device is on the I2C line. Only one device on the line is expected.
How would one go about determining which device is on the I2C line?
I've thought of a few ways:
- Try all possible addresses for items, then search for the device ID in each item. (I've found the location of the device ID register is different on most chips).
- Send out a Device ID request - but the spec says this is optional. And I couldn't find anyone relying on this.
- Uniquely address each component, create a map. (i.e. This address means it must be this component.) Try each address.
For additional context, once the device is determined, capabilities are mapped in the firmware and the firmware executes.
Solution 1 sounds like a brute force approach. I'd like this to be fast, and this doesn't seem fast.
Solution 2 sounds unreliable- but maybe that's only because of my lack of experience.
Solution 3 seems possible, but then I'm limited to the number of I2C devices the address space can support.