Skip to content

Commit 563da21

Browse files
committed
Use core::ptr::addr_of! in spi.rs instead of suppressing the compile error
1 parent 36773a3 commit 563da21

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/spi.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,7 @@ where
413413

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

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

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

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

0 commit comments

Comments
 (0)