@@ -22,10 +22,7 @@ pub trait RccExt {
22
22
fn constrain ( self ) -> Rcc ;
23
23
24
24
/// Constrains the `RCC` peripheral and apply clock configuration
25
- fn freeze ( self , rcc_cfg : Config , acr : & mut ACR ) -> Rcc ;
26
-
27
- /// Constrains the `RCC` peripheral and apply clock configuration
28
- fn freeze_raw ( self , rcc_cfg : RawConfig , acr : & mut ACR ) -> Rcc ;
25
+ fn freeze ( self , rcc_cfg : impl Into < RawConfig > , acr : & mut ACR ) -> Rcc ;
29
26
}
30
27
31
28
impl RccExt for RCC {
@@ -36,13 +33,9 @@ impl RccExt for RCC {
36
33
}
37
34
}
38
35
39
- fn freeze ( self , rcc_cfg : Config , acr : & mut ACR ) -> Rcc {
36
+ fn freeze ( self , rcc_cfg : impl Into < RawConfig > , acr : & mut ACR ) -> Rcc {
40
37
self . constrain ( ) . freeze ( rcc_cfg, acr)
41
38
}
42
-
43
- fn freeze_raw ( self , rcc_cfg : RawConfig , acr : & mut ACR ) -> Rcc {
44
- self . constrain ( ) . freeze_raw ( rcc_cfg, acr)
45
- }
46
39
}
47
40
48
41
/// Constrained RCC peripheral
@@ -214,13 +207,8 @@ impl Rcc {
214
207
/// let clocks = rcc.cfgr.freeze(&mut flash.acr);
215
208
/// ```
216
209
#[ inline( always) ]
217
- pub fn freeze ( self , config : Config , acr : & mut ACR ) -> Self {
218
- let cfg = RawConfig :: from_cfgr ( config) ;
219
- self . freeze_raw ( cfg, acr)
220
- }
221
-
222
- #[ inline( always) ]
223
- pub fn freeze_raw ( self , cfg : RawConfig , acr : & mut ACR ) -> Self {
210
+ pub fn freeze ( self , cfg : impl Into < RawConfig > , acr : & mut ACR ) -> Self {
211
+ let cfg = cfg. into ( ) ;
224
212
let clocks = cfg. get_clocks ( ) ;
225
213
// adjust flash wait states
226
214
#[ cfg( any( feature = "stm32f103" , feature = "connectivity" ) ) ]
@@ -631,6 +619,13 @@ pub type UsbPre = rcc::cfgr::USBPRE;
631
619
pub type UsbPre = rcc:: cfgr:: OTGFSPRE ;
632
620
pub type AdcPre = rcc:: cfgr:: ADCPRE ;
633
621
622
+ impl From < Config > for RawConfig {
623
+ #[ inline( always) ]
624
+ fn from ( cfgr : Config ) -> Self {
625
+ Self :: from_cfgr ( cfgr)
626
+ }
627
+ }
628
+
634
629
impl RawConfig {
635
630
pub const fn from_cfgr ( cfgr : Config ) -> Self {
636
631
let hse = cfgr. hse ;
0 commit comments