With the whole "chip select" pin idea it seems like having multiple devices on the same bus is a big part of the SPI idea.
What I am having trouble with is finding an elegant way of using current SPI api in a configuration with two devices, say with different speeds. With current API, I would need to startSpi with one configuration, then stop it completely before using another device, re-start it with the new config, stop it again and so on. I guess in real life this happens relatively fast and there is nothing to worry about, but I wonder if we are missing an "spiConfigure" method?
This way "SPIConfig" should NOT be a parameter of "spiStart" - spiStart would only execute the general initialization (DMA etc) while only before using SPI in a particular device I would configure it and later re-configure for another device without stopping it completely.
SPI API in case of multiple slaves
Moderators: RoccoMarco, lbednarz, tfAteba
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: SPI API in case of multiple slaves
Hi,
You don't need to call spiStop(), just call spiStart() again with a different configuration, spiStart() is exactly your spiConfigure().
Giovanni
You don't need to call spiStop(), just call spiStart() again with a different configuration, spiStart() is exactly your spiConfigure().
Giovanni
Re: SPI API in case of multiple slaves
Giovanni wrote:Hi,
You don't need to call spiStop(), just call spiStart() again with a different configuration, spiStart() is exactly your spiConfigure().
Giovanni
Thank you Giovenni!
I have honestly tried to read the state check in the implementations but apparently I have failed to understand the logic.
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: SPI API in case of multiple slaves
You have to look at the driver state machine diagram.

Giovanni

Giovanni