pub type R = crate::R<ULFRCOCTRLrs>;
pub type W = crate::W<ULFRCOCTRLrs>;
pub type TuningR = crate::FieldReader;
pub type TuningW<'a, REG> = crate::FieldWriter<'a, REG, 6>;
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum MODE {
_1khz = 0,
_2khz = 1,
_4khz = 2,
_32khz = 3,
}
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) -> MODE {
match self.bits {
0 => MODE::_1khz,
1 => MODE::_2khz,
2 => MODE::_4khz,
3 => MODE::_32khz,
_ => unreachable!(),
}
}
#[inline(always)]
pub fn is_1khz(&self) -> bool {
*self == MODE::_1khz
}
#[inline(always)]
pub fn is_2khz(&self) -> bool {
*self == MODE::_2khz
}
#[inline(always)]
pub fn is_4khz(&self) -> bool {
*self == MODE::_4khz
}
#[inline(always)]
pub fn is_32khz(&self) -> bool {
*self == MODE::_32khz
}
}
pub type ModeW<'a, REG> = crate::FieldWriter<'a, REG, 2, MODE, crate::Safe>;
impl<'a, REG> ModeW<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
REG::Ux: From<u8>,
{
#[inline(always)]
pub fn _1khz(self) -> &'a mut crate::W<REG> {
self.variant(MODE::_1khz)
}
#[inline(always)]
pub fn _2khz(self) -> &'a mut crate::W<REG> {
self.variant(MODE::_2khz)
}
#[inline(always)]
pub fn _4khz(self) -> &'a mut crate::W<REG> {
self.variant(MODE::_4khz)
}
#[inline(always)]
pub fn _32khz(self) -> &'a mut crate::W<REG> {
self.variant(MODE::_32khz)
}
}
pub type RestrimR = crate::FieldReader;
pub type RestrimW<'a, REG> = crate::FieldWriter<'a, REG, 2>;
impl R {
#[inline(always)]
pub fn tuning(&self) -> TuningR {
TuningR::new((self.bits & 0x3f) as u8)
}
#[inline(always)]
pub fn mode(&self) -> ModeR {
ModeR::new(((self.bits >> 10) & 3) as u8)
}
#[inline(always)]
pub fn restrim(&self) -> RestrimR {
RestrimR::new(((self.bits >> 16) & 3) as u8)
}
}
impl core::fmt::Debug for R {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("ULFRCOCTRL")
.field("tuning", &self.tuning())
.field("mode", &self.mode())
.field("restrim", &self.restrim())
.finish()
}
}
impl W {
#[inline(always)]
pub fn tuning(&mut self) -> TuningW<'_, ULFRCOCTRLrs> {
TuningW::new(self, 0)
}
#[inline(always)]
pub fn mode(&mut self) -> ModeW<'_, ULFRCOCTRLrs> {
ModeW::new(self, 10)
}
#[inline(always)]
pub fn restrim(&mut self) -> RestrimW<'_, ULFRCOCTRLrs> {
RestrimW::new(self, 16)
}
}
pub struct ULFRCOCTRLrs;
impl crate::RegisterSpec for ULFRCOCTRLrs {
type Ux = u32;
}
impl crate::Readable for ULFRCOCTRLrs {}
impl crate::Writable for ULFRCOCTRLrs {
type Safety = crate::Unsafe;
}
impl crate::Resettable for ULFRCOCTRLrs {
const RESET_VALUE: u32 = 0x0002_0020;
}