diff --git a/src/lib.rs b/src/lib.rs index b0a23b56e5..4fb110c8c9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -147,6 +147,33 @@ impl Resource> { /// [Resource.borrow](struct.Resource.html#method.borrow). #[cfg(not(thumbv6m))] pub fn mock(&'static self, _prio: &C, _curr_ceil: &C, f: F) -> R + where + F: FnOnce(Ref, &C) -> R, + PRIOTASK: Unsigned, + CURRCEIL: Unsigned, + CEILING: GreaterThanOrEqual + Max + Level + Unsigned, + { + unsafe { + let c1 = ::to_u8(); + let c2 = ::to_u8(); + if c2 > c1 { + let old_basepri = basepri::read(); + basepri_max::write(::hw()); + barrier!(); + let ret = + f(Ref::new(&*self.data.get()), &C { _marker: PhantomData }); + barrier!(); + basepri::write(old_basepri); + ret + } else { + f(Ref::new(&*self.data.get()), &C { _marker: PhantomData }) + + } + } + } +/// Dummy documentation + #[cfg(not(thumbv6m))] + pub fn mock_mut(&'static self, _prio: &mut C, _curr_ceil: &mut C, f: F) -> R where F: FnOnce(Ref, C) -> R, PRIOTASK: Unsigned, @@ -161,7 +188,7 @@ impl Resource> { basepri_max::write(::hw()); barrier!(); let ret = - f(Ref::new(&*self.data.get()), C { _marker: PhantomData }); + f(Ref::new(&mut *self.data.get()), C { _marker: PhantomData }); barrier!(); basepri::write(old_basepri); ret @@ -172,7 +199,6 @@ impl Resource> { } } - /// Like [Resource.lock](struct.Resource.html#method.lock) but returns a /// `&mut-` reference ///