pub type R = crate::R<HFRCOCTRLrs>;
pub type W = crate::W<HFRCOCTRLrs>;
pub type TuningR = crate::FieldReader;
pub type TuningW<'a, REG> = crate::FieldWriter<'a, REG, 7>;
pub type FinetuningR = crate::FieldReader;
pub type FinetuningW<'a, REG> = crate::FieldWriter<'a, REG, 6>;
pub type FreqrangeR = crate::FieldReader;
pub type FreqrangeW<'a, REG> = crate::FieldWriter<'a, REG, 5>;
pub type CmpbiasR = crate::FieldReader;
pub type CmpbiasW<'a, REG> = crate::FieldWriter<'a, REG, 3>;
pub type LdohpR = crate::BitReader;
pub type LdohpW<'a, REG> = crate::BitWriter<'a, REG>;
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum CLKDIV {
Div1 = 0,
Div2 = 1,
Div4 = 2,
}
impl From<CLKDIV> for u8 {
#[inline(always)]
fn from(variant: CLKDIV) -> Self {
variant as _
}
}
impl crate::FieldSpec for CLKDIV {
type Ux = u8;
}
impl crate::IsEnum for CLKDIV {}
pub type ClkdivR = crate::FieldReader<CLKDIV>;
impl ClkdivR {
#[inline(always)]
pub const fn variant(&self) -> Option<CLKDIV> {
match self.bits {
0 => Some(CLKDIV::Div1),
1 => Some(CLKDIV::Div2),
2 => Some(CLKDIV::Div4),
_ => None,
}
}
#[inline(always)]
pub fn is_div1(&self) -> bool {
*self == CLKDIV::Div1
}
#[inline(always)]
pub fn is_div2(&self) -> bool {
*self == CLKDIV::Div2
}
#[inline(always)]
pub fn is_div4(&self) -> bool {
*self == CLKDIV::Div4
}
}
pub type ClkdivW<'a, REG> = crate::FieldWriter<'a, REG, 2, CLKDIV>;
impl<'a, REG> ClkdivW<'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(CLKDIV::Div1)
}
#[inline(always)]
pub fn div2(self) -> &'a mut crate::W<REG> {
self.variant(CLKDIV::Div2)
}
#[inline(always)]
pub fn div4(self) -> &'a mut crate::W<REG> {
self.variant(CLKDIV::Div4)
}
}
pub type FinetuningenR = crate::BitReader;
pub type FinetuningenW<'a, REG> = crate::BitWriter<'a, REG>;
pub type VreftcR = crate::FieldReader;
pub type VreftcW<'a, REG> = crate::FieldWriter<'a, REG, 4>;
impl R {
#[inline(always)]
pub fn tuning(&self) -> TuningR {
TuningR::new((self.bits & 0x7f) as u8)
}
#[inline(always)]
pub fn finetuning(&self) -> FinetuningR {
FinetuningR::new(((self.bits >> 8) & 0x3f) as u8)
}
#[inline(always)]
pub fn freqrange(&self) -> FreqrangeR {
FreqrangeR::new(((self.bits >> 16) & 0x1f) as u8)
}
#[inline(always)]
pub fn cmpbias(&self) -> CmpbiasR {
CmpbiasR::new(((self.bits >> 21) & 7) as u8)
}
#[inline(always)]
pub fn ldohp(&self) -> LdohpR {
LdohpR::new(((self.bits >> 24) & 1) != 0)
}
#[inline(always)]
pub fn clkdiv(&self) -> ClkdivR {
ClkdivR::new(((self.bits >> 25) & 3) as u8)
}
#[inline(always)]
pub fn finetuningen(&self) -> FinetuningenR {
FinetuningenR::new(((self.bits >> 27) & 1) != 0)
}
#[inline(always)]
pub fn vreftc(&self) -> VreftcR {
VreftcR::new(((self.bits >> 28) & 0x0f) as u8)
}
}
impl core::fmt::Debug for R {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("HFRCOCTRL")
.field("tuning", &self.tuning())
.field("finetuning", &self.finetuning())
.field("freqrange", &self.freqrange())
.field("cmpbias", &self.cmpbias())
.field("ldohp", &self.ldohp())
.field("clkdiv", &self.clkdiv())
.field("finetuningen", &self.finetuningen())
.field("vreftc", &self.vreftc())
.finish()
}
}
impl W {
#[inline(always)]
pub fn tuning(&mut self) -> TuningW<'_, HFRCOCTRLrs> {
TuningW::new(self, 0)
}
#[inline(always)]
pub fn finetuning(&mut self) -> FinetuningW<'_, HFRCOCTRLrs> {
FinetuningW::new(self, 8)
}
#[inline(always)]
pub fn freqrange(&mut self) -> FreqrangeW<'_, HFRCOCTRLrs> {
FreqrangeW::new(self, 16)
}
#[inline(always)]
pub fn cmpbias(&mut self) -> CmpbiasW<'_, HFRCOCTRLrs> {
CmpbiasW::new(self, 21)
}
#[inline(always)]
pub fn ldohp(&mut self) -> LdohpW<'_, HFRCOCTRLrs> {
LdohpW::new(self, 24)
}
#[inline(always)]
pub fn clkdiv(&mut self) -> ClkdivW<'_, HFRCOCTRLrs> {
ClkdivW::new(self, 25)
}
#[inline(always)]
pub fn finetuningen(&mut self) -> FinetuningenW<'_, HFRCOCTRLrs> {
FinetuningenW::new(self, 27)
}
#[inline(always)]
pub fn vreftc(&mut self) -> VreftcW<'_, HFRCOCTRLrs> {
VreftcW::new(self, 28)
}
}
pub struct HFRCOCTRLrs;
impl crate::RegisterSpec for HFRCOCTRLrs {
type Ux = u32;
}
impl crate::Readable for HFRCOCTRLrs {}
impl crate::Writable for HFRCOCTRLrs {
type Safety = crate::Unsafe;
}
impl crate::Resettable for HFRCOCTRLrs {
const RESET_VALUE: u32 = 0xb148_1f3c;
}