diff options
Diffstat (limited to 'macros/src/codegen/hardware_tasks.rs')
-rw-r--r-- | macros/src/codegen/hardware_tasks.rs | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/macros/src/codegen/hardware_tasks.rs b/macros/src/codegen/hardware_tasks.rs index 003660c7..e6192e2c 100644 --- a/macros/src/codegen/hardware_tasks.rs +++ b/macros/src/codegen/hardware_tasks.rs @@ -5,7 +5,7 @@ use rtic_syntax::{ast::App, Context}; use crate::{ analyze::Analysis, check::Extra, - codegen::{locals, module, resources_struct}, + codegen::{local_resources_struct, module, shared_resources_struct}, }; /// Generate support code for hardware tasks (`#[exception]`s and `#[interrupt]`s) @@ -29,12 +29,6 @@ pub fn codegen( let mut user_tasks = vec![]; for (name, task) in &app.hardware_tasks { - let locals_new = if task.locals.is_empty() { - quote!() - } else { - quote!(#name::Locals::new(),) - }; - let symbol = task.args.binds.clone(); let priority = task.args.priority; let cfgs = &task.cfgs; @@ -50,19 +44,35 @@ pub fn codegen( rtic::export::run(PRIORITY, || { #name( - #locals_new #name::Context::new(&rtic::export::Priority::new(PRIORITY)) ) }); } )); - let mut needs_lt = false; + let mut shared_needs_lt = false; + let mut local_needs_lt = false; + + // `${task}Locals` + if !task.args.local_resources.is_empty() { + let (item, constructor) = local_resources_struct::codegen( + Context::HardwareTask(name), + &mut local_needs_lt, + app, + ); + + root.push(item); + + mod_app.push(constructor); + } // `${task}Resources` - if !task.args.resources.is_empty() { - let (item, constructor) = - resources_struct::codegen(Context::HardwareTask(name), &mut needs_lt, app); + if !task.args.shared_resources.is_empty() { + let (item, constructor) = shared_resources_struct::codegen( + Context::HardwareTask(name), + &mut shared_needs_lt, + app, + ); root.push(item); @@ -71,30 +81,21 @@ pub fn codegen( root.push(module::codegen( Context::HardwareTask(name), - needs_lt, + shared_needs_lt, + local_needs_lt, app, analysis, extra, )); - // `${task}Locals` - let mut locals_pat = None; - if !task.locals.is_empty() { - let (struct_, pat) = locals::codegen(Context::HardwareTask(name), &task.locals, app); - - root.push(struct_); - locals_pat = Some(pat); - } - - if !&task.is_extern { + if !task.is_extern { let attrs = &task.attrs; let context = &task.context; let stmts = &task.stmts; - let locals_pat = locals_pat.iter(); user_tasks.push(quote!( #(#attrs)* #[allow(non_snake_case)] - fn #name(#(#locals_pat,)* #context: #name::Context) { + fn #name(#context: #name::Context) { use rtic::Mutex as _; use rtic::mutex_prelude::*; |