diff options
author | 2021-11-03 16:10:10 +0100 | |
---|---|---|
committer | 2021-11-03 16:10:10 +0100 | |
commit | 20602bd77c59bd752fabb05713bbbeab1c0ad7cc (patch) | |
tree | 11d98de5c161139d0f51ae4d46c24269c32603e5 /macros/src/codegen/util.rs | |
parent | cbde2c7ef95de5767b830b963dc122a661d65efa (diff) | |
download | rtic-20602bd77c59bd752fabb05713bbbeab1c0ad7cc.tar.gz rtic-20602bd77c59bd752fabb05713bbbeab1c0ad7cc.tar.zst rtic-20602bd77c59bd752fabb05713bbbeab1c0ad7cc.zip |
wip tests do not pass
Diffstat (limited to 'macros/src/codegen/util.rs')
-rw-r--r-- | macros/src/codegen/util.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/macros/src/codegen/util.rs b/macros/src/codegen/util.rs index 9f84359c..671f839a 100644 --- a/macros/src/codegen/util.rs +++ b/macros/src/codegen/util.rs @@ -54,6 +54,41 @@ pub fn impl_mutex( ) } +/// Generates a `MutexStruct` implementation +pub fn impl_mutex_struct( + extra: &Extra, + cfgs: &[Attribute], + path: TokenStream2, + ty: TokenStream2, + ceiling: u8, + priority: TokenStream2, + ptr: TokenStream2, +) -> TokenStream2 { + let device = &extra.device; + quote!( + #(#cfgs)* + impl<'a> rtic::MutexStruct for #path<'a> { + type T = #ty; + + #[inline(always)] + fn lock<RTIC_INTERNAL_R>(&mut self, f: impl FnOnce(#ty) -> RTIC_INTERNAL_R) -> RTIC_INTERNAL_R { + /// Priority ceiling + const CEILING: u8 = #ceiling; + + unsafe { + rtic::export::lock_struct( + #ptr, + #priority, + CEILING, + #device::NVIC_PRIO_BITS, + f, + ) + } + } + } + ) +} + /// Generates an identifier for the `INPUTS` buffer (`spawn` & `schedule` API) pub fn inputs_ident(task: &Ident) -> Ident { mark_internal_name(&format!("{}_INPUTS", task)) |