summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDario Nieuwenhuis <dirbaio@dirbaio.net>2021-02-03 06:44:20 +0100
committerDario Nieuwenhuis <dirbaio@dirbaio.net>2021-02-03 06:44:20 +0100
commit9400ecccb5271e03a46a07825b2775bc3bf7f609 (patch)
tree0ab12661720efd27ebf71ce23b9ee17e9c6a4f72 /examples
parent96e625fc3baa4f258e9e9f761845a76751710b0d (diff)
downloadnrf-softdevice-9400ecccb5271e03a46a07825b2775bc3bf7f609.zip
update embassy
Diffstat (limited to 'examples')
-rw-r--r--examples/Cargo.toml2
-rw-r--r--examples/src/bin/ble_bas_central.rs13
-rw-r--r--examples/src/bin/ble_bas_peripheral.rs13
-rw-r--r--examples/src/bin/ble_l2cap_central.rs13
-rw-r--r--examples/src/bin/ble_l2cap_peripheral.rs16
-rw-r--r--examples/src/bin/ble_peripheral_onoff.rs16
-rw-r--r--examples/src/bin/ble_scan.rs13
-rw-r--r--examples/src/bin/flash.rs13
-rw-r--r--examples/src/bin/interrupts.rs13
-rw-r--r--examples/src/bin/rtic.rs13
10 files changed, 49 insertions, 76 deletions
diff --git a/examples/Cargo.toml b/examples/Cargo.toml
index 4413169..caa6dc5 100644
--- a/examples/Cargo.toml
+++ b/examples/Cargo.toml
@@ -31,7 +31,7 @@ cortex-m-rtic = { version = "0.5.5", optional = true }
defmt = "0.1.3"
nrf-softdevice-defmt-rtt = { path = "../nrf-softdevice-defmt-rtt", version = "0.1.0" }
panic-probe = "0.1.0"
-nrf52840-hal = { version = "0.11.0" }
+nrf52840-hal = { version = "0.12.0" }
nrf-softdevice = { version = "0.1.0", path = "../nrf-softdevice", features = ["defmt", "defmt-trace", "nrf52840", "s140", "ble-peripheral", "ble-central"] }
nrf-softdevice-s140 = { version = "0.1.1", path = "../nrf-softdevice-s140" }
futures = { version = "0.3.5", default-features = false }
diff --git a/examples/src/bin/ble_bas_central.rs b/examples/src/bin/ble_bas_central.rs
index be90a4c..eabc539 100644
--- a/examples/src/bin/ble_bas_central.rs
+++ b/examples/src/bin/ble_bas_central.rs
@@ -98,12 +98,9 @@ fn main() -> ! {
let (sdp, p) = take_peripherals();
let sd = Softdevice::enable(sdp, &config);
- let executor = EXECUTOR.put(Executor::new(cortex_m::asm::sev));
- unwrap!(executor.spawn(softdevice_task(sd)));
- unwrap!(executor.spawn(ble_central_task(sd)));
-
- loop {
- executor.run();
- cortex_m::asm::wfe();
- }
+ let executor = EXECUTOR.put(Executor::new());
+ executor.run(|spawner| {
+ unwrap!(spawner.spawn(softdevice_task(sd)));
+ unwrap!(spawner.spawn(ble_central_task(sd)));
+ });
}
diff --git a/examples/src/bin/ble_bas_peripheral.rs b/examples/src/bin/ble_bas_peripheral.rs
index 53b4e34..7d754b0 100644
--- a/examples/src/bin/ble_bas_peripheral.rs
+++ b/examples/src/bin/ble_bas_peripheral.rs
@@ -128,12 +128,9 @@ fn main() -> ! {
let (sdp, p) = take_peripherals();
let sd = Softdevice::enable(sdp, &config);
- let executor = EXECUTOR.put(Executor::new(cortex_m::asm::sev));
- unwrap!(executor.spawn(softdevice_task(sd)));
- unwrap!(executor.spawn(bluetooth_task(sd, peripheral::Config::default())));
-
- loop {
- executor.run();
- cortex_m::asm::wfe();
- }
+ let executor = EXECUTOR.put(Executor::new());
+ executor.run(|spawner| {
+ unwrap!(spawner.spawn(softdevice_task(sd)));
+ unwrap!(spawner.spawn(bluetooth_task(sd, peripheral::Config::default())));
+ });
}
diff --git a/examples/src/bin/ble_l2cap_central.rs b/examples/src/bin/ble_l2cap_central.rs
index e5f3e3c..7440bd2 100644
--- a/examples/src/bin/ble_l2cap_central.rs
+++ b/examples/src/bin/ble_l2cap_central.rs
@@ -174,12 +174,9 @@ fn main() -> ! {
let (sdp, p) = take_peripherals();
let sd = Softdevice::enable(sdp, &config);
- let executor = EXECUTOR.put(Executor::new(cortex_m::asm::sev));
- unwrap!(executor.spawn(softdevice_task(sd)));
- unwrap!(executor.spawn(ble_central_task(sd)));
-
- loop {
- executor.run();
- cortex_m::asm::wfe();
- }
+ let executor = EXECUTOR.put(Executor::new());
+ executor.run(|spawner| {
+ unwrap!(spawner.spawn(softdevice_task(sd)));
+ unwrap!(spawner.spawn(ble_central_task(sd)));
+ });
}
diff --git a/examples/src/bin/ble_l2cap_peripheral.rs b/examples/src/bin/ble_l2cap_peripheral.rs
index bc20437..54716af 100644
--- a/examples/src/bin/ble_l2cap_peripheral.rs
+++ b/examples/src/bin/ble_l2cap_peripheral.rs
@@ -12,7 +12,6 @@ use core::mem;
use core::ptr::NonNull;
use cortex_m_rt::entry;
use defmt::{panic, *};
-use heapless::consts::*;
use nrf_softdevice::ble;
use nrf_softdevice::ble::{l2cap, peripheral, Connection};
@@ -30,7 +29,7 @@ async fn softdevice_task(sd: &'static Softdevice) {
}
#[task]
-async fn bluetooth_task(sd: &'static Softdevice, config: peripheral::Config) {
+async fn bluetooth_task(sd: &'static Softdevice) {
info!("My address: {:?}", ble::get_address(sd));
#[rustfmt::skip]
@@ -151,12 +150,9 @@ fn main() -> ! {
let (sdp, p) = take_peripherals();
let sd = Softdevice::enable(sdp, &config);
- let executor = EXECUTOR.put(Executor::new(cortex_m::asm::sev));
- unwrap!(executor.spawn(softdevice_task(sd)));
- unwrap!(executor.spawn(bluetooth_task(sd, peripheral::Config::default())));
-
- loop {
- executor.run();
- cortex_m::asm::wfe();
- }
+ let executor = EXECUTOR.put(Executor::new());
+ executor.run(|spawner| {
+ unwrap!(spawner.spawn(softdevice_task(sd)));
+ unwrap!(spawner.spawn(bluetooth_task(sd)));
+ });
}
diff --git a/examples/src/bin/ble_peripheral_onoff.rs b/examples/src/bin/ble_peripheral_onoff.rs
index 50f31bf..cad1145 100644
--- a/examples/src/bin/ble_peripheral_onoff.rs
+++ b/examples/src/bin/ble_peripheral_onoff.rs
@@ -13,6 +13,7 @@ use defmt::{panic, *};
use embassy::executor::{task, Executor};
use embassy::util::Forever;
use embassy_nrf::gpiote::{Gpiote, PortInputPolarity};
+use embassy_nrf::interrupt;
use futures::pin_mut;
use nrf52840_hal::gpio;
@@ -77,7 +78,7 @@ async fn bluetooth_task(sd: &'static Softdevice, gpiote: pac::GPIOTE, p0: pac::P
let server: FooService = unwrap!(gatt_server::register(sd));
let port0 = gpio::p0::Parts::new(p0);
- let gpiote = Gpiote::new(gpiote);
+ let gpiote = Gpiote::new(gpiote, interrupt::take!(GPIOTE));
info!("Bluetooth is OFF");
info!("Press nrf52840-dk button 1 to enable, button 2 to disable");
@@ -165,12 +166,9 @@ fn main() -> ! {
let (sdp, p) = take_peripherals();
let sd = Softdevice::enable(sdp, &config);
- let executor = EXECUTOR.put(Executor::new(cortex_m::asm::sev));
- unwrap!(executor.spawn(softdevice_task(sd)));
- unwrap!(executor.spawn(bluetooth_task(sd, p.GPIOTE, p.P0,)));
-
- loop {
- executor.run();
- cortex_m::asm::wfe();
- }
+ let executor = EXECUTOR.put(Executor::new());
+ executor.run(|spawner| {
+ unwrap!(spawner.spawn(softdevice_task(sd)));
+ unwrap!(spawner.spawn(bluetooth_task(sd, p.GPIOTE, p.P0,)));
+ });
}
diff --git a/examples/src/bin/ble_scan.rs b/examples/src/bin/ble_scan.rs
index 7250364..c8b71e3 100644
--- a/examples/src/bin/ble_scan.rs
+++ b/examples/src/bin/ble_scan.rs
@@ -109,12 +109,9 @@ fn main() -> ! {
let (sdp, p) = take_peripherals();
let sd = Softdevice::enable(sdp, &config);
- let executor = EXECUTOR.put(Executor::new(cortex_m::asm::sev));
- unwrap!(executor.spawn(softdevice_task(sd)));
- unwrap!(executor.spawn(ble_task(sd)));
-
- loop {
- executor.run();
- cortex_m::asm::wfe();
- }
+ let executor = EXECUTOR.put(Executor::new());
+ executor.run(|spawner| {
+ unwrap!(spawner.spawn(softdevice_task(sd)));
+ unwrap!(spawner.spawn(ble_task(sd)));
+ });
}
diff --git a/examples/src/bin/flash.rs b/examples/src/bin/flash.rs
index 825a62b..1d765c7 100644
--- a/examples/src/bin/flash.rs
+++ b/examples/src/bin/flash.rs
@@ -42,12 +42,9 @@ fn main() -> ! {
let (sdp, p) = take_peripherals();
let sd = Softdevice::enable(sdp, &Default::default());
- let executor = EXECUTOR.put(Executor::new(cortex_m::asm::sev));
- unwrap!(executor.spawn(softdevice_task(sd)));
- unwrap!(executor.spawn(flash_task(sd)));
-
- loop {
- executor.run();
- cortex_m::asm::wfe();
- }
+ let executor = EXECUTOR.put(Executor::new());
+ executor.run(|spawner| {
+ unwrap!(spawner.spawn(softdevice_task(sd)));
+ unwrap!(spawner.spawn(flash_task(sd)));
+ });
}
diff --git a/examples/src/bin/interrupts.rs b/examples/src/bin/interrupts.rs
index 1c777b5..55c896c 100644
--- a/examples/src/bin/interrupts.rs
+++ b/examples/src/bin/interrupts.rs
@@ -92,12 +92,9 @@ fn main() -> ! {
let (sdp, p) = take_peripherals();
let sd = Softdevice::enable(sdp, &Default::default());
- let executor = EXECUTOR.put(Executor::new(cortex_m::asm::sev));
- unwrap!(executor.spawn(softdevice_task(sd)));
- unwrap!(executor.spawn(interrupt_task(sd)));
-
- loop {
- executor.run();
- cortex_m::asm::wfe();
- }
+ let executor = EXECUTOR.put(Executor::new());
+ executor.run(|spawner| {
+ unwrap!(spawner.spawn(softdevice_task(sd)));
+ unwrap!(spawner.spawn(interrupt_task(sd)));
+ });
}
diff --git a/examples/src/bin/rtic.rs b/examples/src/bin/rtic.rs
index 988b124..583325e 100644
--- a/examples/src/bin/rtic.rs
+++ b/examples/src/bin/rtic.rs
@@ -126,14 +126,11 @@ const APP: () = {
let temp = unwrap!(temperature_celsius(&sd));
info!("{:i32}°C", temp.to_num::<i32>());
- let executor = EXECUTOR.put(Executor::new(cortex_m::asm::sev));
- unwrap!(executor.spawn(softdevice_task(sd)));
- unwrap!(executor.spawn(bluetooth_task(sd)));
-
- loop {
- executor.run();
- cortex_m::asm::wfe();
- }
+ let executor = EXECUTOR.put(Executor::new());
+ executor.run(|spawner| {
+ unwrap!(spawner.spawn(softdevice_task(sd)));
+ unwrap!(spawner.spawn(bluetooth_task(sd)));
+ });
}
#[task(binds = TIMER1, resources = [timer], priority = 1)]