interrupt: transmute instead of steal.

That steal method has a TAKEN=true write [here](6b013138b7/src/peripheral/mod.rs (L180)).
This is not zero cost, we don't want it. Transmute instead, which is zero cost.
This commit is contained in:
Dario Nieuwenhuis 2021-10-16 04:11:19 +02:00
parent 05bc4d198e
commit 4c0fa03c14

View file

@ -1,8 +1,8 @@
use atomic_polyfill::{compiler_fence, AtomicPtr, Ordering};
use core::mem;
use core::ptr;
use cortex_m::peripheral::NVIC;
use atomic_polyfill::{compiler_fence, AtomicPtr, Ordering};
pub use embassy_macros::interrupt_declare as declare;
pub use embassy_macros::interrupt_take as take;
@ -124,9 +124,8 @@ impl<T: Interrupt + ?Sized> InterruptExt for T {
#[inline]
fn set_priority(&self, prio: Self::Priority) {
unsafe {
cortex_m::peripheral::Peripherals::steal()
.NVIC
.set_priority(NrWrap(self.number()), prio.into())
let mut nvic: cortex_m::peripheral::NVIC = mem::transmute(());
nvic.set_priority(NrWrap(self.number()), prio.into())
}
}
}