aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorROMemories <[email protected]>2025-05-21 11:36:55 +0200
committerROMemories <[email protected]>2025-05-21 14:19:21 +0200
commitda86052586b38768bdc2f709fda299ab06260cdb (patch)
treea79ada0e2a897ead0bd2c512f47caf6fa12fdc06
parent48b36adafd0e001e5d277f480359396759a0509e (diff)
feat(stm32-u5): provide a `const` constructor on `rcc::Config`
-rw-r--r--embassy-stm32/src/rcc/u5.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/embassy-stm32/src/rcc/u5.rs b/embassy-stm32/src/rcc/u5.rs
index 93a327be7..ff70466b9 100644
--- a/embassy-stm32/src/rcc/u5.rs
+++ b/embassy-stm32/src/rcc/u5.rs
@@ -97,14 +97,14 @@ pub struct Config {
97 pub mux: super::mux::ClockMux, 97 pub mux: super::mux::ClockMux,
98} 98}
99 99
100impl Default for Config { 100impl Config {
101 fn default() -> Self { 101 pub const fn new() -> Self {
102 Self { 102 Self {
103 msis: Some(Msirange::RANGE_4MHZ), 103 msis: Some(Msirange::RANGE_4MHZ),
104 msik: Some(Msirange::RANGE_4MHZ), 104 msik: Some(Msirange::RANGE_4MHZ),
105 hse: None, 105 hse: None,
106 hsi: false, 106 hsi: false,
107 hsi48: Some(Default::default()), 107 hsi48: Some(crate::rcc::Hsi48Config::new()),
108 pll1: None, 108 pll1: None,
109 pll2: None, 109 pll2: None,
110 pll3: None, 110 pll3: None,
@@ -114,12 +114,18 @@ impl Default for Config {
114 apb2_pre: APBPrescaler::DIV1, 114 apb2_pre: APBPrescaler::DIV1,
115 apb3_pre: APBPrescaler::DIV1, 115 apb3_pre: APBPrescaler::DIV1,
116 voltage_range: VoltageScale::RANGE1, 116 voltage_range: VoltageScale::RANGE1,
117 ls: Default::default(), 117 ls: crate::rcc::LsConfig::new(),
118 mux: Default::default(), 118 mux: super::mux::ClockMux::default(),
119 } 119 }
120 } 120 }
121} 121}
122 122
123impl Default for Config {
124 fn default() -> Self {
125 Self::new()
126 }
127}
128
123pub(crate) unsafe fn init(config: Config) { 129pub(crate) unsafe fn init(config: Config) {
124 // Set the requested power mode 130 // Set the requested power mode
125 PWR.vosr().modify(|w| w.set_vos(config.voltage_range)); 131 PWR.vosr().modify(|w| w.set_vos(config.voltage_range));