aboutsummaryrefslogtreecommitdiff
path: root/embassy-extras
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2021-05-17 01:04:13 +0200
committerGitHub <[email protected]>2021-05-17 01:04:13 +0200
commit35d05a4214e035bbb6da380c38c0a90b285887f2 (patch)
treede9f18e1f858e62b03c0c465135bea3f57d926ac /embassy-extras
parentcd4111736c0384b1ef957df7f6aa51e3727c29b2 (diff)
parenta5ad79927ecaa9d6cd7bd96e015b66afa9201d84 (diff)
Merge pull request #174 from embassy-rs/nrf-neo
nRF-neo
Diffstat (limited to 'embassy-extras')
-rw-r--r--embassy-extras/src/macros.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/embassy-extras/src/macros.rs b/embassy-extras/src/macros.rs
index 860c0795a..fba752619 100644
--- a/embassy-extras/src/macros.rs
+++ b/embassy-extras/src/macros.rs
@@ -46,18 +46,17 @@ macro_rules! peripherals {
46 impl Peripherals { 46 impl Peripherals {
47 ///Returns all the peripherals *once* 47 ///Returns all the peripherals *once*
48 #[inline] 48 #[inline]
49 pub fn take() -> Option<Self> { 49 pub(crate) fn take() -> Self {
50 50
51 #[no_mangle] 51 #[no_mangle]
52 static mut _EMBASSY_DEVICE_PERIPHERALS: bool = false; 52 static mut _EMBASSY_DEVICE_PERIPHERALS: bool = false;
53 53
54 critical_section::with(|_| { 54 critical_section::with(|_| unsafe {
55 if unsafe { _EMBASSY_DEVICE_PERIPHERALS } { 55 if _EMBASSY_DEVICE_PERIPHERALS {
56 None 56 panic!("init called more than once!")
57 } else {
58 unsafe { _EMBASSY_DEVICE_PERIPHERALS = true };
59 Some(unsafe { <Self as embassy::util::Steal>::steal() })
60 } 57 }
58 _EMBASSY_DEVICE_PERIPHERALS = true;
59 <Self as embassy::util::Steal>::steal()
61 }) 60 })
62 } 61 }
63 } 62 }