Remove Forever, switch to static_cell.

This commit is contained in:
Dario Nieuwenhuis
2022-08-22 15:51:44 +02:00
parent 1b95990258
commit 478f472784
45 changed files with 139 additions and 220 deletions

View File

@ -23,6 +23,7 @@ heapless = { version = "0.7.5", default-features = false }
nb = "1.0.0"
embedded-storage = "0.3.0"
micromath = "2.0.0"
static_cell = "1.0"
usb-device = "0.2"
usbd-serial = "0.1.1"

View File

@ -63,7 +63,7 @@ use embassy_stm32::executor::{Executor, InterruptExecutor};
use embassy_stm32::interrupt;
use embassy_stm32::interrupt::InterruptExt;
use embassy_time::{Duration, Instant, Timer};
use embassy_util::Forever;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::task]
@ -108,9 +108,9 @@ async fn run_low() {
}
}
static EXECUTOR_HIGH: Forever<InterruptExecutor<interrupt::UART4>> = Forever::new();
static EXECUTOR_MED: Forever<InterruptExecutor<interrupt::UART5>> = Forever::new();
static EXECUTOR_LOW: Forever<Executor> = Forever::new();
static EXECUTOR_HIGH: StaticCell<InterruptExecutor<interrupt::UART4>> = StaticCell::new();
static EXECUTOR_MED: StaticCell<InterruptExecutor<interrupt::UART5>> = StaticCell::new();
static EXECUTOR_LOW: StaticCell<Executor> = StaticCell::new();
#[entry]
fn main() -> ! {
@ -121,19 +121,19 @@ fn main() -> ! {
// High-priority executor: SWI1_EGU1, priority level 6
let irq = interrupt::take!(UART4);
irq.set_priority(interrupt::Priority::P6);
let executor = EXECUTOR_HIGH.put(InterruptExecutor::new(irq));
let executor = EXECUTOR_HIGH.init(InterruptExecutor::new(irq));
let spawner = executor.start();
unwrap!(spawner.spawn(run_high()));
// Medium-priority executor: SWI0_EGU0, priority level 7
let irq = interrupt::take!(UART5);
irq.set_priority(interrupt::Priority::P7);
let executor = EXECUTOR_MED.put(InterruptExecutor::new(irq));
let executor = EXECUTOR_MED.init(InterruptExecutor::new(irq));
let spawner = executor.start();
unwrap!(spawner.spawn(run_med()));
// Low priority executor: runs in thread mode, using WFE/SEV
let executor = EXECUTOR_LOW.put(Executor::new());
let executor = EXECUTOR_LOW.init(Executor::new());
executor.run(|spawner| {
unwrap!(spawner.spawn(run_low()));
});