@@ -412,22 +412,15 @@ macro_rules! adc_hal {
412
412
self . select_single_chan( chan) ;
413
413
414
414
self . rb. cr. modify( |_, w| w. adstart( ) . set_bit( ) ) ;
415
- while self . rb. isr. read( ) . eos( ) . is_not_complete( )
416
- { }
415
+ while self . rb. isr. read( ) . eos( ) . is_not_complete( ) { }
417
416
self . rb. isr. modify( |_, w| w. eos( ) . clear( ) ) ;
418
417
return self . rb. dr. read( ) . rdata( ) . bits( ) ;
419
418
}
420
419
421
420
fn ensure_oneshot( & mut self ) {
422
- match self . operation_mode {
423
- Some ( mode) =>
424
- {
425
- if mode != OperationMode :: OneShot {
426
- self . setup_oneshot( ) ;
427
- }
428
- } ,
429
- _ => self . setup_oneshot( ) ,
430
- } ;
421
+ if self . operation_mode != Some ( OperationMode :: OneShot ) {
422
+ self . setup_oneshot( ) ;
423
+ }
431
424
}
432
425
433
426
/// This should only be invoked with the defined channels for the particular
@@ -490,10 +483,12 @@ macro_rules! adc12_hal {
490
483
) +) => {
491
484
$(
492
485
impl Adc <$ADC> {
486
+ /// Returns true iff
487
+ /// the clock can be enabled with the given settings
488
+ /// or the clock was already enabled with the same settings
493
489
fn enable_clock( & self , ahb: & mut AHB , adc_common: & mut ADC1_2 ) -> bool {
494
- if ahb. enr( ) . read( ) . adc34en( ) . is_enabled( ) &&
495
- ( adc_common. ccr. read( ) . ckmode( ) . variant( ) != self . ckmode. into( ) ) {
496
- return false ;
490
+ if ahb. enr( ) . read( ) . adc12en( ) . is_enabled( ) {
491
+ return ( adc_common. ccr. read( ) . ckmode( ) . variant( ) == self . ckmode. into( ) ) ;
497
492
}
498
493
ahb. enr( ) . modify( |_, w| w. adc12en( ) . enabled( ) ) ;
499
494
adc_common. ccr. modify( |_, w| w
@@ -525,11 +520,11 @@ macro_rules! adc34_hal {
525
520
$(
526
521
impl Adc <$ADC> {
527
522
/// Returns true iff
528
- /// the clock was enabled
523
+ /// the clock can be enabled with the given settings
529
524
/// or the clock was already enabled with the same settings
530
525
fn enable_clock( & self , ahb: & mut AHB , adc_common: & mut ADC3_4 ) -> bool {
531
526
if ahb. enr( ) . read( ) . adc34en( ) . is_enabled( ) {
532
- return ( adc_common. ccr. read( ) . ckmode( ) . variant( ) == self . ckmode. into( ) )
527
+ return ( adc_common. ccr. read( ) . ckmode( ) . variant( ) == self . ckmode. into( ) ) ;
533
528
}
534
529
ahb. enr( ) . modify( |_, w| w. adc34en( ) . enabled( ) ) ;
535
530
adc_common. ccr. modify( |_, w| w
0 commit comments