The current SPI driver will not support officially a slave mode, it is not designed for that.
A separate slave SPI driver will be eventually introduced, so far I have no clear idea of how it should be, there is a lot of variability on possible slave SPI uses.
Would you recommend using plyatovs solution from here: viewtopic.php?f=38&t=3213&start=20#p32291 (earlier in this thread) for a production system? Or is it more wise to create a complete Slave SPI solution without using chibiOS HAL?
Furthermore a driver that has a read/write buffer it transmits/receives on NSS and an interrupt/event for a incoming message probably would be very low level and expandable.
For a slave SPI application, my recommendation is to design a driver specifically for the protocol you need, I have not found yet a generic enough solution or I would have already implemented it in HAL.
The current SPI driver can be adapted (like you did) to implement very simple SPI slave scenarios, like exchanging fixed size buffers, more complex things like "idle frames" are more difficult to implement. See the SPI MMC/SD protocol, that would be very hard to implement without a specific driver.
Understood. Why not expose the the "very simple" scenario by just exposing the slave flag to the config? As I understand the rest of the code would already allow for simple receive/sends (see example from plyatov).
Can you help me understand how the HAL API would behave in this slave scenario? As far as I understood, calling the Send/Receive/Exchange function "primes" the SPI to fill/empty the receive/transmit buffer when the master sends a signal, how is that triggered? Over the hardware NSS or simply when the clock starts running?
Here is my idea of things: I'm planning to use the HAL without an RTOS, so I would call the exchange function and set a callback interrupt when a transmission was handled. In the callback I deal with my data, clear the buffer and call the exchange function again for the next transfer. I always know that my transmission is two bytes so I can set that beforehand.