mirror of https://github.com/Desuuuu/klipper.git
stm32: Clear SPE flag on a change to SPI CR1 register
The stm32 specs indicate that the SPE bit must be cleared before changing the CPHA or CPOL bits. Reported by @cbc02009 and @bigtreetech. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
99d55185a2
commit
e3cbe7ea36
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue