feat(stm32-u5): provide a const constructor on rcc::Config

This commit is contained in:
ROMemories 2025-05-21 11:36:55 +02:00
parent 48b36adafd
commit da86052586

View File

@ -97,14 +97,14 @@ pub struct Config {
pub mux: super::mux::ClockMux, pub mux: super::mux::ClockMux,
} }
impl Default for Config { impl Config {
fn default() -> Self { pub const fn new() -> Self {
Self { Self {
msis: Some(Msirange::RANGE_4MHZ), msis: Some(Msirange::RANGE_4MHZ),
msik: Some(Msirange::RANGE_4MHZ), msik: Some(Msirange::RANGE_4MHZ),
hse: None, hse: None,
hsi: false, hsi: false,
hsi48: Some(Default::default()), hsi48: Some(crate::rcc::Hsi48Config::new()),
pll1: None, pll1: None,
pll2: None, pll2: None,
pll3: None, pll3: None,
@ -114,12 +114,18 @@ impl Default for Config {
apb2_pre: APBPrescaler::DIV1, apb2_pre: APBPrescaler::DIV1,
apb3_pre: APBPrescaler::DIV1, apb3_pre: APBPrescaler::DIV1,
voltage_range: VoltageScale::RANGE1, voltage_range: VoltageScale::RANGE1,
ls: Default::default(), ls: crate::rcc::LsConfig::new(),
mux: Default::default(), mux: super::mux::ClockMux::default(),
} }
} }
} }
impl Default for Config {
fn default() -> Self {
Self::new()
}
}
pub(crate) unsafe fn init(config: Config) { pub(crate) unsafe fn init(config: Config) {
// Set the requested power mode // Set the requested power mode
PWR.vosr().modify(|w| w.set_vos(config.voltage_range)); PWR.vosr().modify(|w| w.set_vos(config.voltage_range));