efm32tg11b540_pac/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> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 0>;
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> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 2>;
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> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 4>;
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> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 5>;
53#[doc = "Counter Prescaler Value\n\nValue on reset: 0"]
54#[derive(Clone, Copy, Debug, PartialEq)]
55#[repr(u8)]
56pub enum CNTPRESC_A {
57    #[doc = "0: CLKCNT = LFECLKRTCC/1"]
58    DIV1 = 0,
59    #[doc = "1: CLKCNT = LFECLKRTCC/2"]
60    DIV2 = 1,
61    #[doc = "2: CLKCNT = LFECLKRTCC/4"]
62    DIV4 = 2,
63    #[doc = "3: CLKCNT = LFECLKRTCC/8"]
64    DIV8 = 3,
65    #[doc = "4: CLKCNT = LFECLKRTCC/16"]
66    DIV16 = 4,
67    #[doc = "5: CLKCNT = LFECLKRTCC/32"]
68    DIV32 = 5,
69    #[doc = "6: CLKCNT = LFECLKRTCC/64"]
70    DIV64 = 6,
71    #[doc = "7: CLKCNT = LFECLKRTCC/128"]
72    DIV128 = 7,
73    #[doc = "8: CLKCNT = LFECLKRTCC/256"]
74    DIV256 = 8,
75    #[doc = "9: CLKCNT = LFECLKRTCC/512"]
76    DIV512 = 9,
77    #[doc = "10: CLKCNT = LFECLKRTCC/1024"]
78    DIV1024 = 10,
79    #[doc = "11: CLKCNT = LFECLKRTCC/2048"]
80    DIV2048 = 11,
81    #[doc = "12: CLKCNT = LFECLKRTCC/4096"]
82    DIV4096 = 12,
83    #[doc = "13: CLKCNT = LFECLKRTCC/8192"]
84    DIV8192 = 13,
85    #[doc = "14: CLKCNT = LFECLKRTCC/16384"]
86    DIV16384 = 14,
87    #[doc = "15: CLKCNT = LFECLKRTCC/32768"]
88    DIV32768 = 15,
89}
90impl From<CNTPRESC_A> for u8 {
91    #[inline(always)]
92    fn from(variant: CNTPRESC_A) -> Self {
93        variant as _
94    }
95}
96#[doc = "Field `CNTPRESC` reader - Counter Prescaler Value"]
97pub type CNTPRESC_R = crate::FieldReader<u8, CNTPRESC_A>;
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> = crate::FieldWriterSafe<'a, u32, CTRL_SPEC, u8, CNTPRESC_A, 4, 8>;
205impl<'a> CNTPRESC_W<'a> {
206    #[doc = "CLKCNT = LFECLKRTCC/1"]
207    #[inline(always)]
208    pub fn div1(self) -> &'a mut W {
209        self.variant(CNTPRESC_A::DIV1)
210    }
211    #[doc = "CLKCNT = LFECLKRTCC/2"]
212    #[inline(always)]
213    pub fn div2(self) -> &'a mut W {
214        self.variant(CNTPRESC_A::DIV2)
215    }
216    #[doc = "CLKCNT = LFECLKRTCC/4"]
217    #[inline(always)]
218    pub fn div4(self) -> &'a mut W {
219        self.variant(CNTPRESC_A::DIV4)
220    }
221    #[doc = "CLKCNT = LFECLKRTCC/8"]
222    #[inline(always)]
223    pub fn div8(self) -> &'a mut W {
224        self.variant(CNTPRESC_A::DIV8)
225    }
226    #[doc = "CLKCNT = LFECLKRTCC/16"]
227    #[inline(always)]
228    pub fn div16(self) -> &'a mut W {
229        self.variant(CNTPRESC_A::DIV16)
230    }
231    #[doc = "CLKCNT = LFECLKRTCC/32"]
232    #[inline(always)]
233    pub fn div32(self) -> &'a mut W {
234        self.variant(CNTPRESC_A::DIV32)
235    }
236    #[doc = "CLKCNT = LFECLKRTCC/64"]
237    #[inline(always)]
238    pub fn div64(self) -> &'a mut W {
239        self.variant(CNTPRESC_A::DIV64)
240    }
241    #[doc = "CLKCNT = LFECLKRTCC/128"]
242    #[inline(always)]
243    pub fn div128(self) -> &'a mut W {
244        self.variant(CNTPRESC_A::DIV128)
245    }
246    #[doc = "CLKCNT = LFECLKRTCC/256"]
247    #[inline(always)]
248    pub fn div256(self) -> &'a mut W {
249        self.variant(CNTPRESC_A::DIV256)
250    }
251    #[doc = "CLKCNT = LFECLKRTCC/512"]
252    #[inline(always)]
253    pub fn div512(self) -> &'a mut W {
254        self.variant(CNTPRESC_A::DIV512)
255    }
256    #[doc = "CLKCNT = LFECLKRTCC/1024"]
257    #[inline(always)]
258    pub fn div1024(self) -> &'a mut W {
259        self.variant(CNTPRESC_A::DIV1024)
260    }
261    #[doc = "CLKCNT = LFECLKRTCC/2048"]
262    #[inline(always)]
263    pub fn div2048(self) -> &'a mut W {
264        self.variant(CNTPRESC_A::DIV2048)
265    }
266    #[doc = "CLKCNT = LFECLKRTCC/4096"]
267    #[inline(always)]
268    pub fn div4096(self) -> &'a mut W {
269        self.variant(CNTPRESC_A::DIV4096)
270    }
271    #[doc = "CLKCNT = LFECLKRTCC/8192"]
272    #[inline(always)]
273    pub fn div8192(self) -> &'a mut W {
274        self.variant(CNTPRESC_A::DIV8192)
275    }
276    #[doc = "CLKCNT = LFECLKRTCC/16384"]
277    #[inline(always)]
278    pub fn div16384(self) -> &'a mut W {
279        self.variant(CNTPRESC_A::DIV16384)
280    }
281    #[doc = "CLKCNT = LFECLKRTCC/32768"]
282    #[inline(always)]
283    pub fn div32768(self) -> &'a mut W {
284        self.variant(CNTPRESC_A::DIV32768)
285    }
286}
287#[doc = "Field `CNTTICK` reader - Counter Prescaler Mode"]
288pub type CNTTICK_R = crate::BitReader<bool>;
289#[doc = "Field `CNTTICK` writer - Counter Prescaler Mode"]
290pub type CNTTICK_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 12>;
291#[doc = "Field `BUMODETSEN` reader - Backup Mode Timestamp Enable"]
292pub type BUMODETSEN_R = crate::BitReader<bool>;
293#[doc = "Field `BUMODETSEN` writer - Backup Mode Timestamp Enable"]
294pub type BUMODETSEN_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 14>;
295#[doc = "Field `OSCFDETEN` reader - Oscillator Failure Detection Enable"]
296pub type OSCFDETEN_R = crate::BitReader<bool>;
297#[doc = "Field `OSCFDETEN` writer - Oscillator Failure Detection Enable"]
298pub type OSCFDETEN_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 15>;
299#[doc = "Field `CNTMODE` reader - Main Counter Mode"]
300pub type CNTMODE_R = crate::BitReader<bool>;
301#[doc = "Field `CNTMODE` writer - Main Counter Mode"]
302pub type CNTMODE_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 16>;
303#[doc = "Field `LYEARCORRDIS` reader - Leap Year Correction Disabled"]
304pub type LYEARCORRDIS_R = crate::BitReader<bool>;
305#[doc = "Field `LYEARCORRDIS` writer - Leap Year Correction Disabled"]
306pub type LYEARCORRDIS_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 17>;
307impl R {
308    #[doc = "Bit 0 - RTCC Enable"]
309    #[inline(always)]
310    pub fn enable(&self) -> ENABLE_R {
311        ENABLE_R::new((self.bits & 1) != 0)
312    }
313    #[doc = "Bit 2 - Debug Mode Run Enable"]
314    #[inline(always)]
315    pub fn debugrun(&self) -> DEBUGRUN_R {
316        DEBUGRUN_R::new(((self.bits >> 2) & 1) != 0)
317    }
318    #[doc = "Bit 4 - Pre-counter CCV0 Top Value Enable"]
319    #[inline(always)]
320    pub fn preccv0top(&self) -> PRECCV0TOP_R {
321        PRECCV0TOP_R::new(((self.bits >> 4) & 1) != 0)
322    }
323    #[doc = "Bit 5 - CCV1 Top Value Enable"]
324    #[inline(always)]
325    pub fn ccv1top(&self) -> CCV1TOP_R {
326        CCV1TOP_R::new(((self.bits >> 5) & 1) != 0)
327    }
328    #[doc = "Bits 8:11 - Counter Prescaler Value"]
329    #[inline(always)]
330    pub fn cntpresc(&self) -> CNTPRESC_R {
331        CNTPRESC_R::new(((self.bits >> 8) & 0x0f) as u8)
332    }
333    #[doc = "Bit 12 - Counter Prescaler Mode"]
334    #[inline(always)]
335    pub fn cnttick(&self) -> CNTTICK_R {
336        CNTTICK_R::new(((self.bits >> 12) & 1) != 0)
337    }
338    #[doc = "Bit 14 - Backup Mode Timestamp Enable"]
339    #[inline(always)]
340    pub fn bumodetsen(&self) -> BUMODETSEN_R {
341        BUMODETSEN_R::new(((self.bits >> 14) & 1) != 0)
342    }
343    #[doc = "Bit 15 - Oscillator Failure Detection Enable"]
344    #[inline(always)]
345    pub fn oscfdeten(&self) -> OSCFDETEN_R {
346        OSCFDETEN_R::new(((self.bits >> 15) & 1) != 0)
347    }
348    #[doc = "Bit 16 - Main Counter Mode"]
349    #[inline(always)]
350    pub fn cntmode(&self) -> CNTMODE_R {
351        CNTMODE_R::new(((self.bits >> 16) & 1) != 0)
352    }
353    #[doc = "Bit 17 - Leap Year Correction Disabled"]
354    #[inline(always)]
355    pub fn lyearcorrdis(&self) -> LYEARCORRDIS_R {
356        LYEARCORRDIS_R::new(((self.bits >> 17) & 1) != 0)
357    }
358}
359impl W {
360    #[doc = "Bit 0 - RTCC Enable"]
361    #[inline(always)]
362    pub fn enable(&mut self) -> ENABLE_W {
363        ENABLE_W::new(self)
364    }
365    #[doc = "Bit 2 - Debug Mode Run Enable"]
366    #[inline(always)]
367    pub fn debugrun(&mut self) -> DEBUGRUN_W {
368        DEBUGRUN_W::new(self)
369    }
370    #[doc = "Bit 4 - Pre-counter CCV0 Top Value Enable"]
371    #[inline(always)]
372    pub fn preccv0top(&mut self) -> PRECCV0TOP_W {
373        PRECCV0TOP_W::new(self)
374    }
375    #[doc = "Bit 5 - CCV1 Top Value Enable"]
376    #[inline(always)]
377    pub fn ccv1top(&mut self) -> CCV1TOP_W {
378        CCV1TOP_W::new(self)
379    }
380    #[doc = "Bits 8:11 - Counter Prescaler Value"]
381    #[inline(always)]
382    pub fn cntpresc(&mut self) -> CNTPRESC_W {
383        CNTPRESC_W::new(self)
384    }
385    #[doc = "Bit 12 - Counter Prescaler Mode"]
386    #[inline(always)]
387    pub fn cnttick(&mut self) -> CNTTICK_W {
388        CNTTICK_W::new(self)
389    }
390    #[doc = "Bit 14 - Backup Mode Timestamp Enable"]
391    #[inline(always)]
392    pub fn bumodetsen(&mut self) -> BUMODETSEN_W {
393        BUMODETSEN_W::new(self)
394    }
395    #[doc = "Bit 15 - Oscillator Failure Detection Enable"]
396    #[inline(always)]
397    pub fn oscfdeten(&mut self) -> OSCFDETEN_W {
398        OSCFDETEN_W::new(self)
399    }
400    #[doc = "Bit 16 - Main Counter Mode"]
401    #[inline(always)]
402    pub fn cntmode(&mut self) -> CNTMODE_W {
403        CNTMODE_W::new(self)
404    }
405    #[doc = "Bit 17 - Leap Year Correction Disabled"]
406    #[inline(always)]
407    pub fn lyearcorrdis(&mut self) -> LYEARCORRDIS_W {
408        LYEARCORRDIS_W::new(self)
409    }
410    #[doc = "Writes raw bits to the register."]
411    #[inline(always)]
412    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
413        self.0.bits(bits);
414        self
415    }
416}
417#[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"]
418pub struct CTRL_SPEC;
419impl crate::RegisterSpec for CTRL_SPEC {
420    type Ux = u32;
421}
422#[doc = "`read()` method returns [ctrl::R](R) reader structure"]
423impl crate::Readable for CTRL_SPEC {
424    type Reader = R;
425}
426#[doc = "`write(|w| ..)` method takes [ctrl::W](W) writer structure"]
427impl crate::Writable for CTRL_SPEC {
428    type Writer = W;
429}
430#[doc = "`reset()` method sets CTRL to value 0"]
431impl crate::Resettable for CTRL_SPEC {
432    #[inline(always)]
433    fn reset_value() -> Self::Ux {
434        0
435    }
436}