From 7614b96fe45240dafe91ae549e712b560e2d4c10 Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Sat, 31 Dec 2022 14:45:13 +0100 Subject: RTIC v2: Initial commit rtic-syntax is now part of RTIC repository --- macros/src/analyze.rs | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) (limited to 'macros/src/analyze.rs') diff --git a/macros/src/analyze.rs b/macros/src/analyze.rs index d255b7f..ec12cfb 100644 --- a/macros/src/analyze.rs +++ b/macros/src/analyze.rs @@ -1,17 +1,17 @@ use core::ops; use std::collections::{BTreeMap, BTreeSet}; -use rtic_syntax::{ +use crate::syntax::{ analyze::{self, Priority}, - ast::{App, ExternInterrupt}, - P, + ast::{App, Dispatcher}, }; use syn::Ident; /// Extend the upstream `Analysis` struct with our field pub struct Analysis { - parent: P, - pub interrupts: BTreeMap, + parent: analyze::Analysis, + pub interrupts_normal: BTreeMap, + pub interrupts_async: BTreeMap, } impl ops::Deref for Analysis { @@ -23,25 +23,43 @@ impl ops::Deref for Analysis { } // Assign an interrupt to each priority level -pub fn app(analysis: P, app: &App) -> P { +pub fn app(analysis: analyze::Analysis, app: &App) -> Analysis { + let mut available_interrupt = app.args.dispatchers.clone(); + // the set of priorities (each priority only once) let priorities = app .software_tasks .values() + .filter(|task| !task.is_async) + .map(|task| task.args.priority) + .collect::>(); + + let priorities_async = app + .software_tasks + .values() + .filter(|task| task.is_async) .map(|task| task.args.priority) .collect::>(); // map from priorities to interrupts (holding name and attributes) - let interrupts: BTreeMap = priorities + + let interrupts_normal: BTreeMap = priorities .iter() .copied() .rev() - .zip(&app.args.extern_interrupts) - .map(|(p, (id, ext))| (p, (id.clone(), ext.clone()))) + .map(|p| (p, available_interrupt.pop().expect("UNREACHABLE"))) .collect(); - P::new(Analysis { + let interrupts_async: BTreeMap = priorities_async + .iter() + .copied() + .rev() + .map(|p| (p, available_interrupt.pop().expect("UNREACHABLE"))) + .collect(); + + Analysis { parent: analysis, - interrupts, - }) + interrupts_normal, + interrupts_async, + } } -- cgit v1.2.3 From f8352122a301c30db7c7851ebf50ad1608ebdad3 Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Tue, 3 Jan 2023 15:10:59 +0100 Subject: Min codegen --- macros/src/analyze.rs | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) (limited to 'macros/src/analyze.rs') diff --git a/macros/src/analyze.rs b/macros/src/analyze.rs index ec12cfb..cb42ad6 100644 --- a/macros/src/analyze.rs +++ b/macros/src/analyze.rs @@ -10,8 +10,7 @@ use syn::Ident; /// Extend the upstream `Analysis` struct with our field pub struct Analysis { parent: analyze::Analysis, - pub interrupts_normal: BTreeMap, - pub interrupts_async: BTreeMap, + pub interrupts: BTreeMap, } impl ops::Deref for Analysis { @@ -30,27 +29,12 @@ pub fn app(analysis: analyze::Analysis, app: &App) -> Analysis { let priorities = app .software_tasks .values() - .filter(|task| !task.is_async) - .map(|task| task.args.priority) - .collect::>(); - - let priorities_async = app - .software_tasks - .values() - .filter(|task| task.is_async) .map(|task| task.args.priority) .collect::>(); // map from priorities to interrupts (holding name and attributes) - let interrupts_normal: BTreeMap = priorities - .iter() - .copied() - .rev() - .map(|p| (p, available_interrupt.pop().expect("UNREACHABLE"))) - .collect(); - - let interrupts_async: BTreeMap = priorities_async + let interrupts: BTreeMap = priorities .iter() .copied() .rev() @@ -59,7 +43,6 @@ pub fn app(analysis: analyze::Analysis, app: &App) -> Analysis { Analysis { parent: analysis, - interrupts_normal, - interrupts_async, + interrupts, } } -- cgit v1.2.3 From 6d252785e83218eeb5d080836281c90b86ca0e03 Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Sun, 8 Jan 2023 21:10:06 +0100 Subject: Support 0 prio tasks --- macros/src/analyze.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'macros/src/analyze.rs') diff --git a/macros/src/analyze.rs b/macros/src/analyze.rs index cb42ad6..65774f6 100644 --- a/macros/src/analyze.rs +++ b/macros/src/analyze.rs @@ -36,6 +36,7 @@ pub fn app(analysis: analyze::Analysis, app: &App) -> Analysis { let interrupts: BTreeMap = priorities .iter() + .filter(|prio| **prio > 0) // 0 prio tasks are run in main .copied() .rev() .map(|p| (p, available_interrupt.pop().expect("UNREACHABLE"))) -- cgit v1.2.3 From 306aa47170fd59369b7a184924e287dc3706d64d Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Mon, 23 Jan 2023 20:05:47 +0100 Subject: Add rtic-timer (timerqueue + monotonic) and rtic-monotonics (systick-monotonic) --- macros/src/analyze.rs | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 macros/src/analyze.rs (limited to 'macros/src/analyze.rs') diff --git a/macros/src/analyze.rs b/macros/src/analyze.rs deleted file mode 100644 index 65774f6..0000000 --- a/macros/src/analyze.rs +++ /dev/null @@ -1,49 +0,0 @@ -use core::ops; -use std::collections::{BTreeMap, BTreeSet}; - -use crate::syntax::{ - analyze::{self, Priority}, - ast::{App, Dispatcher}, -}; -use syn::Ident; - -/// Extend the upstream `Analysis` struct with our field -pub struct Analysis { - parent: analyze::Analysis, - pub interrupts: BTreeMap, -} - -impl ops::Deref for Analysis { - type Target = analyze::Analysis; - - fn deref(&self) -> &Self::Target { - &self.parent - } -} - -// Assign an interrupt to each priority level -pub fn app(analysis: analyze::Analysis, app: &App) -> Analysis { - let mut available_interrupt = app.args.dispatchers.clone(); - - // the set of priorities (each priority only once) - let priorities = app - .software_tasks - .values() - .map(|task| task.args.priority) - .collect::>(); - - // map from priorities to interrupts (holding name and attributes) - - let interrupts: BTreeMap = priorities - .iter() - .filter(|prio| **prio > 0) // 0 prio tasks are run in main - .copied() - .rev() - .map(|p| (p, available_interrupt.pop().expect("UNREACHABLE"))) - .collect(); - - Analysis { - parent: analysis, - interrupts, - } -} -- cgit v1.2.3