pub type R = crate::R<CFGR3rs>;
pub type W = crate::W<CFGR3rs>;
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum USART1SW {
        Pclk = 0,
        Sysclk = 1,
        Lse = 2,
        Hsi = 3,
}
impl From<USART1SW> for u8 {
    #[inline(always)]
    fn from(variant: USART1SW) -> Self {
        variant as _
    }
}
impl crate::FieldSpec for USART1SW {
    type Ux = u8;
}
impl crate::IsEnum for USART1SW {}
pub type USART1SW_R = crate::FieldReader<USART1SW>;
impl USART1SW_R {
        #[inline(always)]
    pub const fn variant(&self) -> USART1SW {
        match self.bits {
            0 => USART1SW::Pclk,
            1 => USART1SW::Sysclk,
            2 => USART1SW::Lse,
            3 => USART1SW::Hsi,
            _ => unreachable!(),
        }
    }
        #[inline(always)]
    pub fn is_pclk(&self) -> bool {
        *self == USART1SW::Pclk
    }
        #[inline(always)]
    pub fn is_sysclk(&self) -> bool {
        *self == USART1SW::Sysclk
    }
        #[inline(always)]
    pub fn is_lse(&self) -> bool {
        *self == USART1SW::Lse
    }
        #[inline(always)]
    pub fn is_hsi(&self) -> bool {
        *self == USART1SW::Hsi
    }
}
pub type USART1SW_W<'a, REG> = crate::FieldWriter<'a, REG, 2, USART1SW, crate::Safe>;
impl<'a, REG> USART1SW_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
    REG::Ux: From<u8>,
{
        #[inline(always)]
    pub fn pclk(self) -> &'a mut crate::W<REG> {
        self.variant(USART1SW::Pclk)
    }
        #[inline(always)]
    pub fn sysclk(self) -> &'a mut crate::W<REG> {
        self.variant(USART1SW::Sysclk)
    }
        #[inline(always)]
    pub fn lse(self) -> &'a mut crate::W<REG> {
        self.variant(USART1SW::Lse)
    }
        #[inline(always)]
    pub fn hsi(self) -> &'a mut crate::W<REG> {
        self.variant(USART1SW::Hsi)
    }
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum I2C1SW {
        Hsi = 0,
        Sysclk = 1,
}
impl From<I2C1SW> for bool {
    #[inline(always)]
    fn from(variant: I2C1SW) -> Self {
        variant as u8 != 0
    }
}
pub type I2C1SW_R = crate::BitReader<I2C1SW>;
impl I2C1SW_R {
        #[inline(always)]
    pub const fn variant(&self) -> I2C1SW {
        match self.bits {
            false => I2C1SW::Hsi,
            true => I2C1SW::Sysclk,
        }
    }
        #[inline(always)]
    pub fn is_hsi(&self) -> bool {
        *self == I2C1SW::Hsi
    }
        #[inline(always)]
    pub fn is_sysclk(&self) -> bool {
        *self == I2C1SW::Sysclk
    }
}
pub type I2C1SW_W<'a, REG> = crate::BitWriter<'a, REG, I2C1SW>;
impl<'a, REG> I2C1SW_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
        #[inline(always)]
    pub fn hsi(self) -> &'a mut crate::W<REG> {
        self.variant(I2C1SW::Hsi)
    }
        #[inline(always)]
    pub fn sysclk(self) -> &'a mut crate::W<REG> {
        self.variant(I2C1SW::Sysclk)
    }
}
pub use I2C1SW_R as I2C2SW_R;
pub use I2C1SW_W as I2C2SW_W;
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CECSW {
        HsiDiv244 = 0,
        Lse = 1,
}
impl From<CECSW> for bool {
    #[inline(always)]
    fn from(variant: CECSW) -> Self {
        variant as u8 != 0
    }
}
pub type CECSW_R = crate::BitReader<CECSW>;
impl CECSW_R {
        #[inline(always)]
    pub const fn variant(&self) -> CECSW {
        match self.bits {
            false => CECSW::HsiDiv244,
            true => CECSW::Lse,
        }
    }
        #[inline(always)]
    pub fn is_hsi_div244(&self) -> bool {
        *self == CECSW::HsiDiv244
    }
        #[inline(always)]
    pub fn is_lse(&self) -> bool {
        *self == CECSW::Lse
    }
}
pub type CECSW_W<'a, REG> = crate::BitWriter<'a, REG, CECSW>;
impl<'a, REG> CECSW_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
        #[inline(always)]
    pub fn hsi_div244(self) -> &'a mut crate::W<REG> {
        self.variant(CECSW::HsiDiv244)
    }
        #[inline(always)]
    pub fn lse(self) -> &'a mut crate::W<REG> {
        self.variant(CECSW::Lse)
    }
}
pub use USART1SW_R as USART2SW_R;
pub use USART1SW_R as USART3SW_R;
pub use USART1SW_W as USART2SW_W;
pub use USART1SW_W as USART3SW_W;
impl R {
        #[inline(always)]
    pub fn usart1sw(&self) -> USART1SW_R {
        USART1SW_R::new((self.bits & 3) as u8)
    }
        #[inline(always)]
    pub fn i2c1sw(&self) -> I2C1SW_R {
        I2C1SW_R::new(((self.bits >> 4) & 1) != 0)
    }
        #[inline(always)]
    pub fn i2c2sw(&self) -> I2C2SW_R {
        I2C2SW_R::new(((self.bits >> 5) & 1) != 0)
    }
        #[inline(always)]
    pub fn cecsw(&self) -> CECSW_R {
        CECSW_R::new(((self.bits >> 6) & 1) != 0)
    }
        #[inline(always)]
    pub fn usart2sw(&self) -> USART2SW_R {
        USART2SW_R::new(((self.bits >> 16) & 3) as u8)
    }
        #[inline(always)]
    pub fn usart3sw(&self) -> USART3SW_R {
        USART3SW_R::new(((self.bits >> 18) & 3) as u8)
    }
}
impl core::fmt::Debug for R {
    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
        f.debug_struct("CFGR3")
            .field("usart1sw", &self.usart1sw())
            .field("i2c1sw", &self.i2c1sw())
            .field("i2c2sw", &self.i2c2sw())
            .field("cecsw", &self.cecsw())
            .field("usart2sw", &self.usart2sw())
            .field("usart3sw", &self.usart3sw())
            .finish()
    }
}
impl W {
        #[inline(always)]
    pub fn usart1sw(&mut self) -> USART1SW_W<CFGR3rs> {
        USART1SW_W::new(self, 0)
    }
        #[inline(always)]
    pub fn i2c1sw(&mut self) -> I2C1SW_W<CFGR3rs> {
        I2C1SW_W::new(self, 4)
    }
        #[inline(always)]
    pub fn i2c2sw(&mut self) -> I2C2SW_W<CFGR3rs> {
        I2C2SW_W::new(self, 5)
    }
        #[inline(always)]
    pub fn cecsw(&mut self) -> CECSW_W<CFGR3rs> {
        CECSW_W::new(self, 6)
    }
        #[inline(always)]
    pub fn usart2sw(&mut self) -> USART2SW_W<CFGR3rs> {
        USART2SW_W::new(self, 16)
    }
        #[inline(always)]
    pub fn usart3sw(&mut self) -> USART3SW_W<CFGR3rs> {
        USART3SW_W::new(self, 18)
    }
}
pub struct CFGR3rs;
impl crate::RegisterSpec for CFGR3rs {
    type Ux = u32;
}
impl crate::Readable for CFGR3rs {}
impl crate::Writable for CFGR3rs {
    type Safety = crate::Unsafe;
}
impl crate::Resettable for CFGR3rs {}