Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions neotron-bmc-pico/src/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,19 @@ impl<const RXC: usize, const TXC: usize> SpiPeripheral<RXC, TXC> {
fn raw_read(&mut self) -> u8 {
// PAC only supports 16-bit read, but that pops two bytes off the FIFO.
// So force an 8-bit read.
unsafe { core::ptr::read_volatile(&self.dev.dr as *const _ as *const u8) }
let spi_dr_ptr = self.dev.dr.as_ptr() as *mut u8;
// Safety: we own the SPI device
unsafe { spi_dr_ptr.read_volatile() }
}

fn raw_write(&mut self, data: u8) {
// PAC only supports 16-bit read, but that pushes two bytes onto the FIFO.
// So force an 8-bit write.
unsafe { core::ptr::write_volatile(&self.dev.dr as *const _ as *mut u8, data) }
let spi_dr_ptr = self.dev.dr.as_ptr() as *mut u8;
// Safety: we own the SPI device
unsafe {
spi_dr_ptr.write_volatile(data);
}
}

/// Get a slice of data received so far.
Expand Down