mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-23 20:22:51 +01:00
mock updated mock_mut still broken
This commit is contained in:
parent
7072115573
commit
586f759c33
1 changed files with 28 additions and 2 deletions
30
src/lib.rs
30
src/lib.rs
|
@ -147,6 +147,33 @@ impl<T, CEILING> Resource<T, C<CEILING>> {
|
||||||
/// [Resource.borrow](struct.Resource.html#method.borrow).
|
/// [Resource.borrow](struct.Resource.html#method.borrow).
|
||||||
#[cfg(not(thumbv6m))]
|
#[cfg(not(thumbv6m))]
|
||||||
pub fn mock<R, PRIOTASK, CURRCEIL, F>(&'static self, _prio: &C<PRIOTASK>, _curr_ceil: &C<CURRCEIL>, f: F) -> R
|
pub fn mock<R, PRIOTASK, CURRCEIL, F>(&'static self, _prio: &C<PRIOTASK>, _curr_ceil: &C<CURRCEIL>, f: F) -> R
|
||||||
|
where
|
||||||
|
F: FnOnce(Ref<T>, &C<CEILING>) -> R,
|
||||||
|
PRIOTASK: Unsigned,
|
||||||
|
CURRCEIL: Unsigned,
|
||||||
|
CEILING: GreaterThanOrEqual<PRIOTASK> + Max<CURRCEIL> + Level + Unsigned,
|
||||||
|
{
|
||||||
|
unsafe {
|
||||||
|
let c1 = <CURRCEIL>::to_u8();
|
||||||
|
let c2 = <CEILING>::to_u8();
|
||||||
|
if c2 > c1 {
|
||||||
|
let old_basepri = basepri::read();
|
||||||
|
basepri_max::write(<CEILING>::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<R, PRIOTASK, CURRCEIL, F>(&'static self, _prio: &mut C<PRIOTASK>, _curr_ceil: &mut C<CURRCEIL>, f: F) -> R
|
||||||
where
|
where
|
||||||
F: FnOnce(Ref<T>, C<CEILING>) -> R,
|
F: FnOnce(Ref<T>, C<CEILING>) -> R,
|
||||||
PRIOTASK: Unsigned,
|
PRIOTASK: Unsigned,
|
||||||
|
@ -161,7 +188,7 @@ impl<T, CEILING> Resource<T, C<CEILING>> {
|
||||||
basepri_max::write(<CEILING>::hw());
|
basepri_max::write(<CEILING>::hw());
|
||||||
barrier!();
|
barrier!();
|
||||||
let ret =
|
let ret =
|
||||||
f(Ref::new(&*self.data.get()), C { _marker: PhantomData });
|
f(Ref::new(&mut *self.data.get()), C { _marker: PhantomData });
|
||||||
barrier!();
|
barrier!();
|
||||||
basepri::write(old_basepri);
|
basepri::write(old_basepri);
|
||||||
ret
|
ret
|
||||||
|
@ -172,7 +199,6 @@ impl<T, CEILING> Resource<T, C<CEILING>> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Like [Resource.lock](struct.Resource.html#method.lock) but returns a
|
/// Like [Resource.lock](struct.Resource.html#method.lock) but returns a
|
||||||
/// `&mut-` reference
|
/// `&mut-` reference
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in a new issue