#![allow(non_snake_case, non_upper_case_globals)]
#![allow(non_camel_case_types)]
#[cfg(not(feature = "nosync"))]
pub use crate::imxrt101::peripherals::kpp::Instance;
pub use crate::imxrt101::peripherals::kpp::{RegisterBlock, ResetValues};
pub use crate::imxrt101::peripherals::kpp::{KDDR, KPCR, KPDR, KPSR};
pub mod KPP {
use super::ResetValues;
#[cfg(not(feature = "nosync"))]
use super::Instance;
#[cfg(not(feature = "nosync"))]
const INSTANCE: Instance = Instance {
addr: 0x401fc000,
_marker: ::core::marker::PhantomData,
};
pub const reset: ResetValues = ResetValues {
KPCR: 0x00000000,
KPSR: 0x00000400,
KDDR: 0x00000000,
KPDR: 0x00000000,
};
#[cfg(not(feature = "nosync"))]
#[allow(renamed_and_removed_lints)]
#[allow(private_no_mangle_statics)]
#[no_mangle]
static mut KPP_TAKEN: bool = false;
#[cfg(not(feature = "nosync"))]
#[inline]
pub fn take() -> Option<Instance> {
external_cortex_m::interrupt::free(|_| unsafe {
if KPP_TAKEN {
None
} else {
KPP_TAKEN = true;
Some(INSTANCE)
}
})
}
#[cfg(not(feature = "nosync"))]
#[inline]
pub fn release(inst: Instance) {
external_cortex_m::interrupt::free(|_| unsafe {
if KPP_TAKEN && inst.addr == INSTANCE.addr {
KPP_TAKEN = false;
} else {
panic!("Released a peripheral which was not taken");
}
});
}
#[cfg(not(feature = "nosync"))]
#[inline]
pub unsafe fn steal() -> Instance {
KPP_TAKEN = true;
INSTANCE
}
}
pub const KPP: *const RegisterBlock = 0x401fc000 as *const _;