efm32wg230_pac/cmu/
calctrl.rs

1#[doc = "Register `CALCTRL` reader"]
2pub struct R(crate::R<CALCTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CALCTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CALCTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CALCTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CALCTRL` writer"]
17pub struct W(crate::W<CALCTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CALCTRL_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<CALCTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CALCTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Calibration Up-counter Select\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum UPSEL_A {
41    #[doc = "0: Select HFXO as up-counter."]
42    HFXO = 0,
43    #[doc = "1: Select LFXO as up-counter."]
44    LFXO = 1,
45    #[doc = "2: Select HFRCO as up-counter."]
46    HFRCO = 2,
47    #[doc = "3: Select LFRCO as up-counter."]
48    LFRCO = 3,
49    #[doc = "4: Select AUXHFRCO as up-counter."]
50    AUXHFRCO = 4,
51}
52impl From<UPSEL_A> for u8 {
53    #[inline(always)]
54    fn from(variant: UPSEL_A) -> Self {
55        variant as _
56    }
57}
58#[doc = "Field `UPSEL` reader - Calibration Up-counter Select"]
59pub type UPSEL_R = crate::FieldReader<u8, UPSEL_A>;
60impl UPSEL_R {
61    #[doc = "Get enumerated values variant"]
62    #[inline(always)]
63    pub fn variant(&self) -> Option<UPSEL_A> {
64        match self.bits {
65            0 => Some(UPSEL_A::HFXO),
66            1 => Some(UPSEL_A::LFXO),
67            2 => Some(UPSEL_A::HFRCO),
68            3 => Some(UPSEL_A::LFRCO),
69            4 => Some(UPSEL_A::AUXHFRCO),
70            _ => None,
71        }
72    }
73    #[doc = "Checks if the value of the field is `HFXO`"]
74    #[inline(always)]
75    pub fn is_hfxo(&self) -> bool {
76        *self == UPSEL_A::HFXO
77    }
78    #[doc = "Checks if the value of the field is `LFXO`"]
79    #[inline(always)]
80    pub fn is_lfxo(&self) -> bool {
81        *self == UPSEL_A::LFXO
82    }
83    #[doc = "Checks if the value of the field is `HFRCO`"]
84    #[inline(always)]
85    pub fn is_hfrco(&self) -> bool {
86        *self == UPSEL_A::HFRCO
87    }
88    #[doc = "Checks if the value of the field is `LFRCO`"]
89    #[inline(always)]
90    pub fn is_lfrco(&self) -> bool {
91        *self == UPSEL_A::LFRCO
92    }
93    #[doc = "Checks if the value of the field is `AUXHFRCO`"]
94    #[inline(always)]
95    pub fn is_auxhfrco(&self) -> bool {
96        *self == UPSEL_A::AUXHFRCO
97    }
98}
99#[doc = "Field `UPSEL` writer - Calibration Up-counter Select"]
100pub type UPSEL_W<'a> = crate::FieldWriter<'a, u32, CALCTRL_SPEC, u8, UPSEL_A, 3, 0>;
101impl<'a> UPSEL_W<'a> {
102    #[doc = "Select HFXO as up-counter."]
103    #[inline(always)]
104    pub fn hfxo(self) -> &'a mut W {
105        self.variant(UPSEL_A::HFXO)
106    }
107    #[doc = "Select LFXO as up-counter."]
108    #[inline(always)]
109    pub fn lfxo(self) -> &'a mut W {
110        self.variant(UPSEL_A::LFXO)
111    }
112    #[doc = "Select HFRCO as up-counter."]
113    #[inline(always)]
114    pub fn hfrco(self) -> &'a mut W {
115        self.variant(UPSEL_A::HFRCO)
116    }
117    #[doc = "Select LFRCO as up-counter."]
118    #[inline(always)]
119    pub fn lfrco(self) -> &'a mut W {
120        self.variant(UPSEL_A::LFRCO)
121    }
122    #[doc = "Select AUXHFRCO as up-counter."]
123    #[inline(always)]
124    pub fn auxhfrco(self) -> &'a mut W {
125        self.variant(UPSEL_A::AUXHFRCO)
126    }
127}
128#[doc = "Calibration Down-counter Select\n\nValue on reset: 0"]
129#[derive(Clone, Copy, Debug, PartialEq)]
130#[repr(u8)]
131pub enum DOWNSEL_A {
132    #[doc = "0: Select HFCLK for down-counter."]
133    HFCLK = 0,
134    #[doc = "1: Select HFXO for down-counter."]
135    HFXO = 1,
136    #[doc = "2: Select LFXO for down-counter."]
137    LFXO = 2,
138    #[doc = "3: Select HFRCO for down-counter."]
139    HFRCO = 3,
140    #[doc = "4: Select LFRCO for down-counter."]
141    LFRCO = 4,
142    #[doc = "5: Select AUXHFRCO for down-counter."]
143    AUXHFRCO = 5,
144}
145impl From<DOWNSEL_A> for u8 {
146    #[inline(always)]
147    fn from(variant: DOWNSEL_A) -> Self {
148        variant as _
149    }
150}
151#[doc = "Field `DOWNSEL` reader - Calibration Down-counter Select"]
152pub type DOWNSEL_R = crate::FieldReader<u8, DOWNSEL_A>;
153impl DOWNSEL_R {
154    #[doc = "Get enumerated values variant"]
155    #[inline(always)]
156    pub fn variant(&self) -> Option<DOWNSEL_A> {
157        match self.bits {
158            0 => Some(DOWNSEL_A::HFCLK),
159            1 => Some(DOWNSEL_A::HFXO),
160            2 => Some(DOWNSEL_A::LFXO),
161            3 => Some(DOWNSEL_A::HFRCO),
162            4 => Some(DOWNSEL_A::LFRCO),
163            5 => Some(DOWNSEL_A::AUXHFRCO),
164            _ => None,
165        }
166    }
167    #[doc = "Checks if the value of the field is `HFCLK`"]
168    #[inline(always)]
169    pub fn is_hfclk(&self) -> bool {
170        *self == DOWNSEL_A::HFCLK
171    }
172    #[doc = "Checks if the value of the field is `HFXO`"]
173    #[inline(always)]
174    pub fn is_hfxo(&self) -> bool {
175        *self == DOWNSEL_A::HFXO
176    }
177    #[doc = "Checks if the value of the field is `LFXO`"]
178    #[inline(always)]
179    pub fn is_lfxo(&self) -> bool {
180        *self == DOWNSEL_A::LFXO
181    }
182    #[doc = "Checks if the value of the field is `HFRCO`"]
183    #[inline(always)]
184    pub fn is_hfrco(&self) -> bool {
185        *self == DOWNSEL_A::HFRCO
186    }
187    #[doc = "Checks if the value of the field is `LFRCO`"]
188    #[inline(always)]
189    pub fn is_lfrco(&self) -> bool {
190        *self == DOWNSEL_A::LFRCO
191    }
192    #[doc = "Checks if the value of the field is `AUXHFRCO`"]
193    #[inline(always)]
194    pub fn is_auxhfrco(&self) -> bool {
195        *self == DOWNSEL_A::AUXHFRCO
196    }
197}
198#[doc = "Field `DOWNSEL` writer - Calibration Down-counter Select"]
199pub type DOWNSEL_W<'a> = crate::FieldWriter<'a, u32, CALCTRL_SPEC, u8, DOWNSEL_A, 3, 3>;
200impl<'a> DOWNSEL_W<'a> {
201    #[doc = "Select HFCLK for down-counter."]
202    #[inline(always)]
203    pub fn hfclk(self) -> &'a mut W {
204        self.variant(DOWNSEL_A::HFCLK)
205    }
206    #[doc = "Select HFXO for down-counter."]
207    #[inline(always)]
208    pub fn hfxo(self) -> &'a mut W {
209        self.variant(DOWNSEL_A::HFXO)
210    }
211    #[doc = "Select LFXO for down-counter."]
212    #[inline(always)]
213    pub fn lfxo(self) -> &'a mut W {
214        self.variant(DOWNSEL_A::LFXO)
215    }
216    #[doc = "Select HFRCO for down-counter."]
217    #[inline(always)]
218    pub fn hfrco(self) -> &'a mut W {
219        self.variant(DOWNSEL_A::HFRCO)
220    }
221    #[doc = "Select LFRCO for down-counter."]
222    #[inline(always)]
223    pub fn lfrco(self) -> &'a mut W {
224        self.variant(DOWNSEL_A::LFRCO)
225    }
226    #[doc = "Select AUXHFRCO for down-counter."]
227    #[inline(always)]
228    pub fn auxhfrco(self) -> &'a mut W {
229        self.variant(DOWNSEL_A::AUXHFRCO)
230    }
231}
232#[doc = "Field `CONT` reader - Continuous Calibration"]
233pub type CONT_R = crate::BitReader<bool>;
234#[doc = "Field `CONT` writer - Continuous Calibration"]
235pub type CONT_W<'a> = crate::BitWriter<'a, u32, CALCTRL_SPEC, bool, 6>;
236impl R {
237    #[doc = "Bits 0:2 - Calibration Up-counter Select"]
238    #[inline(always)]
239    pub fn upsel(&self) -> UPSEL_R {
240        UPSEL_R::new((self.bits & 7) as u8)
241    }
242    #[doc = "Bits 3:5 - Calibration Down-counter Select"]
243    #[inline(always)]
244    pub fn downsel(&self) -> DOWNSEL_R {
245        DOWNSEL_R::new(((self.bits >> 3) & 7) as u8)
246    }
247    #[doc = "Bit 6 - Continuous Calibration"]
248    #[inline(always)]
249    pub fn cont(&self) -> CONT_R {
250        CONT_R::new(((self.bits >> 6) & 1) != 0)
251    }
252}
253impl W {
254    #[doc = "Bits 0:2 - Calibration Up-counter Select"]
255    #[inline(always)]
256    pub fn upsel(&mut self) -> UPSEL_W {
257        UPSEL_W::new(self)
258    }
259    #[doc = "Bits 3:5 - Calibration Down-counter Select"]
260    #[inline(always)]
261    pub fn downsel(&mut self) -> DOWNSEL_W {
262        DOWNSEL_W::new(self)
263    }
264    #[doc = "Bit 6 - Continuous Calibration"]
265    #[inline(always)]
266    pub fn cont(&mut self) -> CONT_W {
267        CONT_W::new(self)
268    }
269    #[doc = "Writes raw bits to the register."]
270    #[inline(always)]
271    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
272        self.0.bits(bits);
273        self
274    }
275}
276#[doc = "Calibration 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 [calctrl](index.html) module"]
277pub struct CALCTRL_SPEC;
278impl crate::RegisterSpec for CALCTRL_SPEC {
279    type Ux = u32;
280}
281#[doc = "`read()` method returns [calctrl::R](R) reader structure"]
282impl crate::Readable for CALCTRL_SPEC {
283    type Reader = R;
284}
285#[doc = "`write(|w| ..)` method takes [calctrl::W](W) writer structure"]
286impl crate::Writable for CALCTRL_SPEC {
287    type Writer = W;
288}
289#[doc = "`reset()` method sets CALCTRL to value 0"]
290impl crate::Resettable for CALCTRL_SPEC {
291    #[inline(always)]
292    fn reset_value() -> Self::Ux {
293        0
294    }
295}