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

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

View File

@ -126,13 +126,13 @@ pub struct Config {
pub ls: super::LsConfig,
}
impl Default for Config {
fn default() -> Self {
impl Config {
pub const fn new() -> Self {
Self {
hsi: true,
hse: None,
#[cfg(crs)]
hsi48: Some(Default::default()),
hsi48: Some(crate::rcc::Hsi48Config::new()),
sys: Sysclk::HSI,
pll: None,
@ -147,7 +147,7 @@ impl Default for Config {
apb1_pre: APBPrescaler::DIV1,
#[cfg(not(stm32f0))]
apb2_pre: APBPrescaler::DIV1,
ls: Default::default(),
ls: crate::rcc::LsConfig::new(),
#[cfg(stm32f1)]
// ensure ADC is not out of range by default even if APB2 is maxxed out (36mhz)
@ -163,11 +163,17 @@ impl Default for Config {
#[cfg(stm32f107)]
i2s3_src: I2s2src::SYS,
mux: Default::default(),
mux: super::mux::ClockMux::default(),
}
}
}
impl Default for Config {
fn default() -> Self {
Self::new()
}
}
/// Initialize and Set the clock frequencies
pub(crate) unsafe fn init(config: Config) {
// Turn on the HSI