Ulf Lilleengen 37b3d8b22c Add embassy_prefix attribute parameter to task and main macros
This allows crates depending on embassy that wants to use a different
module path to do so for the 'task' and 'main' macros, by passing the
parameter 'embassy_prefix'. The prefix defaults to '::', which will
retain the existing behavior.
2021-04-14 11:06:30 +02:00

21 lines
554 B
Rust

use crate::path::ModulePrefix;
use darling::FromMeta;
use proc_macro2::TokenStream;
use quote::quote;
#[derive(Debug, FromMeta, Default)]
pub struct Args {
#[darling(default)]
pub embassy_prefix: ModulePrefix,
}
pub fn generate(args: &Args) -> TokenStream {
let embassy_rp_path = args.embassy_prefix.append("embassy_rp").path();
quote!(
use #embassy_rp_path::{interrupt, peripherals};
let mut config = #embassy_rp_path::system::Config::default();
unsafe { #embassy_rp_path::system::configure(config) };
)
}