summaryrefslogtreecommitdiff
path: root/examples/src/bin/flash.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/src/bin/flash.rs')
-rw-r--r--examples/src/bin/flash.rs32
1 files changed, 10 insertions, 22 deletions
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<Executor> = 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)));
- });
-}