#[doc = "Register `CFG0` reader"]
pub struct R(crate::R<CFG0_SPEC>);
impl core::ops::Deref for R {
    type Target = crate::R<CFG0_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::convert::From<crate::R<CFG0_SPEC>> for R {
    fn from(reader: crate::R<CFG0_SPEC>) -> Self {
        R(reader)
    }
}
#[doc = "Register `CFG0` writer"]
pub struct W(crate::W<CFG0_SPEC>);
impl core::ops::Deref for W {
    type Target = crate::W<CFG0_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<CFG0_SPEC>> for W {
    fn from(writer: crate::W<CFG0_SPEC>) -> Self {
        W(writer)
    }
}
#[doc = "Select one of four choices for clock enable\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum CLKIN_EN_SEL_A {
    #[doc = "0: No description available"]
    PIN_RC = 0,
    #[doc = "1: No description available"]
    DSI_RC_0 = 1,
    #[doc = "2: No description available"]
    DSI_RC_1 = 2,
    #[doc = "3: No description available"]
    DSI_RC_2 = 3,
}
impl From<CLKIN_EN_SEL_A> for u8 {
    #[inline(always)]
    fn from(variant: CLKIN_EN_SEL_A) -> Self {
        variant as _
    }
}
#[doc = "Field `CLKIN_EN_SEL` reader - Select one of four choices for clock enable"]
pub struct CLKIN_EN_SEL_R(crate::FieldReader<u8, CLKIN_EN_SEL_A>);
impl CLKIN_EN_SEL_R {
    pub(crate) fn new(bits: u8) -> Self {
        CLKIN_EN_SEL_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> CLKIN_EN_SEL_A {
        match self.bits {
            0 => CLKIN_EN_SEL_A::PIN_RC,
            1 => CLKIN_EN_SEL_A::DSI_RC_0,
            2 => CLKIN_EN_SEL_A::DSI_RC_1,
            3 => CLKIN_EN_SEL_A::DSI_RC_2,
            _ => unreachable!(),
        }
    }
    #[doc = "Checks if the value of the field is `PIN_RC`"]
    #[inline(always)]
    pub fn is_pin_rc(&self) -> bool {
        **self == CLKIN_EN_SEL_A::PIN_RC
    }
    #[doc = "Checks if the value of the field is `DSI_RC_0`"]
    #[inline(always)]
    pub fn is_dsi_rc_0(&self) -> bool {
        **self == CLKIN_EN_SEL_A::DSI_RC_0
    }
    #[doc = "Checks if the value of the field is `DSI_RC_1`"]
    #[inline(always)]
    pub fn is_dsi_rc_1(&self) -> bool {
        **self == CLKIN_EN_SEL_A::DSI_RC_1
    }
    #[doc = "Checks if the value of the field is `DSI_RC_2`"]
    #[inline(always)]
    pub fn is_dsi_rc_2(&self) -> bool {
        **self == CLKIN_EN_SEL_A::DSI_RC_2
    }
}
impl core::ops::Deref for CLKIN_EN_SEL_R {
    type Target = crate::FieldReader<u8, CLKIN_EN_SEL_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `CLKIN_EN_SEL` writer - Select one of four choices for clock enable"]
pub struct CLKIN_EN_SEL_W<'a> {
    w: &'a mut W,
}
impl<'a> CLKIN_EN_SEL_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: CLKIN_EN_SEL_A) -> &'a mut W {
        self.bits(variant.into())
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn pin_rc(self) -> &'a mut W {
        self.variant(CLKIN_EN_SEL_A::PIN_RC)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn dsi_rc_0(self) -> &'a mut W {
        self.variant(CLKIN_EN_SEL_A::DSI_RC_0)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn dsi_rc_1(self) -> &'a mut W {
        self.variant(CLKIN_EN_SEL_A::DSI_RC_1)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn dsi_rc_2(self) -> &'a mut W {
        self.variant(CLKIN_EN_SEL_A::DSI_RC_2)
    }
    #[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
    }
}
#[doc = "Select one of four operating modes\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum CLKIN_EN_MODE_A {
    #[doc = "0: No description available"]
    OFF = 0,
    #[doc = "1: No description available"]
    ON = 1,
    #[doc = "2: No description available"]
    POSEDGE = 2,
    #[doc = "3: No description available"]
    LEVEL = 3,
}
impl From<CLKIN_EN_MODE_A> for u8 {
    #[inline(always)]
    fn from(variant: CLKIN_EN_MODE_A) -> Self {
        variant as _
    }
}
#[doc = "Field `CLKIN_EN_MODE` reader - Select one of four operating modes"]
pub struct CLKIN_EN_MODE_R(crate::FieldReader<u8, CLKIN_EN_MODE_A>);
impl CLKIN_EN_MODE_R {
    pub(crate) fn new(bits: u8) -> Self {
        CLKIN_EN_MODE_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> CLKIN_EN_MODE_A {
        match self.bits {
            0 => CLKIN_EN_MODE_A::OFF,
            1 => CLKIN_EN_MODE_A::ON,
            2 => CLKIN_EN_MODE_A::POSEDGE,
            3 => CLKIN_EN_MODE_A::LEVEL,
            _ => unreachable!(),
        }
    }
    #[doc = "Checks if the value of the field is `OFF`"]
    #[inline(always)]
    pub fn is_off(&self) -> bool {
        **self == CLKIN_EN_MODE_A::OFF
    }
    #[doc = "Checks if the value of the field is `ON`"]
    #[inline(always)]
    pub fn is_on(&self) -> bool {
        **self == CLKIN_EN_MODE_A::ON
    }
    #[doc = "Checks if the value of the field is `POSEDGE`"]
    #[inline(always)]
    pub fn is_posedge(&self) -> bool {
        **self == CLKIN_EN_MODE_A::POSEDGE
    }
    #[doc = "Checks if the value of the field is `LEVEL`"]
    #[inline(always)]
    pub fn is_level(&self) -> bool {
        **self == CLKIN_EN_MODE_A::LEVEL
    }
}
impl core::ops::Deref for CLKIN_EN_MODE_R {
    type Target = crate::FieldReader<u8, CLKIN_EN_MODE_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `CLKIN_EN_MODE` writer - Select one of four operating modes"]
pub struct CLKIN_EN_MODE_W<'a> {
    w: &'a mut W,
}
impl<'a> CLKIN_EN_MODE_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: CLKIN_EN_MODE_A) -> &'a mut W {
        self.bits(variant.into())
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn off(self) -> &'a mut W {
        self.variant(CLKIN_EN_MODE_A::OFF)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn on(self) -> &'a mut W {
        self.variant(CLKIN_EN_MODE_A::ON)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn posedge(self) -> &'a mut W {
        self.variant(CLKIN_EN_MODE_A::POSEDGE)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn level(self) -> &'a mut W {
        self.variant(CLKIN_EN_MODE_A::LEVEL)
    }
    #[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 << 2)) | ((value as u8 & 0x03) << 2);
        self.w
    }
}
#[doc = "Determines whether the selected enable is inverted or not.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum CLKIN_EN_INV_A {
    #[doc = "0: No description available"]
    NOINV = 0,
    #[doc = "1: No description available"]
    INV = 1,
}
impl From<CLKIN_EN_INV_A> for bool {
    #[inline(always)]
    fn from(variant: CLKIN_EN_INV_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `CLKIN_EN_INV` reader - Determines whether the selected enable is inverted or not."]
pub struct CLKIN_EN_INV_R(crate::FieldReader<bool, CLKIN_EN_INV_A>);
impl CLKIN_EN_INV_R {
    pub(crate) fn new(bits: bool) -> Self {
        CLKIN_EN_INV_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> CLKIN_EN_INV_A {
        match self.bits {
            false => CLKIN_EN_INV_A::NOINV,
            true => CLKIN_EN_INV_A::INV,
        }
    }
    #[doc = "Checks if the value of the field is `NOINV`"]
    #[inline(always)]
    pub fn is_noinv(&self) -> bool {
        **self == CLKIN_EN_INV_A::NOINV
    }
    #[doc = "Checks if the value of the field is `INV`"]
    #[inline(always)]
    pub fn is_inv(&self) -> bool {
        **self == CLKIN_EN_INV_A::INV
    }
}
impl core::ops::Deref for CLKIN_EN_INV_R {
    type Target = crate::FieldReader<bool, CLKIN_EN_INV_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `CLKIN_EN_INV` writer - Determines whether the selected enable is inverted or not."]
pub struct CLKIN_EN_INV_W<'a> {
    w: &'a mut W,
}
impl<'a> CLKIN_EN_INV_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: CLKIN_EN_INV_A) -> &'a mut W {
        self.bit(variant.into())
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn noinv(self) -> &'a mut W {
        self.variant(CLKIN_EN_INV_A::NOINV)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn inv(self) -> &'a mut W {
        self.variant(CLKIN_EN_INV_A::INV)
    }
    #[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 u8 & 0x01) << 4);
        self.w
    }
}
#[doc = "Determines whether the selected clock is inverted or not.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum CLKIN_INV_A {
    #[doc = "0: No description available"]
    NOINV = 0,
    #[doc = "1: No description available"]
    INV = 1,
}
impl From<CLKIN_INV_A> for bool {
    #[inline(always)]
    fn from(variant: CLKIN_INV_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `CLKIN_INV` reader - Determines whether the selected clock is inverted or not."]
pub struct CLKIN_INV_R(crate::FieldReader<bool, CLKIN_INV_A>);
impl CLKIN_INV_R {
    pub(crate) fn new(bits: bool) -> Self {
        CLKIN_INV_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> CLKIN_INV_A {
        match self.bits {
            false => CLKIN_INV_A::NOINV,
            true => CLKIN_INV_A::INV,
        }
    }
    #[doc = "Checks if the value of the field is `NOINV`"]
    #[inline(always)]
    pub fn is_noinv(&self) -> bool {
        **self == CLKIN_INV_A::NOINV
    }
    #[doc = "Checks if the value of the field is `INV`"]
    #[inline(always)]
    pub fn is_inv(&self) -> bool {
        **self == CLKIN_INV_A::INV
    }
}
impl core::ops::Deref for CLKIN_INV_R {
    type Target = crate::FieldReader<bool, CLKIN_INV_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `CLKIN_INV` writer - Determines whether the selected clock is inverted or not."]
pub struct CLKIN_INV_W<'a> {
    w: &'a mut W,
}
impl<'a> CLKIN_INV_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: CLKIN_INV_A) -> &'a mut W {
        self.bit(variant.into())
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn noinv(self) -> &'a mut W {
        self.variant(CLKIN_INV_A::NOINV)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn inv(self) -> &'a mut W {
        self.variant(CLKIN_INV_A::INV)
    }
    #[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 << 5)) | ((value as u8 & 0x01) << 5);
        self.w
    }
}
#[doc = "Field `NC` reader - Spare register bits"]
pub struct NC_R(crate::FieldReader<u8, u8>);
impl NC_R {
    pub(crate) fn new(bits: u8) -> Self {
        NC_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for NC_R {
    type Target = crate::FieldReader<u8, u8>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `NC` writer - Spare register bits"]
pub struct NC_W<'a> {
    w: &'a mut W,
}
impl<'a> NC_W<'a> {
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub unsafe fn bits(self, value: u8) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x03 << 6)) | ((value as u8 & 0x03) << 6);
        self.w
    }
}
impl R {
    #[doc = "Bits 0:1 - Select one of four choices for clock enable"]
    #[inline(always)]
    pub fn clkin_en_sel(&self) -> CLKIN_EN_SEL_R {
        CLKIN_EN_SEL_R::new((self.bits & 0x03) as u8)
    }
    #[doc = "Bits 2:3 - Select one of four operating modes"]
    #[inline(always)]
    pub fn clkin_en_mode(&self) -> CLKIN_EN_MODE_R {
        CLKIN_EN_MODE_R::new(((self.bits >> 2) & 0x03) as u8)
    }
    #[doc = "Bit 4 - Determines whether the selected enable is inverted or not."]
    #[inline(always)]
    pub fn clkin_en_inv(&self) -> CLKIN_EN_INV_R {
        CLKIN_EN_INV_R::new(((self.bits >> 4) & 0x01) != 0)
    }
    #[doc = "Bit 5 - Determines whether the selected clock is inverted or not."]
    #[inline(always)]
    pub fn clkin_inv(&self) -> CLKIN_INV_R {
        CLKIN_INV_R::new(((self.bits >> 5) & 0x01) != 0)
    }
    #[doc = "Bits 6:7 - Spare register bits"]
    #[inline(always)]
    pub fn nc(&self) -> NC_R {
        NC_R::new(((self.bits >> 6) & 0x03) as u8)
    }
}
impl W {
    #[doc = "Bits 0:1 - Select one of four choices for clock enable"]
    #[inline(always)]
    pub fn clkin_en_sel(&mut self) -> CLKIN_EN_SEL_W {
        CLKIN_EN_SEL_W { w: self }
    }
    #[doc = "Bits 2:3 - Select one of four operating modes"]
    #[inline(always)]
    pub fn clkin_en_mode(&mut self) -> CLKIN_EN_MODE_W {
        CLKIN_EN_MODE_W { w: self }
    }
    #[doc = "Bit 4 - Determines whether the selected enable is inverted or not."]
    #[inline(always)]
    pub fn clkin_en_inv(&mut self) -> CLKIN_EN_INV_W {
        CLKIN_EN_INV_W { w: self }
    }
    #[doc = "Bit 5 - Determines whether the selected clock is inverted or not."]
    #[inline(always)]
    pub fn clkin_inv(&mut self) -> CLKIN_INV_W {
        CLKIN_INV_W { w: self }
    }
    #[doc = "Bits 6:7 - Spare register bits"]
    #[inline(always)]
    pub fn nc(&mut self) -> NC_W {
        NC_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 = "PA Data In Clock Control 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 [cfg0](index.html) module"]
pub struct CFG0_SPEC;
impl crate::RegisterSpec for CFG0_SPEC {
    type Ux = u8;
}
#[doc = "`read()` method returns [cfg0::R](R) reader structure"]
impl crate::Readable for CFG0_SPEC {
    type Reader = R;
}
#[doc = "`write(|w| ..)` method takes [cfg0::W](W) writer structure"]
impl crate::Writable for CFG0_SPEC {
    type Writer = W;
}
#[doc = "`reset()` method sets CFG0 to value 0"]
impl crate::Resettable for CFG0_SPEC {
    #[inline(always)]
    fn reset_value() -> Self::Ux {
        0
    }
}
