diff options
author | Dario Nieuwenhuis <dirbaio@dirbaio.net> | 2020-10-31 23:24:31 +0100 |
---|---|---|
committer | Dario Nieuwenhuis <dirbaio@dirbaio.net> | 2020-10-31 23:24:31 +0100 |
commit | c621ed316cf6f49805a4db7b1f8e220bfc8fe86e (patch) | |
tree | 7950b43e8ea8d4de7cee8b9954807d2e2b9b0848 /examples/src/bin/flash.rs | |
parent | 908eb3faedfd029704b068ed92bfd2c8680798a7 (diff) | |
download | nrf-softdevice-c621ed316cf6f49805a4db7b1f8e220bfc8fe86e.zip |
Migrate to embassy (removes static-executor and async-flash)
Diffstat (limited to 'examples/src/bin/flash.rs')
-rw-r--r-- | examples/src/bin/flash.rs | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/examples/src/bin/flash.rs b/examples/src/bin/flash.rs index e4570c2..54bde9a 100644 --- a/examples/src/bin/flash.rs +++ b/examples/src/bin/flash.rs @@ -6,16 +6,21 @@ mod example_common; use example_common::*; -use async_flash::Flash as _; use cortex_m_rt::entry; +use embassy::executor::{task, Executor}; +use embassy::flash::Flash as _; +use embassy::util::Forever; + use nrf_softdevice::{Flash, Softdevice}; -#[static_executor::task] +static EXECUTOR: Forever<Executor> = Forever::new(); + +#[task] async fn softdevice_task(sd: &'static Softdevice) { sd.run().await; } -#[static_executor::task] +#[task] async fn flash_task(sd: &'static Softdevice) { let mut f = Flash::take(sd); @@ -38,10 +43,12 @@ fn main() -> ! { let sd = Softdevice::enable(&Default::default()); - unsafe { - softdevice_task.spawn(sd).dewrap(); - flash_task.spawn(sd).dewrap(); + let executor = EXECUTOR.put(Executor::new(cortex_m::asm::wfi)); + executor.spawn(softdevice_task(sd)).dewrap(); + executor.spawn(flash_task(sd)).dewrap(); - static_executor::run(); + loop { + executor.run(); + cortex_m::asm::wfe(); } } |