Update to static-executor "multi"

This commit is contained in:
Dario Nieuwenhuis 2020-09-24 22:04:45 +02:00
parent 3b39ab07e5
commit f8d63b1f30
6 changed files with 31 additions and 13 deletions

View File

@ -10,8 +10,7 @@ members = [
panic-probe = { git = "https://github.com/knurling-rs/probe-run", branch="main" } panic-probe = { git = "https://github.com/knurling-rs/probe-run", branch="main" }
defmt-rtt = { git = "https://github.com/knurling-rs/defmt", branch="cursed-symbol-names-linkers-must-repent-for-their-sins" } defmt-rtt = { git = "https://github.com/knurling-rs/defmt", branch="cursed-symbol-names-linkers-must-repent-for-their-sins" }
defmt = { git = "https://github.com/knurling-rs/defmt", branch="cursed-symbol-names-linkers-must-repent-for-their-sins" } defmt = { git = "https://github.com/knurling-rs/defmt", branch="cursed-symbol-names-linkers-must-repent-for-their-sins" }
static-executor = { git = "https://github.com/Dirbaio/static-executor" } static-executor = { git = "https://github.com/Dirbaio/static-executor", branch="multi"}
static-executor-cortex-m = { git = "https://github.com/Dirbaio/static-executor" }
[profile.dev] [profile.dev]
codegen-units = 1 codegen-units = 1

View File

@ -27,5 +27,4 @@ nrf52840-hal = { version = "0.11.0" }
embassy = { version = "0.1.0", path = "../embassy" } embassy = { version = "0.1.0", path = "../embassy" }
embassy-nrf = { version = "0.1.0", path = "../embassy-nrf", features = ["defmt-trace", "52840"] } embassy-nrf = { version = "0.1.0", path = "../embassy-nrf", features = ["defmt-trace", "52840"] }
static-executor = { version = "0.1.0", features=["defmt"]} static-executor = { version = "0.1.0", features=["defmt"]}
static-executor-cortex-m = { version = "0.1.0" }
futures = { version = "0.3.5", default-features = false } futures = { version = "0.3.5", default-features = false }

View File

@ -13,7 +13,10 @@ use embassy_nrf::gpiote;
use futures::pin_mut; use futures::pin_mut;
use nrf52840_hal::gpio; use nrf52840_hal::gpio;
#[static_executor::task] use static_executor::{task, Executor};
static EXECUTOR: Executor = Executor::new(|| cortex_m::asm::sev());
#[task]
async fn run() { async fn run() {
let p = embassy_nrf::pac::Peripherals::take().dewrap(); let p = embassy_nrf::pac::Peripherals::take().dewrap();
let port0 = gpio::p0::Parts::new(p.P0); let port0 = gpio::p0::Parts::new(p.P0);
@ -78,7 +81,11 @@ fn main() -> ! {
info!("Hello World!"); info!("Hello World!");
unsafe { unsafe {
run.spawn().dewrap(); EXECUTOR.spawn(run()).dewrap();
static_executor::run();
loop {
EXECUTOR.run();
cortex_m::asm::wfe();
}
} }
} }

View File

@ -11,6 +11,9 @@ use embassy::flash::Flash;
use embassy_nrf::qspi; use embassy_nrf::qspi;
use nrf52840_hal::gpio; use nrf52840_hal::gpio;
use static_executor::{task, Executor};
static EXECUTOR: Executor = Executor::new(|| cortex_m::asm::sev());
const PAGE_SIZE: usize = 4096; const PAGE_SIZE: usize = 4096;
// Workaround for alignment requirements. // Workaround for alignment requirements.
@ -18,7 +21,7 @@ const PAGE_SIZE: usize = 4096;
#[repr(C, align(4))] #[repr(C, align(4))]
struct AlignedBuf([u8; 4096]); struct AlignedBuf([u8; 4096]);
#[static_executor::task] #[task]
async fn run() { async fn run() {
let p = embassy_nrf::pac::Peripherals::take().dewrap(); let p = embassy_nrf::pac::Peripherals::take().dewrap();
@ -117,7 +120,11 @@ fn main() -> ! {
info!("Hello World!"); info!("Hello World!");
unsafe { unsafe {
run.spawn().dewrap(); EXECUTOR.spawn(run()).dewrap();
static_executor::run();
loop {
EXECUTOR.run();
cortex_m::asm::wfe();
}
} }
} }

View File

@ -12,7 +12,10 @@ use embassy_nrf::uarte;
use futures::pin_mut; use futures::pin_mut;
use nrf52840_hal::gpio; use nrf52840_hal::gpio;
#[static_executor::task] use static_executor::{task, Executor};
static EXECUTOR: Executor = Executor::new(|| cortex_m::asm::sev());
#[task]
async fn run() { async fn run() {
let p = embassy_nrf::pac::Peripherals::take().dewrap(); let p = embassy_nrf::pac::Peripherals::take().dewrap();
@ -66,7 +69,11 @@ fn main() -> ! {
info!("Hello World!"); info!("Hello World!");
unsafe { unsafe {
run.spawn().dewrap(); EXECUTOR.spawn(run()).dewrap();
static_executor::run();
loop {
EXECUTOR.run();
cortex_m::asm::wfe();
}
} }
} }

View File

@ -3,7 +3,6 @@
use defmt_rtt as _; // global logger use defmt_rtt as _; // global logger
use nrf52840_hal as _; use nrf52840_hal as _;
use panic_probe as _; use panic_probe as _;
use static_executor_cortex_m as _;
pub use defmt::{info, intern}; pub use defmt::{info, intern};