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 {
143143// NOTE `no_mangle` is used here to prevent linking different minor versions of this crate as that
144144// would let you `take` the core peripherals more than once (one per minor version)
145145#[ 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 ;
147150
148151impl Peripherals {
149152 /// Returns all the core peripherals *once*
150153 #[ inline]
151154 pub fn take ( ) -> Option < Self > {
152155 interrupt:: free ( |_| {
153- if unsafe { CORE_PERIPHERALS } {
156+ if unsafe { TAKEN } {
154157 None
155158 } else {
156159 Some ( unsafe { Peripherals :: steal ( ) } )
@@ -161,7 +164,7 @@ impl Peripherals {
161164 /// Unchecked version of `Peripherals::take`
162165 #[ inline]
163166 pub unsafe fn steal ( ) -> Self {
164- CORE_PERIPHERALS = true ;
167+ TAKEN = true ;
165168
166169 Peripherals {
167170 CBP : CBP {
You can’t perform that action at this time.
0 commit comments