File tree Expand file tree Collapse file tree 3 files changed +8
-12
lines changed Expand file tree Collapse file tree 3 files changed +8
-12
lines changed Original file line number Diff line number Diff line change 21
21
use crate :: rcc:: { Enable , Rcc , Reset } ;
22
22
use crate :: stm32:: CRC ;
23
23
use core:: hash:: Hasher ;
24
- use core:: ptr;
25
24
26
25
/// Extension trait to constrain the CRC peripheral.
27
26
pub trait CrcExt {
@@ -174,11 +173,8 @@ impl Crc {
174
173
pub fn feed ( & mut self , data : & [ u8 ] ) {
175
174
let crc = unsafe { & ( * CRC :: ptr ( ) ) } ;
176
175
for byte in data {
177
- unsafe {
178
- // Workaround with svd2rust, it does not generate the byte interface to the DR
179
- // register
180
- ptr:: write_volatile ( & crc. dr as * const _ as * mut u8 , * byte) ;
181
- }
176
+ let ptr = & crc. dr as * const _ ;
177
+ unsafe { core:: ptr:: write_volatile ( ptr as * mut u8 , * byte) } ;
182
178
}
183
179
}
184
180
Original file line number Diff line number Diff line change @@ -445,9 +445,9 @@ macro_rules! gpio {
445
445
let _ = & ( * $GPIOX:: ptr( ) ) . pupdr. modify( |r, w| {
446
446
w. bits( r. bits( ) & !( 0b11 << offset) )
447
447
} ) ;
448
- & ( * $GPIOX:: ptr( ) ) . moder. modify( |r, w| {
448
+ let _ = & ( * $GPIOX:: ptr( ) ) . moder. modify( |r, w| {
449
449
w. bits( r. bits( ) & !( 0b11 << offset) )
450
- } )
450
+ } ) ;
451
451
} ;
452
452
let offset = ( $i % 4 ) * 8 ;
453
453
let mask = $Pxn << offset;
@@ -475,9 +475,9 @@ macro_rules! gpio {
475
475
pub fn set_speed( self , speed: Speed ) -> Self {
476
476
let offset = 2 * $i;
477
477
unsafe {
478
- & ( * $GPIOX:: ptr( ) ) . ospeedr. modify( |r, w| {
478
+ let _ = & ( * $GPIOX:: ptr( ) ) . ospeedr. modify( |r, w| {
479
479
w. bits( ( r. bits( ) & !( 0b11 << offset) ) | ( ( speed as u32 ) << offset) )
480
- } )
480
+ } ) ;
481
481
} ;
482
482
self
483
483
}
Original file line number Diff line number Diff line change @@ -264,8 +264,8 @@ macro_rules! spi {
264
264
} else if sr. crcerr( ) . bit_is_set( ) {
265
265
nb:: Error :: Other ( Error :: Crc )
266
266
} else if sr. txe( ) . bit_is_set( ) {
267
- // NOTE(write_volatile) see note above
268
- unsafe { ptr:: write_volatile( & self . spi . dr as * const _ as * mut u8 , byte) }
267
+ let ptr = & self . spi . dr as * const _ ;
268
+ unsafe { core :: ptr:: write_volatile( ptr as * mut u8 , byte) } ;
269
269
return Ok ( ( ) ) ;
270
270
} else {
271
271
nb:: Error :: WouldBlock
You can’t perform that action at this time.
0 commit comments