← index #1650PR #2058
Related · high · value 0.622
QUERY · ISSUE

stm32: Implement Asynchronous SPI Slave

openby ryannathansopened 2015-11-26updated 2017-10-24
enhancementport-stm32

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.

CANDIDATE · PULL REQUEST

stmhal/spi.c: Support for one line SPI communication.

closedby tobbadopened 2016-05-09updated 2017-08-30

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.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied