Skip to content

Commit 7a348ed

Browse files
committed
clippy
1 parent 0fea786 commit 7a348ed

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/crc.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use crate::rcc::{Enable, Rcc, Reset};
2020
use crate::stm32::CRC;
2121
use core::hash::Hasher;
22+
use core::{cell, ptr};
2223

2324
/// Extension trait to constrain the CRC peripheral.
2425
pub trait CrcExt {
@@ -169,8 +170,9 @@ impl Crc {
169170
pub fn feed(&mut self, data: &[u8]) {
170171
let crc = unsafe { &(*CRC::ptr()) };
171172
for byte in data {
172-
let ptr = &crc.dr as *const _;
173-
unsafe { core::ptr::write_volatile(ptr as *mut u8, *byte) };
173+
unsafe {
174+
ptr::write_volatile(cell::UnsafeCell::raw_get(&crc.dr as *const _ as _), byte)
175+
}
174176
}
175177
}
176178

src/spi.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,9 @@ macro_rules! spi {
262262
} else if sr.crcerr().bit_is_set() {
263263
nb::Error::Other(Error::Crc)
264264
} else if sr.txe().bit_is_set() {
265-
let ptr = &self.spi.dr as *const _;
266-
unsafe { core::ptr::write_volatile(ptr as *mut u8, byte) };
265+
unsafe {
266+
ptr::write_volatile(core::cell::UnsafeCell::raw_get(&self.spi.dr as *const _ as _), byte)
267+
}
267268
return Ok(());
268269
} else {
269270
nb::Error::WouldBlock

0 commit comments

Comments
 (0)