aboutsummaryrefslogtreecommitdiff
path: root/macros/src/codegen/hardware_tasks.rs
diff options
context:
space:
mode:
authorGravatar Henrik Tjäder <henrik@tjaders.com> 2020-05-19 19:03:19 +0000
committerGravatar Henrik Tjäder <henrik@tjaders.com> 2020-09-25 14:29:34 +0000
commit46bf583cc21bd8fa34e3163149b4327fcc08057e (patch)
treefc95b5becb044b01fc59aaf27edf5f49ce063b49 /macros/src/codegen/hardware_tasks.rs
parent5cfd9b92384a6e2d352e35de9da1b7a2b53cc2ea (diff)
downloadrtic-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.rs19
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)
}