aboutsummaryrefslogtreecommitdiff
path: root/macros/src/analyze.rs
diff options
context:
space:
mode:
authorEmil Fresk <emil.fresk@gmail.com>2022-12-31 14:45:13 +0100
committerHenrik Tjäder <henrik@tjaders.com>2023-03-01 00:29:10 +0100
commit7614b96fe45240dafe91ae549e712b560e2d4c10 (patch)
tree30e1666c0aac09480e1a87e5fe7965487f4a99e6 /macros/src/analyze.rs
parent1c5db277e4161470136dbd2a11e914ff1d383581 (diff)
RTIC v2: Initial commit
rtic-syntax is now part of RTIC repository
Diffstat (limited to 'macros/src/analyze.rs')
-rw-r--r--macros/src/analyze.rs42
1 files changed, 30 insertions, 12 deletions
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<analyze::Analysis>,
- pub interrupts: BTreeMap<Priority, (Ident, ExternInterrupt)>,
+ parent: analyze::Analysis,
+ pub interrupts_normal: BTreeMap<Priority, (Ident, Dispatcher)>,
+ pub interrupts_async: BTreeMap<Priority, (Ident, Dispatcher)>,
}
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<analyze::Analysis>, app: &App) -> P<Analysis> {
+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::<BTreeSet<_>>();
+
+ let priorities_async = app
+ .software_tasks
+ .values()
+ .filter(|task| task.is_async)
.map(|task| task.args.priority)
.collect::<BTreeSet<_>>();
// map from priorities to interrupts (holding name and attributes)
- let interrupts: BTreeMap<Priority, _> = priorities
+
+ let interrupts_normal: BTreeMap<Priority, _> = 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<Priority, _> = priorities_async
+ .iter()
+ .copied()
+ .rev()
+ .map(|p| (p, available_interrupt.pop().expect("UNREACHABLE")))
+ .collect();
+
+ Analysis {
parent: analysis,
- interrupts,
- })
+ interrupts_normal,
+ interrupts_async,
+ }
}