Provide a way for a peripheral to query its clock frequency

Currently this looks up the frequency in the global singleton that must
be initialized by the per-chip RCC implementation. At present, this is
only done for the L0 family of chips.
This commit is contained in:
Ulf Lilleengen
2021-06-11 09:19:02 +02:00
parent 85f172dd93
commit 952f525af5
6 changed files with 44 additions and 28 deletions

View File

@ -17,9 +17,7 @@ pub fn generate(embassy_prefix: &ModulePrefix, config: syn::Expr) -> TokenStream
);
let clock = unsafe { make_static(&mut c) };
// TODO: Is TIM2 always APB1?
let timer_freq = unsafe { #embassy_stm32_path::rcc::get_freqs().apb1_clk };
clock.start(timer_freq);
clock.start();
let mut alarm = clock.alarm1();
unsafe { #embassy_path::time::set_clock(clock) };