#[doc = "Register `PROT_PROTECTION` reader"]
pub struct R(crate::R<PROT_PROTECTION_SPEC>);
impl core::ops::Deref for R {
    type Target = crate::R<PROT_PROTECTION_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::convert::From<crate::R<PROT_PROTECTION_SPEC>> for R {
    fn from(reader: crate::R<PROT_PROTECTION_SPEC>) -> Self {
        R(reader)
    }
}
#[doc = "Register `PROT_PROTECTION` writer"]
pub struct W(crate::W<PROT_PROTECTION_SPEC>);
impl core::ops::Deref for W {
    type Target = crate::W<PROT_PROTECTION_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::ops::DerefMut for W {
    #[inline(always)]
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}
impl core::convert::From<crate::W<PROT_PROTECTION_SPEC>> for W {
    fn from(writer: crate::W<PROT_PROTECTION_SPEC>) -> Self {
        W(writer)
    }
}
#[doc = "Current Protection Mode - note that encoding is different from CPUSS_PROTECTION !!\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum PROT_LEVEL_A {
    #[doc = "1: No description available"]
    VIRGIN = 1,
    #[doc = "0: No description available"]
    OPEN = 0,
    #[doc = "2: No description available"]
    PROTECTED = 2,
    #[doc = "3: No description available"]
    KILL = 3,
}
impl From<PROT_LEVEL_A> for u8 {
    #[inline(always)]
    fn from(variant: PROT_LEVEL_A) -> Self {
        variant as _
    }
}
#[doc = "Field `PROT_LEVEL` reader - Current Protection Mode - note that encoding is different from CPUSS_PROTECTION !!"]
pub struct PROT_LEVEL_R(crate::FieldReader<u8, PROT_LEVEL_A>);
impl PROT_LEVEL_R {
    pub(crate) fn new(bits: u8) -> Self {
        PROT_LEVEL_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> PROT_LEVEL_A {
        match self.bits {
            1 => PROT_LEVEL_A::VIRGIN,
            0 => PROT_LEVEL_A::OPEN,
            2 => PROT_LEVEL_A::PROTECTED,
            3 => PROT_LEVEL_A::KILL,
            _ => unreachable!(),
        }
    }
    #[doc = "Checks if the value of the field is `VIRGIN`"]
    #[inline(always)]
    pub fn is_virgin(&self) -> bool {
        **self == PROT_LEVEL_A::VIRGIN
    }
    #[doc = "Checks if the value of the field is `OPEN`"]
    #[inline(always)]
    pub fn is_open(&self) -> bool {
        **self == PROT_LEVEL_A::OPEN
    }
    #[doc = "Checks if the value of the field is `PROTECTED`"]
    #[inline(always)]
    pub fn is_protected(&self) -> bool {
        **self == PROT_LEVEL_A::PROTECTED
    }
    #[doc = "Checks if the value of the field is `KILL`"]
    #[inline(always)]
    pub fn is_kill(&self) -> bool {
        **self == PROT_LEVEL_A::KILL
    }
}
impl core::ops::Deref for PROT_LEVEL_R {
    type Target = crate::FieldReader<u8, PROT_LEVEL_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `PROT_LEVEL` writer - Current Protection Mode - note that encoding is different from CPUSS_PROTECTION !!"]
pub struct PROT_LEVEL_W<'a> {
    w: &'a mut W,
}
impl<'a> PROT_LEVEL_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: PROT_LEVEL_A) -> &'a mut W {
        self.bits(variant.into())
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn virgin(self) -> &'a mut W {
        self.variant(PROT_LEVEL_A::VIRGIN)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn open(self) -> &'a mut W {
        self.variant(PROT_LEVEL_A::OPEN)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn protected(self) -> &'a mut W {
        self.variant(PROT_LEVEL_A::PROTECTED)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn kill(self) -> &'a mut W {
        self.variant(PROT_LEVEL_A::KILL)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bits(self, value: u8) -> &'a mut W {
        self.w.bits = (self.w.bits & !0x03) | (value as u8 & 0x03);
        self.w
    }
}
impl R {
    #[doc = "Bits 0:1 - Current Protection Mode - note that encoding is different from CPUSS_PROTECTION !!"]
    #[inline(always)]
    pub fn prot_level(&self) -> PROT_LEVEL_R {
        PROT_LEVEL_R::new((self.bits & 0x03) as u8)
    }
}
impl W {
    #[doc = "Bits 0:1 - Current Protection Mode - note that encoding is different from CPUSS_PROTECTION !!"]
    #[inline(always)]
    pub fn prot_level(&mut self) -> PROT_LEVEL_W {
        PROT_LEVEL_W { w: self }
    }
    #[doc = "Writes raw bits to the register."]
    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
        self.0.bits(bits);
        self
    }
}
#[doc = "Protection Level\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [prot_protection](index.html) module"]
pub struct PROT_PROTECTION_SPEC;
impl crate::RegisterSpec for PROT_PROTECTION_SPEC {
    type Ux = u8;
}
#[doc = "`read()` method returns [prot_protection::R](R) reader structure"]
impl crate::Readable for PROT_PROTECTION_SPEC {
    type Reader = R;
}
#[doc = "`write(|w| ..)` method takes [prot_protection::W](W) writer structure"]
impl crate::Writable for PROT_PROTECTION_SPEC {
    type Writer = W;
}
#[doc = "`reset()` method sets PROT_PROTECTION to value 0"]
impl crate::Resettable for PROT_PROTECTION_SPEC {
    #[inline(always)]
    fn reset_value() -> Self::Ux {
        0
    }
}
