summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDario Nieuwenhuis <dirbaio@dirbaio.net>2021-05-19 13:10:36 +0200
committerDario Nieuwenhuis <dirbaio@dirbaio.net>2021-05-19 13:10:36 +0200
commita18014a20878bdb8bf43fe196be8fa38ca0c1fd0 (patch)
tree6543dd85664e29cc4cefed4a35e43e0a9ef5d65d /examples
parent8201255a9d6dde4b29a5a539a1d6aeefcbd467df (diff)
downloadnrf-softdevice-a18014a20878bdb8bf43fe196be8fa38ca0c1fd0.zip
Update embassy
Diffstat (limited to 'examples')
-rw-r--r--examples/Cargo.toml2
-rw-r--r--examples/src/bin/ble_l2cap_central.rs1
-rw-r--r--examples/src/bin/ble_peripheral_onoff.rs23
3 files changed, 9 insertions, 17 deletions
diff --git a/examples/Cargo.toml b/examples/Cargo.toml
index 6b54d8a..0b87825 100644
--- a/examples/Cargo.toml
+++ b/examples/Cargo.toml
@@ -25,7 +25,7 @@ ble-gatt-client = ["nrf-softdevice/ble-gatt-client"]
[dependencies]
embassy = { version = "0.1.0", features = ["defmt"]}
embassy-traits = { version = "0.1.0", features = ["defmt"]}
-embassy-nrf = { version = "0.1.0", features = [ "defmt", "52840" ]}
+embassy-nrf = { version = "0.1.0", features = [ "defmt", "nrf52840" ]}
cortex-m = { version = "0.6.4" }
cortex-m-rt = "0.6.13"
defmt = { version = "0.2.0", features = ["alloc"] }
diff --git a/examples/src/bin/ble_l2cap_central.rs b/examples/src/bin/ble_l2cap_central.rs
index 1bb4e3f..e710e9b 100644
--- a/examples/src/bin/ble_l2cap_central.rs
+++ b/examples/src/bin/ble_l2cap_central.rs
@@ -9,7 +9,6 @@ extern crate alloc;
#[path = "../example_common.rs"]
mod example_common;
-use example_common::*;
use core::mem;
use core::ptr::NonNull;
diff --git a/examples/src/bin/ble_peripheral_onoff.rs b/examples/src/bin/ble_peripheral_onoff.rs
index 8e53c15..1caf4f6 100644
--- a/examples/src/bin/ble_peripheral_onoff.rs
+++ b/examples/src/bin/ble_peripheral_onoff.rs
@@ -11,13 +11,12 @@ mod example_common;
use core::mem;
use cortex_m_rt::entry;
-use defmt::{panic, *};
+use defmt::*;
use embassy::executor::Executor;
use embassy::traits::gpio::WaitForLow;
use embassy::util::Forever;
use embassy_nrf::gpio::{AnyPin, Input, Pin as _, Pull};
-use embassy_nrf::gpiote::{self, PortInput};
-use embassy_nrf::interrupt;
+use embassy_nrf::gpiote::PortInput;
use futures::pin_mut;
use nrf_softdevice::ble::{gatt_server, peripheral};
@@ -77,19 +76,14 @@ async fn run_bluetooth(sd: &'static Softdevice, server: &FooService) {
}
#[embassy::task]
-async fn bluetooth_task(
- sd: &'static Softdevice,
- gpiote: gpiote::Initialized,
- button1: AnyPin,
- button2: AnyPin,
-) {
+async fn bluetooth_task(sd: &'static Softdevice, button1: AnyPin, button2: AnyPin) {
let server: FooService = unwrap!(gatt_server::register(sd));
info!("Bluetooth is OFF");
info!("Press nrf52840-dk button 1 to enable, button 2 to disable");
- let button1 = PortInput::new(gpiote, Input::new(button1, Pull::Up));
- let button2 = PortInput::new(gpiote, Input::new(button2, Pull::Up));
+ let button1 = PortInput::new(Input::new(button1, Pull::Up));
+ let button2 = PortInput::new(Input::new(button2, Pull::Up));
pin_mut!(button1);
pin_mut!(button2);
loop {
@@ -131,6 +125,8 @@ async fn bluetooth_task(
fn main() -> ! {
info!("Hello World!");
+ let p = embassy_nrf::init(embassy_nrf::config::Config::default());
+
let config = nrf_softdevice::Config {
clock: Some(raw::nrf_clock_lf_cfg_t {
source: raw::NRF_CLOCK_LF_SRC_XTAL as u8,
@@ -169,10 +165,7 @@ fn main() -> ! {
let executor = EXECUTOR.put(Executor::new());
executor.run(|spawner| {
- let p = embassy_nrf::Peripherals::take().unwrap();
- let g = gpiote::initialize(p.GPIOTE, interrupt::take!(GPIOTE));
-
unwrap!(spawner.spawn(softdevice_task(sd)));
- unwrap!(spawner.spawn(bluetooth_task(sd, g, p.P0_11.degrade(), p.P0_12.degrade())));
+ unwrap!(spawner.spawn(bluetooth_task(sd, p.P0_11.degrade(), p.P0_12.degrade())));
});
}