Merge pull request #4019 from techmccat/main

stm32: allow using LSI/LSE as SYSCLK on g0/c0
This commit is contained in:
Dario Nieuwenhuis 2025-03-28 12:20:24 +00:00 committed by GitHub
commit bda7ba7b14
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 4 deletions

View File

@ -3,6 +3,7 @@ pub use crate::pac::rcc::vals::{
Hpre as AHBPrescaler, Hsidiv as HsiSysDiv, Hsikerdiv as HsiKerDiv, Ppre as APBPrescaler, Sw as Sysclk,
};
use crate::pac::{FLASH, RCC};
use crate::rcc::LSI_FREQ;
use crate::time::Hertz;
/// HSI speed
@ -121,9 +122,16 @@ pub(crate) unsafe fn init(config: Config) {
}
};
let rtc = config.ls.init();
let sys = match config.sys {
Sysclk::HSISYS => unwrap!(hsisys),
Sysclk::HSE => unwrap!(hse),
Sysclk::LSI => {
assert!(config.ls.lsi);
LSI_FREQ
}
Sysclk::LSE => unwrap!(config.ls.lse).frequency,
_ => unreachable!(),
};
@ -162,8 +170,6 @@ pub(crate) unsafe fn init(config: Config) {
RCC.cr().modify(|w| w.set_hsion(false));
}
let rtc = config.ls.init();
config.mux.init();
set_clocks!(

View File

@ -5,6 +5,7 @@ pub use crate::pac::rcc::vals::{
Pllr as PllRDiv, Pllsrc as PllSource, Ppre as APBPrescaler, Sw as Sysclk,
};
use crate::pac::{FLASH, PWR, RCC};
use crate::rcc::LSI_FREQ;
use crate::time::Hertz;
/// HSI speed
@ -234,10 +235,17 @@ pub(crate) unsafe fn init(config: Config) {
})
.unwrap_or_default();
let rtc = config.ls.init();
let sys = match config.sys {
Sysclk::HSI => unwrap!(hsisys),
Sysclk::HSE => unwrap!(hse),
Sysclk::PLL1_R => unwrap!(pll.pll_r),
Sysclk::LSI => {
assert!(config.ls.lsi);
LSI_FREQ
}
Sysclk::LSE => unwrap!(config.ls.lse).frequency,
_ => unreachable!(),
};
@ -286,8 +294,6 @@ pub(crate) unsafe fn init(config: Config) {
PWR.cr1().modify(|w| w.set_lpr(true));
}
let rtc = config.ls.init();
config.mux.init();
set_clocks!(