Stm32f1xx-hal, how to configure spi as slave or for hardware slave selection?

i have been trying learn embedded programming in rust. i picked up a blue pill and stm32f1xx-hal crate.
stm32f1xx-hal spi this is spi docs. but i dont find any way to configure spi as slave or other configuration.
To access it via PAC, hal gets ownership of spi so cant use that one.

Am i missing something?

It looks like the stm32f1xx-hal repository contains a bunch of examples targeting the blue pill.

Does this example for using DMA to transfer data over SPI help?

https://github.com/stm32-rs/stm32f1xx-hal/blob/f58d8e9216495bb96e9d7aac984ef4b953278463/examples/spi-dma.rs

It may also be that the SPI code in stm32f1xx-hal is only intended as a master. If so, I'd open a ticket against the repository and they may be able to point you in the right direction.

yep thanks i saw that example but it didn't solved my problem. then i tried to look in documentation there's also i couldn't find it.

i think configuring isn't yet implemented, i wish i could contribute to that but i am afraid my knowledge isn't enough for that.

Trying to implement something like this is the perfect way to improve your knowledge. It doesn't matter that you don't know how to implement it at the moment, people are always happy to provide guidance or answer questions.

You can always ask for help on the Embedded Rust matrix server.

2 Likes

Maintainer of that crate here :wave:. Configuring it as a slave is not implemented yet unfortunately. Feel free to open an issue about this :).

Pull requests are always welcome and I'd be more than happy to point you in the right direction for implementing this, just contact me on github or matrix as Michael said.

2 Likes

I recommend to configure the slave once in CubeMX and see what code it generates. If the HAL is too fluffy for you, switch the output to LL.

Then see what code that makes and compare it to what you have.

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.