#[doc = "Reader of register LOCK"]
pub type R = crate::R<u32, super::LOCK>;
#[doc = "Writer for register LOCK"]
pub type W = crate::W<u32, super::LOCK>;
#[doc = "Register LOCK `reset()`'s with value 0"]
impl crate::ResetValue for super::LOCK {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
0
}
}
#[doc = "GPIO Lock\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u32)]
pub enum LOCK_A {
#[doc = "0: The GPIOCR register is unlocked and may be modified"]
UNLOCKED = 0,
#[doc = "1: The GPIOCR register is locked and may not be modified"]
LOCKED = 1,
#[doc = "1280262987: Unlocks the GPIO_CR register"]
KEY = 1280262987,
}
impl From<LOCK_A> for u32 {
#[inline(always)]
fn from(variant: LOCK_A) -> Self {
variant as _
}
}
#[doc = "Reader of field `LOCK`"]
pub type LOCK_R = crate::R<u32, LOCK_A>;
impl LOCK_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> crate::Variant<u32, LOCK_A> {
use crate::Variant::*;
match self.bits {
0 => Val(LOCK_A::UNLOCKED),
1 => Val(LOCK_A::LOCKED),
1280262987 => Val(LOCK_A::KEY),
i => Res(i),
}
}
#[doc = "Checks if the value of the field is `UNLOCKED`"]
#[inline(always)]
pub fn is_unlocked(&self) -> bool {
*self == LOCK_A::UNLOCKED
}
#[doc = "Checks if the value of the field is `LOCKED`"]
#[inline(always)]
pub fn is_locked(&self) -> bool {
*self == LOCK_A::LOCKED
}
#[doc = "Checks if the value of the field is `KEY`"]
#[inline(always)]
pub fn is_key(&self) -> bool {
*self == LOCK_A::KEY
}
}
#[doc = "Write proxy for field `LOCK`"]
pub struct LOCK_W<'a> {
w: &'a mut W,
}
impl<'a> LOCK_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: LOCK_A) -> &'a mut W {
unsafe { self.bits(variant.into()) }
}
#[doc = "The GPIOCR register is unlocked and may be modified"]
#[inline(always)]
pub fn unlocked(self) -> &'a mut W {
self.variant(LOCK_A::UNLOCKED)
}
#[doc = "The GPIOCR register is locked and may not be modified"]
#[inline(always)]
pub fn locked(self) -> &'a mut W {
self.variant(LOCK_A::LOCKED)
}
#[doc = "Unlocks the GPIO_CR register"]
#[inline(always)]
pub fn key(self) -> &'a mut W {
self.variant(LOCK_A::KEY)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u32) -> &'a mut W {
self.w.bits = (self.w.bits & !0xffff_ffff) | ((value as u32) & 0xffff_ffff);
self.w
}
}
impl R {
#[doc = "Bits 0:31 - GPIO Lock"]
#[inline(always)]
pub fn lock(&self) -> LOCK_R {
LOCK_R::new((self.bits & 0xffff_ffff) as u32)
}
}
impl W {
#[doc = "Bits 0:31 - GPIO Lock"]
#[inline(always)]
pub fn lock(&mut self) -> LOCK_W {
LOCK_W { w: self }
}
}