diff options
author | 2023-01-22 03:03:24 +0100 | |
---|---|---|
committer | 2023-01-22 12:00:08 +0100 | |
commit | be74469ab71341da9a564ce1bc3e0e3f17009688 (patch) | |
tree | f4a8c431fb449c394ef80cb171002ba6e58913e8 /macros/src/codegen/timer_queue.rs | |
parent | 3240fb332a7b1b17333ac1c589b303909bde1dc9 (diff) | |
download | rtic-be74469ab71341da9a564ce1bc3e0e3f17009688.tar.gz rtic-be74469ab71341da9a564ce1bc3e0e3f17009688.tar.zst rtic-be74469ab71341da9a564ce1bc3e0e3f17009688.zip |
Enable at least masking out a Monotonic
Simplest case working, but leaves a lot to ask
as shown by examples/cfg-monotonic.rs
Current `rtic-syntax` is unable to validate and
handle the `cfgs[]` which limits the usefulness
of this.
Diffstat (limited to 'macros/src/codegen/timer_queue.rs')
-rw-r--r-- | macros/src/codegen/timer_queue.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/macros/src/codegen/timer_queue.rs b/macros/src/codegen/timer_queue.rs index 32e288c5..f5867dc4 100644 --- a/macros/src/codegen/timer_queue.rs +++ b/macros/src/codegen/timer_queue.rs @@ -13,7 +13,6 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea // Generate the marker counter used to track for `cancel` and `reschedule` let tq_marker = util::timer_queue_marker_ident(); items.push(quote!( - // #[doc = #doc] #[doc(hidden)] #[allow(non_camel_case_types)] #[allow(non_upper_case_globals)] @@ -56,6 +55,7 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea let tq = util::tq_ident(&monotonic_name); let t = util::schedule_t_ident(); let mono_type = &monotonic.ty; + let cfgs = &monotonic.cfgs; let m_ident = util::monotonic_ident(&monotonic_name); // Static variables and resource proxy @@ -76,6 +76,7 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea #[doc(hidden)] #[allow(non_camel_case_types)] #[allow(non_upper_case_globals)] + #(#cfgs)* static #tq: rtic::RacyCell<#tq_ty> = rtic::RacyCell::new(rtic::export::TimerQueue(rtic::export::SortedLinkedList::new_u16())); )); @@ -88,6 +89,7 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea #[doc(hidden)] #[allow(non_camel_case_types)] #[allow(non_upper_case_globals)] + #(#cfgs)* static #mono: rtic::RacyCell<Option<#mono_type>> = rtic::RacyCell::new(None); )); } @@ -126,6 +128,7 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea }) .collect::<Vec<_>>(); + let cfgs = &monotonic.cfgs; let bound_interrupt = &monotonic.args.binds; let disable_isr = if &*bound_interrupt.to_string() == "SysTick" { quote!(core::mem::transmute::<_, rtic::export::SYST>(()).disable_interrupt()) @@ -136,6 +139,7 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea items.push(quote!( #[no_mangle] #[allow(non_snake_case)] + #(#cfgs)* unsafe fn #bound_interrupt() { while let Some((task, index)) = rtic::export::interrupt::free(|_| if let Some(mono) = (&mut *#m_ident.get_mut()).as_mut() { |