diff options
author | 2020-05-19 19:03:19 +0000 | |
---|---|---|
committer | 2020-09-25 14:29:34 +0000 | |
commit | 46bf583cc21bd8fa34e3163149b4327fcc08057e (patch) | |
tree | fc95b5becb044b01fc59aaf27edf5f49ce063b49 /macros/src/codegen/hardware_tasks.rs | |
parent | 5cfd9b92384a6e2d352e35de9da1b7a2b53cc2ea (diff) | |
download | rtic-46bf583cc21bd8fa34e3163149b4327fcc08057e.tar.gz rtic-46bf583cc21bd8fa34e3163149b4327fcc08057e.tar.zst rtic-46bf583cc21bd8fa34e3163149b4327fcc08057e.zip |
Handle user hardware and software tasks and some resources
Diffstat (limited to 'macros/src/codegen/hardware_tasks.rs')
-rw-r--r-- | macros/src/codegen/hardware_tasks.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/macros/src/codegen/hardware_tasks.rs b/macros/src/codegen/hardware_tasks.rs index 7f14b5e1..4f60876a 100644 --- a/macros/src/codegen/hardware_tasks.rs +++ b/macros/src/codegen/hardware_tasks.rs @@ -23,10 +23,13 @@ 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 const_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 app.uses_schedule() { @@ -78,6 +81,13 @@ 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); const_app.push(constructor); @@ -112,7 +122,14 @@ pub fn codegen( #(#stmts)* } )); + + hardware_tasks_imports.push(quote!( + #(#attrs)* + #[allow(non_snake_case)] + use super::#name; + )); + } - (const_app, root, user_tasks) + (const_app, root, user_tasks, hardware_tasks_imports) } |