Add init fn. Initializes hw and returns Peripherals.
				
					
				
			This commit is contained in:
		@@ -46,18 +46,17 @@ macro_rules! peripherals {
 | 
			
		||||
        impl Peripherals {
 | 
			
		||||
            ///Returns all the peripherals *once*
 | 
			
		||||
            #[inline]
 | 
			
		||||
            pub fn take() -> Option<Self> {
 | 
			
		||||
            pub(crate) fn take() -> Self {
 | 
			
		||||
 | 
			
		||||
                #[no_mangle]
 | 
			
		||||
                static mut _EMBASSY_DEVICE_PERIPHERALS: bool = false;
 | 
			
		||||
 | 
			
		||||
                critical_section::with(|_| {
 | 
			
		||||
                    if unsafe { _EMBASSY_DEVICE_PERIPHERALS } {
 | 
			
		||||
                        None
 | 
			
		||||
                    } else {
 | 
			
		||||
                        unsafe { _EMBASSY_DEVICE_PERIPHERALS = true };
 | 
			
		||||
                        Some(unsafe { <Self as embassy::util::Steal>::steal() })
 | 
			
		||||
                critical_section::with(|_| unsafe {
 | 
			
		||||
                    if _EMBASSY_DEVICE_PERIPHERALS {
 | 
			
		||||
                        panic!("init called more than once!")
 | 
			
		||||
                    }
 | 
			
		||||
                    _EMBASSY_DEVICE_PERIPHERALS = true;
 | 
			
		||||
                    <Self as embassy::util::Steal>::steal()
 | 
			
		||||
                })
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user