diff options
| author | Dario Nieuwenhuis <[email protected]> | 2021-10-16 04:11:19 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2021-10-16 04:11:19 +0200 |
| commit | 4c0fa03c14b95726e4107a65e54601e07d6653ae (patch) | |
| tree | dfe2295a72f3c09a34c90e67cec917c14e37b9c6 | |
| parent | 05bc4d198e558a153d78e0fa07228c73023c4b5b (diff) | |
interrupt: transmute instead of steal.
That steal method has a TAKEN=true write [here](https://github.com/rust-embedded/cortex-m/blob/6b013138b734b9bbeb24a345f75d2bcc1c69fa8d/src/peripheral/mod.rs#L180).
This is not zero cost, we don't want it. Transmute instead, which is zero cost.
| -rw-r--r-- | embassy/src/interrupt.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/embassy/src/interrupt.rs b/embassy/src/interrupt.rs index df3a79ccc..7848ee698 100644 --- a/embassy/src/interrupt.rs +++ b/embassy/src/interrupt.rs | |||
| @@ -1,8 +1,8 @@ | |||
| 1 | use atomic_polyfill::{compiler_fence, AtomicPtr, Ordering}; | ||
| 2 | use core::mem; | ||
| 1 | use core::ptr; | 3 | use core::ptr; |
| 2 | use cortex_m::peripheral::NVIC; | 4 | use cortex_m::peripheral::NVIC; |
| 3 | 5 | ||
| 4 | use atomic_polyfill::{compiler_fence, AtomicPtr, Ordering}; | ||
| 5 | |||
| 6 | pub use embassy_macros::interrupt_declare as declare; | 6 | pub use embassy_macros::interrupt_declare as declare; |
| 7 | pub use embassy_macros::interrupt_take as take; | 7 | pub use embassy_macros::interrupt_take as take; |
| 8 | 8 | ||
| @@ -124,9 +124,8 @@ impl<T: Interrupt + ?Sized> InterruptExt for T { | |||
| 124 | #[inline] | 124 | #[inline] |
| 125 | fn set_priority(&self, prio: Self::Priority) { | 125 | fn set_priority(&self, prio: Self::Priority) { |
| 126 | unsafe { | 126 | unsafe { |
| 127 | cortex_m::peripheral::Peripherals::steal() | 127 | let mut nvic: cortex_m::peripheral::NVIC = mem::transmute(()); |
| 128 | .NVIC | 128 | nvic.set_priority(NrWrap(self.number()), prio.into()) |
| 129 | .set_priority(NrWrap(self.number()), prio.into()) | ||
| 130 | } | 129 | } |
| 131 | } | 130 | } |
| 132 | } | 131 | } |
