From 4b0c3bff871eb6125835fd911891bf503c61c820 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Thu, 6 Jul 2017 17:51:34 -0500 Subject: rtfm!: remove init.resources and make idle.local optional --- macros/src/trans.rs | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) (limited to 'macros/src/trans.rs') diff --git a/macros/src/trans.rs b/macros/src/trans.rs index 6cf3a51..14d24fd 100644 --- a/macros/src/trans.rs +++ b/macros/src/trans.rs @@ -33,32 +33,24 @@ fn init(app: &App, main: &mut Vec, root: &mut Vec) { let mut fields = vec![]; let mut exprs = vec![]; let mut lifetime = None; - for name in &app.init.resources { + for (name, resource) in &app.resources { lifetime = Some(quote!('a)); - if let Some(resource) = app.resources.get(name) { - let ty = &resource.ty; - - fields.push(quote! { - pub #name: &'a mut #ty, - }); + let ty = &resource.ty; - exprs.push(quote! { - #name: &mut *super::#name.get(), - }); - } else { - fields.push(quote! { - pub #name: &'a mut ::#device::#name, - }); + fields.push(quote! { + pub #name: &'a mut #ty, + }); - exprs.push(quote! { - #name: &mut *::#device::#name.get(), - }); - } + exprs.push(quote! { + #name: &mut *super::#name.get(), + }); } root.push(quote! { mod init { + pub use ::#device::Peripherals; + #[allow(non_snake_case)] pub struct Resources<#lifetime> { #(#fields)* @@ -122,10 +114,10 @@ fn init(app: &App, main: &mut Vec, root: &mut Vec) { let init = &app.init.path; main.push(quote! { // type check - let init: fn(init::Resources) = #init; + let init: fn(init::Peripherals, init::Resources) = #init; #krate::atomic(|cs| unsafe { - init(init::Resources::new()); + init(init::Peripherals::all(), init::Resources::new()); #(#exceptions)* #(#interrupts)* -- cgit v1.2.3