stm32: Implement Asynchronous SPI Slave
This issue is to implement asynchronous sending and receiving on the SPI when configured as a slave - instead of blocking and waiting for whenever a clock is provided from the master. SPI (read and write) should probably have a configurable buffer like uart rx currently does. When the master clocks, the contents of the send buffer should be clocked out and whatever the master is sending should be clocked in to the read buffer (if exists). The user should probably be able to choose between blocking and non-blocking modes as mentioned in #1533.
Related: #1642 (async uart tx)
Bug with existing implementation:
Currently when reading SPI as a slave, the function blocks until the specified number of bytes is received or the timeout occurs. If the timeout occurs an exception is raised (OS: 116) #1414 . An exception shouldn't be raised. Whatever data was read should be returned, just as the uart read currently does.
As a result of not having asynchronous read/writes and with the existing quirky behaviors, spi slave mode seems rather unusable.
stmhal/spi.c: Support for one line SPI communication.
With this additional method on a spi object it is possible to configure SPI to communicate bidirectional over MOSI (Master mode) or MISO (Slave mode).
This improvement was tested on STM32L476 with the on board lsm303c Mag/Accelerator MEMS.
There seems to be a bug in HAL_SPI for L4 as the SPI is not disabled after a transmit of data. See comment or TECH018409 on my.st.com.
I removed line 64-77 as this comment is obsolete.