examples: use nicer InterrupExt to set irq priority in multprio.
This commit is contained in:
parent
98c821ac39
commit
6653f262d7
5 changed files with 25 additions and 47 deletions
|
@ -57,14 +57,11 @@
|
|||
#![no_main]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
use core::mem;
|
||||
|
||||
use cortex_m::peripheral::NVIC;
|
||||
use cortex_m_rt::entry;
|
||||
use defmt::{info, unwrap};
|
||||
use embassy_executor::{Executor, InterruptExecutor};
|
||||
use embassy_nrf::interrupt;
|
||||
use embassy_nrf::pac::Interrupt;
|
||||
use embassy_nrf::interrupt::{InterruptExt, Priority};
|
||||
use embassy_time::{Duration, Instant, Timer};
|
||||
use static_cell::StaticCell;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
@ -130,16 +127,15 @@ fn main() -> ! {
|
|||
info!("Hello World!");
|
||||
|
||||
let _p = embassy_nrf::init(Default::default());
|
||||
let mut nvic: NVIC = unsafe { mem::transmute(()) };
|
||||
|
||||
// High-priority executor: SWI1_EGU1, priority level 6
|
||||
unsafe { nvic.set_priority(Interrupt::SWI1_EGU1, 6 << 5) };
|
||||
let spawner = EXECUTOR_HIGH.start(Interrupt::SWI1_EGU1);
|
||||
interrupt::SWI1_EGU1.set_priority(Priority::P6);
|
||||
let spawner = EXECUTOR_HIGH.start(interrupt::SWI1_EGU1);
|
||||
unwrap!(spawner.spawn(run_high()));
|
||||
|
||||
// Medium-priority executor: SWI0_EGU0, priority level 7
|
||||
unsafe { nvic.set_priority(Interrupt::SWI0_EGU0, 7 << 5) };
|
||||
let spawner = EXECUTOR_MED.start(Interrupt::SWI0_EGU0);
|
||||
interrupt::SWI0_EGU0.set_priority(Priority::P7);
|
||||
let spawner = EXECUTOR_MED.start(interrupt::SWI0_EGU0);
|
||||
unwrap!(spawner.spawn(run_med()));
|
||||
|
||||
// Low priority executor: runs in thread mode, using WFE/SEV
|
||||
|
|
|
@ -57,14 +57,11 @@
|
|||
#![no_main]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
use core::mem;
|
||||
|
||||
use cortex_m::peripheral::NVIC;
|
||||
use cortex_m_rt::entry;
|
||||
use defmt::{info, unwrap};
|
||||
use embassy_executor::{Executor, InterruptExecutor};
|
||||
use embassy_rp::interrupt;
|
||||
use embassy_rp::pac::Interrupt;
|
||||
use embassy_rp::interrupt::{InterruptExt, Priority};
|
||||
use embassy_time::{Duration, Instant, Timer, TICK_HZ};
|
||||
use static_cell::StaticCell;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
@ -130,18 +127,15 @@ fn main() -> ! {
|
|||
info!("Hello World!");
|
||||
|
||||
let _p = embassy_rp::init(Default::default());
|
||||
let mut nvic: NVIC = unsafe { mem::transmute(()) };
|
||||
|
||||
// High-priority executor: SWI_IRQ_1, priority level 2
|
||||
unsafe { nvic.set_priority(Interrupt::SWI_IRQ_1, 2 << 6) };
|
||||
info!("bla: {}", NVIC::get_priority(Interrupt::SWI_IRQ_1));
|
||||
let spawner = EXECUTOR_HIGH.start(Interrupt::SWI_IRQ_1);
|
||||
interrupt::SWI_IRQ_1.set_priority(Priority::P2);
|
||||
let spawner = EXECUTOR_HIGH.start(interrupt::SWI_IRQ_1);
|
||||
unwrap!(spawner.spawn(run_high()));
|
||||
|
||||
// Medium-priority executor: SWI_IRQ_0, priority level 3
|
||||
unsafe { nvic.set_priority(Interrupt::SWI_IRQ_0, 3 << 6) };
|
||||
info!("bla: {}", NVIC::get_priority(Interrupt::SWI_IRQ_0));
|
||||
let spawner = EXECUTOR_MED.start(Interrupt::SWI_IRQ_0);
|
||||
interrupt::SWI_IRQ_0.set_priority(Priority::P3);
|
||||
let spawner = EXECUTOR_MED.start(interrupt::SWI_IRQ_0);
|
||||
unwrap!(spawner.spawn(run_med()));
|
||||
|
||||
// Low priority executor: runs in thread mode, using WFE/SEV
|
||||
|
|
|
@ -57,14 +57,11 @@
|
|||
#![no_main]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
use core::mem;
|
||||
|
||||
use cortex_m::peripheral::NVIC;
|
||||
use cortex_m_rt::entry;
|
||||
use defmt::*;
|
||||
use embassy_executor::{Executor, InterruptExecutor};
|
||||
use embassy_stm32::interrupt;
|
||||
use embassy_stm32::pac::Interrupt;
|
||||
use embassy_stm32::interrupt::{InterruptExt, Priority};
|
||||
use embassy_time::{Duration, Instant, Timer};
|
||||
use static_cell::StaticCell;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
@ -129,16 +126,15 @@ unsafe fn USART2() {
|
|||
fn main() -> ! {
|
||||
// Initialize and create handle for devicer peripherals
|
||||
let _p = embassy_stm32::init(Default::default());
|
||||
let mut nvic: NVIC = unsafe { mem::transmute(()) };
|
||||
|
||||
// High-priority executor: USART1, priority level 6
|
||||
unsafe { nvic.set_priority(Interrupt::USART1, 6 << 4) };
|
||||
let spawner = EXECUTOR_HIGH.start(Interrupt::USART1);
|
||||
interrupt::USART1.set_priority(Priority::P6);
|
||||
let spawner = EXECUTOR_HIGH.start(interrupt::USART1);
|
||||
unwrap!(spawner.spawn(run_high()));
|
||||
|
||||
// Medium-priority executor: USART2, priority level 7
|
||||
unsafe { nvic.set_priority(Interrupt::USART2, 7 << 4) };
|
||||
let spawner = EXECUTOR_MED.start(Interrupt::USART2);
|
||||
interrupt::USART2.set_priority(Priority::P7);
|
||||
let spawner = EXECUTOR_MED.start(interrupt::USART2);
|
||||
unwrap!(spawner.spawn(run_med()));
|
||||
|
||||
// Low priority executor: runs in thread mode, using WFE/SEV
|
||||
|
|
|
@ -57,14 +57,11 @@
|
|||
#![no_main]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
use core::mem;
|
||||
|
||||
use cortex_m::peripheral::NVIC;
|
||||
use cortex_m_rt::entry;
|
||||
use defmt::*;
|
||||
use embassy_executor::{Executor, InterruptExecutor};
|
||||
use embassy_stm32::interrupt;
|
||||
use embassy_stm32::pac::Interrupt;
|
||||
use embassy_stm32::interrupt::{InterruptExt, Priority};
|
||||
use embassy_time::{Duration, Instant, Timer};
|
||||
use static_cell::StaticCell;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
@ -130,16 +127,15 @@ fn main() -> ! {
|
|||
info!("Hello World!");
|
||||
|
||||
let _p = embassy_stm32::init(Default::default());
|
||||
let mut nvic: NVIC = unsafe { mem::transmute(()) };
|
||||
|
||||
// High-priority executor: UART4, priority level 6
|
||||
unsafe { nvic.set_priority(Interrupt::UART4, 6 << 4) };
|
||||
let spawner = EXECUTOR_HIGH.start(Interrupt::UART4);
|
||||
interrupt::UART4.set_priority(Priority::P6);
|
||||
let spawner = EXECUTOR_HIGH.start(interrupt::UART4);
|
||||
unwrap!(spawner.spawn(run_high()));
|
||||
|
||||
// Medium-priority executor: UART5, priority level 7
|
||||
unsafe { nvic.set_priority(Interrupt::UART5, 7 << 4) };
|
||||
let spawner = EXECUTOR_MED.start(Interrupt::UART5);
|
||||
interrupt::UART5.set_priority(Priority::P7);
|
||||
let spawner = EXECUTOR_MED.start(interrupt::UART5);
|
||||
unwrap!(spawner.spawn(run_med()));
|
||||
|
||||
// Low priority executor: runs in thread mode, using WFE/SEV
|
||||
|
|
|
@ -57,14 +57,11 @@
|
|||
#![no_main]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
use core::mem;
|
||||
|
||||
use cortex_m::peripheral::NVIC;
|
||||
use cortex_m_rt::entry;
|
||||
use defmt::*;
|
||||
use embassy_executor::{Executor, InterruptExecutor};
|
||||
use embassy_stm32::interrupt;
|
||||
use embassy_stm32::pac::Interrupt;
|
||||
use embassy_stm32::interrupt::{InterruptExt, Priority};
|
||||
use embassy_time::{Duration, Instant, Timer};
|
||||
use static_cell::StaticCell;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
@ -130,16 +127,15 @@ fn main() -> ! {
|
|||
info!("Hello World!");
|
||||
|
||||
let _p = embassy_stm32::init(Default::default());
|
||||
let mut nvic: NVIC = unsafe { mem::transmute(()) };
|
||||
|
||||
// High-priority executor: UART4, priority level 6
|
||||
unsafe { nvic.set_priority(Interrupt::UART4, 6 << 4) };
|
||||
let spawner = EXECUTOR_HIGH.start(Interrupt::UART4);
|
||||
interrupt::UART4.set_priority(Priority::P6);
|
||||
let spawner = EXECUTOR_HIGH.start(interrupt::UART4);
|
||||
unwrap!(spawner.spawn(run_high()));
|
||||
|
||||
// Medium-priority executor: UART5, priority level 7
|
||||
unsafe { nvic.set_priority(Interrupt::UART5, 7 << 4) };
|
||||
let spawner = EXECUTOR_MED.start(Interrupt::UART5);
|
||||
interrupt::UART5.set_priority(Priority::P7);
|
||||
let spawner = EXECUTOR_MED.start(interrupt::UART5);
|
||||
unwrap!(spawner.spawn(run_med()));
|
||||
|
||||
// Low priority executor: runs in thread mode, using WFE/SEV
|
||||
|
|
Loading…
Reference in a new issue