@@ -132,9 +132,12 @@ impl Adc {
132132 /// Sets ADC source
133133 pub fn set_clock_source ( & mut self , clock_source : ClockSource ) {
134134 match clock_source {
135- ClockSource :: Pclk ( div) => self . rb . cfgr2 . modify ( |_, w| w. ckmode ( ) . bits ( div as u8 ) ) ,
135+ ClockSource :: Pclk ( div) => self
136+ . rb
137+ . cfgr2
138+ . modify ( |_, w| unsafe { w. ckmode ( ) . bits ( div as u8 ) } ) ,
136139 ClockSource :: Async ( div) => {
137- self . rb . cfgr2 . modify ( |_, w| w. ckmode ( ) . bits ( 0 ) ) ;
140+ self . rb . cfgr2 . modify ( |_, w| unsafe { w. ckmode ( ) . bits ( 0 ) } ) ;
138141 self . rb
139142 . ccr
140143 . modify ( |_, w| unsafe { w. presc ( ) . bits ( div as u8 ) } ) ;
@@ -201,7 +204,9 @@ impl Adc {
201204
202205 /// Oversampling of adc
203206 pub fn set_oversampling_ratio ( & mut self , ratio : OversamplingRatio ) {
204- self . rb . cfgr2 . modify ( |_, w| w. ovsr ( ) . bits ( ratio as u8 ) ) ;
207+ self . rb
208+ . cfgr2
209+ . modify ( |_, w| unsafe { w. ovsr ( ) . bits ( ratio as u8 ) } ) ;
205210 }
206211
207212 pub fn oversampling_enable ( & mut self , enable : bool ) {
@@ -301,9 +306,9 @@ where
301306 fn prepare_injected ( & mut self , _pin : & mut PIN , triger_source : InjTrigSource ) {
302307 self . rb
303308 . cfgr1
304- . modify ( |_, w| w. exten ( ) . bits ( 1 ) . extsel ( ) . bits ( triger_source as u8 ) ) ;
309+ . modify ( |_, w| unsafe { w. exten ( ) . bits ( 1 ) . extsel ( ) . bits ( triger_source as u8 ) } ) ;
305310
306- self . rb . cfgr1 . modify ( |_, w| {
311+ self . rb . cfgr1 . modify ( |_, w| unsafe {
307312 w. res ( ) // set ADC resolution bits (ADEN must be =0)
308313 . bits ( self . precision as u8 )
309314 . align ( ) // set alignment bit is (ADSTART must be 0)
@@ -314,7 +319,7 @@ where
314319
315320 self . rb
316321 . smpr // set sampling time set 1 (ADSTART must be 0)
317- . modify ( |_, w| w. smp1 ( ) . bits ( self . sample_time as u8 ) ) ;
322+ . modify ( |_, w| unsafe { w. smp1 ( ) . bits ( self . sample_time as u8 ) } ) ;
318323
319324 todo ! ( ) ;
320325 // self.rb
@@ -359,7 +364,7 @@ where
359364
360365 fn read ( & mut self , _pin : & mut PIN ) -> nb:: Result < WORD , Self :: Error > {
361366 self . power_up ( ) ;
362- self . rb . cfgr1 . modify ( |_, w| {
367+ self . rb . cfgr1 . modify ( |_, w| unsafe {
363368 w. res ( )
364369 . bits ( self . precision as u8 )
365370 . align ( )
@@ -368,7 +373,7 @@ where
368373
369374 self . rb
370375 . smpr
371- . modify ( |_, w| w. smp1 ( ) . bits ( self . sample_time as u8 ) ) ;
376+ . modify ( |_, w| unsafe { w. smp1 ( ) . bits ( self . sample_time as u8 ) } ) ;
372377
373378 self . rb
374379 . chselr0 ( )
0 commit comments