From c360ffaad8a2349a8bb210c2de2eed40d1765fd7 Mon Sep 17 00:00:00 2001 From: Per Lindgren Date: Sat, 13 Jun 2020 00:19:01 +0200 Subject: wip2 --- macros/src/codegen/util.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'macros/src/codegen/util.rs') diff --git a/macros/src/codegen/util.rs b/macros/src/codegen/util.rs index 68aca5d1..d8d05453 100644 --- a/macros/src/codegen/util.rs +++ b/macros/src/codegen/util.rs @@ -71,13 +71,17 @@ pub fn impl_mutex( #cfg_core impl<'a> rtic::Mutex for #path<'a> { type T = #ty; - #[inline(always)] fn lock(&mut self, f: impl FnOnce(&mut #ty) -> R) -> R { /// Priority ceiling const CEILING: u8 = #ceiling; - unsafe { + if unsafe { self.get_locked() } { + panic!("Resource locked in sequential context"); + }; + unsafe { self.set_locked(true); } + + let r = unsafe { rtic::export::lock( #ptr, #priority, @@ -85,7 +89,9 @@ pub fn impl_mutex( #device::NVIC_PRIO_BITS, f, ) - } + }; + unsafe { self.set_locked(false); } + r } } ) -- cgit v1.2.3