diff --git a/macros/src/codegen/util.rs b/macros/src/codegen/util.rs index 4a29754bc8..591db62bb3 100644 --- a/macros/src/codegen/util.rs +++ b/macros/src/codegen/util.rs @@ -36,11 +36,32 @@ 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(&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, + &MASKS, + f, + ) + } + } + + #[cfg(armv7m)] #[inline(always)] fn lock(&mut self, f: impl FnOnce(&mut #ty) -> RTIC_INTERNAL_R) -> RTIC_INTERNAL_R { /// Priority ceiling @@ -52,7 +73,6 @@ pub fn impl_mutex( #priority, CEILING, #device::NVIC_PRIO_BITS, - &MASKS, f, ) }