aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs47
1 files changed, 22 insertions, 25 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 70de1a5..910635f 100644
--- a/src/lib.rs
+++ b/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>,