Enable timer clock in RCC on timer start
* Moves the tim2-specific code into macro which always uses TIM2 * For peripherals without clock specified, attempt to locate enable and reset registers in the RCC block matching the peripheral name. This could be useful for peripherals where deducing the clock name might not be feasible, but it remains to be tested with more chip families to see if it is sufficiently accurate.
This commit is contained in:
@ -16,7 +16,10 @@ pub fn generate(embassy_prefix: &ModulePrefix, config: syn::Expr) -> TokenStream
|
||||
interrupt::take!(TIM2),
|
||||
);
|
||||
let clock = unsafe { make_static(&mut c) };
|
||||
clock.start_tim2();
|
||||
|
||||
// TODO: Is TIM2 always APB1?
|
||||
let timer_freq = unsafe { #embassy_stm32_path::rcc::get_freqs().apb1_clk };
|
||||
clock.start(timer_freq);
|
||||
|
||||
let mut alarm = clock.alarm1();
|
||||
unsafe { #embassy_path::time::set_clock(clock) };
|
||||
|
Reference in New Issue
Block a user