c4a2c62096
1199: STM32 SPI: Set clk-pin pull-up/-down to match spi clock polarity r=Dirbaio a=jr-oss Fixes #1094 There are some proposed solutions in #1094 > Keep the DMA transaction open across calls to read/write This may be problematic if the user changes bus settings between calls, and also the reference manual says the chip should not be placed into low power mode while SPI is enabled As already described, this is problematic and against reference manual recommendation > Set the CLK (and maybe MOSI) pins as pull-down on setup (or pull-up, depending on config - and this would need to be updated if the user modified the config) This is less good than driving the pin to the correct value, but may be better than nothing That is also my preferred solution. See below citation from reference manual. > Document this and require users fix it themselves (add a pull-up/down resistor - or configure the pins as pull-up/pull-down before passing them into SPI setup) Setting internal pull-up/-down won't work, because `sck.set_as_af()` will change the gpio pull mode to none: https://github.com/embassy-rs/embassy/blob/master/embassy-stm32/src/gpio.rs#L552-L555 > Dig around in the reference manual and determine if there is a better way to start/stop a DMA transaction while keeping active control of the clock the whole time I haven't found a better way ------ From ST reference manual RM0394 (L4) (Same note in RM0399 (H7) / RM0038 (L1) / RM0316 /F3)): 40.4.6 Communication formats ... The idle state of SCK must correspond to the polarity selected in the SPIx_CR1 register (by pulling up SCK if CPOL=1 or pulling down SCK if CPOL=0). Co-authored-by: Ralf <jr-oss@gmx.net> |
||
---|---|---|
.. | ||
src | ||
build.rs | ||
Cargo.toml |