diff options
author | 2022-04-14 11:35:21 +0200 | |
---|---|---|
committer | 2022-04-14 11:35:21 +0200 | |
commit | 688b199c443b59a757b01193097fa3c4e18bcae9 (patch) | |
tree | 45e5267310632fc93aee35e9d5c373cd4c62471c | |
parent | 33174ac65baf0d671a81b870b036056fcfe95ea7 (diff) | |
download | rtic-688b199c443b59a757b01193097fa3c4e18bcae9.tar.gz rtic-688b199c443b59a757b01193097fa3c4e18bcae9.tar.zst rtic-688b199c443b59a757b01193097fa3c4e18bcae9.zip |
lock impl behind cfg
-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, + ) + } + } } ) } |