diff options
| author | Emil Fresk <emil.fresk@gmail.com> | 2023-02-11 08:55:19 +0100 |
|---|---|---|
| committer | Henrik Tjäder <henrik@tjaders.com> | 2023-03-01 00:35:20 +0100 |
| commit | 60f0342b697cdddbab9c0e8c6d772bc7aab9de38 (patch) | |
| tree | 5bbb73e299f416f4c10adf329704b734379caa41 /rtic-macros/src/check.rs | |
| parent | 1cda61fbda205920517f7b63af90c97c38ff9af6 (diff) | |
Break out core specific codegen to bindings
Diffstat (limited to 'rtic-macros/src/check.rs')
| -rw-r--r-- | rtic-macros/src/check.rs | 71 |
1 files changed, 4 insertions, 67 deletions
diff --git a/rtic-macros/src/check.rs b/rtic-macros/src/check.rs index a05c82e..957a9b3 100644 --- a/rtic-macros/src/check.rs +++ b/rtic-macros/src/check.rs @@ -1,70 +1,7 @@ -use std::collections::HashSet; - -use crate::syntax::ast::App; +use crate::codegen::bindings::architecture_specific_analysis; +use crate::syntax::{analyze::Analysis, ast::App}; use syn::parse; -pub fn app(app: &App) -> parse::Result<()> { - // Check that external (device-specific) interrupts are not named after known (Cortex-M) - // exceptions - for name in app.args.dispatchers.keys() { - let name_s = name.to_string(); - - match &*name_s { - "NonMaskableInt" | "HardFault" | "MemoryManagement" | "BusFault" | "UsageFault" - | "SecureFault" | "SVCall" | "DebugMonitor" | "PendSV" | "SysTick" => { - return Err(parse::Error::new( - name.span(), - "Cortex-M exceptions can't be used as `extern` interrupts", - )); - } - - _ => {} - } - } - - // Check that there are enough external interrupts to dispatch the software tasks and the timer - // queue handler - let mut first = None; - let priorities = app - .software_tasks - .iter() - .map(|(name, task)| { - first = Some(name); - task.args.priority - }) - .filter(|prio| *prio > 0) - .collect::<HashSet<_>>(); - - let need = priorities.len(); - let given = app.args.dispatchers.len(); - if need > given { - let s = { - format!( - "not enough interrupts to dispatch \ - all software tasks (need: {need}; given: {given})" - ) - }; - - // If not enough tasks and first still is None, may cause - // "custom attribute panicked" due to unwrap on None - return Err(parse::Error::new(first.unwrap().span(), s)); - } - - // Check that all exceptions are valid; only exceptions with configurable priorities are - // accepted - for (name, task) in &app.hardware_tasks { - let name_s = task.args.binds.to_string(); - match &*name_s { - "NonMaskableInt" | "HardFault" => { - return Err(parse::Error::new( - name.span(), - "only exceptions with configurable priority can be used as hardware tasks", - )); - } - - _ => {} - } - } - - Ok(()) +pub fn app(app: &App, analysis: &Analysis) -> parse::Result<()> { + architecture_specific_analysis(app, analysis) } |
