stm32-rs / stm32f1xx-hal

A Rust embedded-hal HAL impl for the STM32F1 family based on japarics stm32f103xx-hal
Apache License 2.0
565 stars 177 forks source link

SPI bidirection mode support #493

Open showier-drastic opened 1 month ago

showier-drastic commented 1 month ago

When interfacing with single wire half-duplex SPI devices such as the TLE5012 magnetic sensor, we should enable bidirection mode as shown in "25.3.4 Configuring the SPI for half-duplex communication" of STM32F1 reference manual. Mainly, BIDIMODE bit of CR1 should be set high, and BIDIOE bit should be set according to transfer direction. Is it possible for the HAL to support this?

burrbull commented 1 month ago

In f4xx-hal it is done using advanced BIDI generic marker. See https://github.com/stm32-rs/stm32f4xx-hal/blob/910163d4d0e2b64091e15a72667fb1273e49a1c2/src/spi.rs#L172

You could improve API making similar PR.