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

This commit is contained in:
ROMemories 2025-05-21 11:36:55 +02:00
parent 65a22439d5
commit 79b24bd35d

View File

@ -59,9 +59,9 @@ pub struct Config {
pub mux: super::mux::ClockMux, pub mux: super::mux::ClockMux,
} }
impl Default for Config { impl Config {
#[inline] #[inline]
fn default() -> Config { pub const fn new() -> Self {
Config { Config {
hsi: Some(Hsi { hsi: Some(Hsi {
sys_div: HsiSysDiv::DIV4, sys_div: HsiSysDiv::DIV4,
@ -71,12 +71,19 @@ impl Default for Config {
sys: Sysclk::HSISYS, sys: Sysclk::HSISYS,
ahb_pre: AHBPrescaler::DIV1, ahb_pre: AHBPrescaler::DIV1,
apb1_pre: APBPrescaler::DIV1, apb1_pre: APBPrescaler::DIV1,
ls: Default::default(), ls: crate::rcc::LsConfig::new(),
mux: Default::default(), mux: super::mux::ClockMux::default(),
} }
} }
} }
impl Default for Config {
#[inline]
fn default() -> Config {
Self::new()
}
}
pub(crate) unsafe fn init(config: Config) { pub(crate) unsafe fn init(config: Config) {
// Turn on the HSI // Turn on the HSI
match config.hsi { match config.hsi {