pub type R = crate::R<CTRLrs>;
pub type W = crate::W<CTRLrs>;
pub type EnR = crate::BitReader;
pub type EnW<'a, REG> = crate::BitWriter<'a, REG>;
pub type DebugrunR = crate::BitReader;
pub type DebugrunW<'a, REG> = crate::BitWriter<'a, REG>;
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum OSCSEL {
Lfrco = 0,
Lfxo = 1,
Ulfrco = 2,
}
impl From<OSCSEL> for u8 {
#[inline(always)]
fn from(variant: OSCSEL) -> Self {
variant as _
}
}
impl crate::FieldSpec for OSCSEL {
type Ux = u8;
}
impl crate::IsEnum for OSCSEL {}
pub type OscselR = crate::FieldReader<OSCSEL>;
impl OscselR {
#[inline(always)]
pub const fn variant(&self) -> Option<OSCSEL> {
match self.bits {
0 => Some(OSCSEL::Lfrco),
1 => Some(OSCSEL::Lfxo),
2 => Some(OSCSEL::Ulfrco),
_ => None,
}
}
#[inline(always)]
pub fn is_lfrco(&self) -> bool {
*self == OSCSEL::Lfrco
}
#[inline(always)]
pub fn is_lfxo(&self) -> bool {
*self == OSCSEL::Lfxo
}
#[inline(always)]
pub fn is_ulfrco(&self) -> bool {
*self == OSCSEL::Ulfrco
}
}
pub type OscselW<'a, REG> = crate::FieldWriter<'a, REG, 2, OSCSEL>;
impl<'a, REG> OscselW<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
REG::Ux: From<u8>,
{
#[inline(always)]
pub fn lfrco(self) -> &'a mut crate::W<REG> {
self.variant(OSCSEL::Lfrco)
}
#[inline(always)]
pub fn lfxo(self) -> &'a mut crate::W<REG> {
self.variant(OSCSEL::Lfxo)
}
#[inline(always)]
pub fn ulfrco(self) -> &'a mut crate::W<REG> {
self.variant(OSCSEL::Ulfrco)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum PRESC {
Div1 = 0,
Div2 = 1,
Div4 = 2,
Div8 = 3,
Div16 = 4,
Div32 = 5,
Div64 = 6,
Div128 = 7,
}
impl From<PRESC> for u8 {
#[inline(always)]
fn from(variant: PRESC) -> Self {
variant as _
}
}
impl crate::FieldSpec for PRESC {
type Ux = u8;
}
impl crate::IsEnum for PRESC {}
pub type PrescR = crate::FieldReader<PRESC>;
impl PrescR {
#[inline(always)]
pub const fn variant(&self) -> PRESC {
match self.bits {
0 => PRESC::Div1,
1 => PRESC::Div2,
2 => PRESC::Div4,
3 => PRESC::Div8,
4 => PRESC::Div16,
5 => PRESC::Div32,
6 => PRESC::Div64,
7 => PRESC::Div128,
_ => unreachable!(),
}
}
#[inline(always)]
pub fn is_div1(&self) -> bool {
*self == PRESC::Div1
}
#[inline(always)]
pub fn is_div2(&self) -> bool {
*self == PRESC::Div2
}
#[inline(always)]
pub fn is_div4(&self) -> bool {
*self == PRESC::Div4
}
#[inline(always)]
pub fn is_div8(&self) -> bool {
*self == PRESC::Div8
}
#[inline(always)]
pub fn is_div16(&self) -> bool {
*self == PRESC::Div16
}
#[inline(always)]
pub fn is_div32(&self) -> bool {
*self == PRESC::Div32
}
#[inline(always)]
pub fn is_div64(&self) -> bool {
*self == PRESC::Div64
}
#[inline(always)]
pub fn is_div128(&self) -> bool {
*self == PRESC::Div128
}
}
pub type PrescW<'a, REG> = crate::FieldWriter<'a, REG, 3, PRESC, crate::Safe>;
impl<'a, REG> PrescW<'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(PRESC::Div1)
}
#[inline(always)]
pub fn div2(self) -> &'a mut crate::W<REG> {
self.variant(PRESC::Div2)
}
#[inline(always)]
pub fn div4(self) -> &'a mut crate::W<REG> {
self.variant(PRESC::Div4)
}
#[inline(always)]
pub fn div8(self) -> &'a mut crate::W<REG> {
self.variant(PRESC::Div8)
}
#[inline(always)]
pub fn div16(self) -> &'a mut crate::W<REG> {
self.variant(PRESC::Div16)
}
#[inline(always)]
pub fn div32(self) -> &'a mut crate::W<REG> {
self.variant(PRESC::Div32)
}
#[inline(always)]
pub fn div64(self) -> &'a mut crate::W<REG> {
self.variant(PRESC::Div64)
}
#[inline(always)]
pub fn div128(self) -> &'a mut crate::W<REG> {
self.variant(PRESC::Div128)
}
}
impl R {
#[inline(always)]
pub fn en(&self) -> EnR {
EnR::new((self.bits & 1) != 0)
}
#[inline(always)]
pub fn debugrun(&self) -> DebugrunR {
DebugrunR::new(((self.bits >> 1) & 1) != 0)
}
#[inline(always)]
pub fn oscsel(&self) -> OscselR {
OscselR::new(((self.bits >> 2) & 3) as u8)
}
#[inline(always)]
pub fn presc(&self) -> PrescR {
PrescR::new(((self.bits >> 5) & 7) as u8)
}
}
impl core::fmt::Debug for R {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("CTRL")
.field("en", &self.en())
.field("debugrun", &self.debugrun())
.field("oscsel", &self.oscsel())
.field("presc", &self.presc())
.finish()
}
}
impl W {
#[inline(always)]
pub fn en(&mut self) -> EnW<'_, CTRLrs> {
EnW::new(self, 0)
}
#[inline(always)]
pub fn debugrun(&mut self) -> DebugrunW<'_, CTRLrs> {
DebugrunW::new(self, 1)
}
#[inline(always)]
pub fn oscsel(&mut self) -> OscselW<'_, CTRLrs> {
OscselW::new(self, 2)
}
#[inline(always)]
pub fn presc(&mut self) -> PrescW<'_, CTRLrs> {
PrescW::new(self, 5)
}
}
pub struct CTRLrs;
impl crate::RegisterSpec for CTRLrs {
type Ux = u32;
}
impl crate::Readable for CTRLrs {}
impl crate::Writable for CTRLrs {
type Safety = crate::Unsafe;
}
impl crate::Resettable for CTRLrs {}