diff options
Diffstat (limited to 'macros/src/codegen')
-rw-r--r-- | macros/src/codegen/hardware_tasks.rs | 4 | ||||
-rw-r--r-- | macros/src/codegen/pre_init.rs | 14 | ||||
-rw-r--r-- | macros/src/codegen/util.rs | 12 |
3 files changed, 21 insertions, 9 deletions
diff --git a/macros/src/codegen/hardware_tasks.rs b/macros/src/codegen/hardware_tasks.rs index e7f053d3..a7af510a 100644 --- a/macros/src/codegen/hardware_tasks.rs +++ b/macros/src/codegen/hardware_tasks.rs @@ -50,9 +50,9 @@ pub fn codegen( }; let symbol = if cfg!(feature = "homogeneous") { - util::suffixed(&task.args.binds(name).to_string(), core) + util::suffixed(&task.args.binds.to_string(), core) } else { - task.args.binds(name).clone() + task.args.binds.clone() }; let priority = task.args.priority; diff --git a/macros/src/codegen/pre_init.rs b/macros/src/codegen/pre_init.rs index 19fc6461..948dae54 100644 --- a/macros/src/codegen/pre_init.rs +++ b/macros/src/codegen/pre_init.rs @@ -1,6 +1,6 @@ use proc_macro2::TokenStream as TokenStream2; use quote::quote; -use rtfm_syntax::ast::{App, HardwareTaskKind}; +use rtfm_syntax::ast::App; use crate::{analyze::Analysis, check::Extra, codegen::util}; @@ -52,9 +52,9 @@ pub fn codegen( .get(&core) .iter() .flat_map(|interrupts| *interrupts) - .chain(app.hardware_tasks.iter().flat_map(|(name, task)| { - if task.kind == HardwareTaskKind::Interrupt { - Some((&task.args.priority, task.args.binds(name))) + .chain(app.hardware_tasks.values().flat_map(|task| { + if !util::is_exception(&task.args.binds) { + Some((&task.args.priority, &task.args.binds)) } else { // we do exceptions in another pass None @@ -102,9 +102,9 @@ pub fn codegen( } // set exception priorities - for (name, priority) in app.hardware_tasks.iter().filter_map(|(name, task)| { - if task.kind == HardwareTaskKind::Exception { - Some((task.args.binds(name), task.args.priority)) + for (name, priority) in app.hardware_tasks.values().filter_map(|task| { + if util::is_exception(&task.args.binds) { + Some((&task.args.binds, task.args.priority)) } else { None } diff --git a/macros/src/codegen/util.rs b/macros/src/codegen/util.rs index 8c43b350..cd01264d 100644 --- a/macros/src/codegen/util.rs +++ b/macros/src/codegen/util.rs @@ -113,6 +113,18 @@ pub fn interrupt_ident(core: Core, cores: u8) -> Ident { } } +/// Whether `name` is an exception with configurable priority +pub fn is_exception(name: &Ident) -> bool { + let s = name.to_string(); + + match &*s { + "MemoryManagement" | "BusFault" | "UsageFault" | "SecureFault" | "SVCall" + | "DebugMonitor" | "PendSV" | "SysTick" => true, + + _ => false, + } +} + /// Generates a pre-reexport identifier for the "late resources" struct pub fn late_resources_ident(init: &Ident) -> Ident { Ident::new( |