diff options
Diffstat (limited to 'macros/src/codegen/util.rs')
-rw-r--r-- | macros/src/codegen/util.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/macros/src/codegen/util.rs b/macros/src/codegen/util.rs index 4a29754b..591db62b 100644 --- a/macros/src/codegen/util.rs +++ b/macros/src/codegen/util.rs @@ -36,16 +36,19 @@ pub fn impl_mutex( }; let device = &extra.device; + quote!( #(#cfgs)* impl<'a> rtic::Mutex for #path<'a> { type T = #ty; + #[cfg(not(armv7m))] #[inline(always)] fn lock<RTIC_INTERNAL_R>(&mut self, f: impl FnOnce(&mut #ty) -> RTIC_INTERNAL_R) -> RTIC_INTERNAL_R { /// Priority ceiling const CEILING: u8 = #ceiling; + unsafe { rtic::export::lock( #ptr, @@ -57,6 +60,23 @@ pub fn impl_mutex( ) } } + + #[cfg(armv7m)] + #[inline(always)] + fn lock<RTIC_INTERNAL_R>(&mut self, f: impl FnOnce(&mut #ty) -> RTIC_INTERNAL_R) -> RTIC_INTERNAL_R { + /// Priority ceiling + const CEILING: u8 = #ceiling; + + unsafe { + rtic::export::lock( + #ptr, + #priority, + CEILING, + #device::NVIC_PRIO_BITS, + f, + ) + } + } } ) } |