mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-19 06:15:45 +01:00
raise_to -> Ceiling.raise
This commit is contained in:
parent
3e165f2a42
commit
1c82f1b119
6 changed files with 31 additions and 34 deletions
47
src/lib.rs
47
src/lib.rs
|
|
@ -522,31 +522,6 @@ where
|
|||
r
|
||||
}
|
||||
|
||||
/// Raises the system ceiling to match `resource`'s ceiling
|
||||
#[cfg(not(thumbv6m))]
|
||||
pub fn raise_to<R, CURRENT, HIGHER, RES, F>(
|
||||
_current_ceiling: &C<CURRENT>,
|
||||
_resource: &RES,
|
||||
f: F,
|
||||
) -> R
|
||||
where
|
||||
F: FnOnce(&C<HIGHER>) -> R,
|
||||
RES: ResourceLike<Ceiling = HIGHER>,
|
||||
HIGHER: Cmp<CURRENT, Output = Greater>,
|
||||
HIGHER: Cmp<UMAX, Output = Less>,
|
||||
HIGHER: Unsigned,
|
||||
{
|
||||
unsafe {
|
||||
let old_basepri = basepri::read();
|
||||
basepri_max::write(logical2hw(HIGHER::to_u8()));
|
||||
barrier!();
|
||||
let ret = f(&C { _marker: PhantomData });
|
||||
barrier!();
|
||||
basepri::write(old_basepri);
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
||||
/// Requests the execution of a `task`
|
||||
pub fn request<T, PRIORITY>(_task: fn(T, P<PRIORITY>))
|
||||
where
|
||||
|
|
@ -586,6 +561,28 @@ pub struct C<T> {
|
|||
_marker: PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<CURRENT> C<CURRENT> {
|
||||
/// Raises the ceiling to match `resource`'s ceiling
|
||||
pub fn raise<HIGHER, RES, R, F>(&self, _resource: &'static RES, f: F) -> R
|
||||
where
|
||||
RES: ResourceLike<Ceiling = HIGHER>,
|
||||
HIGHER: Cmp<CURRENT, Output = Greater>,
|
||||
HIGHER: Cmp<UMAX, Output = Less>,
|
||||
HIGHER: Unsigned,
|
||||
F: FnOnce(&C<HIGHER>) -> R,
|
||||
{
|
||||
unsafe {
|
||||
let old_basepri = basepri::read();
|
||||
basepri_max::write(logical2hw(HIGHER::to_u8()));
|
||||
barrier!();
|
||||
let ret = f(&C { _marker: PhantomData });
|
||||
barrier!();
|
||||
basepri::write(old_basepri);
|
||||
ret
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A type-level priority
|
||||
pub struct P<T> {
|
||||
_marker: PhantomData<T>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue