-
Notifications
You must be signed in to change notification settings - Fork 976
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
Add SPI slave support and basic example #1612
Add SPI slave support and basic example #1612
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brainelectronics,
Thanks for this Pull Request.
This is a good starting point, but if we go for an implementation of SPI slave in this core, your proposal doesn't match with Arduino API spirit:
- user application should access to
SPIClass
API
but it should not access tospi_init()
for example (which is more for an internal core usage) - user application (like the proposed example) should not use STM32 HAL API like HAL_SPI_Receive(), ...
- ... on the contrary, all this HAL_SPI_xxx() stuff should be part of the driver itself:
For example by reusing/extending SPIClass likebegin()
with an optional parameter to specify the mode (with default master).
Also maybe adding new function to this class like a function to register slave receive call back, and another function to provide the slave response ... - Driver, as well as example, should be compatible with any stm32 series supported.
This means that :- driver implementation should use STM32 HAL/LL API common to STM32 series (or should be implement with compilation switch depending on series).
- Example should use the default and predefined variable
SPI
(default SPI instance)
Instead of defining DEBUG_LED, you can use predefined LED_BUILTIN
and remove reference to specific MCU pin like PA4
Hi, is this actively being worked on? |
Hi @ric96 |
I'd also really like to see this going upstream and I think it'd be worth putting some effort into once for a peace of mind later on, when using it in a project and not having to continuously level local patchsets. |
Superseded by #2050. |
Summary
This PR implements SPI slave mode.
References
This is a follow up for the ticket #1600.
Motivation
Most high level possible functions to implement this feature were used. In
order to be as close as possible to other Arduino examples.
SPIClass
functions have not been touched as much as possible.Validation
Example sketches for SPI master and slave are provided with this PR.