rp/clocks: store clock frequencies in ram

don't recalculate clock frequencies every time they are asked for. while
this is not very often in practice it does consume a bunch of flash
space that cannot be optimized away, and was pulled in unconditionally
previously. while we technically only need the configured rosc, xosc and
gpin frequencies it is easier to store all frequencies (and much cheaper
at runtime too).
This commit is contained in:
pennae
2023-05-16 22:45:50 +02:00
parent 0d4ab559a7
commit f79d8cb2d3
2 changed files with 183 additions and 206 deletions

View File

@ -26,12 +26,7 @@ impl<'d, T: Instance> RealTimeClock<'d, T> {
into_ref!(inner);
// Set the RTC divider
unsafe {
inner
.regs()
.clkdiv_m1()
.write(|w| w.set_clkdiv_m1(clk_rtc_freq() as u16 - 1))
};
unsafe { inner.regs().clkdiv_m1().write(|w| w.set_clkdiv_m1(clk_rtc_freq() - 1)) };
let mut result = Self { inner };
result.set_leap_year_check(true); // should be on by default, make sure this is the case.