efm32pg1b200_pac/cmu/
ulfrcoctrl.rs

1#[doc = "Register `ULFRCOCTRL` reader"]
2pub struct R(crate::R<ULFRCOCTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<ULFRCOCTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<ULFRCOCTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<ULFRCOCTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `ULFRCOCTRL` writer"]
17pub struct W(crate::W<ULFRCOCTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<ULFRCOCTRL_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<ULFRCOCTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<ULFRCOCTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `TUNING` reader - ULFRCO TUNING Value"]
38pub type TUNING_R = crate::FieldReader<u8, u8>;
39#[doc = "Field `TUNING` writer - ULFRCO TUNING Value"]
40pub type TUNING_W<'a> = crate::FieldWriter<'a, u32, ULFRCOCTRL_SPEC, u8, u8, 6, 0>;
41#[doc = "ULFRCO Mode\n\nValue on reset: 0"]
42#[derive(Clone, Copy, Debug, PartialEq)]
43#[repr(u8)]
44pub enum MODE_A {
45    #[doc = "0: ULFRCO = 1 kHz"]
46    _1KHZ = 0,
47    #[doc = "1: ULFRCO = 2 kHz"]
48    _2KHZ = 1,
49    #[doc = "2: ULFRCO = 4 kHz"]
50    _4KHZ = 2,
51    #[doc = "3: ULFRCO = 32 kHz"]
52    _32KHZ = 3,
53}
54impl From<MODE_A> for u8 {
55    #[inline(always)]
56    fn from(variant: MODE_A) -> Self {
57        variant as _
58    }
59}
60#[doc = "Field `MODE` reader - ULFRCO Mode"]
61pub type MODE_R = crate::FieldReader<u8, MODE_A>;
62impl MODE_R {
63    #[doc = "Get enumerated values variant"]
64    #[inline(always)]
65    pub fn variant(&self) -> MODE_A {
66        match self.bits {
67            0 => MODE_A::_1KHZ,
68            1 => MODE_A::_2KHZ,
69            2 => MODE_A::_4KHZ,
70            3 => MODE_A::_32KHZ,
71            _ => unreachable!(),
72        }
73    }
74    #[doc = "Checks if the value of the field is `_1KHZ`"]
75    #[inline(always)]
76    pub fn is_1khz(&self) -> bool {
77        *self == MODE_A::_1KHZ
78    }
79    #[doc = "Checks if the value of the field is `_2KHZ`"]
80    #[inline(always)]
81    pub fn is_2khz(&self) -> bool {
82        *self == MODE_A::_2KHZ
83    }
84    #[doc = "Checks if the value of the field is `_4KHZ`"]
85    #[inline(always)]
86    pub fn is_4khz(&self) -> bool {
87        *self == MODE_A::_4KHZ
88    }
89    #[doc = "Checks if the value of the field is `_32KHZ`"]
90    #[inline(always)]
91    pub fn is_32khz(&self) -> bool {
92        *self == MODE_A::_32KHZ
93    }
94}
95#[doc = "Field `MODE` writer - ULFRCO Mode"]
96pub type MODE_W<'a> = crate::FieldWriterSafe<'a, u32, ULFRCOCTRL_SPEC, u8, MODE_A, 2, 10>;
97impl<'a> MODE_W<'a> {
98    #[doc = "ULFRCO = 1 kHz"]
99    #[inline(always)]
100    pub fn _1khz(self) -> &'a mut W {
101        self.variant(MODE_A::_1KHZ)
102    }
103    #[doc = "ULFRCO = 2 kHz"]
104    #[inline(always)]
105    pub fn _2khz(self) -> &'a mut W {
106        self.variant(MODE_A::_2KHZ)
107    }
108    #[doc = "ULFRCO = 4 kHz"]
109    #[inline(always)]
110    pub fn _4khz(self) -> &'a mut W {
111        self.variant(MODE_A::_4KHZ)
112    }
113    #[doc = "ULFRCO = 32 kHz"]
114    #[inline(always)]
115    pub fn _32khz(self) -> &'a mut W {
116        self.variant(MODE_A::_32KHZ)
117    }
118}
119#[doc = "Field `RESTRIM` reader - ULFRCO Resistor Trim Value (for Resistor in Bias Circuit; NOT for USE as FREQUENCY CALIBRATION)"]
120pub type RESTRIM_R = crate::FieldReader<u8, u8>;
121#[doc = "Field `RESTRIM` writer - ULFRCO Resistor Trim Value (for Resistor in Bias Circuit; NOT for USE as FREQUENCY CALIBRATION)"]
122pub type RESTRIM_W<'a> = crate::FieldWriter<'a, u32, ULFRCOCTRL_SPEC, u8, u8, 2, 16>;
123impl R {
124    #[doc = "Bits 0:5 - ULFRCO TUNING Value"]
125    #[inline(always)]
126    pub fn tuning(&self) -> TUNING_R {
127        TUNING_R::new((self.bits & 0x3f) as u8)
128    }
129    #[doc = "Bits 10:11 - ULFRCO Mode"]
130    #[inline(always)]
131    pub fn mode(&self) -> MODE_R {
132        MODE_R::new(((self.bits >> 10) & 3) as u8)
133    }
134    #[doc = "Bits 16:17 - ULFRCO Resistor Trim Value (for Resistor in Bias Circuit; NOT for USE as FREQUENCY CALIBRATION)"]
135    #[inline(always)]
136    pub fn restrim(&self) -> RESTRIM_R {
137        RESTRIM_R::new(((self.bits >> 16) & 3) as u8)
138    }
139}
140impl W {
141    #[doc = "Bits 0:5 - ULFRCO TUNING Value"]
142    #[inline(always)]
143    pub fn tuning(&mut self) -> TUNING_W {
144        TUNING_W::new(self)
145    }
146    #[doc = "Bits 10:11 - ULFRCO Mode"]
147    #[inline(always)]
148    pub fn mode(&mut self) -> MODE_W {
149        MODE_W::new(self)
150    }
151    #[doc = "Bits 16:17 - ULFRCO Resistor Trim Value (for Resistor in Bias Circuit; NOT for USE as FREQUENCY CALIBRATION)"]
152    #[inline(always)]
153    pub fn restrim(&mut self) -> RESTRIM_W {
154        RESTRIM_W::new(self)
155    }
156    #[doc = "Writes raw bits to the register."]
157    #[inline(always)]
158    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
159        self.0.bits(bits);
160        self
161    }
162}
163#[doc = "ULFRCO Control Register\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [ulfrcoctrl](index.html) module"]
164pub struct ULFRCOCTRL_SPEC;
165impl crate::RegisterSpec for ULFRCOCTRL_SPEC {
166    type Ux = u32;
167}
168#[doc = "`read()` method returns [ulfrcoctrl::R](R) reader structure"]
169impl crate::Readable for ULFRCOCTRL_SPEC {
170    type Reader = R;
171}
172#[doc = "`write(|w| ..)` method takes [ulfrcoctrl::W](W) writer structure"]
173impl crate::Writable for ULFRCOCTRL_SPEC {
174    type Writer = W;
175}
176#[doc = "`reset()` method sets ULFRCOCTRL to value 0x0002_0020"]
177impl crate::Resettable for ULFRCOCTRL_SPEC {
178    #[inline(always)]
179    fn reset_value() -> Self::Ux {
180        0x0002_0020
181    }
182}