diff options
| author | Jorge Aparicio <jorge@japaric.io> | 2017-04-21 15:41:03 -0500 |
|---|---|---|
| committer | Jorge Aparicio <jorge@japaric.io> | 2017-04-21 15:41:03 -0500 |
| commit | 1c82f1b1190cb40a3502d5b74a8c98775a788850 (patch) | |
| tree | 4157ac304a4b372e7e4a79daaecf06e7a5c78664 /src/lib.rs | |
| parent | 3e165f2a42b8f3c66e3e77742a54feb875ec4bd6 (diff) | |
raise_to -> Ceiling.raise
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 47 |
1 files changed, 22 insertions, 25 deletions
@@ -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>, |
