Skip to content

embassy-stm32: Added ability for SPI driver to function in slave mode #4388

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

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

cmilatinov
Copy link
Contributor

Hello!

This PR adds the ability to create an SPI driver instance in slave mode. I have taken inspiration from the I2C driver for the added traits. The original master SPI driver API is left intact.

From the reference manual and STM32 HAL SPI driver source, it seems as though the only extra step required to run in slave mode is to disable the SSM and SSI bits in the SPI control registers.

Two new functions are added to allow for construction of a slave blocking and non-blocking driver, namely Spi::new_blocking_slave and Spi::new_slave (with an extra NSS parameter of course).

I have tested this on the STM32F723ZE with success. Please let me know if I have missed something in the implementation as I am still quite new to driver development.

Cheers

@cmilatinov cmilatinov force-pushed the feature/stm32-spi-slave branch from 6e73f2d to c4b9e59 Compare July 12, 2025 18:17
@elliotsayes
Copy link

elliotsayes commented Jul 24, 2025

Neat, if this gets accepted I'd like to do something similar for embassy-rp. Also tagging #2750 as it appears to be attempting the same thing.
Edit: noticed this already in the repo https://github.com/embassy-rs/embassy/blob/main/embassy-nrf/src/spis.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants