efm32pg22_pac/efm32pg22c200/cmu_ns/
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 = "Field `CALTOP` reader - Calibration Counter Top Value"]
38pub type CALTOP_R = crate::FieldReader<u32, u32>;
39#[doc = "Field `CALTOP` writer - Calibration Counter Top Value"]
40pub type CALTOP_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CALCTRL_SPEC, u32, u32, 20, O>;
41#[doc = "Field `CONT` reader - Continuous Calibration"]
42pub type CONT_R = crate::BitReader<bool>;
43#[doc = "Field `CONT` writer - Continuous Calibration"]
44pub type CONT_W<'a, const O: u8> = crate::BitWriter<'a, u32, CALCTRL_SPEC, bool, O>;
45#[doc = "Field `UPSEL` reader - Calibration Up-counter Select"]
46pub type UPSEL_R = crate::FieldReader<u8, UPSEL_A>;
47#[doc = "Calibration Up-counter Select\n\nValue on reset: 0"]
48#[derive(Clone, Copy, Debug, PartialEq, Eq)]
49#[repr(u8)]
50pub enum UPSEL_A {
51    #[doc = "0: Up-counter is not clocked"]
52    DISABLED = 0,
53    #[doc = "1: PRS CMU_CALUP consumer is clocking up-counter"]
54    PRS = 1,
55    #[doc = "2: HFXO is clocking up-counter"]
56    HFXO = 2,
57    #[doc = "3: LFXO is clocking up-counter"]
58    LFXO = 3,
59    #[doc = "4: HFRCODPLL is clocking up-counter"]
60    HFRCODPLL = 4,
61    #[doc = "8: FSRCO is clocking up-counter"]
62    FSRCO = 8,
63    #[doc = "9: LFRCO is clocking up-counter"]
64    LFRCO = 9,
65    #[doc = "10: ULFRCO is clocking up-counter"]
66    ULFRCO = 10,
67}
68impl From<UPSEL_A> for u8 {
69    #[inline(always)]
70    fn from(variant: UPSEL_A) -> Self {
71        variant as _
72    }
73}
74impl UPSEL_R {
75    #[doc = "Get enumerated values variant"]
76    #[inline(always)]
77    pub fn variant(&self) -> Option<UPSEL_A> {
78        match self.bits {
79            0 => Some(UPSEL_A::DISABLED),
80            1 => Some(UPSEL_A::PRS),
81            2 => Some(UPSEL_A::HFXO),
82            3 => Some(UPSEL_A::LFXO),
83            4 => Some(UPSEL_A::HFRCODPLL),
84            8 => Some(UPSEL_A::FSRCO),
85            9 => Some(UPSEL_A::LFRCO),
86            10 => Some(UPSEL_A::ULFRCO),
87            _ => None,
88        }
89    }
90    #[doc = "Checks if the value of the field is `DISABLED`"]
91    #[inline(always)]
92    pub fn is_disabled(&self) -> bool {
93        *self == UPSEL_A::DISABLED
94    }
95    #[doc = "Checks if the value of the field is `PRS`"]
96    #[inline(always)]
97    pub fn is_prs(&self) -> bool {
98        *self == UPSEL_A::PRS
99    }
100    #[doc = "Checks if the value of the field is `HFXO`"]
101    #[inline(always)]
102    pub fn is_hfxo(&self) -> bool {
103        *self == UPSEL_A::HFXO
104    }
105    #[doc = "Checks if the value of the field is `LFXO`"]
106    #[inline(always)]
107    pub fn is_lfxo(&self) -> bool {
108        *self == UPSEL_A::LFXO
109    }
110    #[doc = "Checks if the value of the field is `HFRCODPLL`"]
111    #[inline(always)]
112    pub fn is_hfrcodpll(&self) -> bool {
113        *self == UPSEL_A::HFRCODPLL
114    }
115    #[doc = "Checks if the value of the field is `FSRCO`"]
116    #[inline(always)]
117    pub fn is_fsrco(&self) -> bool {
118        *self == UPSEL_A::FSRCO
119    }
120    #[doc = "Checks if the value of the field is `LFRCO`"]
121    #[inline(always)]
122    pub fn is_lfrco(&self) -> bool {
123        *self == UPSEL_A::LFRCO
124    }
125    #[doc = "Checks if the value of the field is `ULFRCO`"]
126    #[inline(always)]
127    pub fn is_ulfrco(&self) -> bool {
128        *self == UPSEL_A::ULFRCO
129    }
130}
131#[doc = "Field `UPSEL` writer - Calibration Up-counter Select"]
132pub type UPSEL_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CALCTRL_SPEC, u8, UPSEL_A, 4, O>;
133impl<'a, const O: u8> UPSEL_W<'a, O> {
134    #[doc = "Up-counter is not clocked"]
135    #[inline(always)]
136    pub fn disabled(self) -> &'a mut W {
137        self.variant(UPSEL_A::DISABLED)
138    }
139    #[doc = "PRS CMU_CALUP consumer is clocking up-counter"]
140    #[inline(always)]
141    pub fn prs(self) -> &'a mut W {
142        self.variant(UPSEL_A::PRS)
143    }
144    #[doc = "HFXO is clocking up-counter"]
145    #[inline(always)]
146    pub fn hfxo(self) -> &'a mut W {
147        self.variant(UPSEL_A::HFXO)
148    }
149    #[doc = "LFXO is clocking up-counter"]
150    #[inline(always)]
151    pub fn lfxo(self) -> &'a mut W {
152        self.variant(UPSEL_A::LFXO)
153    }
154    #[doc = "HFRCODPLL is clocking up-counter"]
155    #[inline(always)]
156    pub fn hfrcodpll(self) -> &'a mut W {
157        self.variant(UPSEL_A::HFRCODPLL)
158    }
159    #[doc = "FSRCO is clocking up-counter"]
160    #[inline(always)]
161    pub fn fsrco(self) -> &'a mut W {
162        self.variant(UPSEL_A::FSRCO)
163    }
164    #[doc = "LFRCO is clocking up-counter"]
165    #[inline(always)]
166    pub fn lfrco(self) -> &'a mut W {
167        self.variant(UPSEL_A::LFRCO)
168    }
169    #[doc = "ULFRCO is clocking up-counter"]
170    #[inline(always)]
171    pub fn ulfrco(self) -> &'a mut W {
172        self.variant(UPSEL_A::ULFRCO)
173    }
174}
175#[doc = "Field `DOWNSEL` reader - Calibration Down-counter Select"]
176pub type DOWNSEL_R = crate::FieldReader<u8, DOWNSEL_A>;
177#[doc = "Calibration Down-counter Select\n\nValue on reset: 0"]
178#[derive(Clone, Copy, Debug, PartialEq, Eq)]
179#[repr(u8)]
180pub enum DOWNSEL_A {
181    #[doc = "0: Down-counter is not clocked"]
182    DISABLED = 0,
183    #[doc = "1: HCLK is clocking down-counter"]
184    HCLK = 1,
185    #[doc = "2: PRS CMU_CALDN consumer is clocking down-counter"]
186    PRS = 2,
187    #[doc = "3: HFXO is clocking down-counter"]
188    HFXO = 3,
189    #[doc = "4: LFXO is clocking down-counter"]
190    LFXO = 4,
191    #[doc = "5: HFRCODPLL is clocking down-counter"]
192    HFRCODPLL = 5,
193    #[doc = "9: FSRCO is clocking down-counter"]
194    FSRCO = 9,
195    #[doc = "10: LFRCO is clocking down-counter"]
196    LFRCO = 10,
197    #[doc = "11: ULFRCO is clocking down-counter"]
198    ULFRCO = 11,
199}
200impl From<DOWNSEL_A> for u8 {
201    #[inline(always)]
202    fn from(variant: DOWNSEL_A) -> Self {
203        variant as _
204    }
205}
206impl DOWNSEL_R {
207    #[doc = "Get enumerated values variant"]
208    #[inline(always)]
209    pub fn variant(&self) -> Option<DOWNSEL_A> {
210        match self.bits {
211            0 => Some(DOWNSEL_A::DISABLED),
212            1 => Some(DOWNSEL_A::HCLK),
213            2 => Some(DOWNSEL_A::PRS),
214            3 => Some(DOWNSEL_A::HFXO),
215            4 => Some(DOWNSEL_A::LFXO),
216            5 => Some(DOWNSEL_A::HFRCODPLL),
217            9 => Some(DOWNSEL_A::FSRCO),
218            10 => Some(DOWNSEL_A::LFRCO),
219            11 => Some(DOWNSEL_A::ULFRCO),
220            _ => None,
221        }
222    }
223    #[doc = "Checks if the value of the field is `DISABLED`"]
224    #[inline(always)]
225    pub fn is_disabled(&self) -> bool {
226        *self == DOWNSEL_A::DISABLED
227    }
228    #[doc = "Checks if the value of the field is `HCLK`"]
229    #[inline(always)]
230    pub fn is_hclk(&self) -> bool {
231        *self == DOWNSEL_A::HCLK
232    }
233    #[doc = "Checks if the value of the field is `PRS`"]
234    #[inline(always)]
235    pub fn is_prs(&self) -> bool {
236        *self == DOWNSEL_A::PRS
237    }
238    #[doc = "Checks if the value of the field is `HFXO`"]
239    #[inline(always)]
240    pub fn is_hfxo(&self) -> bool {
241        *self == DOWNSEL_A::HFXO
242    }
243    #[doc = "Checks if the value of the field is `LFXO`"]
244    #[inline(always)]
245    pub fn is_lfxo(&self) -> bool {
246        *self == DOWNSEL_A::LFXO
247    }
248    #[doc = "Checks if the value of the field is `HFRCODPLL`"]
249    #[inline(always)]
250    pub fn is_hfrcodpll(&self) -> bool {
251        *self == DOWNSEL_A::HFRCODPLL
252    }
253    #[doc = "Checks if the value of the field is `FSRCO`"]
254    #[inline(always)]
255    pub fn is_fsrco(&self) -> bool {
256        *self == DOWNSEL_A::FSRCO
257    }
258    #[doc = "Checks if the value of the field is `LFRCO`"]
259    #[inline(always)]
260    pub fn is_lfrco(&self) -> bool {
261        *self == DOWNSEL_A::LFRCO
262    }
263    #[doc = "Checks if the value of the field is `ULFRCO`"]
264    #[inline(always)]
265    pub fn is_ulfrco(&self) -> bool {
266        *self == DOWNSEL_A::ULFRCO
267    }
268}
269#[doc = "Field `DOWNSEL` writer - Calibration Down-counter Select"]
270pub type DOWNSEL_W<'a, const O: u8> =
271    crate::FieldWriter<'a, u32, CALCTRL_SPEC, u8, DOWNSEL_A, 4, O>;
272impl<'a, const O: u8> DOWNSEL_W<'a, O> {
273    #[doc = "Down-counter is not clocked"]
274    #[inline(always)]
275    pub fn disabled(self) -> &'a mut W {
276        self.variant(DOWNSEL_A::DISABLED)
277    }
278    #[doc = "HCLK is clocking down-counter"]
279    #[inline(always)]
280    pub fn hclk(self) -> &'a mut W {
281        self.variant(DOWNSEL_A::HCLK)
282    }
283    #[doc = "PRS CMU_CALDN consumer is clocking down-counter"]
284    #[inline(always)]
285    pub fn prs(self) -> &'a mut W {
286        self.variant(DOWNSEL_A::PRS)
287    }
288    #[doc = "HFXO is clocking down-counter"]
289    #[inline(always)]
290    pub fn hfxo(self) -> &'a mut W {
291        self.variant(DOWNSEL_A::HFXO)
292    }
293    #[doc = "LFXO is clocking down-counter"]
294    #[inline(always)]
295    pub fn lfxo(self) -> &'a mut W {
296        self.variant(DOWNSEL_A::LFXO)
297    }
298    #[doc = "HFRCODPLL is clocking down-counter"]
299    #[inline(always)]
300    pub fn hfrcodpll(self) -> &'a mut W {
301        self.variant(DOWNSEL_A::HFRCODPLL)
302    }
303    #[doc = "FSRCO is clocking down-counter"]
304    #[inline(always)]
305    pub fn fsrco(self) -> &'a mut W {
306        self.variant(DOWNSEL_A::FSRCO)
307    }
308    #[doc = "LFRCO is clocking down-counter"]
309    #[inline(always)]
310    pub fn lfrco(self) -> &'a mut W {
311        self.variant(DOWNSEL_A::LFRCO)
312    }
313    #[doc = "ULFRCO is clocking down-counter"]
314    #[inline(always)]
315    pub fn ulfrco(self) -> &'a mut W {
316        self.variant(DOWNSEL_A::ULFRCO)
317    }
318}
319impl R {
320    #[doc = "Bits 0:19 - Calibration Counter Top Value"]
321    #[inline(always)]
322    pub fn caltop(&self) -> CALTOP_R {
323        CALTOP_R::new(self.bits & 0x000f_ffff)
324    }
325    #[doc = "Bit 23 - Continuous Calibration"]
326    #[inline(always)]
327    pub fn cont(&self) -> CONT_R {
328        CONT_R::new(((self.bits >> 23) & 1) != 0)
329    }
330    #[doc = "Bits 24:27 - Calibration Up-counter Select"]
331    #[inline(always)]
332    pub fn upsel(&self) -> UPSEL_R {
333        UPSEL_R::new(((self.bits >> 24) & 0x0f) as u8)
334    }
335    #[doc = "Bits 28:31 - Calibration Down-counter Select"]
336    #[inline(always)]
337    pub fn downsel(&self) -> DOWNSEL_R {
338        DOWNSEL_R::new(((self.bits >> 28) & 0x0f) as u8)
339    }
340}
341impl W {
342    #[doc = "Bits 0:19 - Calibration Counter Top Value"]
343    #[inline(always)]
344    #[must_use]
345    pub fn caltop(&mut self) -> CALTOP_W<0> {
346        CALTOP_W::new(self)
347    }
348    #[doc = "Bit 23 - Continuous Calibration"]
349    #[inline(always)]
350    #[must_use]
351    pub fn cont(&mut self) -> CONT_W<23> {
352        CONT_W::new(self)
353    }
354    #[doc = "Bits 24:27 - Calibration Up-counter Select"]
355    #[inline(always)]
356    #[must_use]
357    pub fn upsel(&mut self) -> UPSEL_W<24> {
358        UPSEL_W::new(self)
359    }
360    #[doc = "Bits 28:31 - Calibration Down-counter Select"]
361    #[inline(always)]
362    #[must_use]
363    pub fn downsel(&mut self) -> DOWNSEL_W<28> {
364        DOWNSEL_W::new(self)
365    }
366    #[doc = "Writes raw bits to the register."]
367    #[inline(always)]
368    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
369        self.0.bits(bits);
370        self
371    }
372}
373#[doc = "No Description\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"]
374pub struct CALCTRL_SPEC;
375impl crate::RegisterSpec for CALCTRL_SPEC {
376    type Ux = u32;
377}
378#[doc = "`read()` method returns [calctrl::R](R) reader structure"]
379impl crate::Readable for CALCTRL_SPEC {
380    type Reader = R;
381}
382#[doc = "`write(|w| ..)` method takes [calctrl::W](W) writer structure"]
383impl crate::Writable for CALCTRL_SPEC {
384    type Writer = W;
385    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
386    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
387}
388#[doc = "`reset()` method sets CALCTRL to value 0"]
389impl crate::Resettable for CALCTRL_SPEC {
390    const RESET_VALUE: Self::Ux = 0;
391}