mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-22 06:42:32 +00:00
Switch to use PrioritX enums.
This commit is contained in:
parent
e6a8c8bfcc
commit
e0809ab0fb
@ -135,7 +135,7 @@ fn main() -> ! {
|
|||||||
|
|
||||||
// High-priority executor: SWI1_EGU1, priority level 6
|
// High-priority executor: SWI1_EGU1, priority level 6
|
||||||
let irq = interrupt::take!(SWI1_EGU1);
|
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 alarm = ALARM_HIGH.put(rtc.alarm2());
|
||||||
let executor = EXECUTOR_HIGH.put(InterruptExecutor::new(irq));
|
let executor = EXECUTOR_HIGH.put(InterruptExecutor::new(irq));
|
||||||
executor.set_alarm(alarm);
|
executor.set_alarm(alarm);
|
||||||
@ -145,7 +145,7 @@ fn main() -> ! {
|
|||||||
|
|
||||||
// Medium-priority executor: SWI0_EGU0, priority level 7
|
// Medium-priority executor: SWI0_EGU0, priority level 7
|
||||||
let irq = interrupt::take!(SWI0_EGU0);
|
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 alarm = ALARM_MED.put(rtc.alarm1());
|
||||||
let executor = EXECUTOR_MED.put(InterruptExecutor::new(irq));
|
let executor = EXECUTOR_MED.put(InterruptExecutor::new(irq));
|
||||||
executor.set_alarm(alarm);
|
executor.set_alarm(alarm);
|
||||||
|
@ -3,48 +3,9 @@
|
|||||||
//! This module implements an API for managing interrupts compatible with
|
//! This module implements an API for managing interrupts compatible with
|
||||||
//! nrf_softdevice::interrupt. Intended for switching between the two at compile-time.
|
//! 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
|
// Re-exports
|
||||||
pub use embassy::interrupt::{declare, take, Interrupt};
|
pub use embassy::interrupt::{declare, take, Interrupt};
|
||||||
|
pub use embassy_extras::interrupt::Priority3 as Priority;
|
||||||
#[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<u8> 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<Priority> for u8 {
|
|
||||||
fn from(p: Priority) -> Self {
|
|
||||||
(p as u8) << (8 - NVIC_PRIO_BITS)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "52810")]
|
#[cfg(feature = "52810")]
|
||||||
mod irqs {
|
mod irqs {
|
||||||
|
@ -3,48 +3,9 @@
|
|||||||
//! This module implements an API for managing interrupts compatible with
|
//! This module implements an API for managing interrupts compatible with
|
||||||
//! nrf_softdevice::interrupt. Intended for switching between the two at compile-time.
|
//! 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
|
// Re-exports
|
||||||
pub use embassy::interrupt::{declare, take, Interrupt};
|
pub use embassy::interrupt::{declare, take, Interrupt};
|
||||||
|
pub use embassy_extras::interrupt::Priority3 as Priority;
|
||||||
#[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<u8> 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<Priority> for u8 {
|
|
||||||
fn from(p: Priority) -> Self {
|
|
||||||
(p as u8) << (8 - NVIC_PRIO_BITS)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mod irqs {
|
mod irqs {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
@ -41,7 +41,7 @@ async fn run1(bus: &'static mut UsbBusAllocator<UsbBus<USB>>) {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
let irq = interrupt::take!(OTG_FS);
|
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);
|
let usb = Usb::new(device, serial, irq);
|
||||||
pin_mut!(usb);
|
pin_mut!(usb);
|
||||||
|
@ -3,64 +3,9 @@
|
|||||||
//! This module implements an API for managing interrupts compatible with
|
//! This module implements an API for managing interrupts compatible with
|
||||||
//! nrf_softdevice::interrupt. Intended for switching between the two at compile-time.
|
//! 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
|
// Re-exports
|
||||||
pub use embassy::interrupt::{declare, take, Interrupt};
|
pub use embassy::interrupt::{declare, take, Interrupt};
|
||||||
|
pub use embassy_extras::interrupt::Priority4 as Priority;
|
||||||
#[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<u8> 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<Priority> for u8 {
|
|
||||||
fn from(p: Priority) -> Self {
|
|
||||||
(p as u8) << (8 - NVIC_PRIO_BITS)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "stm32f401")]
|
#[cfg(feature = "stm32f401")]
|
||||||
mod irqs {
|
mod irqs {
|
||||||
|
Loading…
Reference in New Issue
Block a user