diff --git a/embassy-nrf-examples/src/bin/multiprio.rs b/embassy-nrf-examples/src/bin/multiprio.rs index c6228a1e..9ed5c136 100644 --- a/embassy-nrf-examples/src/bin/multiprio.rs +++ b/embassy-nrf-examples/src/bin/multiprio.rs @@ -135,7 +135,7 @@ fn main() -> ! { // High-priority executor: SWI1_EGU1, priority level 6 let irq = interrupt::take!(SWI1_EGU1); - irq.set_priority(interrupt::Priority::Level6); + irq.set_priority(interrupt::Priority::P6); let alarm = ALARM_HIGH.put(rtc.alarm2()); let executor = EXECUTOR_HIGH.put(InterruptExecutor::new(irq)); executor.set_alarm(alarm); @@ -145,7 +145,7 @@ fn main() -> ! { // Medium-priority executor: SWI0_EGU0, priority level 7 let irq = interrupt::take!(SWI0_EGU0); - irq.set_priority(interrupt::Priority::Level7); + irq.set_priority(interrupt::Priority::P7); let alarm = ALARM_MED.put(rtc.alarm1()); let executor = EXECUTOR_MED.put(InterruptExecutor::new(irq)); executor.set_alarm(alarm); diff --git a/embassy-nrf/src/interrupt.rs b/embassy-nrf/src/interrupt.rs index 8d069e32..a2986197 100644 --- a/embassy-nrf/src/interrupt.rs +++ b/embassy-nrf/src/interrupt.rs @@ -3,48 +3,9 @@ //! This module implements an API for managing interrupts compatible with //! nrf_softdevice::interrupt. Intended for switching between the two at compile-time. -use core::sync::atomic::{compiler_fence, Ordering}; - -use crate::pac::NVIC_PRIO_BITS; - // Re-exports pub use embassy::interrupt::{declare, take, Interrupt}; - -#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] -#[cfg_attr(feature = "defmt", derive(defmt::Format))] -#[repr(u8)] -pub enum Priority { - Level0 = 0, - Level1 = 1, - Level2 = 2, - Level3 = 3, - Level4 = 4, - Level5 = 5, - Level6 = 6, - Level7 = 7, -} - -impl From for Priority { - fn from(priority: u8) -> Self { - match priority >> (8 - NVIC_PRIO_BITS) { - 0 => Self::Level0, - 1 => Self::Level1, - 2 => Self::Level2, - 3 => Self::Level3, - 4 => Self::Level4, - 5 => Self::Level5, - 6 => Self::Level6, - 7 => Self::Level7, - _ => unreachable!(), - } - } -} - -impl From for u8 { - fn from(p: Priority) -> Self { - (p as u8) << (8 - NVIC_PRIO_BITS) - } -} +pub use embassy_extras::interrupt::Priority3 as Priority; #[cfg(feature = "52810")] mod irqs { diff --git a/embassy-rp/src/interrupt.rs b/embassy-rp/src/interrupt.rs index cb9f3654..262f7f54 100644 --- a/embassy-rp/src/interrupt.rs +++ b/embassy-rp/src/interrupt.rs @@ -3,48 +3,9 @@ //! This module implements an API for managing interrupts compatible with //! nrf_softdevice::interrupt. Intended for switching between the two at compile-time. -use core::sync::atomic::{compiler_fence, Ordering}; - -use crate::pac::NVIC_PRIO_BITS; - // Re-exports pub use embassy::interrupt::{declare, take, Interrupt}; - -#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] -#[cfg_attr(feature = "defmt", derive(defmt::Format))] -#[repr(u8)] -pub enum Priority { - Level0 = 0, - Level1 = 1, - Level2 = 2, - Level3 = 3, - Level4 = 4, - Level5 = 5, - Level6 = 6, - Level7 = 7, -} - -impl From for Priority { - fn from(priority: u8) -> Self { - match priority >> (8 - NVIC_PRIO_BITS) { - 0 => Self::Level0, - 1 => Self::Level1, - 2 => Self::Level2, - 3 => Self::Level3, - 4 => Self::Level4, - 5 => Self::Level5, - 6 => Self::Level6, - 7 => Self::Level7, - _ => unreachable!(), - } - } -} - -impl From for u8 { - fn from(p: Priority) -> Self { - (p as u8) << (8 - NVIC_PRIO_BITS) - } -} +pub use embassy_extras::interrupt::Priority3 as Priority; mod irqs { use super::*; diff --git a/embassy-stm32-examples/src/bin/usb_serial.rs b/embassy-stm32-examples/src/bin/usb_serial.rs index e13275dd..38656b97 100644 --- a/embassy-stm32-examples/src/bin/usb_serial.rs +++ b/embassy-stm32-examples/src/bin/usb_serial.rs @@ -41,7 +41,7 @@ async fn run1(bus: &'static mut UsbBusAllocator>) { .build(); let irq = interrupt::take!(OTG_FS); - irq.set_priority(interrupt::Priority::Level3); + irq.set_priority(interrupt::Priority::P3); let usb = Usb::new(device, serial, irq); pin_mut!(usb); diff --git a/embassy-stm32/src/interrupt.rs b/embassy-stm32/src/interrupt.rs index 1d48dc58..76dea28f 100644 --- a/embassy-stm32/src/interrupt.rs +++ b/embassy-stm32/src/interrupt.rs @@ -3,64 +3,9 @@ //! This module implements an API for managing interrupts compatible with //! nrf_softdevice::interrupt. Intended for switching between the two at compile-time. -use core::sync::atomic::{compiler_fence, Ordering}; - -use crate::pac::NVIC_PRIO_BITS; - // Re-exports pub use embassy::interrupt::{declare, take, Interrupt}; - -#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] -#[cfg_attr(feature = "defmt", derive(defmt::Format))] -#[repr(u8)] -pub enum Priority { - Level0 = 0, - Level1 = 1, - Level2 = 2, - Level3 = 3, - Level4 = 4, - Level5 = 5, - Level6 = 6, - Level7 = 7, - Level8 = 8, - Level9 = 9, - Level10 = 10, - Level11 = 11, - Level12 = 12, - Level13 = 13, - Level14 = 14, - Level15 = 15, -} - -impl From for Priority { - fn from(priority: u8) -> Self { - match priority >> (8 - NVIC_PRIO_BITS) { - 0 => Self::Level0, - 1 => Self::Level1, - 2 => Self::Level2, - 3 => Self::Level3, - 4 => Self::Level4, - 5 => Self::Level5, - 6 => Self::Level6, - 7 => Self::Level7, - 8 => Self::Level8, - 9 => Self::Level9, - 10 => Self::Level10, - 11 => Self::Level11, - 12 => Self::Level12, - 13 => Self::Level13, - 14 => Self::Level14, - 15 => Self::Level15, - _ => unreachable!(), - } - } -} - -impl From for u8 { - fn from(p: Priority) -> Self { - (p as u8) << (8 - NVIC_PRIO_BITS) - } -} +pub use embassy_extras::interrupt::Priority4 as Priority; #[cfg(feature = "stm32f401")] mod irqs {