diff options
| author | ROMemories <[email protected]> | 2025-05-21 11:36:55 +0200 |
|---|---|---|
| committer | ROMemories <[email protected]> | 2025-05-21 14:19:04 +0200 |
| commit | 3fcfec7b943c3ac26668c1c168e549fe3009547e (patch) | |
| tree | 234b91b68033c5abf30273ae221bdf756ffffcee | |
| parent | 4e6df1704703d69162fe91416fba6daa12eec0f4 (diff) | |
feat(stm32-f247): provide a `const` constructor on `rcc::Config`
| -rw-r--r-- | embassy-stm32/src/rcc/f247.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/embassy-stm32/src/rcc/f247.rs b/embassy-stm32/src/rcc/f247.rs index ee67f1cc0..8f2e8db5f 100644 --- a/embassy-stm32/src/rcc/f247.rs +++ b/embassy-stm32/src/rcc/f247.rs | |||
| @@ -108,8 +108,8 @@ pub struct Config { | |||
| 108 | pub voltage: VoltageScale, | 108 | pub voltage: VoltageScale, |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | impl Default for Config { | 111 | impl Config { |
| 112 | fn default() -> Self { | 112 | pub const fn new() -> Self { |
| 113 | Self { | 113 | Self { |
| 114 | hsi: true, | 114 | hsi: true, |
| 115 | hse: None, | 115 | hse: None, |
| @@ -127,15 +127,21 @@ impl Default for Config { | |||
| 127 | apb1_pre: APBPrescaler::DIV1, | 127 | apb1_pre: APBPrescaler::DIV1, |
| 128 | apb2_pre: APBPrescaler::DIV1, | 128 | apb2_pre: APBPrescaler::DIV1, |
| 129 | 129 | ||
| 130 | ls: Default::default(), | 130 | ls: crate::rcc::LsConfig::new(), |
| 131 | 131 | ||
| 132 | #[cfg(stm32f2)] | 132 | #[cfg(stm32f2)] |
| 133 | voltage: VoltageScale::Range3, | 133 | voltage: VoltageScale::Range3, |
| 134 | mux: Default::default(), | 134 | mux: super::mux::ClockMux::default(), |
| 135 | } | 135 | } |
| 136 | } | 136 | } |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | impl Default for Config { | ||
| 140 | fn default() -> Self { | ||
| 141 | Self::new() | ||
| 142 | } | ||
| 143 | } | ||
| 144 | |||
| 139 | pub(crate) unsafe fn init(config: Config) { | 145 | pub(crate) unsafe fn init(config: Config) { |
| 140 | // set VOS to SCALE1, if use PLL | 146 | // set VOS to SCALE1, if use PLL |
| 141 | // TODO: check real clock speed before set VOS | 147 | // TODO: check real clock speed before set VOS |
