aboutsummaryrefslogtreecommitdiff
path: root/macros/src/codegen/dispatchers.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2023-03-04 21:10:24 +0000
committerGitHub <noreply@github.com>2023-03-04 21:10:24 +0000
commit7c7d6558f6d9c50fbb4d2487c98c9a5be15f2f7b (patch)
tree80a47f0dc40059014e9448c4c2eb34c54dff45fe /macros/src/codegen/dispatchers.rs
parent1c5db277e4161470136dbd2a11e914ff1d383581 (diff)
parent98c5490d94950608d31cd5ad9dd260f2f853735c (diff)
Merge #694
694: RTIC 2 r=AfoHT a=korken89 Co-authored-by: Emil Fresk <emil.fresk@gmail.com> Co-authored-by: Per Lindgren <per.lindgren@ltu.se>
Diffstat (limited to 'macros/src/codegen/dispatchers.rs')
-rw-r--r--macros/src/codegen/dispatchers.rs125
1 files changed, 0 insertions, 125 deletions
diff --git a/macros/src/codegen/dispatchers.rs b/macros/src/codegen/dispatchers.rs
deleted file mode 100644
index a90a97c..0000000
--- a/macros/src/codegen/dispatchers.rs
+++ /dev/null
@@ -1,125 +0,0 @@
-use proc_macro2::TokenStream as TokenStream2;
-use quote::quote;
-use rtic_syntax::ast::App;
-
-use crate::{analyze::Analysis, check::Extra, codegen::util};
-
-/// Generates task dispatchers
-pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStream2> {
- let mut items = vec![];
-
- let interrupts = &analysis.interrupts;
-
- for (&level, channel) in &analysis.channels {
- let mut stmts = vec![];
-
- let variants = channel
- .tasks
- .iter()
- .map(|name| {
- let cfgs = &app.software_tasks[name].cfgs;
-
- quote!(
- #(#cfgs)*
- #name
- )
- })
- .collect::<Vec<_>>();
-
- // For future use
- // let doc = format!(
- // "Software tasks to be dispatched at priority level {}",
- // level,
- // );
- let t = util::spawn_t_ident(level);
- items.push(quote!(
- #[allow(non_snake_case)]
- #[allow(non_camel_case_types)]
- #[derive(Clone, Copy)]
- // #[doc = #doc]
- #[doc(hidden)]
- pub enum #t {
- #(#variants,)*
- }
- ));
-
- let n = util::capacity_literal(channel.capacity as usize + 1);
- let rq = util::rq_ident(level);
- let (rq_ty, rq_expr) = {
- (
- quote!(rtic::export::SCRQ<#t, #n>),
- quote!(rtic::export::Queue::new()),
- )
- };
-
- // For future use
- // let doc = format!(
- // "Queue of tasks ready to be dispatched at priority level {}",
- // level
- // );
- items.push(quote!(
- #[doc(hidden)]
- #[allow(non_camel_case_types)]
- #[allow(non_upper_case_globals)]
- static #rq: rtic::RacyCell<#rq_ty> = rtic::RacyCell::new(#rq_expr);
- ));
-
- let arms = channel
- .tasks
- .iter()
- .map(|name| {
- let task = &app.software_tasks[name];
- let cfgs = &task.cfgs;
- let fq = util::fq_ident(name);
- let inputs = util::inputs_ident(name);
- let (_, tupled, pats, _) = util::regroup_inputs(&task.inputs);
-
- quote!(
- #(#cfgs)*
- #t::#name => {
- let #tupled =
- (&*#inputs
- .get())
- .get_unchecked(usize::from(index))
- .as_ptr()
- .read();
- (&mut *#fq.get_mut()).split().0.enqueue_unchecked(index);
- let priority = &rtic::export::Priority::new(PRIORITY);
- #name(
- #name::Context::new(priority)
- #(,#pats)*
- )
- }
- )
- })
- .collect::<Vec<_>>();
-
- stmts.push(quote!(
- while let Some((task, index)) = (&mut *#rq.get_mut()).split().1.dequeue() {
- match task {
- #(#arms)*
- }
- }
- ));
-
- let doc = format!("Interrupt handler to dispatch tasks at priority {}", level);
- let interrupt = util::suffixed(&interrupts[&level].0.to_string());
- let attribute = &interrupts[&level].1.attrs;
- items.push(quote!(
- #[allow(non_snake_case)]
- #[doc = #doc]
- #[no_mangle]
- #(#attribute)*
- unsafe fn #interrupt() {
- /// The priority of this interrupt handler
- const PRIORITY: u8 = #level;
-
- rtic::export::run(PRIORITY, || {
- #(#stmts)*
- });
- }
- ));
- }
-
- items
-}