From 36d14808e2019556d502105081bd36f80aba06c0 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 22 Aug 2022 19:53:17 +0200 Subject: Update Embassy. --- examples/src/bin/flash.rs | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) (limited to 'examples/src/bin/flash.rs') diff --git a/examples/src/bin/flash.rs b/examples/src/bin/flash.rs index 78cb42d..81e65e6 100644 --- a/examples/src/bin/flash.rs +++ b/examples/src/bin/flash.rs @@ -5,23 +5,24 @@ #[path = "../example_common.rs"] mod example_common; -use cortex_m_rt::entry; use defmt::*; -use embassy_executor::executor::Executor; -use embassy_util::Forever; +use embassy_executor::Spawner; use embedded_storage_async::nor_flash::*; use futures::pin_mut; use nrf_softdevice::{Flash, Softdevice}; -static EXECUTOR: Forever = Forever::new(); - #[embassy_executor::task] -async fn softdevice_task(sd: &'static Softdevice) { - sd.run().await; +async fn softdevice_task(sd: &'static Softdevice) -> ! { + sd.run().await } -#[embassy_executor::task] -async fn flash_task(sd: &'static Softdevice) { +#[embassy_executor::main] +async fn main(spawner: Spawner) { + info!("Hello World!"); + + let sd = Softdevice::enable(&Default::default()); + unwrap!(spawner.spawn(softdevice_task(sd))); + let f = Flash::take(sd); pin_mut!(f); @@ -33,16 +34,3 @@ async fn flash_task(sd: &'static Softdevice) { unwrap!(f.as_mut().write(0x80000, &[1, 2, 3, 4]).await); info!("write done!"); } - -#[entry] -fn main() -> ! { - info!("Hello World!"); - - let sd = Softdevice::enable(&Default::default()); - - let executor = EXECUTOR.put(Executor::new()); - executor.run(move |spawner| { - unwrap!(spawner.spawn(softdevice_task(sd))); - unwrap!(spawner.spawn(flash_task(sd))); - }); -} -- cgit v1.2.3