#[doc = "Register `PLL1_TEST` reader"]
pub struct R(crate::R<PLL1_TEST_SPEC>);
impl core::ops::Deref for R {
    type Target = crate::R<PLL1_TEST_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::convert::From<crate::R<PLL1_TEST_SPEC>> for R {
    fn from(reader: crate::R<PLL1_TEST_SPEC>) -> Self {
        R(reader)
    }
}
#[doc = "Register `PLL1_TEST` writer"]
pub struct W(crate::W<PLL1_TEST_SPEC>);
impl core::ops::Deref for W {
    type Target = crate::W<PLL1_TEST_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<PLL1_TEST_SPEC>> for W {
    fn from(writer: crate::W<PLL1_TEST_SPEC>) -> Self {
        W(writer)
    }
}
#[doc = "Test Mode\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum TEST_MODE_A {
    #[doc = "0: No description available"]
    NORMAL = 0,
    #[doc = "1: No description available"]
    TEST_VC_LKG = 1,
    #[doc = "2: No description available"]
    TEST_CP_DN = 2,
    #[doc = "3: No description available"]
    TEST_CP_UP = 3,
    #[doc = "4: No description available"]
    USER_EXT_FL = 4,
    #[doc = "5: No description available"]
    TEST_CTR_PQ = 5,
    #[doc = "6: No description available"]
    TEST_LD_DLY = 6,
    #[doc = "7: No description available"]
    TEST_CTR_ALT = 7,
}
impl From<TEST_MODE_A> for u8 {
    #[inline(always)]
    fn from(variant: TEST_MODE_A) -> Self {
        variant as _
    }
}
#[doc = "Field `TEST_MODE` reader - Test Mode"]
pub struct TEST_MODE_R(crate::FieldReader<u8, TEST_MODE_A>);
impl TEST_MODE_R {
    pub(crate) fn new(bits: u8) -> Self {
        TEST_MODE_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> TEST_MODE_A {
        match self.bits {
            0 => TEST_MODE_A::NORMAL,
            1 => TEST_MODE_A::TEST_VC_LKG,
            2 => TEST_MODE_A::TEST_CP_DN,
            3 => TEST_MODE_A::TEST_CP_UP,
            4 => TEST_MODE_A::USER_EXT_FL,
            5 => TEST_MODE_A::TEST_CTR_PQ,
            6 => TEST_MODE_A::TEST_LD_DLY,
            7 => TEST_MODE_A::TEST_CTR_ALT,
            _ => unreachable!(),
        }
    }
    #[doc = "Checks if the value of the field is `NORMAL`"]
    #[inline(always)]
    pub fn is_normal(&self) -> bool {
        **self == TEST_MODE_A::NORMAL
    }
    #[doc = "Checks if the value of the field is `TEST_VC_LKG`"]
    #[inline(always)]
    pub fn is_test_vc_lkg(&self) -> bool {
        **self == TEST_MODE_A::TEST_VC_LKG
    }
    #[doc = "Checks if the value of the field is `TEST_CP_DN`"]
    #[inline(always)]
    pub fn is_test_cp_dn(&self) -> bool {
        **self == TEST_MODE_A::TEST_CP_DN
    }
    #[doc = "Checks if the value of the field is `TEST_CP_UP`"]
    #[inline(always)]
    pub fn is_test_cp_up(&self) -> bool {
        **self == TEST_MODE_A::TEST_CP_UP
    }
    #[doc = "Checks if the value of the field is `USER_EXT_FL`"]
    #[inline(always)]
    pub fn is_user_ext_fl(&self) -> bool {
        **self == TEST_MODE_A::USER_EXT_FL
    }
    #[doc = "Checks if the value of the field is `TEST_CTR_PQ`"]
    #[inline(always)]
    pub fn is_test_ctr_pq(&self) -> bool {
        **self == TEST_MODE_A::TEST_CTR_PQ
    }
    #[doc = "Checks if the value of the field is `TEST_LD_DLY`"]
    #[inline(always)]
    pub fn is_test_ld_dly(&self) -> bool {
        **self == TEST_MODE_A::TEST_LD_DLY
    }
    #[doc = "Checks if the value of the field is `TEST_CTR_ALT`"]
    #[inline(always)]
    pub fn is_test_ctr_alt(&self) -> bool {
        **self == TEST_MODE_A::TEST_CTR_ALT
    }
}
impl core::ops::Deref for TEST_MODE_R {
    type Target = crate::FieldReader<u8, TEST_MODE_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `TEST_MODE` writer - Test Mode"]
pub struct TEST_MODE_W<'a> {
    w: &'a mut W,
}
impl<'a> TEST_MODE_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: TEST_MODE_A) -> &'a mut W {
        self.bits(variant.into())
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn normal(self) -> &'a mut W {
        self.variant(TEST_MODE_A::NORMAL)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn test_vc_lkg(self) -> &'a mut W {
        self.variant(TEST_MODE_A::TEST_VC_LKG)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn test_cp_dn(self) -> &'a mut W {
        self.variant(TEST_MODE_A::TEST_CP_DN)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn test_cp_up(self) -> &'a mut W {
        self.variant(TEST_MODE_A::TEST_CP_UP)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn user_ext_fl(self) -> &'a mut W {
        self.variant(TEST_MODE_A::USER_EXT_FL)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn test_ctr_pq(self) -> &'a mut W {
        self.variant(TEST_MODE_A::TEST_CTR_PQ)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn test_ld_dly(self) -> &'a mut W {
        self.variant(TEST_MODE_A::TEST_LD_DLY)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn test_ctr_alt(self) -> &'a mut W {
        self.variant(TEST_MODE_A::TEST_CTR_ALT)
    }
    #[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 & !0x07) | (value as u32 & 0x07);
        self.w
    }
}
#[doc = "Field `FAST_LOCK_EN` reader - Fast Lock Enable - Speeds up the lock time when set to 1. When ISOLATE_N is high, the PLL control voltage will be precharged to reduce time spent acquiring frequency lock."]
pub struct FAST_LOCK_EN_R(crate::FieldReader<bool, bool>);
impl FAST_LOCK_EN_R {
    pub(crate) fn new(bits: bool) -> Self {
        FAST_LOCK_EN_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for FAST_LOCK_EN_R {
    type Target = crate::FieldReader<bool, bool>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `FAST_LOCK_EN` writer - Fast Lock Enable - Speeds up the lock time when set to 1. When ISOLATE_N is high, the PLL control voltage will be precharged to reduce time spent acquiring frequency lock."]
pub struct FAST_LOCK_EN_W<'a> {
    w: &'a mut W,
}
impl<'a> FAST_LOCK_EN_W<'a> {
    #[doc = r"Sets the field bit"]
    #[inline(always)]
    pub fn set_bit(self) -> &'a mut W {
        self.bit(true)
    }
    #[doc = r"Clears the field bit"]
    #[inline(always)]
    pub fn clear_bit(self) -> &'a mut W {
        self.bit(false)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bit(self, value: bool) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x01 << 3)) | ((value as u32 & 0x01) << 3);
        self.w
    }
}
#[doc = "Field `UNLOCK_OCCURRED` writer - This bit sets whenever the PLL Lock bit goes low, and stays set until cleared by firmware. This is a diagnostic bit used for char and validation."]
pub struct UNLOCK_OCCURRED_W<'a> {
    w: &'a mut W,
}
impl<'a> UNLOCK_OCCURRED_W<'a> {
    #[doc = r"Sets the field bit"]
    #[inline(always)]
    pub fn set_bit(self) -> &'a mut W {
        self.bit(true)
    }
    #[doc = r"Clears the field bit"]
    #[inline(always)]
    pub fn clear_bit(self) -> &'a mut W {
        self.bit(false)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bit(self, value: bool) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x01 << 4)) | ((value as u32 & 0x01) << 4);
        self.w
    }
}
impl R {
    #[doc = "Bits 0:2 - Test Mode"]
    #[inline(always)]
    pub fn test_mode(&self) -> TEST_MODE_R {
        TEST_MODE_R::new((self.bits & 0x07) as u8)
    }
    #[doc = "Bit 3 - Fast Lock Enable - Speeds up the lock time when set to 1. When ISOLATE_N is high, the PLL control voltage will be precharged to reduce time spent acquiring frequency lock."]
    #[inline(always)]
    pub fn fast_lock_en(&self) -> FAST_LOCK_EN_R {
        FAST_LOCK_EN_R::new(((self.bits >> 3) & 0x01) != 0)
    }
}
impl W {
    #[doc = "Bits 0:2 - Test Mode"]
    #[inline(always)]
    pub fn test_mode(&mut self) -> TEST_MODE_W {
        TEST_MODE_W { w: self }
    }
    #[doc = "Bit 3 - Fast Lock Enable - Speeds up the lock time when set to 1. When ISOLATE_N is high, the PLL control voltage will be precharged to reduce time spent acquiring frequency lock."]
    #[inline(always)]
    pub fn fast_lock_en(&mut self) -> FAST_LOCK_EN_W {
        FAST_LOCK_EN_W { w: self }
    }
    #[doc = "Bit 4 - This bit sets whenever the PLL Lock bit goes low, and stays set until cleared by firmware. This is a diagnostic bit used for char and validation."]
    #[inline(always)]
    pub fn unlock_occurred(&mut self) -> UNLOCK_OCCURRED_W {
        UNLOCK_OCCURRED_W { w: self }
    }
    #[doc = "Writes raw bits to the register."]
    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
        self.0.bits(bits);
        self
    }
}
#[doc = "PLL #1 Test Register\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 [pll1_test](index.html) module"]
pub struct PLL1_TEST_SPEC;
impl crate::RegisterSpec for PLL1_TEST_SPEC {
    type Ux = u32;
}
#[doc = "`read()` method returns [pll1_test::R](R) reader structure"]
impl crate::Readable for PLL1_TEST_SPEC {
    type Reader = R;
}
#[doc = "`write(|w| ..)` method takes [pll1_test::W](W) writer structure"]
impl crate::Writable for PLL1_TEST_SPEC {
    type Writer = W;
}
#[doc = "`reset()` method sets PLL1_TEST to value 0"]
impl crate::Resettable for PLL1_TEST_SPEC {
    #[inline(always)]
    fn reset_value() -> Self::Ux {
        0
    }
}
