summaryrefslogtreecommitdiff
path: root/examples/src/bin/flash.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <dirbaio@dirbaio.net>2022-08-22 19:53:17 +0200
committerDario Nieuwenhuis <dirbaio@dirbaio.net>2022-08-22 19:55:16 +0200
commit36d14808e2019556d502105081bd36f80aba06c0 (patch)
tree67c1824e23c96b7ddb4440ce895b37646618e6d4 /examples/src/bin/flash.rs
parente1e4e2a2c2e9a8243368214fac02532e79c127a8 (diff)
downloadnrf-softdevice-36d14808e2019556d502105081bd36f80aba06c0.zip
Update Embassy.
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)));
- });
-}