diff options
| author | Dario Nieuwenhuis <[email protected]> | 2021-05-11 01:27:46 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2021-05-11 01:34:24 +0200 |
| commit | e0809ab0fb64ff71be23e2d041d4fbae67dca234 (patch) | |
| tree | 3ac40e1f52a0ed3981d2983074fafe70563548e6 /embassy-rp | |
| parent | e6a8c8bfcce1e882d4cd6b37c83eb6662762810b (diff) | |
Switch to use PrioritX enums.
Diffstat (limited to 'embassy-rp')
| -rw-r--r-- | embassy-rp/src/interrupt.rs | 41 |
1 files changed, 1 insertions, 40 deletions
diff --git a/embassy-rp/src/interrupt.rs b/embassy-rp/src/interrupt.rs index cb9f36546..262f7f546 100644 --- a/embassy-rp/src/interrupt.rs +++ b/embassy-rp/src/interrupt.rs | |||
| @@ -3,48 +3,9 @@ | |||
| 3 | //! This module implements an API for managing interrupts compatible with | 3 | //! This module implements an API for managing interrupts compatible with |
| 4 | //! nrf_softdevice::interrupt. Intended for switching between the two at compile-time. | 4 | //! nrf_softdevice::interrupt. Intended for switching between the two at compile-time. |
| 5 | 5 | ||
| 6 | use core::sync::atomic::{compiler_fence, Ordering}; | ||
| 7 | |||
| 8 | use crate::pac::NVIC_PRIO_BITS; | ||
| 9 | |||
| 10 | // Re-exports | 6 | // Re-exports |
| 11 | pub use embassy::interrupt::{declare, take, Interrupt}; | 7 | pub use embassy::interrupt::{declare, take, Interrupt}; |
| 12 | 8 | pub use embassy_extras::interrupt::Priority3 as Priority; | |
| 13 | #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 14 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 15 | #[repr(u8)] | ||
| 16 | pub enum Priority { | ||
| 17 | Level0 = 0, | ||
| 18 | Level1 = 1, | ||
| 19 | Level2 = 2, | ||
| 20 | Level3 = 3, | ||
| 21 | Level4 = 4, | ||
| 22 | Level5 = 5, | ||
| 23 | Level6 = 6, | ||
| 24 | Level7 = 7, | ||
| 25 | } | ||
| 26 | |||
| 27 | impl From<u8> for Priority { | ||
| 28 | fn from(priority: u8) -> Self { | ||
| 29 | match priority >> (8 - NVIC_PRIO_BITS) { | ||
| 30 | 0 => Self::Level0, | ||
| 31 | 1 => Self::Level1, | ||
| 32 | 2 => Self::Level2, | ||
| 33 | 3 => Self::Level3, | ||
| 34 | 4 => Self::Level4, | ||
| 35 | 5 => Self::Level5, | ||
| 36 | 6 => Self::Level6, | ||
| 37 | 7 => Self::Level7, | ||
| 38 | _ => unreachable!(), | ||
| 39 | } | ||
| 40 | } | ||
| 41 | } | ||
| 42 | |||
| 43 | impl From<Priority> for u8 { | ||
| 44 | fn from(p: Priority) -> Self { | ||
| 45 | (p as u8) << (8 - NVIC_PRIO_BITS) | ||
| 46 | } | ||
| 47 | } | ||
| 48 | 9 | ||
| 49 | mod irqs { | 10 | mod irqs { |
| 50 | use super::*; | 11 | use super::*; |
