diff options
| author | ROMemories <[email protected]> | 2025-05-21 11:36:55 +0200 |
|---|---|---|
| committer | ROMemories <[email protected]> | 2025-05-21 14:18:52 +0200 |
| commit | 4e6df1704703d69162fe91416fba6daa12eec0f4 (patch) | |
| tree | 1375e9e3d90e9532ab2c948199fdca12be881c0d | |
| parent | 79b24bd35d452d162867480327e7b77296aad8c5 (diff) | |
feat(stm32-f013): provide a `const` constructor on `rcc::Config`
| -rw-r--r-- | embassy-stm32/src/rcc/f013.rs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/embassy-stm32/src/rcc/f013.rs b/embassy-stm32/src/rcc/f013.rs index cfa223d1f..1155b6acd 100644 --- a/embassy-stm32/src/rcc/f013.rs +++ b/embassy-stm32/src/rcc/f013.rs | |||
| @@ -126,13 +126,13 @@ pub struct Config { | |||
| 126 | pub ls: super::LsConfig, | 126 | pub ls: super::LsConfig, |
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | impl Default for Config { | 129 | impl Config { |
| 130 | fn default() -> Self { | 130 | pub const fn new() -> Self { |
| 131 | Self { | 131 | Self { |
| 132 | hsi: true, | 132 | hsi: true, |
| 133 | hse: None, | 133 | hse: None, |
| 134 | #[cfg(crs)] | 134 | #[cfg(crs)] |
| 135 | hsi48: Some(Default::default()), | 135 | hsi48: Some(crate::rcc::Hsi48Config::new()), |
| 136 | sys: Sysclk::HSI, | 136 | sys: Sysclk::HSI, |
| 137 | pll: None, | 137 | pll: None, |
| 138 | 138 | ||
| @@ -147,7 +147,7 @@ impl Default for Config { | |||
| 147 | apb1_pre: APBPrescaler::DIV1, | 147 | apb1_pre: APBPrescaler::DIV1, |
| 148 | #[cfg(not(stm32f0))] | 148 | #[cfg(not(stm32f0))] |
| 149 | apb2_pre: APBPrescaler::DIV1, | 149 | apb2_pre: APBPrescaler::DIV1, |
| 150 | ls: Default::default(), | 150 | ls: crate::rcc::LsConfig::new(), |
| 151 | 151 | ||
| 152 | #[cfg(stm32f1)] | 152 | #[cfg(stm32f1)] |
| 153 | // ensure ADC is not out of range by default even if APB2 is maxxed out (36mhz) | 153 | // ensure ADC is not out of range by default even if APB2 is maxxed out (36mhz) |
| @@ -163,11 +163,17 @@ impl Default for Config { | |||
| 163 | #[cfg(stm32f107)] | 163 | #[cfg(stm32f107)] |
| 164 | i2s3_src: I2s2src::SYS, | 164 | i2s3_src: I2s2src::SYS, |
| 165 | 165 | ||
| 166 | mux: Default::default(), | 166 | mux: super::mux::ClockMux::default(), |
| 167 | } | 167 | } |
| 168 | } | 168 | } |
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | impl Default for Config { | ||
| 172 | fn default() -> Self { | ||
| 173 | Self::new() | ||
| 174 | } | ||
| 175 | } | ||
| 176 | |||
| 171 | /// Initialize and Set the clock frequencies | 177 | /// Initialize and Set the clock frequencies |
| 172 | pub(crate) unsafe fn init(config: Config) { | 178 | pub(crate) unsafe fn init(config: Config) { |
| 173 | // Turn on the HSI | 179 | // Turn on the HSI |
