efm32tg11b_pac/efm32tg11b120/rtcc/
ctrl.rs

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