Hi Robin,
SPI itself do not specify any communication protocol for broadcast mode. It is just low level communication channel between master and slave. So, it depends on you how you will implement this feature.
In typical case we have one master and several slaves. CLK, MOSI, MISO signals are shared between all devices and master decide target slave by CS (SS) pins.
So, if you want send broadcast, you have to set active all (part of all) CS pins.
In case of MQX SPI driver you have two ways how to manage it:
- You can generate CS pins by SPI module. In that case you will open SPI channel with more than one active CS signals. For example, if we will open channel “spi0:11”, CS0, CS1 and CS3 will be active during sending data trough this channel.
- You can install CS callback and this callback you can drive CS pins according your needs. Advantage of this approach is that you are no more limited by number of CS pins and number of channel does not need fits to configuration of CS pins. For example, if we will open channel “spi0:99”, cs_mask parameter in callback told you that you should set configuration for channel 99. In that case you can simply set CS0, CS1 and CS3 as active during sending data trough this channel. When cs_mask parameter is zero, you should set all CS signals into inactive state.
So, there isn’t any limitation from SPI driver point of view.
Remaining limitation is only on electric side. In default solution, SPI works in full duplex mode – slave receives data from MOSI line and simultaneously sends data trough MISO line. The question is what happened when more than one slaves drives the same line with different voltage level.
So, broadcast could work only in case when we don’t connect MISO line (slaves just receiving) or we somehow protect output drivers by electric way (by disconnection, by wired-OR = open collectors,…)
Idea: In some cases, slaves allow serial connection. E.g. master output to Slave0 input, Slave0 output to Slave1 input, Slave1 output to Slave2 input, Slave2 output to Master input. In that case you can just serialize commands for all slaves and clocked out all together. However this option depends on SPI slave implementation…
I hope it helps you.
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------