File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change 1919use crate :: rcc:: { Enable , Rcc , Reset } ;
2020use crate :: stm32:: CRC ;
2121use core:: hash:: Hasher ;
22+ use core:: { cell, ptr} ;
2223
2324/// Extension trait to constrain the CRC peripheral.
2425pub 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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments