summaryrefslogtreecommitdiff
path: root/nrf-softdevice
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 /nrf-softdevice
parente1e4e2a2c2e9a8243368214fac02532e79c127a8 (diff)
downloadnrf-softdevice-36d14808e2019556d502105081bd36f80aba06c0.zip
Update Embassy.
Diffstat (limited to 'nrf-softdevice')
-rw-r--r--nrf-softdevice/src/softdevice.rs19
1 files changed, 11 insertions, 8 deletions
diff --git a/nrf-softdevice/src/softdevice.rs b/nrf-softdevice/src/softdevice.rs
index caad633..d744389 100644
--- a/nrf-softdevice/src/softdevice.rs
+++ b/nrf-softdevice/src/softdevice.rs
@@ -1,9 +1,8 @@
use core::marker::PhantomData;
+use core::mem::MaybeUninit;
use core::ptr;
use core::sync::atomic::{AtomicBool, Ordering};
-use embassy_util::Forever;
-
use crate::{pac, raw, RawError, SocEvent};
unsafe extern "C" fn fault_handler(id: u32, pc: u32, info: u32) {
@@ -85,13 +84,11 @@ fn cfg_set(id: u32, cfg: &raw::ble_cfg_t) {
}
static ENABLED: AtomicBool = AtomicBool::new(false);
-static SOFTDEVICE: Forever<Softdevice> = Forever::new();
+static mut SOFTDEVICE: MaybeUninit<Softdevice> = MaybeUninit::uninit();
impl Softdevice {
/// Enable the softdevice.
///
- /// This function takes ownership of the softdevice-reserved peripherals to ensure application code doesn't attempt to use them after enabling.
- ///
/// # Panics
/// - 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.
@@ -280,7 +277,7 @@ impl Softdevice {
.map(|x| x.rx_mps)
.unwrap_or(raw::BLE_L2CAP_MPS_MIN as u16);
- SOFTDEVICE.put(Softdevice {
+ let sd = Softdevice {
_private: PhantomData,
#[cfg(feature = "ble-gatt")]
@@ -288,7 +285,13 @@ impl Softdevice {
#[cfg(feature = "ble-l2cap")]
l2cap_rx_mps,
- })
+ };
+
+ unsafe {
+ let p = SOFTDEVICE.as_mut_ptr();
+ p.write(sd);
+ &mut *p
+ }
}
/// Return an instance to the softdevice without checking whether
@@ -296,7 +299,7 @@ impl Softdevice {
/// (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()
+ &*SOFTDEVICE.as_ptr()
}
/// Runs the softdevice event handling loop.