Disable SPI before changing config, then re-enable SPI on STM32

Fixes #2259
This commit is contained in:
Sebastian Gabrielli 2025-04-22 12:47:33 +02:00
parent fb5ce05b26
commit d8631f96d9

View File

@ -284,6 +284,10 @@ impl<'d, M: PeriMode> Spi<'d, M> {
#[cfg(any(spi_v3, spi_v4, spi_v5))]
{
self.info.regs.cr1().modify(|w| {
w.set_spe(false);
});
self.info.regs.cfg2().modify(|w| {
w.set_cpha(cpha);
w.set_cpol(cpol);
@ -292,6 +296,10 @@ impl<'d, M: PeriMode> Spi<'d, M> {
self.info.regs.cfg1().modify(|w| {
w.set_mbr(br);
});
self.info.regs.cr1().modify(|w| {
w.set_spe(true);
});
}
Ok(())
}