Assume tim2 in macro and remove clock setup in chip specific rcc init

Add temporary start_tim2() fn to Clock to assist macro in starting
embassy clock
This commit is contained in:
Ulf Lilleengen
2021-05-26 21:42:07 +02:00
parent aaab7d87a5
commit bfa999a2e0
6 changed files with 48 additions and 28 deletions

View File

@ -9,10 +9,14 @@ pub fn generate(embassy_prefix: &ModulePrefix, config: syn::Expr) -> TokenStream
quote!(
use #embassy_stm32_path::{interrupt, peripherals, clock::Clock, time::Hertz};
let (p, mut c) = #embassy_stm32_path::init(#config);
let p = #embassy_stm32_path::init(#config);
let mut c = Clock::new(
unsafe { <peripherals::TIM2 as embassy::util::Steal>::steal() },
interrupt::take!(TIM2),
);
let clock = unsafe { make_static(&mut c) };
clock.start();
clock.start_tim2();
let mut alarm = clock.alarm1();
unsafe { #embassy_path::time::set_clock(clock) };