Skip to content

Commit a103135

Browse files
committed
Fix invalid reference casting compile error in spi.rs
NOTE: I have not tested this on hardware, just added the allow attribute. Also see [this](rust-lang/rust#116410) issue
1 parent c14bb7c commit a103135

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/spi.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,10 @@ where
413413

414414
fn send_u8(&mut self, byte: u8) {
415415
// NOTE(write_volatile) see note above
416-
unsafe { ptr::write_volatile(&self.spi.dr as *const _ as *mut u8, byte) }
416+
#[allow(invalid_reference_casting)]
417+
unsafe {
418+
ptr::write_volatile(&self.spi.dr as *const _ as *mut u8, byte)
419+
}
417420
}
418421

419422
fn read_u16(&mut self) -> u16 {
@@ -423,7 +426,10 @@ where
423426

424427
fn send_u16(&mut self, byte: u16) {
425428
// NOTE(write_volatile) see note above
426-
unsafe { ptr::write_volatile(&self.spi.dr as *const _ as *mut u16, byte) }
429+
#[allow(invalid_reference_casting)]
430+
unsafe {
431+
ptr::write_volatile(&self.spi.dr as *const _ as *mut u16, byte)
432+
}
427433
}
428434

429435
pub fn release(self) -> (SPI, (SCKPIN, MISOPIN, MOSIPIN)) {

0 commit comments

Comments
 (0)