Re-adds embassy macros for stm32

* Hook RCC config into chip config and use chip-specific RCC init
  function
* RTC/clock setup is ignored for now
This commit is contained in:
Ulf Lilleengen
2021-05-25 13:30:42 +02:00
parent 4b98361967
commit 1c10e746b6
7 changed files with 58 additions and 9 deletions

View File

@ -15,5 +15,6 @@ proc-macro = true
[features]
nrf = []
stm32 = []
rp = []
std = []

View File

@ -0,0 +1,26 @@
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!(
use #embassy_stm32_path::{clock::Clock};
let p = #embassy_stm32_path::init(#config);
/*
let mut rtc = #embass::RTC::new(unsafe { <peripherals::TIM2 as #embassy_path::util::Steal>::steal() }, interrupt::take!(TIM2));
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);
*/
)
}

View File

@ -256,6 +256,10 @@ pub fn interrupt_take(item: TokenStream) -> TokenStream {
result.into()
}
#[cfg(feature = "stm32")]
#[path = "chip/stm32.rs"]
mod chip;
#[cfg(feature = "nrf")]
#[path = "chip/nrf.rs"]
mod chip;
@ -273,7 +277,7 @@ struct MainArgs {
config: Option<syn::LitStr>,
}
#[cfg(any(feature = "nrf", feature = "rp"))]
#[cfg(any(feature = "nrf", feature = "rp", feature = "stm32"))]
#[proc_macro_attribute]
pub fn main(args: TokenStream, item: TokenStream) -> TokenStream {
let macro_args = syn::parse_macro_input!(args as syn::AttributeArgs);