#[doc = "Register `LOCK` reader"]
pub type R = crate::R<LOCK_SPEC>;
#[doc = "Register `LOCK` writer"]
pub type W = crate::W<LOCK_SPEC>;
#[doc = "Field `LOCKKEY` reader - Configuration Lock Key"]
pub type LOCKKEY_R = crate::FieldReader<LOCKKEY_A>;
#[doc = "Configuration Lock Key\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u16)]
pub enum LOCKKEY_A {
#[doc = "0: `0`"]
UNLOCKED = 0,
#[doc = "1: `1`"]
LOCKED = 1,
}
impl From<LOCKKEY_A> for u16 {
#[inline(always)]
fn from(variant: LOCKKEY_A) -> Self {
variant as _
}
}
impl crate::FieldSpec for LOCKKEY_A {
type Ux = u16;
}
impl LOCKKEY_R {
#[doc = "Get enumerated values variant"]
#[inline(always)]
pub const fn variant(&self) -> Option<LOCKKEY_A> {
match self.bits {
0 => Some(LOCKKEY_A::UNLOCKED),
1 => Some(LOCKKEY_A::LOCKED),
_ => None,
}
}
#[doc = "`0`"]
#[inline(always)]
pub fn is_unlocked(&self) -> bool {
*self == LOCKKEY_A::UNLOCKED
}
#[doc = "`1`"]
#[inline(always)]
pub fn is_locked(&self) -> bool {
*self == LOCKKEY_A::LOCKED
}
}
#[doc = "Field `LOCKKEY` writer - Configuration Lock Key"]
pub type LOCKKEY_W<'a, REG, const O: u8> = crate::FieldWriter<'a, REG, 16, O, LOCKKEY_A>;
impl<'a, REG, const O: u8> LOCKKEY_W<'a, REG, O>
where
REG: crate::Writable + crate::RegisterSpec,
REG::Ux: From<u16>,
{
#[doc = "`0`"]
#[inline(always)]
pub fn unlocked(self) -> &'a mut crate::W<REG> {
self.variant(LOCKKEY_A::UNLOCKED)
}
#[doc = "`1`"]
#[inline(always)]
pub fn locked(self) -> &'a mut crate::W<REG> {
self.variant(LOCKKEY_A::LOCKED)
}
}
impl R {
#[doc = "Bits 0:15 - Configuration Lock Key"]
#[inline(always)]
pub fn lockkey(&self) -> LOCKKEY_R {
LOCKKEY_R::new((self.bits & 0xffff) as u16)
}
}
impl core::fmt::Debug for R {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("LOCK")
.field("lockkey", &format_args!("{}", self.lockkey().bits()))
.finish()
}
}
impl core::fmt::Debug for crate::generic::Reg<LOCK_SPEC> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
self.read().fmt(f)
}
}
impl W {
#[doc = "Bits 0:15 - Configuration Lock Key"]
#[inline(always)]
#[must_use]
pub fn lockkey(&mut self) -> LOCKKEY_W<LOCK_SPEC, 0> {
LOCKKEY_W::new(self)
}
#[doc = r" Writes raw bits to the register."]
#[doc = r""]
#[doc = r" # Safety"]
#[doc = r""]
#[doc = r" Passing incorrect value can cause undefined behaviour. See reference manual"]
#[inline(always)]
pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
self.bits = bits;
self
}
}
#[doc = "Configuration Lock Register\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`lock::R`](R). You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`lock::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
pub struct LOCK_SPEC;
impl crate::RegisterSpec for LOCK_SPEC {
type Ux = u32;
}
#[doc = "`read()` method returns [`lock::R`](R) reader structure"]
impl crate::Readable for LOCK_SPEC {}
#[doc = "`write(|w| ..)` method takes [`lock::W`](W) writer structure"]
impl crate::Writable for LOCK_SPEC {
const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
}
#[doc = "`reset()` method sets LOCK to value 0"]
impl crate::Resettable for LOCK_SPEC {
const RESET_VALUE: Self::Ux = 0;
}