@@ -118,7 +118,7 @@ impl Adc {
118118 // Enable ADC clocks
119119 ADC :: enable ( rcc) ;
120120
121- adc. cr . modify ( |_, w| w. advregen ( ) . set_bit ( ) ) ;
121+ adc. cr ( ) . modify ( |_, w| w. advregen ( ) . set_bit ( ) ) ;
122122
123123 Self {
124124 rb : adc,
@@ -134,12 +134,12 @@ impl Adc {
134134 match clock_source {
135135 ClockSource :: Pclk ( div) => self
136136 . rb
137- . cfgr2
137+ . cfgr2 ( )
138138 . modify ( |_, w| unsafe { w. ckmode ( ) . bits ( div as u8 ) } ) ,
139139 ClockSource :: Async ( div) => {
140- self . rb . cfgr2 . modify ( |_, w| unsafe { w. ckmode ( ) . bits ( 0 ) } ) ;
140+ self . rb . cfgr2 ( ) . modify ( |_, w| unsafe { w. ckmode ( ) . bits ( 0 ) } ) ;
141141 self . rb
142- . ccr
142+ . ccr ( )
143143 . modify ( |_, w| unsafe { w. presc ( ) . bits ( div as u8 ) } ) ;
144144 }
145145 }
@@ -152,8 +152,8 @@ impl Adc {
152152 ///
153153 /// Do not call if an ADC reading is ongoing.
154154 pub fn calibrate ( & mut self ) {
155- self . rb . cr . modify ( |_, w| w. adcal ( ) . set_bit ( ) ) ;
156- while self . rb . cr . read ( ) . adcal ( ) . bit_is_set ( ) { }
155+ self . rb . cr ( ) . modify ( |_, w| w. adcal ( ) . set_bit ( ) ) ;
156+ while self . rb . cr ( ) . read ( ) . adcal ( ) . bit_is_set ( ) { }
157157 }
158158
159159 /// Returns the calibration factors used by the ADC
@@ -166,7 +166,7 @@ impl Adc {
166166 /// Note that VDDA changes and to a lesser extent temperature changes affect the ADC operating conditions and
167167 /// calibration should be run again for the best accuracy.
168168 pub fn get_calibration ( & self ) -> CalibrationFactor {
169- CalibrationFactor ( self . rb . calfact . read ( ) . calfact ( ) . bits ( ) )
169+ CalibrationFactor ( self . rb . calfact ( ) . read ( ) . calfact ( ) . bits ( ) )
170170 }
171171
172172 /// Writes the calibration factors used by the ADC
@@ -176,7 +176,7 @@ impl Adc {
176176 /// Do not call if an ADC reading is ongoing.
177177 pub fn set_calibration ( & mut self , calfact : CalibrationFactor ) {
178178 self . rb
179- . calfact
179+ . calfact ( )
180180 . write ( |w| unsafe { w. calfact ( ) . bits ( calfact. 0 ) } ) ;
181181 }
182182
@@ -198,34 +198,34 @@ impl Adc {
198198 /// The nuber of bits, the oversampling result is shifted in bits at the end of oversampling
199199 pub fn set_oversampling_shift ( & mut self , nrbits : u8 ) {
200200 self . rb
201- . cfgr2
201+ . cfgr2 ( )
202202 . modify ( |_, w| unsafe { w. ovss ( ) . bits ( nrbits) } ) ;
203203 }
204204
205205 /// Oversampling of adc
206206 pub fn set_oversampling_ratio ( & mut self , ratio : OversamplingRatio ) {
207207 self . rb
208- . cfgr2
208+ . cfgr2 ( )
209209 . modify ( |_, w| unsafe { w. ovsr ( ) . bits ( ratio as u8 ) } ) ;
210210 }
211211
212212 pub fn oversampling_enable ( & mut self , enable : bool ) {
213- self . rb . cfgr2 . modify ( |_, w| w. ovse ( ) . bit ( enable) ) ;
213+ self . rb . cfgr2 ( ) . modify ( |_, w| w. ovse ( ) . bit ( enable) ) ;
214214 }
215215
216216 pub fn start_injected ( & mut self ) {
217- self . rb . cr . modify ( |_, w| w. adstart ( ) . set_bit ( ) ) ;
217+ self . rb . cr ( ) . modify ( |_, w| w. adstart ( ) . set_bit ( ) ) ;
218218 // ADSTART bit is cleared to 0 bevor using this function
219219 // enable self.rb.isr.eos() flag is set after each converstion
220- self . rb . ier . modify ( |_, w| w. eocie ( ) . set_bit ( ) ) ; // end of sequence interupt enable
220+ self . rb . ier ( ) . modify ( |_, w| w. eocie ( ) . set_bit ( ) ) ; // end of sequence interupt enable
221221 }
222222
223223 pub fn stop_injected ( & mut self ) {
224224 // ?????? or is it reset after each conversion?
225225 // ADSTART bit is cleared to 0 bevor using this function
226226 // disable EOS interrupt
227- // maybe self.rb.cr.adstp().set_bit() must be performed before interrupt is disabled + wait abortion
228- self . rb . ier . modify ( |_, w| w. eocie ( ) . clear_bit ( ) ) ; // end of sequence interupt disable
227+ // maybe self.rb.cr() .adstp().set_bit() must be performed before interrupt is disabled + wait abortion
228+ self . rb . ier ( ) . modify ( |_, w| w. eocie ( ) . clear_bit ( ) ) ; // end of sequence interupt disable
229229 }
230230
231231 pub fn read_voltage < PIN : Channel < Adc , ID = u8 > > (
@@ -263,15 +263,15 @@ impl Adc {
263263 }
264264
265265 fn power_up ( & mut self ) {
266- self . rb . isr . modify ( |_, w| w. adrdy ( ) . set_bit ( ) ) ;
267- self . rb . cr . modify ( |_, w| w. aden ( ) . set_bit ( ) ) ;
268- while self . rb . isr . read ( ) . adrdy ( ) . bit_is_clear ( ) { }
266+ self . rb . isr ( ) . modify ( |_, w| w. adrdy ( ) . set_bit ( ) ) ;
267+ self . rb . cr ( ) . modify ( |_, w| w. aden ( ) . set_bit ( ) ) ;
268+ while self . rb . isr ( ) . read ( ) . adrdy ( ) . bit_is_clear ( ) { }
269269 }
270270
271271 fn power_down ( & mut self ) {
272- self . rb . cr . modify ( |_, w| w. addis ( ) . set_bit ( ) ) ;
273- self . rb . isr . modify ( |_, w| w. adrdy ( ) . set_bit ( ) ) ;
274- while self . rb . cr . read ( ) . aden ( ) . bit_is_set ( ) { }
272+ self . rb . cr ( ) . modify ( |_, w| w. addis ( ) . set_bit ( ) ) ;
273+ self . rb . isr ( ) . modify ( |_, w| w. adrdy ( ) . set_bit ( ) ) ;
274+ while self . rb . cr ( ) . read ( ) . aden ( ) . bit_is_set ( ) { }
275275 }
276276}
277277
@@ -300,10 +300,10 @@ where
300300
301301 fn prepare_injected ( & mut self , _pin : & mut PIN , triger_source : InjTrigSource ) {
302302 self . rb
303- . cfgr1
303+ . cfgr1 ( )
304304 . modify ( |_, w| unsafe { w. exten ( ) . bits ( 1 ) . extsel ( ) . bits ( triger_source as u8 ) } ) ;
305305
306- self . rb . cfgr1 . modify ( |_, w| unsafe {
306+ self . rb . cfgr1 ( ) . modify ( |_, w| unsafe {
307307 w. res ( ) // set ADC resolution bits (ADEN must be =0)
308308 . bits ( self . precision as u8 )
309309 . align ( ) // set alignment bit is (ADSTART must be 0)
@@ -313,7 +313,7 @@ where
313313 self . power_up ( ) ;
314314
315315 self . rb
316- . smpr // set sampling time set 1 (ADSTART must be 0)
316+ . smpr ( ) // set sampling time set 1 (ADSTART must be 0)
317317 . modify ( |_, w| unsafe { w. smp1 ( ) . bits ( self . sample_time as u8 ) } ) ;
318318
319319 todo ! ( ) ;
@@ -335,17 +335,17 @@ impl DmaMode<Adc> for Adc {
335335
336336 fn dma_enable ( & mut self , enable : bool ) {
337337 if enable {
338- self . rb . cfgr1 . modify ( |_, w| w. dmaen ( ) . set_bit ( ) ) ; // enable dma beeing called
338+ self . rb . cfgr1 ( ) . modify ( |_, w| w. dmaen ( ) . set_bit ( ) ) ; // enable dma beeing called
339339 } else {
340- self . rb . cfgr1 . modify ( |_, w| w. dmaen ( ) . clear_bit ( ) ) ; // disable dma beeing called
340+ self . rb . cfgr1 ( ) . modify ( |_, w| w. dmaen ( ) . clear_bit ( ) ) ; // disable dma beeing called
341341 }
342342 }
343343
344344 fn dma_circualr_mode ( & mut self , enable : bool ) {
345345 if enable {
346- self . rb . cfgr1 . modify ( |_, w| w. dmacfg ( ) . set_bit ( ) ) ; // activate circular mode
346+ self . rb . cfgr1 ( ) . modify ( |_, w| w. dmacfg ( ) . set_bit ( ) ) ; // activate circular mode
347347 } else {
348- self . rb . cfgr1 . modify ( |_, w| w. dmacfg ( ) . clear_bit ( ) ) ; // disable circular mode
348+ self . rb . cfgr1 ( ) . modify ( |_, w| w. dmacfg ( ) . clear_bit ( ) ) ; // disable circular mode
349349 }
350350 }
351351}
@@ -359,26 +359,26 @@ where
359359
360360 fn read ( & mut self , _pin : & mut PIN ) -> nb:: Result < WORD , Self :: Error > {
361361 self . power_up ( ) ;
362- self . rb . cfgr1 . modify ( |_, w| unsafe {
362+ self . rb . cfgr1 ( ) . modify ( |_, w| unsafe {
363363 w. res ( )
364364 . bits ( self . precision as u8 )
365365 . align ( )
366366 . bit ( self . align == Align :: Left )
367367 } ) ;
368368
369369 self . rb
370- . smpr
370+ . smpr ( )
371371 . modify ( |_, w| unsafe { w. smp1 ( ) . bits ( self . sample_time as u8 ) } ) ;
372372
373373 self . rb
374374 . chselr0 ( )
375375 . modify ( |_, w| unsafe { w. bits ( 1 << PIN :: channel ( ) ) } ) ;
376376
377- self . rb . isr . modify ( |_, w| w. eos ( ) . set_bit ( ) ) ;
378- self . rb . cr . modify ( |_, w| w. adstart ( ) . set_bit ( ) ) ;
379- while self . rb . isr . read ( ) . eos ( ) . bit_is_clear ( ) { }
377+ self . rb . isr ( ) . modify ( |_, w| w. eos ( ) . set_bit ( ) ) ;
378+ self . rb . cr ( ) . modify ( |_, w| w. adstart ( ) . set_bit ( ) ) ;
379+ while self . rb . isr ( ) . read ( ) . eos ( ) . bit_is_clear ( ) { }
380380
381- let res = self . rb . dr . read ( ) . bits ( ) as u16 ;
381+ let res = self . rb . dr ( ) . read ( ) . bits ( ) as u16 ;
382382 let val = if self . align == Align :: Left && self . precision == Precision :: B_6 {
383383 res << 8
384384 } else {
@@ -401,15 +401,15 @@ macro_rules! int_adc {
401401 }
402402
403403 pub fn enable( & mut self , adc: & mut Adc ) {
404- adc. rb. ccr. modify( |_, w| w. $en( ) . set_bit( ) ) ;
404+ adc. rb. ccr( ) . modify( |_, w| w. $en( ) . set_bit( ) ) ;
405405 }
406406
407407 pub fn disable( & mut self , adc: & mut Adc ) {
408- adc. rb. ccr. modify( |_, w| w. $en( ) . clear_bit( ) ) ;
408+ adc. rb. ccr( ) . modify( |_, w| w. $en( ) . clear_bit( ) ) ;
409409 }
410410
411411 pub fn enabled( & self , adc: & Adc ) -> bool {
412- adc. rb. ccr. read( ) . $en( ) . bit_is_set( )
412+ adc. rb. ccr( ) . read( ) . $en( ) . bit_is_set( )
413413 }
414414 }
415415
0 commit comments