aboutsummaryrefslogtreecommitdiffstats
path: root/src/stm32/spi.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stm32/spi.c')
-rw-r--r--src/stm32/spi.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/stm32/spi.c b/src/stm32/spi.c
index f1ba33cf..3afe342a 100644
--- a/src/stm32/spi.c
+++ b/src/stm32/spi.c
@@ -100,6 +100,12 @@ void
spi_prepare(struct spi_config config)
{
SPI_TypeDef *spi = config.spi;
+ uint32_t cr1 = spi->CR1;
+ if (cr1 == config.spi_cr1)
+ return;
+ // The SPE bit must be disabled before changing CPOL/CPHA bits
+ spi->CR1 = cr1 & ~SPI_CR1_SPE;
+ spi->CR1; // Force flush of previous write
spi->CR1 = config.spi_cr1;
}