diff options
| author | Jorge Aparicio <jorge@japaric.io> | 2017-07-06 17:51:34 -0500 |
|---|---|---|
| committer | Jorge Aparicio <jorge@japaric.io> | 2017-07-06 17:51:34 -0500 |
| commit | 4b0c3bff871eb6125835fd911891bf503c61c820 (patch) | |
| tree | 7110c0bdd1f87c9cd04092bffb1dad61bb6d5fdb /macros/src/trans.rs | |
| parent | 86a360a3964ecb04a37c0424c76d7b43a9fd40fe (diff) | |
rtfm!: remove init.resources and make idle.local optional
Diffstat (limited to 'macros/src/trans.rs')
| -rw-r--r-- | macros/src/trans.rs | 32 |
1 files changed, 12 insertions, 20 deletions
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<Tokens>, root: &mut Vec<Tokens>) { 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<Tokens>, root: &mut Vec<Tokens>) { 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)* |
