Skip to content

Commit 865ed9d

Browse files
committed
fix spi
1 parent 9040390 commit 865ed9d

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/spi.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use crate::rcc::{self, Rcc};
33
use crate::stm32::{self as pac, spi1};
44
use crate::time::Hertz;
55
use core::convert::Infallible;
6-
use core::ptr;
76
use embedded_hal::delay::DelayNs;
87
use hal::digital;
98
use hal::digital::OutputPin;
@@ -324,9 +323,7 @@ impl<SPI: Instance, PINS> SpiBus<SPI, PINS> {
324323
} else if sr.crcerr().bit_is_set() {
325324
nb::Error::Other(Error::Crc)
326325
} else if sr.rxne().bit_is_set() {
327-
// NOTE(read_volatile) read only 1 byte (the svd2rust API only allows
328-
// reading a half-word)
329-
return Ok(unsafe { ptr::read_volatile(&self.spi.dr() as *const _ as *const u8) });
326+
return Ok(self.spi.dr8().read().bits() as u8);
330327
} else {
331328
nb::Error::WouldBlock
332329
})
@@ -341,7 +338,7 @@ impl<SPI: Instance, PINS> SpiBus<SPI, PINS> {
341338
} else if sr.crcerr().bit_is_set() {
342339
nb::Error::Other(Error::Crc)
343340
} else if sr.txe().bit_is_set() {
344-
self.spi.dr().write(|w| w.dr().set(byte.into()));
341+
self.spi.dr8().write(|w| unsafe { w.dr().bits(byte as _) });
345342
return Ok(());
346343
} else {
347344
nb::Error::WouldBlock

0 commit comments

Comments
 (0)