@@ -495,12 +495,12 @@ impl Default for Config {
495
495
Self {
496
496
hse : None ,
497
497
pllmul : None ,
498
- hpre : HPre :: DIV1 ,
499
- ppre1 : PPre :: DIV1 ,
500
- ppre2 : PPre :: DIV1 ,
498
+ hpre : HPre :: Div1 ,
499
+ ppre1 : PPre :: Div1 ,
500
+ ppre2 : PPre :: Div1 ,
501
501
#[ cfg( any( feature = "stm32f103" , feature = "connectivity" ) ) ]
502
- usbpre : UsbPre :: DIV1_5 ,
503
- adcpre : AdcPre :: DIV2 ,
502
+ usbpre : UsbPre :: Div15 ,
503
+ adcpre : AdcPre :: Div2 ,
504
504
}
505
505
}
506
506
}
@@ -509,38 +509,38 @@ impl Default for Config {
509
509
#[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
510
510
pub enum HPre {
511
511
/// SYSCLK not divided
512
- DIV1 = 7 ,
512
+ Div1 = 7 ,
513
513
/// SYSCLK divided by 2
514
- DIV2 = 8 ,
514
+ Div2 = 8 ,
515
515
/// SYSCLK divided by 4
516
- DIV4 = 9 ,
516
+ Div4 = 9 ,
517
517
/// SYSCLK divided by 8
518
- DIV8 = 10 ,
518
+ Div8 = 10 ,
519
519
/// SYSCLK divided by 16
520
- DIV16 = 11 ,
520
+ Div16 = 11 ,
521
521
/// SYSCLK divided by 64
522
- DIV64 = 12 ,
522
+ Div64 = 12 ,
523
523
/// SYSCLK divided by 128
524
- DIV128 = 13 ,
524
+ Div128 = 13 ,
525
525
/// SYSCLK divided by 256
526
- DIV256 = 14 ,
526
+ Div256 = 14 ,
527
527
/// SYSCLK divided by 512
528
- DIV512 = 15 ,
528
+ Div512 = 15 ,
529
529
}
530
530
531
531
#[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
532
532
#[ repr( u8 ) ]
533
533
pub enum PPre {
534
534
/// HCLK not divided
535
- DIV1 = 3 ,
535
+ Div1 = 3 ,
536
536
/// HCLK divided by 2
537
- DIV2 = 4 ,
537
+ Div2 = 4 ,
538
538
/// HCLK divided by 4
539
- DIV4 = 5 ,
539
+ Div4 = 5 ,
540
540
/// HCLK divided by 8
541
- DIV8 = 6 ,
541
+ Div8 = 6 ,
542
542
/// HCLK divided by 16
543
- DIV16 = 7 ,
543
+ Div16 = 7 ,
544
544
}
545
545
546
546
#[ cfg( feature = "stm32f103" ) ]
@@ -582,18 +582,18 @@ impl Config {
582
582
583
583
let hpre_bits = if let Some ( hclk) = cfgr. hclk {
584
584
match sysclk / hclk {
585
- 0 ..=1 => HPre :: DIV1 ,
586
- 2 => HPre :: DIV2 ,
587
- 3 ..=5 => HPre :: DIV4 ,
588
- 6 ..=11 => HPre :: DIV8 ,
589
- 12 ..=39 => HPre :: DIV16 ,
590
- 40 ..=95 => HPre :: DIV64 ,
591
- 96 ..=191 => HPre :: DIV128 ,
592
- 192 ..=383 => HPre :: DIV256 ,
593
- _ => HPre :: DIV512 ,
585
+ 0 ..=1 => HPre :: Div1 ,
586
+ 2 => HPre :: Div2 ,
587
+ 3 ..=5 => HPre :: Div4 ,
588
+ 6 ..=11 => HPre :: Div8 ,
589
+ 12 ..=39 => HPre :: Div16 ,
590
+ 40 ..=95 => HPre :: Div64 ,
591
+ 96 ..=191 => HPre :: Div128 ,
592
+ 192 ..=383 => HPre :: Div256 ,
593
+ _ => HPre :: Div512 ,
594
594
}
595
595
} else {
596
- HPre :: DIV1
596
+ HPre :: Div1
597
597
} ;
598
598
599
599
let hclk = if hpre_bits as u8 >= 0b1100 {
@@ -610,23 +610,23 @@ impl Config {
610
610
36_000_000
611
611
} ;
612
612
let ppre1_bits = match ( hclk + pclk1 - 1 ) / pclk1 {
613
- 0 | 1 => PPre :: DIV1 ,
614
- 2 => PPre :: DIV2 ,
615
- 3 ..=5 => PPre :: DIV4 ,
616
- 6 ..=11 => PPre :: DIV8 ,
617
- _ => PPre :: DIV16 ,
613
+ 0 | 1 => PPre :: Div1 ,
614
+ 2 => PPre :: Div2 ,
615
+ 3 ..=5 => PPre :: Div4 ,
616
+ 6 ..=11 => PPre :: Div8 ,
617
+ _ => PPre :: Div16 ,
618
618
} ;
619
619
620
620
let ppre2_bits = if let Some ( pclk2) = cfgr. pclk2 {
621
621
match hclk / pclk2 {
622
- 0 ..=1 => PPre :: DIV1 ,
623
- 2 => PPre :: DIV2 ,
624
- 3 ..=5 => PPre :: DIV4 ,
625
- 6 ..=11 => PPre :: DIV8 ,
626
- _ => PPre :: DIV16 ,
622
+ 0 ..=1 => PPre :: Div1 ,
623
+ 2 => PPre :: Div2 ,
624
+ 3 ..=5 => PPre :: Div4 ,
625
+ 6 ..=11 => PPre :: Div8 ,
626
+ _ => PPre :: Div16 ,
627
627
}
628
628
} else {
629
- PPre :: DIV1
629
+ PPre :: Div1
630
630
} ;
631
631
632
632
let ppre2 = 1 << ( ppre2_bits as u8 - 0b011 ) ;
@@ -635,19 +635,19 @@ impl Config {
635
635
// usbpre == false: divide clock by 1.5, otherwise no division
636
636
#[ cfg( any( feature = "stm32f103" , feature = "connectivity" ) ) ]
637
637
let usbpre = match ( hse, pllmul_bits, sysclk) {
638
- ( Some ( _) , Some ( _) , 72_000_000 ) => UsbPre :: DIV1_5 ,
639
- _ => UsbPre :: DIV1 ,
638
+ ( Some ( _) , Some ( _) , 72_000_000 ) => UsbPre :: Div15 ,
639
+ _ => UsbPre :: Div1 ,
640
640
} ;
641
641
642
642
let apre_bits = if let Some ( adcclk) = cfgr. adcclk {
643
643
match pclk2 / adcclk {
644
- 0 ..=2 => AdcPre :: DIV2 ,
645
- 3 ..=4 => AdcPre :: DIV4 ,
646
- 5 ..=7 => AdcPre :: DIV6 ,
647
- _ => AdcPre :: DIV8 ,
644
+ 0 ..=2 => AdcPre :: Div2 ,
645
+ 3 ..=4 => AdcPre :: Div4 ,
646
+ 5 ..=7 => AdcPre :: Div6 ,
647
+ _ => AdcPre :: Div8 ,
648
648
}
649
649
} else {
650
- AdcPre :: DIV8
650
+ AdcPre :: Div8
651
651
} ;
652
652
653
653
Self {
@@ -731,12 +731,12 @@ fn rcc_config_usb() {
731
731
let config_expected = Config {
732
732
hse : Some ( 8_000_000 ) ,
733
733
pllmul : Some ( 4 ) ,
734
- hpre : HPre :: DIV1 ,
735
- ppre1 : PPre :: DIV2 ,
736
- ppre2 : PPre :: DIV1 ,
734
+ hpre : HPre :: Div1 ,
735
+ ppre1 : PPre :: Div2 ,
736
+ ppre2 : PPre :: Div1 ,
737
737
#[ cfg( any( feature = "stm32f103" , feature = "connectivity" ) ) ]
738
- usbpre : UsbPre :: DIV1 ,
739
- adcpre : AdcPre :: DIV8 ,
738
+ usbpre : UsbPre :: Div1 ,
739
+ adcpre : AdcPre :: Div8 ,
740
740
} ;
741
741
assert_eq ! ( config, config_expected) ;
742
742
0 commit comments