How to configure SPI in slave mode in STM32F411

Hello, I am writing code for STM32F411 using embassy framework. I don't see any example or anything like that to configure SPI as slave, am I missing something or I have to use some bypass?

I think embassy does not have support for spi slave drivers as of now. there's been some efforts (see #885 and #2750 for example) to add them, but I don't see them coming very soon.

I suggest you try embassy alternatives. for example, if your application doesn't require RTOS, you can use stm32f4xx-hal directly, which has a SpiSlave driver.

if, however, your application's complexity requires an RTOS, you can try stm32f4xx-hal with rtic. note however, in case you are not familiar with rtic: it very "minimalism" as an RTOS in terms of features, and is very different from embassy, see "is rtic an RTOS" and "rtic and embassy".

a useful tip: check out the examples directory in the stm32f4xx-hal repository, specially, you might be interested with the "rtic-spi-slave-dma.rs" and "spi_slave.rs" examples.

I thought about using stm32f4xx-hal but it wouldn't argue with embassy in some way?

I think embassy can be used with different HAL drivers, but I have no real world experience with embassy, I only played with it for limited time, so I don't know how easy (or how hard) to do it.

personally, I have used rtic several times and it plays very nicely with every HAL crate I tried, like nrf52840, rp2040, and stm32.

let's wait someone on this forum who is familiar with embassy to give more useful answers than myself. in the mean time, you may also ask in the embassy chat room, where you have better chance to meet some embassy experts. there's a link on the website of embassy:

I have encountered a similar problem. i have checked out the examples directory in the stm32h7xx-hal repository . However, there is not file contained "spi salve". I wonder if it is possible to generate configuration code through STM32CubeMX, package it into a library, and call it in Rust Embassy.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.