#[doc = "Reader of register OSC8M"]
pub type R = crate::R<u32, super::OSC8M>;
#[doc = "Writer for register OSC8M"]
pub type W = crate::W<u32, super::OSC8M>;
#[doc = "Register OSC8M `reset()`'s with value 0x8707_0382"]
impl crate::ResetValue for super::OSC8M {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
0x8707_0382
}
}
#[doc = "Reader of field `ENABLE`"]
pub type ENABLE_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `ENABLE`"]
pub struct ENABLE_W<'a> {
w: &'a mut W,
}
impl<'a> ENABLE_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u32) & 0x01) << 1);
self.w
}
}
#[doc = "Reader of field `RUNSTDBY`"]
pub type RUNSTDBY_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `RUNSTDBY`"]
pub struct RUNSTDBY_W<'a> {
w: &'a mut W,
}
impl<'a> RUNSTDBY_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 6)) | (((value as u32) & 0x01) << 6);
self.w
}
}
#[doc = "Reader of field `ONDEMAND`"]
pub type ONDEMAND_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `ONDEMAND`"]
pub struct ONDEMAND_W<'a> {
w: &'a mut W,
}
impl<'a> ONDEMAND_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u32) & 0x01) << 7);
self.w
}
}
#[doc = "Oscillator Prescaler\n\nValue on reset: 3"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum PRESC_A {
#[doc = "0: 1"]
_0 = 0,
#[doc = "1: 2"]
_1 = 1,
#[doc = "2: 4"]
_2 = 2,
#[doc = "3: 8"]
_3 = 3,
}
impl From<PRESC_A> for u8 {
#[inline(always)]
fn from(variant: PRESC_A) -> Self {
variant as _
}
}
#[doc = "Reader of field `PRESC`"]
pub type PRESC_R = crate::R<u8, PRESC_A>;
impl PRESC_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> PRESC_A {
match self.bits {
0 => PRESC_A::_0,
1 => PRESC_A::_1,
2 => PRESC_A::_2,
3 => PRESC_A::_3,
_ => unreachable!(),
}
}
#[doc = "Checks if the value of the field is `_0`"]
#[inline(always)]
pub fn is_0(&self) -> bool {
*self == PRESC_A::_0
}
#[doc = "Checks if the value of the field is `_1`"]
#[inline(always)]
pub fn is_1(&self) -> bool {
*self == PRESC_A::_1
}
#[doc = "Checks if the value of the field is `_2`"]
#[inline(always)]
pub fn is_2(&self) -> bool {
*self == PRESC_A::_2
}
#[doc = "Checks if the value of the field is `_3`"]
#[inline(always)]
pub fn is_3(&self) -> bool {
*self == PRESC_A::_3
}
}
#[doc = "Write proxy for field `PRESC`"]
pub struct PRESC_W<'a> {
w: &'a mut W,
}
impl<'a> PRESC_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: PRESC_A) -> &'a mut W {
{
self.bits(variant.into())
}
}
#[doc = "1"]
#[inline(always)]
pub fn _0(self) -> &'a mut W {
self.variant(PRESC_A::_0)
}
#[doc = "2"]
#[inline(always)]
pub fn _1(self) -> &'a mut W {
self.variant(PRESC_A::_1)
}
#[doc = "4"]
#[inline(always)]
pub fn _2(self) -> &'a mut W {
self.variant(PRESC_A::_2)
}
#[doc = "8"]
#[inline(always)]
pub fn _3(self) -> &'a mut W {
self.variant(PRESC_A::_3)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bits(self, value: u8) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x03 << 8)) | (((value as u32) & 0x03) << 8);
self.w
}
}
#[doc = "Reader of field `CALIB`"]
pub type CALIB_R = crate::R<u16, u16>;
#[doc = "Write proxy for field `CALIB`"]
pub struct CALIB_W<'a> {
w: &'a mut W,
}
impl<'a> CALIB_W<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u16) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x0fff << 16)) | (((value as u32) & 0x0fff) << 16);
self.w
}
}
#[doc = "Oscillator Frequency Range\n\nValue on reset: 2"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum FRANGE_A {
#[doc = "0: 4 to 6MHz"]
_0 = 0,
#[doc = "1: 6 to 8MHz"]
_1 = 1,
#[doc = "2: 8 to 11MHz"]
_2 = 2,
#[doc = "3: 11 to 15MHz"]
_3 = 3,
}
impl From<FRANGE_A> for u8 {
#[inline(always)]
fn from(variant: FRANGE_A) -> Self {
variant as _
}
}
#[doc = "Reader of field `FRANGE`"]
pub type FRANGE_R = crate::R<u8, FRANGE_A>;
impl FRANGE_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> FRANGE_A {
match self.bits {
0 => FRANGE_A::_0,
1 => FRANGE_A::_1,
2 => FRANGE_A::_2,
3 => FRANGE_A::_3,
_ => unreachable!(),
}
}
#[doc = "Checks if the value of the field is `_0`"]
#[inline(always)]
pub fn is_0(&self) -> bool {
*self == FRANGE_A::_0
}
#[doc = "Checks if the value of the field is `_1`"]
#[inline(always)]
pub fn is_1(&self) -> bool {
*self == FRANGE_A::_1
}
#[doc = "Checks if the value of the field is `_2`"]
#[inline(always)]
pub fn is_2(&self) -> bool {
*self == FRANGE_A::_2
}
#[doc = "Checks if the value of the field is `_3`"]
#[inline(always)]
pub fn is_3(&self) -> bool {
*self == FRANGE_A::_3
}
}
#[doc = "Write proxy for field `FRANGE`"]
pub struct FRANGE_W<'a> {
w: &'a mut W,
}
impl<'a> FRANGE_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: FRANGE_A) -> &'a mut W {
{
self.bits(variant.into())
}
}
#[doc = "4 to 6MHz"]
#[inline(always)]
pub fn _0(self) -> &'a mut W {
self.variant(FRANGE_A::_0)
}
#[doc = "6 to 8MHz"]
#[inline(always)]
pub fn _1(self) -> &'a mut W {
self.variant(FRANGE_A::_1)
}
#[doc = "8 to 11MHz"]
#[inline(always)]
pub fn _2(self) -> &'a mut W {
self.variant(FRANGE_A::_2)
}
#[doc = "11 to 15MHz"]
#[inline(always)]
pub fn _3(self) -> &'a mut W {
self.variant(FRANGE_A::_3)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bits(self, value: u8) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x03 << 30)) | (((value as u32) & 0x03) << 30);
self.w
}
}
impl R {
#[doc = "Bit 1 - Oscillator Enable"]
#[inline(always)]
pub fn enable(&self) -> ENABLE_R {
ENABLE_R::new(((self.bits >> 1) & 0x01) != 0)
}
#[doc = "Bit 6 - Run in Standby"]
#[inline(always)]
pub fn runstdby(&self) -> RUNSTDBY_R {
RUNSTDBY_R::new(((self.bits >> 6) & 0x01) != 0)
}
#[doc = "Bit 7 - On Demand Control"]
#[inline(always)]
pub fn ondemand(&self) -> ONDEMAND_R {
ONDEMAND_R::new(((self.bits >> 7) & 0x01) != 0)
}
#[doc = "Bits 8:9 - Oscillator Prescaler"]
#[inline(always)]
pub fn presc(&self) -> PRESC_R {
PRESC_R::new(((self.bits >> 8) & 0x03) as u8)
}
#[doc = "Bits 16:27 - Oscillator Calibration"]
#[inline(always)]
pub fn calib(&self) -> CALIB_R {
CALIB_R::new(((self.bits >> 16) & 0x0fff) as u16)
}
#[doc = "Bits 30:31 - Oscillator Frequency Range"]
#[inline(always)]
pub fn frange(&self) -> FRANGE_R {
FRANGE_R::new(((self.bits >> 30) & 0x03) as u8)
}
}
impl W {
#[doc = "Bit 1 - Oscillator Enable"]
#[inline(always)]
pub fn enable(&mut self) -> ENABLE_W {
ENABLE_W { w: self }
}
#[doc = "Bit 6 - Run in Standby"]
#[inline(always)]
pub fn runstdby(&mut self) -> RUNSTDBY_W {
RUNSTDBY_W { w: self }
}
#[doc = "Bit 7 - On Demand Control"]
#[inline(always)]
pub fn ondemand(&mut self) -> ONDEMAND_W {
ONDEMAND_W { w: self }
}
#[doc = "Bits 8:9 - Oscillator Prescaler"]
#[inline(always)]
pub fn presc(&mut self) -> PRESC_W {
PRESC_W { w: self }
}
#[doc = "Bits 16:27 - Oscillator Calibration"]
#[inline(always)]
pub fn calib(&mut self) -> CALIB_W {
CALIB_W { w: self }
}
#[doc = "Bits 30:31 - Oscillator Frequency Range"]
#[inline(always)]
pub fn frange(&mut self) -> FRANGE_W {
FRANGE_W { w: self }
}
}