aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <jorge@japaric.io> 2017-12-09 10:55:45 +0100
committerGravatar Jorge Aparicio <jorge@japaric.io> 2017-12-09 10:55:45 +0100
commit9bab4175eb4120612e07470d060d6aca3b5edfd5 (patch)
tree338d4a0114d241c465618801dbca006b0ff0f335 /src
parentc6ed9ef43f6606f654c2392413ca8ed380a35056 (diff)
downloadcortex-m-9bab4175eb4120612e07470d060d6aca3b5edfd5.tar.gz
cortex-m-9bab4175eb4120612e07470d060d6aca3b5edfd5.tar.zst
cortex-m-9bab4175eb4120612e07470d060d6aca3b5edfd5.zip
s/all/take/g s/_all/steal/g
Diffstat (limited to 'src')
-rw-r--r--src/peripheral/mod.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/peripheral/mod.rs b/src/peripheral/mod.rs
index c9c7a28..7482398 100644
--- a/src/peripheral/mod.rs
+++ b/src/peripheral/mod.rs
@@ -62,23 +62,25 @@ pub struct Peripherals {
pub TPIU: TPIU,
}
+// NOTE `no_mangle` is used here to prevent linking different minor versions of this crate as that
+// would let you `take` the core peripherals more than once (one per minor version)
#[no_mangle]
static mut CORE_PERIPHERALS: bool = false;
impl Peripherals {
/// Returns all the core peripherals *once*
- pub fn all() -> Option<Self> {
+ pub fn take() -> Option<Self> {
interrupt::free(|_| {
if unsafe { CORE_PERIPHERALS } {
None
} else {
- Some(unsafe { Peripherals::_all() })
+ Some(unsafe { Peripherals::steal() })
}
})
}
#[doc(hidden)]
- pub unsafe fn _all() -> Self {
+ pub unsafe fn steal() -> Self {
debug_assert!(!CORE_PERIPHERALS);
CORE_PERIPHERALS = true;