mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-23 20:22:51 +01:00
make as_ceiling
a general method of P<N>
This commit is contained in:
parent
a3cc01df67
commit
ec2df608ca
2 changed files with 10 additions and 11 deletions
10
build.rs
10
build.rs
|
@ -55,7 +55,6 @@ fn main() {
|
||||||
|
|
||||||
// Priorities
|
// Priorities
|
||||||
for i in 0..(1 << bits) + 1 {
|
for i in 0..(1 << bits) + 1 {
|
||||||
let c = Ident::new(format!("C{}", i));
|
|
||||||
let p = Ident::new(format!("P{}", i));
|
let p = Ident::new(format!("P{}", i));
|
||||||
let u = Ident::new(format!("U{}", i));
|
let u = Ident::new(format!("U{}", i));
|
||||||
|
|
||||||
|
@ -76,15 +75,6 @@ fn main() {
|
||||||
quote! {
|
quote! {
|
||||||
#[doc = #doc]
|
#[doc = #doc]
|
||||||
pub type #p = P<::typenum::#u>;
|
pub type #p = P<::typenum::#u>;
|
||||||
|
|
||||||
impl #p {
|
|
||||||
/// Turns this priority into a ceiling
|
|
||||||
pub fn as_ceiling(&self) -> &#c {
|
|
||||||
unsafe {
|
|
||||||
::core::mem::transmute(self)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
11
src/lib.rs
11
src/lib.rs
|
@ -436,7 +436,7 @@ extern crate typenum;
|
||||||
|
|
||||||
use core::cell::UnsafeCell;
|
use core::cell::UnsafeCell;
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
use core::ptr;
|
use core::{mem, ptr};
|
||||||
|
|
||||||
use cortex_m::ctxt::Context;
|
use cortex_m::ctxt::Context;
|
||||||
use cortex_m::interrupt::Nr;
|
use cortex_m::interrupt::Nr;
|
||||||
|
@ -719,6 +719,15 @@ pub struct P<T> {
|
||||||
_marker: PhantomData<T>,
|
_marker: PhantomData<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<N> P<N> {
|
||||||
|
/// Turns this priority into a ceiling
|
||||||
|
pub fn as_ceiling(&self) -> &C<N> {
|
||||||
|
unsafe {
|
||||||
|
mem::transmute(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> P<T>
|
impl<T> P<T>
|
||||||
where
|
where
|
||||||
T: Unsigned,
|
T: Unsigned,
|
||||||
|
|
Loading…
Reference in a new issue