time: replace dyn clock/alarm with a global Driver trait
This commit is contained in:
@ -3,22 +3,9 @@ use proc_macro2::TokenStream;
|
||||
use quote::quote;
|
||||
|
||||
pub fn generate(embassy_prefix: &ModulePrefix, config: syn::Expr) -> TokenStream {
|
||||
let embassy_path = embassy_prefix.append("embassy").path();
|
||||
let embassy_nrf_path = embassy_prefix.append("embassy_nrf").path();
|
||||
|
||||
quote!(
|
||||
use #embassy_nrf_path::{interrupt, peripherals, rtc};
|
||||
|
||||
let p = #embassy_nrf_path::init(#config);
|
||||
|
||||
let mut rtc = rtc::RTC::new(unsafe { <peripherals::RTC1 as #embassy_path::util::Steal>::steal() }, interrupt::take!(RTC1));
|
||||
let rtc = unsafe { make_static(&mut rtc) };
|
||||
rtc.start();
|
||||
let mut alarm = rtc.alarm0();
|
||||
|
||||
unsafe { #embassy_path::time::set_clock(rtc) };
|
||||
|
||||
let alarm = unsafe { make_static(&mut alarm) };
|
||||
executor.set_alarm(alarm);
|
||||
)
|
||||
}
|
||||
|
@ -3,16 +3,8 @@ use proc_macro2::TokenStream;
|
||||
use quote::quote;
|
||||
|
||||
pub fn generate(embassy_prefix: &ModulePrefix, config: syn::Expr) -> TokenStream {
|
||||
let embassy_path = embassy_prefix.append("embassy").path();
|
||||
let embassy_rp_path = embassy_prefix.append("embassy_rp").path();
|
||||
quote!(
|
||||
use #embassy_rp_path::{interrupt, peripherals};
|
||||
|
||||
let p = #embassy_rp_path::init(#config);
|
||||
|
||||
let alarm = unsafe { <#embassy_rp_path::peripherals::TIMER_ALARM0 as #embassy_path::util::Steal>::steal() };
|
||||
let mut alarm = #embassy_rp_path::timer::Alarm::new(alarm);
|
||||
let alarm = unsafe { make_static(&mut alarm) };
|
||||
executor.set_alarm(alarm);
|
||||
)
|
||||
}
|
||||
|
@ -3,26 +3,9 @@ use proc_macro2::TokenStream;
|
||||
use quote::quote;
|
||||
|
||||
pub fn generate(embassy_prefix: &ModulePrefix, config: syn::Expr) -> TokenStream {
|
||||
let embassy_path = embassy_prefix.append("embassy").path();
|
||||
let embassy_stm32_path = embassy_prefix.append("embassy_stm32").path();
|
||||
|
||||
quote!(
|
||||
use #embassy_stm32_path::{interrupt, peripherals, clock::Clock, time::Hertz};
|
||||
|
||||
let p = #embassy_stm32_path::init(#config);
|
||||
|
||||
let mut c = Clock::new(
|
||||
unsafe { <peripherals::TIM3 as embassy::util::Steal>::steal() },
|
||||
interrupt::take!(TIM3),
|
||||
);
|
||||
let clock = unsafe { make_static(&mut c) };
|
||||
|
||||
clock.start();
|
||||
|
||||
let mut alarm = clock.alarm1();
|
||||
unsafe { #embassy_path::time::set_clock(clock) };
|
||||
|
||||
let alarm = unsafe { make_static(&mut alarm) };
|
||||
executor.set_alarm(alarm);
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user