diff options
author | 2023-01-25 20:15:31 +0000 | |
---|---|---|
committer | 2023-01-25 20:15:31 +0000 | |
commit | a601c6e449e7222dcfe73bc2f2c41c95b99b46d7 (patch) | |
tree | d7d079786f98a0b1c9d4e698607236adc3fde6d3 /macros/src/codegen/timer_queue.rs | |
parent | a5e18cd5294870be824f90bdd1d586586c37a153 (diff) | |
parent | 259be7bbf9cfa0ac24c276190515e988d98770b7 (diff) | |
download | rtic-a601c6e449e7222dcfe73bc2f2c41c95b99b46d7.tar.gz rtic-a601c6e449e7222dcfe73bc2f2c41c95b99b46d7.tar.zst rtic-a601c6e449e7222dcfe73bc2f2c41c95b99b46d7.zip |
Merge #691
691: Basic cfg support, kind of, for Monotonics r=korken89 a=AfoHT
- Enable at least masking out a Monotonic
- Add example cfg-ing a Monotonic, showing limitations imposed by rtic-syntax
- Update changelog
The use case detailed in linked issue seems to be covered: Fixes #664
Co-authored-by: Henrik Tjäder <henrik@tjaders.com>
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() { |