File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -143,14 +143,17 @@ pub struct Peripherals {
143
143
// NOTE `no_mangle` is used here to prevent linking different minor versions of this crate as that
144
144
// would let you `take` the core peripherals more than once (one per minor version)
145
145
#[ no_mangle]
146
- static mut CORE_PERIPHERALS : bool = false ;
146
+ static CORE_PERIPHERALS : ( ) = ( ) ;
147
+
148
+ /// Set to `true` when `take` or `steal` was called to make `Peripherals` a singleton.
149
+ static mut TAKEN : bool = false ;
147
150
148
151
impl Peripherals {
149
152
/// Returns all the core peripherals *once*
150
153
#[ inline]
151
154
pub fn take ( ) -> Option < Self > {
152
155
interrupt:: free ( |_| {
153
- if unsafe { CORE_PERIPHERALS } {
156
+ if unsafe { TAKEN } {
154
157
None
155
158
} else {
156
159
Some ( unsafe { Peripherals :: steal ( ) } )
@@ -161,7 +164,7 @@ impl Peripherals {
161
164
/// Unchecked version of `Peripherals::take`
162
165
#[ inline]
163
166
pub unsafe fn steal ( ) -> Self {
164
- CORE_PERIPHERALS = true ;
167
+ TAKEN = true ;
165
168
166
169
Peripherals {
167
170
CBP : CBP {
You can’t perform that action at this time.
0 commit comments