Sharing the SPI bus with multiple devices
SPI is designed such that a single bus can be shared accross multiple peripheral devices. Each device requires a chip select line to tell it when to listen and reply to data.
The following diagram explains it nicely:
Embedded-HAL
The currently released version of embedded-hal@v0.2.7
does not support sharing the SPI bus, at least not explicitly. There’s no indication of how chip select is to be used or what to do with multiple devices.
While the current abstraction does not prevent shared use, it encourages HAL implementors to just use the entire bus as a single device.
The upcoming stable version of embedded-hal of embedded-hal changes the definition o that there’s a SpiBus
and one or more SpiDevice
. This forces the implementors into enabling sharing.