pub type R = crate::R<CFGRrs>;
pub type W = crate::W<CFGRrs>;
pub type RELOAD_R = crate::FieldReader<u16>;
pub type RELOAD_W<'a, REG> = crate::FieldWriter<'a, REG, 16, u16, crate::Safe>;
pub type FELIM_R = crate::FieldReader;
pub type FELIM_W<'a, REG> = crate::FieldWriter<'a, REG, 8, u8, crate::Safe>;
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum SYNCDIV {
Div1 = 0,
Div2 = 1,
Div4 = 2,
Div8 = 3,
Div16 = 4,
Div32 = 5,
Div64 = 6,
Div128 = 7,
}
impl From<SYNCDIV> for u8 {
#[inline(always)]
fn from(variant: SYNCDIV) -> Self {
variant as _
}
}
impl crate::FieldSpec for SYNCDIV {
type Ux = u8;
}
impl crate::IsEnum for SYNCDIV {}
pub type SYNCDIV_R = crate::FieldReader<SYNCDIV>;
impl SYNCDIV_R {
#[inline(always)]
pub const fn variant(&self) -> SYNCDIV {
match self.bits {
0 => SYNCDIV::Div1,
1 => SYNCDIV::Div2,
2 => SYNCDIV::Div4,
3 => SYNCDIV::Div8,
4 => SYNCDIV::Div16,
5 => SYNCDIV::Div32,
6 => SYNCDIV::Div64,
7 => SYNCDIV::Div128,
_ => unreachable!(),
}
}
#[inline(always)]
pub fn is_div1(&self) -> bool {
*self == SYNCDIV::Div1
}
#[inline(always)]
pub fn is_div2(&self) -> bool {
*self == SYNCDIV::Div2
}
#[inline(always)]
pub fn is_div4(&self) -> bool {
*self == SYNCDIV::Div4
}
#[inline(always)]
pub fn is_div8(&self) -> bool {
*self == SYNCDIV::Div8
}
#[inline(always)]
pub fn is_div16(&self) -> bool {
*self == SYNCDIV::Div16
}
#[inline(always)]
pub fn is_div32(&self) -> bool {
*self == SYNCDIV::Div32
}
#[inline(always)]
pub fn is_div64(&self) -> bool {
*self == SYNCDIV::Div64
}
#[inline(always)]
pub fn is_div128(&self) -> bool {
*self == SYNCDIV::Div128
}
}
pub type SYNCDIV_W<'a, REG> = crate::FieldWriter<'a, REG, 3, SYNCDIV, crate::Safe>;
impl<'a, REG> SYNCDIV_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
REG::Ux: From<u8>,
{
#[inline(always)]
pub fn div1(self) -> &'a mut crate::W<REG> {
self.variant(SYNCDIV::Div1)
}
#[inline(always)]
pub fn div2(self) -> &'a mut crate::W<REG> {
self.variant(SYNCDIV::Div2)
}
#[inline(always)]
pub fn div4(self) -> &'a mut crate::W<REG> {
self.variant(SYNCDIV::Div4)
}
#[inline(always)]
pub fn div8(self) -> &'a mut crate::W<REG> {
self.variant(SYNCDIV::Div8)
}
#[inline(always)]
pub fn div16(self) -> &'a mut crate::W<REG> {
self.variant(SYNCDIV::Div16)
}
#[inline(always)]
pub fn div32(self) -> &'a mut crate::W<REG> {
self.variant(SYNCDIV::Div32)
}
#[inline(always)]
pub fn div64(self) -> &'a mut crate::W<REG> {
self.variant(SYNCDIV::Div64)
}
#[inline(always)]
pub fn div128(self) -> &'a mut crate::W<REG> {
self.variant(SYNCDIV::Div128)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum SYNCSRC {
GpioAf = 0,
Lse = 1,
UsbSof = 2,
}
impl From<SYNCSRC> for u8 {
#[inline(always)]
fn from(variant: SYNCSRC) -> Self {
variant as _
}
}
impl crate::FieldSpec for SYNCSRC {
type Ux = u8;
}
impl crate::IsEnum for SYNCSRC {}
pub type SYNCSRC_R = crate::FieldReader<SYNCSRC>;
impl SYNCSRC_R {
#[inline(always)]
pub const fn variant(&self) -> Option<SYNCSRC> {
match self.bits {
0 => Some(SYNCSRC::GpioAf),
1 => Some(SYNCSRC::Lse),
2 => Some(SYNCSRC::UsbSof),
_ => None,
}
}
#[inline(always)]
pub fn is_gpio_af(&self) -> bool {
*self == SYNCSRC::GpioAf
}
#[inline(always)]
pub fn is_lse(&self) -> bool {
*self == SYNCSRC::Lse
}
#[inline(always)]
pub fn is_usb_sof(&self) -> bool {
*self == SYNCSRC::UsbSof
}
}
pub type SYNCSRC_W<'a, REG> = crate::FieldWriter<'a, REG, 2, SYNCSRC>;
impl<'a, REG> SYNCSRC_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
REG::Ux: From<u8>,
{
#[inline(always)]
pub fn gpio_af(self) -> &'a mut crate::W<REG> {
self.variant(SYNCSRC::GpioAf)
}
#[inline(always)]
pub fn lse(self) -> &'a mut crate::W<REG> {
self.variant(SYNCSRC::Lse)
}
#[inline(always)]
pub fn usb_sof(self) -> &'a mut crate::W<REG> {
self.variant(SYNCSRC::UsbSof)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SYNCPOL {
RisingEdge = 0,
FallingEdge = 1,
}
impl From<SYNCPOL> for bool {
#[inline(always)]
fn from(variant: SYNCPOL) -> Self {
variant as u8 != 0
}
}
pub type SYNCPOL_R = crate::BitReader<SYNCPOL>;
impl SYNCPOL_R {
#[inline(always)]
pub const fn variant(&self) -> SYNCPOL {
match self.bits {
false => SYNCPOL::RisingEdge,
true => SYNCPOL::FallingEdge,
}
}
#[inline(always)]
pub fn is_rising_edge(&self) -> bool {
*self == SYNCPOL::RisingEdge
}
#[inline(always)]
pub fn is_falling_edge(&self) -> bool {
*self == SYNCPOL::FallingEdge
}
}
pub type SYNCPOL_W<'a, REG> = crate::BitWriter<'a, REG, SYNCPOL>;
impl<'a, REG> SYNCPOL_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
{
#[inline(always)]
pub fn rising_edge(self) -> &'a mut crate::W<REG> {
self.variant(SYNCPOL::RisingEdge)
}
#[inline(always)]
pub fn falling_edge(self) -> &'a mut crate::W<REG> {
self.variant(SYNCPOL::FallingEdge)
}
}
impl R {
#[inline(always)]
pub fn reload(&self) -> RELOAD_R {
RELOAD_R::new((self.bits & 0xffff) as u16)
}
#[inline(always)]
pub fn felim(&self) -> FELIM_R {
FELIM_R::new(((self.bits >> 16) & 0xff) as u8)
}
#[inline(always)]
pub fn syncdiv(&self) -> SYNCDIV_R {
SYNCDIV_R::new(((self.bits >> 24) & 7) as u8)
}
#[inline(always)]
pub fn syncsrc(&self) -> SYNCSRC_R {
SYNCSRC_R::new(((self.bits >> 28) & 3) as u8)
}
#[inline(always)]
pub fn syncpol(&self) -> SYNCPOL_R {
SYNCPOL_R::new(((self.bits >> 31) & 1) != 0)
}
}
impl core::fmt::Debug for R {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("CFGR")
.field("syncpol", &self.syncpol())
.field("syncsrc", &self.syncsrc())
.field("syncdiv", &self.syncdiv())
.field("felim", &self.felim())
.field("reload", &self.reload())
.finish()
}
}
impl W {
#[inline(always)]
pub fn reload(&mut self) -> RELOAD_W<CFGRrs> {
RELOAD_W::new(self, 0)
}
#[inline(always)]
pub fn felim(&mut self) -> FELIM_W<CFGRrs> {
FELIM_W::new(self, 16)
}
#[inline(always)]
pub fn syncdiv(&mut self) -> SYNCDIV_W<CFGRrs> {
SYNCDIV_W::new(self, 24)
}
#[inline(always)]
pub fn syncsrc(&mut self) -> SYNCSRC_W<CFGRrs> {
SYNCSRC_W::new(self, 28)
}
#[inline(always)]
pub fn syncpol(&mut self) -> SYNCPOL_W<CFGRrs> {
SYNCPOL_W::new(self, 31)
}
}
pub struct CFGRrs;
impl crate::RegisterSpec for CFGRrs {
type Ux = u32;
}
impl crate::Readable for CFGRrs {}
impl crate::Writable for CFGRrs {
type Safety = crate::Unsafe;
}
impl crate::Resettable for CFGRrs {
const RESET_VALUE: u32 = 0x2022_bb7f;
}