Merge pull request #1252 from pattop/stm32_spi_fifo_fix
stm32/spi: fix occasional data corruption
This commit is contained in:
commit
351e4407ef
1 changed files with 4 additions and 2 deletions
|
@ -456,13 +456,14 @@ impl<'d, T: Instance, Tx, Rx> Spi<'d, T, Tx, Rx> {
|
||||||
T::REGS.cr1().modify(|w| {
|
T::REGS.cr1().modify(|w| {
|
||||||
w.set_spe(false);
|
w.set_spe(false);
|
||||||
});
|
});
|
||||||
set_rxdmaen(T::REGS, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SPIv3 clears rxfifo on SPE=0
|
// SPIv3 clears rxfifo on SPE=0
|
||||||
#[cfg(not(any(spi_v3, spi_v4)))]
|
#[cfg(not(any(spi_v3, spi_v4)))]
|
||||||
flush_rx_fifo(T::REGS);
|
flush_rx_fifo(T::REGS);
|
||||||
|
|
||||||
|
set_rxdmaen(T::REGS, true);
|
||||||
|
|
||||||
let clock_byte_count = data.len();
|
let clock_byte_count = data.len();
|
||||||
|
|
||||||
let rx_request = self.rxdma.request();
|
let rx_request = self.rxdma.request();
|
||||||
|
@ -510,13 +511,14 @@ impl<'d, T: Instance, Tx, Rx> Spi<'d, T, Tx, Rx> {
|
||||||
T::REGS.cr1().modify(|w| {
|
T::REGS.cr1().modify(|w| {
|
||||||
w.set_spe(false);
|
w.set_spe(false);
|
||||||
});
|
});
|
||||||
set_rxdmaen(T::REGS, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SPIv3 clears rxfifo on SPE=0
|
// SPIv3 clears rxfifo on SPE=0
|
||||||
#[cfg(not(any(spi_v3, spi_v4)))]
|
#[cfg(not(any(spi_v3, spi_v4)))]
|
||||||
flush_rx_fifo(T::REGS);
|
flush_rx_fifo(T::REGS);
|
||||||
|
|
||||||
|
set_rxdmaen(T::REGS, true);
|
||||||
|
|
||||||
let rx_request = self.rxdma.request();
|
let rx_request = self.rxdma.request();
|
||||||
let rx_src = T::REGS.rx_ptr();
|
let rx_src = T::REGS.rx_ptr();
|
||||||
unsafe { self.rxdma.start_read(rx_request, rx_src, read, Default::default()) };
|
unsafe { self.rxdma.start_read(rx_request, rx_src, read, Default::default()) };
|
||||||
|
|
Loading…
Reference in a new issue