pub type R = crate::R<LFXOCTRLrs>;
pub type W = crate::W<LFXOCTRLrs>;
pub type TuningR = crate::FieldReader;
pub type TuningW<'a, REG> = crate::FieldWriter<'a, REG, 7>;
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum MODE {
Xtal = 0,
Bufextclk = 1,
Digextclk = 2,
}
impl From<MODE> for u8 {
#[inline(always)]
fn from(variant: MODE) -> Self {
variant as _
}
}
impl crate::FieldSpec for MODE {
type Ux = u8;
}
impl crate::IsEnum for MODE {}
pub type ModeR = crate::FieldReader<MODE>;
impl ModeR {
#[inline(always)]
pub const fn variant(&self) -> Option<MODE> {
match self.bits {
0 => Some(MODE::Xtal),
1 => Some(MODE::Bufextclk),
2 => Some(MODE::Digextclk),
_ => None,
}
}
#[inline(always)]
pub fn is_xtal(&self) -> bool {
*self == MODE::Xtal
}
#[inline(always)]
pub fn is_bufextclk(&self) -> bool {
*self == MODE::Bufextclk
}
#[inline(always)]
pub fn is_digextclk(&self) -> bool {
*self == MODE::Digextclk
}
}
pub type ModeW<'a, REG> = crate::FieldWriter<'a, REG, 2, MODE>;
impl<'a, REG> ModeW<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
REG::Ux: From<u8>,
{
#[inline(always)]
pub fn xtal(self) -> &'a mut crate::W<REG> {
self.variant(MODE::Xtal)
}
#[inline(always)]
pub fn bufextclk(self) -> &'a mut crate::W<REG> {
self.variant(MODE::Bufextclk)
}
#[inline(always)]
pub fn digextclk(self) -> &'a mut crate::W<REG> {
self.variant(MODE::Digextclk)
}
}
pub type GainR = crate::FieldReader;
pub type GainW<'a, REG> = crate::FieldWriter<'a, REG, 2>;
pub type HighamplR = crate::BitReader;
pub type HighamplW<'a, REG> = crate::BitWriter<'a, REG>;
pub type AgcR = crate::BitReader;
pub type AgcW<'a, REG> = crate::BitWriter<'a, REG>;
pub type CurR = crate::FieldReader;
pub type CurW<'a, REG> = crate::FieldWriter<'a, REG, 2>;
pub type BufcurR = crate::BitReader;
pub type BufcurW<'a, REG> = crate::BitWriter<'a, REG>;
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum TIMEOUT {
_2cycles = 0,
_256cycles = 1,
_1kcycles = 2,
_2kcycles = 3,
_4kcycles = 4,
_8kcycles = 5,
_16kcycles = 6,
_32kcycles = 7,
}
impl From<TIMEOUT> for u8 {
#[inline(always)]
fn from(variant: TIMEOUT) -> Self {
variant as _
}
}
impl crate::FieldSpec for TIMEOUT {
type Ux = u8;
}
impl crate::IsEnum for TIMEOUT {}
pub type TimeoutR = crate::FieldReader<TIMEOUT>;
impl TimeoutR {
#[inline(always)]
pub const fn variant(&self) -> TIMEOUT {
match self.bits {
0 => TIMEOUT::_2cycles,
1 => TIMEOUT::_256cycles,
2 => TIMEOUT::_1kcycles,
3 => TIMEOUT::_2kcycles,
4 => TIMEOUT::_4kcycles,
5 => TIMEOUT::_8kcycles,
6 => TIMEOUT::_16kcycles,
7 => TIMEOUT::_32kcycles,
_ => unreachable!(),
}
}
#[inline(always)]
pub fn is_2cycles(&self) -> bool {
*self == TIMEOUT::_2cycles
}
#[inline(always)]
pub fn is_256cycles(&self) -> bool {
*self == TIMEOUT::_256cycles
}
#[inline(always)]
pub fn is_1kcycles(&self) -> bool {
*self == TIMEOUT::_1kcycles
}
#[inline(always)]
pub fn is_2kcycles(&self) -> bool {
*self == TIMEOUT::_2kcycles
}
#[inline(always)]
pub fn is_4kcycles(&self) -> bool {
*self == TIMEOUT::_4kcycles
}
#[inline(always)]
pub fn is_8kcycles(&self) -> bool {
*self == TIMEOUT::_8kcycles
}
#[inline(always)]
pub fn is_16kcycles(&self) -> bool {
*self == TIMEOUT::_16kcycles
}
#[inline(always)]
pub fn is_32kcycles(&self) -> bool {
*self == TIMEOUT::_32kcycles
}
}
pub type TimeoutW<'a, REG> = crate::FieldWriter<'a, REG, 3, TIMEOUT, crate::Safe>;
impl<'a, REG> TimeoutW<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
REG::Ux: From<u8>,
{
#[inline(always)]
pub fn _2cycles(self) -> &'a mut crate::W<REG> {
self.variant(TIMEOUT::_2cycles)
}
#[inline(always)]
pub fn _256cycles(self) -> &'a mut crate::W<REG> {
self.variant(TIMEOUT::_256cycles)
}
#[inline(always)]
pub fn _1kcycles(self) -> &'a mut crate::W<REG> {
self.variant(TIMEOUT::_1kcycles)
}
#[inline(always)]
pub fn _2kcycles(self) -> &'a mut crate::W<REG> {
self.variant(TIMEOUT::_2kcycles)
}
#[inline(always)]
pub fn _4kcycles(self) -> &'a mut crate::W<REG> {
self.variant(TIMEOUT::_4kcycles)
}
#[inline(always)]
pub fn _8kcycles(self) -> &'a mut crate::W<REG> {
self.variant(TIMEOUT::_8kcycles)
}
#[inline(always)]
pub fn _16kcycles(self) -> &'a mut crate::W<REG> {
self.variant(TIMEOUT::_16kcycles)
}
#[inline(always)]
pub fn _32kcycles(self) -> &'a mut crate::W<REG> {
self.variant(TIMEOUT::_32kcycles)
}
}
impl R {
#[inline(always)]
pub fn tuning(&self) -> TuningR {
TuningR::new((self.bits & 0x7f) as u8)
}
#[inline(always)]
pub fn mode(&self) -> ModeR {
ModeR::new(((self.bits >> 8) & 3) as u8)
}
#[inline(always)]
pub fn gain(&self) -> GainR {
GainR::new(((self.bits >> 11) & 3) as u8)
}
#[inline(always)]
pub fn highampl(&self) -> HighamplR {
HighamplR::new(((self.bits >> 14) & 1) != 0)
}
#[inline(always)]
pub fn agc(&self) -> AgcR {
AgcR::new(((self.bits >> 15) & 1) != 0)
}
#[inline(always)]
pub fn cur(&self) -> CurR {
CurR::new(((self.bits >> 16) & 3) as u8)
}
#[inline(always)]
pub fn bufcur(&self) -> BufcurR {
BufcurR::new(((self.bits >> 20) & 1) != 0)
}
#[inline(always)]
pub fn timeout(&self) -> TimeoutR {
TimeoutR::new(((self.bits >> 24) & 7) as u8)
}
}
impl core::fmt::Debug for R {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("LFXOCTRL")
.field("tuning", &self.tuning())
.field("mode", &self.mode())
.field("gain", &self.gain())
.field("highampl", &self.highampl())
.field("agc", &self.agc())
.field("cur", &self.cur())
.field("bufcur", &self.bufcur())
.field("timeout", &self.timeout())
.finish()
}
}
impl W {
#[inline(always)]
pub fn tuning(&mut self) -> TuningW<'_, LFXOCTRLrs> {
TuningW::new(self, 0)
}
#[inline(always)]
pub fn mode(&mut self) -> ModeW<'_, LFXOCTRLrs> {
ModeW::new(self, 8)
}
#[inline(always)]
pub fn gain(&mut self) -> GainW<'_, LFXOCTRLrs> {
GainW::new(self, 11)
}
#[inline(always)]
pub fn highampl(&mut self) -> HighamplW<'_, LFXOCTRLrs> {
HighamplW::new(self, 14)
}
#[inline(always)]
pub fn agc(&mut self) -> AgcW<'_, LFXOCTRLrs> {
AgcW::new(self, 15)
}
#[inline(always)]
pub fn cur(&mut self) -> CurW<'_, LFXOCTRLrs> {
CurW::new(self, 16)
}
#[inline(always)]
pub fn bufcur(&mut self) -> BufcurW<'_, LFXOCTRLrs> {
BufcurW::new(self, 20)
}
#[inline(always)]
pub fn timeout(&mut self) -> TimeoutW<'_, LFXOCTRLrs> {
TimeoutW::new(self, 24)
}
}
pub struct LFXOCTRLrs;
impl crate::RegisterSpec for LFXOCTRLrs {
type Ux = u32;
}
impl crate::Readable for LFXOCTRLrs {}
impl crate::Writable for LFXOCTRLrs {
type Safety = crate::Unsafe;
}
impl crate::Resettable for LFXOCTRLrs {
const RESET_VALUE: u32 = 0x0700_9000;
}