-
Notifications
You must be signed in to change notification settings - Fork 1k
Add SPI slave mode support #2050
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: patricklaf <[email protected]> Co-authored-by: Frederic Pillon <[email protected]>
Hi @patricklaf |
Has been PR been forgotten? It would be helpful to have this feature and not need to modify the local source code. Edit: After looking a bit deeper into this PR, it looks like the implementation is incomplete. |
No. Just no time on my side to deeper check that. |
It's a bit over my head atm but I have looked into it a bit. Just need more free time. |
@patricklaf Thank you for writing this! I've been testing it out and it seems to work well if the slave knows how many bytes to expect from the master. In my use case it can vary, but AFAICT the spi.transfer() functions need a fixed length. Am I missing something? If not, I'm thinking of adding a helper function spi_com.c that reads a variable amount of data until the CS goes high. Let me know if you see any issue with this approach |
Hi @philrittenhouse , |
@philrittenhouse |
Summary
This PR implements SPI slave mode for the SPI library.
There is an existing PR, #1612, but it is not actively developped and it uses HAL and LL functions from user code.
How to use
There is no change to the API for master mode. Existing code should just work without any change.
This is an exemple of a slave device:
Limitation
The read and write operations of the slave must be as fast as possible or data will be lost.
An SPI device is only slave or master.
begin()
andend()
can be called with different device mode to allow role switch.