#![allow(non_snake_case, non_upper_case_globals)]
#![allow(non_camel_case_types)]
use crate::RORegister;
#[cfg(not(feature = "nosync"))]
use core::marker::PhantomData;
pub mod Base {
pub mod IMPLEMENTER {
pub const offset: u32 = 24;
pub const mask: u32 = 0x7f << offset;
pub mod R {}
pub mod W {}
pub mod RW {
pub const ARM: u32 = 0b1000001;
}
}
pub mod VARIANT {
pub const offset: u32 = 20;
pub const mask: u32 = 0b1111 << offset;
pub mod R {}
pub mod W {}
pub mod RW {}
}
pub mod ARCHITECTURE {
pub const offset: u32 = 16;
pub const mask: u32 = 0b1111 << offset;
pub mod R {}
pub mod W {}
pub mod RW {
pub const ARMv6M: u32 = 0b1100;
}
}
pub mod PARTNO {
pub const offset: u32 = 4;
pub const mask: u32 = 0xfff << offset;
pub mod R {}
pub mod W {}
pub mod RW {}
}
pub mod REVISION {
pub const offset: u32 = 0;
pub const mask: u32 = 0b1111 << offset;
pub mod R {}
pub mod W {}
pub mod RW {}
}
}
#[repr(C)]
pub struct RegisterBlock {
pub Base: RORegister<u32>,
}
pub struct ResetValues {
pub Base: u32,
}
#[cfg(not(feature = "nosync"))]
pub struct Instance {
pub(crate) addr: u32,
pub(crate) _marker: PhantomData<*const RegisterBlock>,
}
#[cfg(not(feature = "nosync"))]
impl ::core::ops::Deref for Instance {
type Target = RegisterBlock;
#[inline(always)]
fn deref(&self) -> &RegisterBlock {
unsafe { &*(self.addr as *const _) }
}
}
#[cfg(feature = "rtic")]
unsafe impl Send for Instance {}
pub mod CPUID {
use super::ResetValues;
#[cfg(not(feature = "nosync"))]
use super::Instance;
#[cfg(not(feature = "nosync"))]
const INSTANCE: Instance = Instance {
addr: 0xe000ed00,
_marker: ::core::marker::PhantomData,
};
pub const reset: ResetValues = ResetValues { Base: 0x00000000 };
#[cfg(not(feature = "nosync"))]
#[allow(renamed_and_removed_lints)]
#[allow(private_no_mangle_statics)]
#[no_mangle]
static mut CPUID_TAKEN: bool = false;
#[cfg(not(feature = "nosync"))]
#[inline]
pub fn take() -> Option<Instance> {
external_cortex_m::interrupt::free(|_| unsafe {
if CPUID_TAKEN {
None
} else {
CPUID_TAKEN = true;
Some(INSTANCE)
}
})
}
#[cfg(not(feature = "nosync"))]
#[inline]
pub fn release(inst: Instance) {
external_cortex_m::interrupt::free(|_| unsafe {
if CPUID_TAKEN && inst.addr == INSTANCE.addr {
CPUID_TAKEN = false;
} else {
panic!("Released a peripheral which was not taken");
}
});
}
#[cfg(not(feature = "nosync"))]
#[inline]
pub unsafe fn steal() -> Instance {
CPUID_TAKEN = true;
INSTANCE
}
}
pub const CPUID: *const RegisterBlock = 0xe000ed00 as *const _;