stm32/rtc: autocompute prescalers

This commit is contained in:
xoviat
2023-08-29 19:41:03 -05:00
parent fdb2c4946a
commit 989c98f316
5 changed files with 41 additions and 50 deletions

View File

@ -8,7 +8,7 @@ use crate::rtc::sealed::Instance;
impl super::Rtc {
/// Applies the RTC config
/// It this changes the RTC clock source the time will be reset
pub(super) fn configure(&mut self, rtc_config: RtcConfig) {
pub(super) fn configure(&mut self, async_psc: u8, sync_psc: u16) {
self.write(true, |rtc| {
rtc.cr().modify(|w| {
w.set_fmt(Fmt::TWENTYFOURHOUR);
@ -17,8 +17,8 @@ impl super::Rtc {
});
rtc.prer().modify(|w| {
w.set_prediv_s(rtc_config.sync_prescaler);
w.set_prediv_a(rtc_config.async_prescaler);
w.set_prediv_s(sync_psc);
w.set_prediv_a(async_psc);
});
// TODO: configuration for output pins