File tree 1 file changed +5
-3
lines changed
1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -62,23 +62,25 @@ pub struct Peripherals {
62
62
pub TPIU : TPIU ,
63
63
}
64
64
65
+ // NOTE `no_mangle` is used here to prevent linking different minor versions of this crate as that
66
+ // would let you `take` the core peripherals more than once (one per minor version)
65
67
#[ no_mangle]
66
68
static mut CORE_PERIPHERALS : bool = false ;
67
69
68
70
impl Peripherals {
69
71
/// Returns all the core peripherals *once*
70
- pub fn all ( ) -> Option < Self > {
72
+ pub fn take ( ) -> Option < Self > {
71
73
interrupt:: free ( |_| {
72
74
if unsafe { CORE_PERIPHERALS } {
73
75
None
74
76
} else {
75
- Some ( unsafe { Peripherals :: _all ( ) } )
77
+ Some ( unsafe { Peripherals :: steal ( ) } )
76
78
}
77
79
} )
78
80
}
79
81
80
82
#[ doc( hidden) ]
81
- pub unsafe fn _all ( ) -> Self {
83
+ pub unsafe fn steal ( ) -> Self {
82
84
debug_assert ! ( !CORE_PERIPHERALS ) ;
83
85
84
86
CORE_PERIPHERALS = true ;
You can’t perform that action at this time.
0 commit comments