aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorROMemories <[email protected]>2025-05-21 11:36:55 +0200
committerROMemories <[email protected]>2025-05-21 14:19:16 +0200
commit48b36adafd0e001e5d277f480359396759a0509e (patch)
treea54f0774a21afec589f3a08cac3f825687729caf
parentea243761f727fb4fe2e2a55e85d3f0ac80e6387d (diff)
feat(stm32-h): provide a `const` constructor on `rcc::Config`
-rw-r--r--embassy-stm32/src/rcc/h.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/embassy-stm32/src/rcc/h.rs b/embassy-stm32/src/rcc/h.rs
index eaba8cefb..383f48874 100644
--- a/embassy-stm32/src/rcc/h.rs
+++ b/embassy-stm32/src/rcc/h.rs
@@ -218,13 +218,13 @@ pub struct Config {
218 pub mux: super::mux::ClockMux, 218 pub mux: super::mux::ClockMux,
219} 219}
220 220
221impl Default for Config { 221impl Config {
222 fn default() -> Self { 222 pub const fn new() -> Self {
223 Self { 223 Self {
224 hsi: Some(HSIPrescaler::DIV1), 224 hsi: Some(HSIPrescaler::DIV1),
225 hse: None, 225 hse: None,
226 csi: false, 226 csi: false,
227 hsi48: Some(Default::default()), 227 hsi48: Some(crate::rcc::Hsi48Config::new()),
228 sys: Sysclk::HSI, 228 sys: Sysclk::HSI,
229 pll1: None, 229 pll1: None,
230 pll2: None, 230 pll2: None,
@@ -248,16 +248,22 @@ impl Default for Config {
248 voltage_scale: VoltageScale::Scale0, 248 voltage_scale: VoltageScale::Scale0,
249 #[cfg(rcc_h7rs)] 249 #[cfg(rcc_h7rs)]
250 voltage_scale: VoltageScale::HIGH, 250 voltage_scale: VoltageScale::HIGH,
251 ls: Default::default(), 251 ls: crate::rcc::LsConfig::new(),
252 252
253 #[cfg(any(pwr_h7rm0399, pwr_h7rm0455, pwr_h7rm0468, pwr_h7rs))] 253 #[cfg(any(pwr_h7rm0399, pwr_h7rm0455, pwr_h7rm0468, pwr_h7rs))]
254 supply_config: SupplyConfig::LDO, 254 supply_config: SupplyConfig::LDO,
255 255
256 mux: Default::default(), 256 mux: super::mux::ClockMux::default(),
257 } 257 }
258 } 258 }
259} 259}
260 260
261impl Default for Config {
262 fn default() -> Self {
263 Self::new()
264 }
265}
266
261pub(crate) unsafe fn init(config: Config) { 267pub(crate) unsafe fn init(config: Config) {
262 #[cfg(any(stm32h7))] 268 #[cfg(any(stm32h7))]
263 let pwr_reg = PWR.cr3(); 269 let pwr_reg = PWR.cr3();