diff options
author | 2020-10-15 18:50:17 +0200 | |
---|---|---|
committer | 2020-10-21 20:25:05 +0200 | |
commit | f96b25fdf2d7421cc16830a4ccac4ebb3e69cc5d (patch) | |
tree | a782f21ca0659eda6b9b667e197c4927490a7bc4 /macros/src/codegen/hardware_tasks.rs | |
parent | 355cb82d0693fe108ac28ec8a0d77e8aab4e6e06 (diff) | |
download | rtic-f96b25fdf2d7421cc16830a4ccac4ebb3e69cc5d.tar.gz rtic-f96b25fdf2d7421cc16830a4ccac4ebb3e69cc5d.tar.zst rtic-f96b25fdf2d7421cc16830a4ccac4ebb3e69cc5d.zip |
Updated examples
More work
Diffstat (limited to 'macros/src/codegen/hardware_tasks.rs')
-rw-r--r-- | macros/src/codegen/hardware_tasks.rs | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/macros/src/codegen/hardware_tasks.rs b/macros/src/codegen/hardware_tasks.rs index ebfa69b9..e6fa5ed1 100644 --- a/macros/src/codegen/hardware_tasks.rs +++ b/macros/src/codegen/hardware_tasks.rs @@ -1,5 +1,5 @@ use proc_macro2::TokenStream as TokenStream2; -use quote::{format_ident, quote}; +use quote::quote; use rtic_syntax::{ast::App, Context}; use crate::{ @@ -23,13 +23,10 @@ pub fn codegen( Vec<TokenStream2>, // user_hardware_tasks -- the `#[task]` functions written by the user Vec<TokenStream2>, - // user_hardware_tasks_imports -- the imports for `#[task]` functions written by the user - Vec<TokenStream2>, ) { let mut mod_app = vec![]; let mut root = vec![]; let mut user_tasks = vec![]; - let mut hardware_tasks_imports = vec![]; for (name, task) in &app.hardware_tasks { let (let_instant, instant) = if let Some(m) = extra.monotonic { @@ -50,6 +47,8 @@ pub fn codegen( let symbol = task.args.binds.clone(); let priority = task.args.priority; + let app_name = &app.name; + let app_path = quote! {crate::#app_name}; mod_app.push(quote!( #[allow(non_snake_case)] #[no_mangle] @@ -59,7 +58,7 @@ pub fn codegen( #let_instant rtic::export::run(PRIORITY, || { - crate::#name( + #app_path::#name( #locals_new #name::Context::new(&rtic::export::Priority::new(PRIORITY) #instant) ) @@ -79,13 +78,6 @@ pub fn codegen( analysis, ); - // Add resources to imports - let name_res = format_ident!("{}Resources", name); - hardware_tasks_imports.push(quote!( - #[allow(non_snake_case)] - use super::#name_res; - )); - root.push(item); mod_app.push(constructor); @@ -121,13 +113,7 @@ pub fn codegen( #(#stmts)* } )); - - hardware_tasks_imports.push(quote!( - #(#attrs)* - #[allow(non_snake_case)] - use super::#name; - )); } - (mod_app, root, user_tasks, hardware_tasks_imports) + (mod_app, root, user_tasks) } |