diff options
author | 2020-12-08 20:49:13 +0100 | |
---|---|---|
committer | 2020-12-08 20:49:13 +0100 | |
commit | b23bb1192c8dc1f2e8f157db2147b1737abc1033 (patch) | |
tree | fa0f369feddc3bf838c74a3c5325c60735edc8ab /macros/src/codegen/timer_queue.rs | |
parent | ef50aeb2e8245b69843280fabb62589c0716ffdd (diff) | |
download | rtic-b23bb1192c8dc1f2e8f157db2147b1737abc1033.tar.gz rtic-b23bb1192c8dc1f2e8f157db2147b1737abc1033.tar.zst rtic-b23bb1192c8dc1f2e8f157db2147b1737abc1033.zip |
TQ handlers being generated
Diffstat (limited to 'macros/src/codegen/timer_queue.rs')
-rw-r--r-- | macros/src/codegen/timer_queue.rs | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/macros/src/codegen/timer_queue.rs b/macros/src/codegen/timer_queue.rs index fa2c7b36..ccde957d 100644 --- a/macros/src/codegen/timer_queue.rs +++ b/macros/src/codegen/timer_queue.rs @@ -8,7 +8,7 @@ use crate::{analyze::Analysis, check::Extra, codegen::util}; pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream2> { let mut items = vec![]; - if let Some(m) = &extra.monotonic { + if !app.monotonics.is_empty() { let t = util::schedule_t_ident(); // Enumeration of `schedule`-able tasks @@ -36,12 +36,17 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream } )); } + } - let tq = util::tq_ident(); + for (_, monotonic) in &app.monotonics { + let monotonic_name = monotonic.ident.to_string(); + let tq = util::tq_ident(&monotonic_name); + let t = util::schedule_t_ident(); + let m = &monotonic.ident; - // Static variable and resource proxy + // Static variables and resource proxy { - let doc = "Timer queue".to_string(); + let doc = &format!("Timer queue for {}", monotonic_name); let cap = app .software_tasks .iter() @@ -71,6 +76,8 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream let rq = util::rq_ident(priority); let rqt = util::spawn_t_ident(priority); let enum_ = util::interrupt_ident(); + + // The interrupt that runs the task dispatcher let interrupt = &analysis.interrupts.get(&priority).expect("RTIC-ICE: interrupt not found").0; let pend = { @@ -90,10 +97,10 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream }) .collect::<Vec<_>>(); - let sys_tick = util::suffixed("SysTick"); + let bound_interrupt = &monotonic.args.binds; items.push(quote!( #[no_mangle] - unsafe fn #sys_tick() { + unsafe fn #bound_interrupt() { use rtic::Mutex as _; while let Some((task, index)) = rtic::export::interrupt::free(|_| #tq.dequeue()) @@ -106,5 +113,6 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream )); } } + items } |