aboutsummaryrefslogtreecommitdiff
path: root/macros/src/codegen/spawn_module.rs
diff options
context:
space:
mode:
Diffstat (limited to 'macros/src/codegen/spawn_module.rs')
-rw-r--r--macros/src/codegen/spawn_module.rs79
1 files changed, 79 insertions, 0 deletions
diff --git a/macros/src/codegen/spawn_module.rs b/macros/src/codegen/spawn_module.rs
new file mode 100644
index 00000000..5d3f4652
--- /dev/null
+++ b/macros/src/codegen/spawn_module.rs
@@ -0,0 +1,79 @@
+use proc_macro2::TokenStream as TokenStream2;
+use quote::quote;
+use rtic_syntax::{ast::App, Context};
+use syn::Ident;
+
+#[allow(unused_imports)]
+use crate::{analyze::Analysis, check::Extra, codegen::util};
+
+#[allow(dead_code)]
+pub fn codegen(
+ _spawner: Context,
+ _name: &Ident,
+ _app: &App,
+ _analysis: &Analysis,
+ _extra: &Extra,
+) -> TokenStream2 {
+ // let spawnee = &app.software_tasks[name];
+ // let priority = spawnee.args.priority;
+
+ // let write_instant = if app.uses_schedule() {
+ // let instants = util::instants_ident(name);
+
+ // Some(quote!(
+ // #instants.get_unchecked_mut(usize::from(index)).as_mut_ptr().write(instant);
+ // ))
+ // } else {
+ // None
+ // };
+
+ // let t = util::spawn_t_ident(priority);
+ // let fq = util::fq_ident(name);
+ // let rq = util::rq_ident(priority);
+ // let (dequeue, enqueue) = if spawner.is_init() {
+ // (
+ // quote!(#fq.dequeue()),
+ // quote!(#rq.enqueue_unchecked((#t::#name, index));),
+ // )
+ // } else {
+ // (
+ // quote!((#fq { priority }.lock(|fq| fq.split().1.dequeue()))),
+ // quote!((#rq { priority }.lock(|rq| {
+ // rq.split().0.enqueue_unchecked((#t::#name, index))
+ // }));),
+ // )
+ // };
+
+ // let device = extra.device;
+ // let enum_ = util::interrupt_ident();
+ // let interrupt = &analysis.interrupts.get(&priority);
+ // let pend = {
+ // quote!(
+ // rtic::pend(#device::#enum_::#interrupt);
+ // )
+ // };
+
+ // let (_, tupled, _, _) = util::regroup_inputs(&spawnee.inputs);
+ // let inputs = util::inputs_ident(name);
+ quote!(
+ // unsafe {
+ // use rtic::Mutex as _;
+
+ // let input = #tupled;
+ // // // if let Some(index) = #dequeue {
+ // // // #inputs.get_unchecked_mut(usize::from(index)).as_mut_ptr().write(input);
+
+ // // // #write_instant
+
+ // // // #enqueue
+
+ // // // #pend
+
+ // // // Ok(())
+ // // // } else {
+ // // // Err(input)
+ // // // }
+ // Ok(())
+ // }
+ )
+}