summaryrefslogtreecommitdiff
path: root/examples/src/bin/ble_bas_peripheral.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <dirbaio@dirbaio.net>2020-10-31 23:24:31 +0100
committerDario Nieuwenhuis <dirbaio@dirbaio.net>2020-10-31 23:24:31 +0100
commitc621ed316cf6f49805a4db7b1f8e220bfc8fe86e (patch)
tree7950b43e8ea8d4de7cee8b9954807d2e2b9b0848 /examples/src/bin/ble_bas_peripheral.rs
parent908eb3faedfd029704b068ed92bfd2c8680798a7 (diff)
downloadnrf-softdevice-c621ed316cf6f49805a4db7b1f8e220bfc8fe86e.zip
Migrate to embassy (removes static-executor and async-flash)
Diffstat (limited to 'examples/src/bin/ble_bas_peripheral.rs')
-rw-r--r--examples/src/bin/ble_bas_peripheral.rs18
1 files changed, 12 insertions, 6 deletions
diff --git a/examples/src/bin/ble_bas_peripheral.rs b/examples/src/bin/ble_bas_peripheral.rs
index 131f9c1..ac87c46 100644
--- a/examples/src/bin/ble_bas_peripheral.rs
+++ b/examples/src/bin/ble_bas_peripheral.rs
@@ -14,7 +14,11 @@ use nrf_softdevice::ble::gatt_server::{Characteristic, CharacteristicHandles, Re
use nrf_softdevice::ble::{gatt_server, peripheral, Connection, Uuid};
use nrf_softdevice::{raw, RawError, Softdevice};
-#[static_executor::task]
+use embassy::executor::{task, Executor};
+use embassy::util::Forever;
+static EXECUTOR: Forever<Executor> = Forever::new();
+
+#[task]
async fn softdevice_task(sd: &'static Softdevice) {
sd.run().await;
}
@@ -28,7 +32,7 @@ struct BatteryService {
battery_level: u8,
}
-#[static_executor::task]
+#[task]
async fn bluetooth_task(sd: &'static Softdevice) {
let server: BatteryService = gatt_server::register(sd).dewrap();
@@ -119,10 +123,12 @@ fn main() -> ! {
let sd = Softdevice::enable(&config);
- unsafe {
- softdevice_task.spawn(sd).dewrap();
- bluetooth_task.spawn(sd).dewrap();
+ let executor = EXECUTOR.put(Executor::new(cortex_m::asm::wfi));
+ executor.spawn(softdevice_task(sd)).dewrap();
+ executor.spawn(bluetooth_task(sd)).dewrap();
- static_executor::run();
+ loop {
+ executor.run();
+ cortex_m::asm::wfe();
}
}