rcc: more cleanup

This commit is contained in:
xoviat
2023-09-08 18:20:58 -05:00
parent 48154e18bf
commit 11a78fb1e4
12 changed files with 79 additions and 115 deletions

View File

@ -421,33 +421,9 @@ pub(crate) unsafe fn init(config: Config) {
RCC.apb1enr().modify(|w| w.set_pwren(true));
PWR.cr().read();
match config.rtc {
Some(RtcClockSource::LSE) => {
// 1. Unlock the backup domain
PWR.cr().modify(|w| w.set_dbp(true));
// 2. Setup the LSE
RCC.bdcr().modify(|w| {
// Enable LSE
w.set_lseon(true);
});
// Wait until LSE is running
while !RCC.bdcr().read().lserdy() {}
BackupDomain::set_rtc_clock_source(RtcClockSource::LSE);
}
Some(RtcClockSource::LSI) => {
// Turn on the internal 32 kHz LSI oscillator
RCC.csr().modify(|w| w.set_lsion(true));
// Wait until LSI is running
while !RCC.csr().read().lsirdy() {}
BackupDomain::set_rtc_clock_source(RtcClockSource::LSI);
}
_ => todo!(),
}
config
.rtc
.map(|clock_source| BackupDomain::configure_ls(clock_source, None));
set_freqs(Clocks {
sys: sys_clk,