summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralexmoon <alex.r.moon@gmail.com>2022-04-14 15:20:25 -0400
committeralexmoon <alex.r.moon@gmail.com>2022-07-12 14:34:16 -0400
commit5de2bab964549cd481062d3590f1d0c930c4f2f0 (patch)
treee14c6bdef1650adcf8adeba9053d0183423bae2f
parent96dbdc838ac2d2a0997eebeda77cead2154d5d22 (diff)
downloadnrf-softdevice-5de2bab964549cd481062d3590f1d0c930c4f2f0.zip
Make Softdevice::enable return an exclusive reference
-rw-r--r--examples/src/bin/ble_advertise.rs2
-rw-r--r--examples/src/bin/ble_bas_central.rs2
-rw-r--r--examples/src/bin/ble_bas_peripheral.rs2
-rw-r--r--examples/src/bin/ble_l2cap_central.rs2
-rw-r--r--examples/src/bin/ble_l2cap_peripheral.rs2
-rw-r--r--examples/src/bin/ble_peripheral_onoff.rs2
-rw-r--r--examples/src/bin/ble_scan.rs2
-rw-r--r--examples/src/bin/flash.rs2
-rw-r--r--nrf-softdevice/src/softdevice.rs5
9 files changed, 11 insertions, 10 deletions
diff --git a/examples/src/bin/ble_advertise.rs b/examples/src/bin/ble_advertise.rs
index 23a20df..ea7824c 100644
--- a/examples/src/bin/ble_advertise.rs
+++ b/examples/src/bin/ble_advertise.rs
@@ -89,7 +89,7 @@ fn main() -> ! {
let sd = Softdevice::enable(&config);
let executor = EXECUTOR.put(Executor::new());
- executor.run(|spawner| {
+ executor.run(move |spawner| {
unwrap!(spawner.spawn(softdevice_task(sd)));
unwrap!(spawner.spawn(bluetooth_task(sd)));
});
diff --git a/examples/src/bin/ble_bas_central.rs b/examples/src/bin/ble_bas_central.rs
index 823d09b..fb6bd09 100644
--- a/examples/src/bin/ble_bas_central.rs
+++ b/examples/src/bin/ble_bas_central.rs
@@ -98,7 +98,7 @@ fn main() -> ! {
let sd = Softdevice::enable(&config);
let executor = EXECUTOR.put(Executor::new());
- executor.run(|spawner| {
+ executor.run(move |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 e3e6233..872ddcf 100644
--- a/examples/src/bin/ble_bas_peripheral.rs
+++ b/examples/src/bin/ble_bas_peripheral.rs
@@ -147,7 +147,7 @@ fn main() -> ! {
let sd = Softdevice::enable(&config);
let executor = EXECUTOR.put(Executor::new());
- executor.run(|spawner| {
+ executor.run(move |spawner| {
unwrap!(spawner.spawn(softdevice_task(sd)));
unwrap!(spawner.spawn(bluetooth_task(sd)));
});
diff --git a/examples/src/bin/ble_l2cap_central.rs b/examples/src/bin/ble_l2cap_central.rs
index 2fb1f87..53951e3 100644
--- a/examples/src/bin/ble_l2cap_central.rs
+++ b/examples/src/bin/ble_l2cap_central.rs
@@ -170,7 +170,7 @@ fn main() -> ! {
let sd = Softdevice::enable(&config);
let executor = EXECUTOR.put(Executor::new());
- executor.run(|spawner| {
+ executor.run(move |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 eccd555..23ef03e 100644
--- a/examples/src/bin/ble_l2cap_peripheral.rs
+++ b/examples/src/bin/ble_l2cap_peripheral.rs
@@ -147,7 +147,7 @@ fn main() -> ! {
unwrap!(RawError::convert(unsafe { raw::sd_clock_hfclk_request() }));
let executor = EXECUTOR.put(Executor::new());
- executor.run(|spawner| {
+ executor.run(move |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 9fdc8c0..a12f46e 100644
--- a/examples/src/bin/ble_peripheral_onoff.rs
+++ b/examples/src/bin/ble_peripheral_onoff.rs
@@ -170,7 +170,7 @@ fn main() -> ! {
let sd = Softdevice::enable(&config);
let executor = EXECUTOR.put(Executor::new());
- executor.run(|spawner| {
+ executor.run(move |spawner| {
unwrap!(spawner.spawn(softdevice_task(sd)));
unwrap!(spawner.spawn(bluetooth_task(sd, p.P0_11.degrade(), p.P0_12.degrade())));
});
diff --git a/examples/src/bin/ble_scan.rs b/examples/src/bin/ble_scan.rs
index e9a9376..7c8e7f6 100644
--- a/examples/src/bin/ble_scan.rs
+++ b/examples/src/bin/ble_scan.rs
@@ -109,7 +109,7 @@ fn main() -> ! {
let sd = Softdevice::enable(&config);
let executor = EXECUTOR.put(Executor::new());
- executor.run(|spawner| {
+ executor.run(move |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 2017e86..27ea01b 100644
--- a/examples/src/bin/flash.rs
+++ b/examples/src/bin/flash.rs
@@ -44,7 +44,7 @@ fn main() -> ! {
let sd = Softdevice::enable(&Default::default());
let executor = EXECUTOR.put(Executor::new());
- executor.run(|spawner| {
+ executor.run(move |spawner| {
unwrap!(spawner.spawn(softdevice_task(sd)));
unwrap!(spawner.spawn(flash_task(sd)));
});
diff --git a/nrf-softdevice/src/softdevice.rs b/nrf-softdevice/src/softdevice.rs
index d697cbe..282ba04 100644
--- a/nrf-softdevice/src/softdevice.rs
+++ b/nrf-softdevice/src/softdevice.rs
@@ -97,7 +97,7 @@ impl Softdevice {
/// - Panics if the requested configuration requires more memory than reserved for the softdevice. In that case, you can give more memory to the softdevice by editing the RAM start address in `memory.x`. The required start address is logged prior to panic.
/// - Panics if the requested configuration has too high memory requirements for the softdevice. The softdevice supports a maximum dynamic memory size of 64kb.
/// - Panics if called multiple times. Must be called at most once.
- pub fn enable(config: &Config) -> &'static Softdevice {
+ pub fn enable(config: &Config) -> &'static mut Softdevice {
if ENABLED
.compare_exchange(false, true, Ordering::AcqRel, Ordering::Acquire)
.is_err()
@@ -310,7 +310,8 @@ impl Softdevice {
/// Return an instance to the softdevice without checking whether
/// it is enabled or not. This is only safe if the softdevice is enabled
- /// (a call to [`enable`] has returned without error)
+ /// (a call to [`enable`] has returned without error) and no `&mut` references
+ /// to the softdevice are active
pub unsafe fn steal() -> &'static Softdevice {
SOFTDEVICE.steal()
}