Skip to content

Commit 1a82452

Browse files
SpiPeripheral::reset must not enable the device.
We don't do that until SpiPeripheral::start is called.
1 parent 8a2c301 commit 1a82452

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

neotron-bmc-pico/src/spi.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@ impl<const RXC: usize, const TXC: usize> SpiPeripheral<RXC, TXC> {
6767

6868
// Enable the SPI device
6969
spi.stop();
70-
spi.dev.cr1.write(|w| {
71-
// Enable the peripheral
72-
w.spe().enabled();
73-
w
74-
});
7570

7671
spi
7772
}
@@ -186,6 +181,9 @@ impl<const RXC: usize, const TXC: usize> SpiPeripheral<RXC, TXC> {
186181
}
187182

188183
/// Fully reset the SPI peripheral
184+
///
185+
/// This is like calling [`Self::stop()`] but it reboots the IP block to clear any
186+
/// partial words from the RX FIFO.
189187
pub fn reset(&mut self, _rcc: &mut stm32f0xx_hal::rcc::Rcc) {
190188
self.dev.cr1.write(|w| {
191189
// Disable the peripheral
@@ -211,13 +209,8 @@ impl<const RXC: usize, const TXC: usize> SpiPeripheral<RXC, TXC> {
211209
let _ = self.raw_read();
212210
}
213211

214-
// Enable the SPI device and leave it idle
212+
// Leave the SPI device turned off
215213
self.stop();
216-
self.dev.cr1.write(|w| {
217-
// Enable the peripheral
218-
w.spe().enabled();
219-
w
220-
});
221214
}
222215

223216
/// Does the RX FIFO have any data in it?

0 commit comments

Comments
 (0)