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