Master Assigning Unique IDs to Slave SPI Devices
Hi,
I have successfully setup SPI between a master to many slave STM32F373s.
I include an 8 bit deviceID in the packet header and the master always initiates the request.
I am looking for the best way for the master to assign unique device IDs.
I'm considering adding jumpers or switches to set the device ID in hardware. In this case I would have the master discover devices by sending requests starting with device ID 1 and incrementing device ID until there is no response/timeout. I"m leaning towards this solution since it allows the user to keep devices in the same order after a reboot or if the modules are swapped out. It also allows the ID to be retained.
I'm considering having the master broadcast to all devices, and have each slave device wait for a random period before accepting requests from the master. The master would continue to accept requests until a timeout is reached.
I also have a 1 wire scheme to discover devices but it is a bit more complex and devices may have a different order in the 'chain' after reboot.
Should I be looking at a better solution than the ones I listed?
UPDATE: As a solution, I plan on daisy-chaining slave devices together so the master can assign their device Ids. I'll be using up 2 SPI ports for each slave device. Not sure if there is a better solution using just 2 GPIO pins per device ( bit banging through the daisy chain IO pins to set device IDs )
Thank you,
