diff options
Diffstat (limited to 'macros/src/codegen/async_dispatchers.rs')
-rw-r--r-- | macros/src/codegen/async_dispatchers.rs | 66 |
1 files changed, 24 insertions, 42 deletions
diff --git a/macros/src/codegen/async_dispatchers.rs b/macros/src/codegen/async_dispatchers.rs index 8b0e928b..aa854d7f 100644 --- a/macros/src/codegen/async_dispatchers.rs +++ b/macros/src/codegen/async_dispatchers.rs @@ -7,65 +7,47 @@ use quote::quote; pub fn codegen(app: &App, analysis: &Analysis) -> Vec<TokenStream2> { let mut items = vec![]; - let interrupts = &analysis.interrupts_async; + let interrupts = &analysis.interrupts; // Generate executor definition and priority in global scope - for (name, task) in app.software_tasks.iter() { - if task.is_async { - let type_name = util::internal_task_ident(name, "F"); - let exec_name = util::internal_task_ident(name, "EXEC"); - let prio_name = util::internal_task_ident(name, "PRIORITY"); + for (name, _) in app.software_tasks.iter() { + let type_name = util::internal_task_ident(name, "F"); + let exec_name = util::internal_task_ident(name, "EXEC"); + let prio_name = util::internal_task_ident(name, "PRIORITY"); - items.push(quote!( - #[allow(non_camel_case_types)] - type #type_name = impl core::future::Future + 'static; - #[allow(non_upper_case_globals)] - static #exec_name: - rtic::RacyCell<rtic::export::executor::AsyncTaskExecutor<#type_name>> = - rtic::RacyCell::new(rtic::export::executor::AsyncTaskExecutor::new()); - - // The executors priority, this can be any value - we will overwrite it when we - // start a task - #[allow(non_upper_case_globals)] - static #prio_name: rtic::RacyCell<rtic::export::Priority> = - unsafe { rtic::RacyCell::new(rtic::export::Priority::new(0)) }; - )); - } + items.push(quote!( + #[allow(non_camel_case_types)] + type #type_name = impl core::future::Future + 'static; + #[allow(non_upper_case_globals)] + static #exec_name: + rtic::RacyCell<rtic::export::executor::AsyncTaskExecutor<#type_name>> = + rtic::RacyCell::new(rtic::export::executor::AsyncTaskExecutor::new()); + + // The executors priority, this can be any value - we will overwrite it when we + // start a task + #[allow(non_upper_case_globals)] + static #prio_name: rtic::RacyCell<rtic::export::Priority> = + unsafe { rtic::RacyCell::new(rtic::export::Priority::new(0)) }; + )); } for (&level, channel) in &analysis.channels { - if channel - .tasks - .iter() - .map(|task_name| !app.software_tasks[task_name].is_async) - .all(|is_not_async| is_not_async) - { - // check if all tasks are not async, if so don't generate this. - continue; - } - let mut stmts = vec![]; let device = &app.args.device; let enum_ = util::interrupt_ident(); let interrupt = util::suffixed(&interrupts[&level].0.to_string()); - for name in channel - .tasks - .iter() - .filter(|name| app.software_tasks[*name].is_async) - { + for name in channel.tasks.iter() { let exec_name = util::internal_task_ident(name, "EXEC"); let prio_name = util::internal_task_ident(name, "PRIORITY"); - let task = &app.software_tasks[name]; + // let task = &app.software_tasks[name]; // let cfgs = &task.cfgs; - let (_, tupled, pats, input_types) = util::regroup_inputs(&task.inputs); let executor_run_ident = util::executor_run_ident(name); - let n = util::capacity_literal(channel.capacity as usize + 1); let rq = util::rq_async_ident(name); let (rq_ty, rq_expr) = { ( - quote!(rtic::export::ASYNCRQ<#input_types, #n>), + quote!(rtic::export::ASYNCRQ<(), 2>), // TODO: This needs updating to a counter instead of a queue quote!(rtic::export::Queue::new()), ) }; @@ -79,13 +61,13 @@ pub fn codegen(app: &App, analysis: &Analysis) -> Vec<TokenStream2> { stmts.push(quote!( if !(&*#exec_name.get()).is_running() { - if let Some(#tupled) = rtic::export::interrupt::free(|_| (&mut *#rq.get_mut()).dequeue()) { + if let Some(()) = rtic::export::interrupt::free(|_| (&mut *#rq.get_mut()).dequeue()) { // The async executor needs a static priority #prio_name.get_mut().write(rtic::export::Priority::new(PRIORITY)); let priority: &'static _ = &*#prio_name.get(); - (&mut *#exec_name.get_mut()).spawn(#name(#name::Context::new(priority) #(,#pats)*)); + (&mut *#exec_name.get_mut()).spawn(#name(#name::Context::new(priority))); #executor_run_ident.store(true, core::sync::atomic::Ordering::Relaxed); } } |