2021-05-25 13:30:42 +02:00
|
|
|
use crate::path::ModulePrefix;
|
|
|
|
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!(
|
2021-05-25 17:09:01 +02:00
|
|
|
use #embassy_stm32_path::{interrupt, peripherals, clock::Clock, time::Hertz};
|
2021-05-25 13:30:42 +02:00
|
|
|
|
2021-05-25 17:09:01 +02:00
|
|
|
let (p, mut c) = #embassy_stm32_path::init(#config);
|
2021-05-25 13:30:42 +02:00
|
|
|
|
2021-05-25 17:09:01 +02:00
|
|
|
let clock = unsafe { make_static(&mut c) };
|
|
|
|
clock.start();
|
2021-05-25 13:30:42 +02:00
|
|
|
|
2021-05-25 17:09:01 +02:00
|
|
|
let mut alarm = clock.alarm1();
|
|
|
|
unsafe { #embassy_path::time::set_clock(clock) };
|
2021-05-25 13:30:42 +02:00
|
|
|
|
|
|
|
let alarm = unsafe { make_static(&mut alarm) };
|
|
|
|
executor.set_alarm(alarm);
|
|
|
|
)
|
|
|
|
}
|