mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-25 21:19:35 +01:00
make logical
non-const
, check input using assertions
This commit is contained in:
parent
fd858a1994
commit
2d6af9b5df
1 changed files with 4 additions and 8 deletions
12
src/lib.rs
12
src/lib.rs
|
@ -249,15 +249,11 @@ unsafe impl<T, Ceiling> Sync for Resource<T, Ceiling> {}
|
||||||
/// priorities encode the actual priority in the highest bits of a byte so
|
/// priorities encode the actual priority in the highest bits of a byte so
|
||||||
/// priorities like `1` and `2` aren't actually different)
|
/// priorities like `1` and `2` aren't actually different)
|
||||||
///
|
///
|
||||||
/// NOTE `logical` must be in the range `[1, 15]` (inclusive)
|
/// NOTE Input `priority` must be in the range `[1, 16]` (inclusive)
|
||||||
pub const fn logical(priority: u8) -> u8 {
|
pub fn logical(priority: u8) -> u8 {
|
||||||
// NOTE elements 1 and 2 of the tuple are a poor man's const context range
|
assert!(priority >= 1 && priority <= 16);
|
||||||
// checker
|
|
||||||
(((1 << PRIORITY_BITS) - priority) << (8 - PRIORITY_BITS),
|
|
||||||
priority - 1,
|
|
||||||
priority + 240)
|
|
||||||
.0
|
|
||||||
|
|
||||||
|
((1 << PRIORITY_BITS) - priority) << (8 - PRIORITY_BITS)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Fake ceiling, indicates that the resource is shared by cooperative tasks
|
/// Fake ceiling, indicates that the resource is shared by cooperative tasks
|
||||||
|
|
Loading…
Reference in a new issue