1919use crate :: rcc;
2020use crate :: stm32:: CRC ;
2121use core:: hash:: Hasher ;
22- use core:: ptr;
2322
2423/// Extension trait to constrain the CRC peripheral.
2524pub trait CrcExt {
@@ -119,17 +118,15 @@ impl Config {
119118 Some ( BitReversal :: ByWord ) => 0b11 ,
120119 } ;
121120
122- crc. init . write ( |w| unsafe { w . crc_init ( ) . bits ( init) } ) ;
121+ crc. init . write ( |w| w . init ( ) . bits ( init) ) ;
123122 crc. pol . write ( |w| unsafe { w. bits ( poly) } ) ;
124123 crc. cr . write ( |w| {
125- unsafe {
126- w. rev_in ( )
127- . bits ( in_rev_bits)
128- . polysize ( )
129- . bits ( poly_bits)
130- . reset ( )
131- . set_bit ( ) ;
132- }
124+ w. rev_in ( )
125+ . bits ( in_rev_bits)
126+ . polysize ( )
127+ . bits ( poly_bits)
128+ . reset ( )
129+ . set_bit ( ) ;
133130
134131 if self . output_bit_reversal {
135132 w. rev_out ( ) . set_bit ( )
@@ -162,21 +159,16 @@ impl Crc {
162159 pub fn reset_with_inital_value ( & mut self , initial_value : u32 ) {
163160 let crc = unsafe { & ( * CRC :: ptr ( ) ) } ;
164161
165- crc. init
166- . write ( |w| unsafe { w. crc_init ( ) . bits ( initial_value) } ) ;
162+ crc. init . write ( |w| w. init ( ) . bits ( initial_value) ) ;
167163 crc. cr . modify ( |_, w| w. reset ( ) . set_bit ( ) ) ;
168164 }
169165
170166 /// Feed the CRC with data
171167 #[ inline]
172168 pub fn feed ( & mut self , data : & [ u8 ] ) {
173169 let crc = unsafe { & ( * CRC :: ptr ( ) ) } ;
174- for byte in data {
175- unsafe {
176- // Workaround with svd2rust, it does not generate the byte interface to the DR
177- // register
178- ptr:: write_volatile ( & crc. dr as * const _ as * mut u8 , * byte) ;
179- }
170+ for & byte in data {
171+ crc. dr8 ( ) . write ( |w| w. dr8 ( ) . bits ( byte) ) ;
180172 }
181173 }
182174
@@ -197,7 +189,7 @@ impl Crc {
197189 pub fn peek_result ( & self ) -> u32 {
198190 let crc = unsafe { & ( * CRC :: ptr ( ) ) } ;
199191
200- crc. dr . read ( ) . bits ( )
192+ crc. dr ( ) . read ( ) . bits ( )
201193 }
202194}
203195
0 commit comments