efm32pg22_pac/efm32pg22c200/burtc_ns/
cfg.rs

1#[doc = "Register `CFG` reader"]
2pub struct R(crate::R<CFG_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CFG_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CFG_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CFG_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CFG` writer"]
17pub struct W(crate::W<CFG_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CFG_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<CFG_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CFG_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `DEBUGRUN` reader - Debug Mode Run Enable"]
38pub type DEBUGRUN_R = crate::BitReader<DEBUGRUN_A>;
39#[doc = "Debug Mode Run Enable\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41pub enum DEBUGRUN_A {
42    #[doc = "0: BURTC is frozen in debug mode"]
43    DISABLE = 0,
44    #[doc = "1: BURTC is running in debug mode"]
45    ENABLE = 1,
46}
47impl From<DEBUGRUN_A> for bool {
48    #[inline(always)]
49    fn from(variant: DEBUGRUN_A) -> Self {
50        variant as u8 != 0
51    }
52}
53impl DEBUGRUN_R {
54    #[doc = "Get enumerated values variant"]
55    #[inline(always)]
56    pub fn variant(&self) -> DEBUGRUN_A {
57        match self.bits {
58            false => DEBUGRUN_A::DISABLE,
59            true => DEBUGRUN_A::ENABLE,
60        }
61    }
62    #[doc = "Checks if the value of the field is `DISABLE`"]
63    #[inline(always)]
64    pub fn is_disable(&self) -> bool {
65        *self == DEBUGRUN_A::DISABLE
66    }
67    #[doc = "Checks if the value of the field is `ENABLE`"]
68    #[inline(always)]
69    pub fn is_enable(&self) -> bool {
70        *self == DEBUGRUN_A::ENABLE
71    }
72}
73#[doc = "Field `DEBUGRUN` writer - Debug Mode Run Enable"]
74pub type DEBUGRUN_W<'a, const O: u8> = crate::BitWriter<'a, u32, CFG_SPEC, DEBUGRUN_A, O>;
75impl<'a, const O: u8> DEBUGRUN_W<'a, O> {
76    #[doc = "BURTC is frozen in debug mode"]
77    #[inline(always)]
78    pub fn disable(self) -> &'a mut W {
79        self.variant(DEBUGRUN_A::DISABLE)
80    }
81    #[doc = "BURTC is running in debug mode"]
82    #[inline(always)]
83    pub fn enable(self) -> &'a mut W {
84        self.variant(DEBUGRUN_A::ENABLE)
85    }
86}
87#[doc = "Field `COMPTOP` reader - Compare Channel is Top Value"]
88pub type COMPTOP_R = crate::BitReader<COMPTOP_A>;
89#[doc = "Compare Channel is Top Value\n\nValue on reset: 0"]
90#[derive(Clone, Copy, Debug, PartialEq, Eq)]
91pub enum COMPTOP_A {
92    #[doc = "0: The top value of the BURTC is 4294967295 (0xFFFFFFFF)"]
93    DISABLE = 0,
94    #[doc = "1: The top value of the BURTC is given by COMP"]
95    ENABLE = 1,
96}
97impl From<COMPTOP_A> for bool {
98    #[inline(always)]
99    fn from(variant: COMPTOP_A) -> Self {
100        variant as u8 != 0
101    }
102}
103impl COMPTOP_R {
104    #[doc = "Get enumerated values variant"]
105    #[inline(always)]
106    pub fn variant(&self) -> COMPTOP_A {
107        match self.bits {
108            false => COMPTOP_A::DISABLE,
109            true => COMPTOP_A::ENABLE,
110        }
111    }
112    #[doc = "Checks if the value of the field is `DISABLE`"]
113    #[inline(always)]
114    pub fn is_disable(&self) -> bool {
115        *self == COMPTOP_A::DISABLE
116    }
117    #[doc = "Checks if the value of the field is `ENABLE`"]
118    #[inline(always)]
119    pub fn is_enable(&self) -> bool {
120        *self == COMPTOP_A::ENABLE
121    }
122}
123#[doc = "Field `COMPTOP` writer - Compare Channel is Top Value"]
124pub type COMPTOP_W<'a, const O: u8> = crate::BitWriter<'a, u32, CFG_SPEC, COMPTOP_A, O>;
125impl<'a, const O: u8> COMPTOP_W<'a, O> {
126    #[doc = "The top value of the BURTC is 4294967295 (0xFFFFFFFF)"]
127    #[inline(always)]
128    pub fn disable(self) -> &'a mut W {
129        self.variant(COMPTOP_A::DISABLE)
130    }
131    #[doc = "The top value of the BURTC is given by COMP"]
132    #[inline(always)]
133    pub fn enable(self) -> &'a mut W {
134        self.variant(COMPTOP_A::ENABLE)
135    }
136}
137#[doc = "Field `CNTPRESC` reader - Counter prescaler value."]
138pub type CNTPRESC_R = crate::FieldReader<u8, CNTPRESC_A>;
139#[doc = "Counter prescaler value.\n\nValue on reset: 0"]
140#[derive(Clone, Copy, Debug, PartialEq, Eq)]
141#[repr(u8)]
142pub enum CNTPRESC_A {
143    #[doc = "0: CLK_CNT = (BURTC LF CLK)/1"]
144    DIV1 = 0,
145    #[doc = "1: CLK_CNT = (BURTC LF CLK)/2"]
146    DIV2 = 1,
147    #[doc = "2: CLK_CNT = (BURTC LF CLK)/4"]
148    DIV4 = 2,
149    #[doc = "3: CLK_CNT = (BURTC LF CLK)/8"]
150    DIV8 = 3,
151    #[doc = "4: CLK_CNT = (BURTC LF CLK)/16"]
152    DIV16 = 4,
153    #[doc = "5: CLK_CNT = (BURTC LF CLK)/32"]
154    DIV32 = 5,
155    #[doc = "6: CLK_CNT = (BURTC LF CLK)/64"]
156    DIV64 = 6,
157    #[doc = "7: CLK_CNT = (BURTC LF CLK)/128"]
158    DIV128 = 7,
159    #[doc = "8: CLK_CNT = (BURTC LF CLK)/256"]
160    DIV256 = 8,
161    #[doc = "9: CLK_CNT = (BURTC LF CLK)/512"]
162    DIV512 = 9,
163    #[doc = "10: CLK_CNT = (BURTC LF CLK)/1024"]
164    DIV1024 = 10,
165    #[doc = "11: CLK_CNT = (BURTC LF CLK)/2048"]
166    DIV2048 = 11,
167    #[doc = "12: CLK_CNT = (BURTC LF CLK)/4096"]
168    DIV4096 = 12,
169    #[doc = "13: CLK_CNT = (BURTC LF CLK)/8192"]
170    DIV8192 = 13,
171    #[doc = "14: CLK_CNT = (BURTC LF CLK)/16384"]
172    DIV16384 = 14,
173    #[doc = "15: CLK_CNT = (BURTC LF CLK)/32768"]
174    DIV32768 = 15,
175}
176impl From<CNTPRESC_A> for u8 {
177    #[inline(always)]
178    fn from(variant: CNTPRESC_A) -> Self {
179        variant as _
180    }
181}
182impl CNTPRESC_R {
183    #[doc = "Get enumerated values variant"]
184    #[inline(always)]
185    pub fn variant(&self) -> CNTPRESC_A {
186        match self.bits {
187            0 => CNTPRESC_A::DIV1,
188            1 => CNTPRESC_A::DIV2,
189            2 => CNTPRESC_A::DIV4,
190            3 => CNTPRESC_A::DIV8,
191            4 => CNTPRESC_A::DIV16,
192            5 => CNTPRESC_A::DIV32,
193            6 => CNTPRESC_A::DIV64,
194            7 => CNTPRESC_A::DIV128,
195            8 => CNTPRESC_A::DIV256,
196            9 => CNTPRESC_A::DIV512,
197            10 => CNTPRESC_A::DIV1024,
198            11 => CNTPRESC_A::DIV2048,
199            12 => CNTPRESC_A::DIV4096,
200            13 => CNTPRESC_A::DIV8192,
201            14 => CNTPRESC_A::DIV16384,
202            15 => CNTPRESC_A::DIV32768,
203            _ => unreachable!(),
204        }
205    }
206    #[doc = "Checks if the value of the field is `DIV1`"]
207    #[inline(always)]
208    pub fn is_div1(&self) -> bool {
209        *self == CNTPRESC_A::DIV1
210    }
211    #[doc = "Checks if the value of the field is `DIV2`"]
212    #[inline(always)]
213    pub fn is_div2(&self) -> bool {
214        *self == CNTPRESC_A::DIV2
215    }
216    #[doc = "Checks if the value of the field is `DIV4`"]
217    #[inline(always)]
218    pub fn is_div4(&self) -> bool {
219        *self == CNTPRESC_A::DIV4
220    }
221    #[doc = "Checks if the value of the field is `DIV8`"]
222    #[inline(always)]
223    pub fn is_div8(&self) -> bool {
224        *self == CNTPRESC_A::DIV8
225    }
226    #[doc = "Checks if the value of the field is `DIV16`"]
227    #[inline(always)]
228    pub fn is_div16(&self) -> bool {
229        *self == CNTPRESC_A::DIV16
230    }
231    #[doc = "Checks if the value of the field is `DIV32`"]
232    #[inline(always)]
233    pub fn is_div32(&self) -> bool {
234        *self == CNTPRESC_A::DIV32
235    }
236    #[doc = "Checks if the value of the field is `DIV64`"]
237    #[inline(always)]
238    pub fn is_div64(&self) -> bool {
239        *self == CNTPRESC_A::DIV64
240    }
241    #[doc = "Checks if the value of the field is `DIV128`"]
242    #[inline(always)]
243    pub fn is_div128(&self) -> bool {
244        *self == CNTPRESC_A::DIV128
245    }
246    #[doc = "Checks if the value of the field is `DIV256`"]
247    #[inline(always)]
248    pub fn is_div256(&self) -> bool {
249        *self == CNTPRESC_A::DIV256
250    }
251    #[doc = "Checks if the value of the field is `DIV512`"]
252    #[inline(always)]
253    pub fn is_div512(&self) -> bool {
254        *self == CNTPRESC_A::DIV512
255    }
256    #[doc = "Checks if the value of the field is `DIV1024`"]
257    #[inline(always)]
258    pub fn is_div1024(&self) -> bool {
259        *self == CNTPRESC_A::DIV1024
260    }
261    #[doc = "Checks if the value of the field is `DIV2048`"]
262    #[inline(always)]
263    pub fn is_div2048(&self) -> bool {
264        *self == CNTPRESC_A::DIV2048
265    }
266    #[doc = "Checks if the value of the field is `DIV4096`"]
267    #[inline(always)]
268    pub fn is_div4096(&self) -> bool {
269        *self == CNTPRESC_A::DIV4096
270    }
271    #[doc = "Checks if the value of the field is `DIV8192`"]
272    #[inline(always)]
273    pub fn is_div8192(&self) -> bool {
274        *self == CNTPRESC_A::DIV8192
275    }
276    #[doc = "Checks if the value of the field is `DIV16384`"]
277    #[inline(always)]
278    pub fn is_div16384(&self) -> bool {
279        *self == CNTPRESC_A::DIV16384
280    }
281    #[doc = "Checks if the value of the field is `DIV32768`"]
282    #[inline(always)]
283    pub fn is_div32768(&self) -> bool {
284        *self == CNTPRESC_A::DIV32768
285    }
286}
287#[doc = "Field `CNTPRESC` writer - Counter prescaler value."]
288pub type CNTPRESC_W<'a, const O: u8> =
289    crate::FieldWriterSafe<'a, u32, CFG_SPEC, u8, CNTPRESC_A, 4, O>;
290impl<'a, const O: u8> CNTPRESC_W<'a, O> {
291    #[doc = "CLK_CNT = (BURTC LF CLK)/1"]
292    #[inline(always)]
293    pub fn div1(self) -> &'a mut W {
294        self.variant(CNTPRESC_A::DIV1)
295    }
296    #[doc = "CLK_CNT = (BURTC LF CLK)/2"]
297    #[inline(always)]
298    pub fn div2(self) -> &'a mut W {
299        self.variant(CNTPRESC_A::DIV2)
300    }
301    #[doc = "CLK_CNT = (BURTC LF CLK)/4"]
302    #[inline(always)]
303    pub fn div4(self) -> &'a mut W {
304        self.variant(CNTPRESC_A::DIV4)
305    }
306    #[doc = "CLK_CNT = (BURTC LF CLK)/8"]
307    #[inline(always)]
308    pub fn div8(self) -> &'a mut W {
309        self.variant(CNTPRESC_A::DIV8)
310    }
311    #[doc = "CLK_CNT = (BURTC LF CLK)/16"]
312    #[inline(always)]
313    pub fn div16(self) -> &'a mut W {
314        self.variant(CNTPRESC_A::DIV16)
315    }
316    #[doc = "CLK_CNT = (BURTC LF CLK)/32"]
317    #[inline(always)]
318    pub fn div32(self) -> &'a mut W {
319        self.variant(CNTPRESC_A::DIV32)
320    }
321    #[doc = "CLK_CNT = (BURTC LF CLK)/64"]
322    #[inline(always)]
323    pub fn div64(self) -> &'a mut W {
324        self.variant(CNTPRESC_A::DIV64)
325    }
326    #[doc = "CLK_CNT = (BURTC LF CLK)/128"]
327    #[inline(always)]
328    pub fn div128(self) -> &'a mut W {
329        self.variant(CNTPRESC_A::DIV128)
330    }
331    #[doc = "CLK_CNT = (BURTC LF CLK)/256"]
332    #[inline(always)]
333    pub fn div256(self) -> &'a mut W {
334        self.variant(CNTPRESC_A::DIV256)
335    }
336    #[doc = "CLK_CNT = (BURTC LF CLK)/512"]
337    #[inline(always)]
338    pub fn div512(self) -> &'a mut W {
339        self.variant(CNTPRESC_A::DIV512)
340    }
341    #[doc = "CLK_CNT = (BURTC LF CLK)/1024"]
342    #[inline(always)]
343    pub fn div1024(self) -> &'a mut W {
344        self.variant(CNTPRESC_A::DIV1024)
345    }
346    #[doc = "CLK_CNT = (BURTC LF CLK)/2048"]
347    #[inline(always)]
348    pub fn div2048(self) -> &'a mut W {
349        self.variant(CNTPRESC_A::DIV2048)
350    }
351    #[doc = "CLK_CNT = (BURTC LF CLK)/4096"]
352    #[inline(always)]
353    pub fn div4096(self) -> &'a mut W {
354        self.variant(CNTPRESC_A::DIV4096)
355    }
356    #[doc = "CLK_CNT = (BURTC LF CLK)/8192"]
357    #[inline(always)]
358    pub fn div8192(self) -> &'a mut W {
359        self.variant(CNTPRESC_A::DIV8192)
360    }
361    #[doc = "CLK_CNT = (BURTC LF CLK)/16384"]
362    #[inline(always)]
363    pub fn div16384(self) -> &'a mut W {
364        self.variant(CNTPRESC_A::DIV16384)
365    }
366    #[doc = "CLK_CNT = (BURTC LF CLK)/32768"]
367    #[inline(always)]
368    pub fn div32768(self) -> &'a mut W {
369        self.variant(CNTPRESC_A::DIV32768)
370    }
371}
372impl R {
373    #[doc = "Bit 0 - Debug Mode Run Enable"]
374    #[inline(always)]
375    pub fn debugrun(&self) -> DEBUGRUN_R {
376        DEBUGRUN_R::new((self.bits & 1) != 0)
377    }
378    #[doc = "Bit 1 - Compare Channel is Top Value"]
379    #[inline(always)]
380    pub fn comptop(&self) -> COMPTOP_R {
381        COMPTOP_R::new(((self.bits >> 1) & 1) != 0)
382    }
383    #[doc = "Bits 4:7 - Counter prescaler value."]
384    #[inline(always)]
385    pub fn cntpresc(&self) -> CNTPRESC_R {
386        CNTPRESC_R::new(((self.bits >> 4) & 0x0f) as u8)
387    }
388}
389impl W {
390    #[doc = "Bit 0 - Debug Mode Run Enable"]
391    #[inline(always)]
392    #[must_use]
393    pub fn debugrun(&mut self) -> DEBUGRUN_W<0> {
394        DEBUGRUN_W::new(self)
395    }
396    #[doc = "Bit 1 - Compare Channel is Top Value"]
397    #[inline(always)]
398    #[must_use]
399    pub fn comptop(&mut self) -> COMPTOP_W<1> {
400        COMPTOP_W::new(self)
401    }
402    #[doc = "Bits 4:7 - Counter prescaler value."]
403    #[inline(always)]
404    #[must_use]
405    pub fn cntpresc(&mut self) -> CNTPRESC_W<4> {
406        CNTPRESC_W::new(self)
407    }
408    #[doc = "Writes raw bits to the register."]
409    #[inline(always)]
410    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
411        self.0.bits(bits);
412        self
413    }
414}
415#[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)."]
416pub struct CFG_SPEC;
417impl crate::RegisterSpec for CFG_SPEC {
418    type Ux = u32;
419}
420#[doc = "`read()` method returns [cfg::R](R) reader structure"]
421impl crate::Readable for CFG_SPEC {
422    type Reader = R;
423}
424#[doc = "`write(|w| ..)` method takes [cfg::W](W) writer structure"]
425impl crate::Writable for CFG_SPEC {
426    type Writer = W;
427    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
428    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
429}
430#[doc = "`reset()` method sets CFG to value 0"]
431impl crate::Resettable for CFG_SPEC {
432    const RESET_VALUE: Self::Ux = 0;
433}