efm32pg12_pac/rtcc/
ctrl.rs1#[doc = "Reader of register CTRL"]
2pub type R = crate::R<u32, super::CTRL>;
3#[doc = "Writer for register CTRL"]
4pub type W = crate::W<u32, super::CTRL>;
5#[doc = "Register CTRL `reset()`'s with value 0"]
6impl crate::ResetValue for super::CTRL {
7 type Type = u32;
8 #[inline(always)]
9 fn reset_value() -> Self::Type {
10 0
11 }
12}
13#[doc = "Reader of field `ENABLE`"]
14pub type ENABLE_R = crate::R<bool, bool>;
15#[doc = "Write proxy for field `ENABLE`"]
16pub struct ENABLE_W<'a> {
17 w: &'a mut W,
18}
19impl<'a> ENABLE_W<'a> {
20 #[doc = r"Sets the field bit"]
21 #[inline(always)]
22 pub fn set_bit(self) -> &'a mut W {
23 self.bit(true)
24 }
25 #[doc = r"Clears the field bit"]
26 #[inline(always)]
27 pub fn clear_bit(self) -> &'a mut W {
28 self.bit(false)
29 }
30 #[doc = r"Writes raw bits to the field"]
31 #[inline(always)]
32 pub fn bit(self, value: bool) -> &'a mut W {
33 self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01);
34 self.w
35 }
36}
37#[doc = "Reader of field `DEBUGRUN`"]
38pub type DEBUGRUN_R = crate::R<bool, bool>;
39#[doc = "Write proxy for field `DEBUGRUN`"]
40pub struct DEBUGRUN_W<'a> {
41 w: &'a mut W,
42}
43impl<'a> DEBUGRUN_W<'a> {
44 #[doc = r"Sets the field bit"]
45 #[inline(always)]
46 pub fn set_bit(self) -> &'a mut W {
47 self.bit(true)
48 }
49 #[doc = r"Clears the field bit"]
50 #[inline(always)]
51 pub fn clear_bit(self) -> &'a mut W {
52 self.bit(false)
53 }
54 #[doc = r"Writes raw bits to the field"]
55 #[inline(always)]
56 pub fn bit(self, value: bool) -> &'a mut W {
57 self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2);
58 self.w
59 }
60}
61#[doc = "Reader of field `PRECCV0TOP`"]
62pub type PRECCV0TOP_R = crate::R<bool, bool>;
63#[doc = "Write proxy for field `PRECCV0TOP`"]
64pub struct PRECCV0TOP_W<'a> {
65 w: &'a mut W,
66}
67impl<'a> PRECCV0TOP_W<'a> {
68 #[doc = r"Sets the field bit"]
69 #[inline(always)]
70 pub fn set_bit(self) -> &'a mut W {
71 self.bit(true)
72 }
73 #[doc = r"Clears the field bit"]
74 #[inline(always)]
75 pub fn clear_bit(self) -> &'a mut W {
76 self.bit(false)
77 }
78 #[doc = r"Writes raw bits to the field"]
79 #[inline(always)]
80 pub fn bit(self, value: bool) -> &'a mut W {
81 self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u32) & 0x01) << 4);
82 self.w
83 }
84}
85#[doc = "Reader of field `CCV1TOP`"]
86pub type CCV1TOP_R = crate::R<bool, bool>;
87#[doc = "Write proxy for field `CCV1TOP`"]
88pub struct CCV1TOP_W<'a> {
89 w: &'a mut W,
90}
91impl<'a> CCV1TOP_W<'a> {
92 #[doc = r"Sets the field bit"]
93 #[inline(always)]
94 pub fn set_bit(self) -> &'a mut W {
95 self.bit(true)
96 }
97 #[doc = r"Clears the field bit"]
98 #[inline(always)]
99 pub fn clear_bit(self) -> &'a mut W {
100 self.bit(false)
101 }
102 #[doc = r"Writes raw bits to the field"]
103 #[inline(always)]
104 pub fn bit(self, value: bool) -> &'a mut W {
105 self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u32) & 0x01) << 5);
106 self.w
107 }
108}
109#[doc = "Counter Prescaler Value\n\nValue on reset: 0"]
110#[derive(Clone, Copy, Debug, PartialEq)]
111#[repr(u8)]
112pub enum CNTPRESC_A {
113 #[doc = "0: CLKCNT = LFECLKRTCC/1"]
114 DIV1 = 0,
115 #[doc = "1: CLKCNT = LFECLKRTCC/2"]
116 DIV2 = 1,
117 #[doc = "2: CLKCNT = LFECLKRTCC/4"]
118 DIV4 = 2,
119 #[doc = "3: CLKCNT = LFECLKRTCC/8"]
120 DIV8 = 3,
121 #[doc = "4: CLKCNT = LFECLKRTCC/16"]
122 DIV16 = 4,
123 #[doc = "5: CLKCNT = LFECLKRTCC/32"]
124 DIV32 = 5,
125 #[doc = "6: CLKCNT = LFECLKRTCC/64"]
126 DIV64 = 6,
127 #[doc = "7: CLKCNT = LFECLKRTCC/128"]
128 DIV128 = 7,
129 #[doc = "8: CLKCNT = LFECLKRTCC/256"]
130 DIV256 = 8,
131 #[doc = "9: CLKCNT = LFECLKRTCC/512"]
132 DIV512 = 9,
133 #[doc = "10: CLKCNT = LFECLKRTCC/1024"]
134 DIV1024 = 10,
135 #[doc = "11: CLKCNT = LFECLKRTCC/2048"]
136 DIV2048 = 11,
137 #[doc = "12: CLKCNT = LFECLKRTCC/4096"]
138 DIV4096 = 12,
139 #[doc = "13: CLKCNT = LFECLKRTCC/8192"]
140 DIV8192 = 13,
141 #[doc = "14: CLKCNT = LFECLKRTCC/16384"]
142 DIV16384 = 14,
143 #[doc = "15: CLKCNT = LFECLKRTCC/32768"]
144 DIV32768 = 15,
145}
146impl From<CNTPRESC_A> for u8 {
147 #[inline(always)]
148 fn from(variant: CNTPRESC_A) -> Self {
149 variant as _
150 }
151}
152#[doc = "Reader of field `CNTPRESC`"]
153pub type CNTPRESC_R = crate::R<u8, CNTPRESC_A>;
154impl CNTPRESC_R {
155 #[doc = r"Get enumerated values variant"]
156 #[inline(always)]
157 pub fn variant(&self) -> CNTPRESC_A {
158 match self.bits {
159 0 => CNTPRESC_A::DIV1,
160 1 => CNTPRESC_A::DIV2,
161 2 => CNTPRESC_A::DIV4,
162 3 => CNTPRESC_A::DIV8,
163 4 => CNTPRESC_A::DIV16,
164 5 => CNTPRESC_A::DIV32,
165 6 => CNTPRESC_A::DIV64,
166 7 => CNTPRESC_A::DIV128,
167 8 => CNTPRESC_A::DIV256,
168 9 => CNTPRESC_A::DIV512,
169 10 => CNTPRESC_A::DIV1024,
170 11 => CNTPRESC_A::DIV2048,
171 12 => CNTPRESC_A::DIV4096,
172 13 => CNTPRESC_A::DIV8192,
173 14 => CNTPRESC_A::DIV16384,
174 15 => CNTPRESC_A::DIV32768,
175 _ => unreachable!(),
176 }
177 }
178 #[doc = "Checks if the value of the field is `DIV1`"]
179 #[inline(always)]
180 pub fn is_div1(&self) -> bool {
181 *self == CNTPRESC_A::DIV1
182 }
183 #[doc = "Checks if the value of the field is `DIV2`"]
184 #[inline(always)]
185 pub fn is_div2(&self) -> bool {
186 *self == CNTPRESC_A::DIV2
187 }
188 #[doc = "Checks if the value of the field is `DIV4`"]
189 #[inline(always)]
190 pub fn is_div4(&self) -> bool {
191 *self == CNTPRESC_A::DIV4
192 }
193 #[doc = "Checks if the value of the field is `DIV8`"]
194 #[inline(always)]
195 pub fn is_div8(&self) -> bool {
196 *self == CNTPRESC_A::DIV8
197 }
198 #[doc = "Checks if the value of the field is `DIV16`"]
199 #[inline(always)]
200 pub fn is_div16(&self) -> bool {
201 *self == CNTPRESC_A::DIV16
202 }
203 #[doc = "Checks if the value of the field is `DIV32`"]
204 #[inline(always)]
205 pub fn is_div32(&self) -> bool {
206 *self == CNTPRESC_A::DIV32
207 }
208 #[doc = "Checks if the value of the field is `DIV64`"]
209 #[inline(always)]
210 pub fn is_div64(&self) -> bool {
211 *self == CNTPRESC_A::DIV64
212 }
213 #[doc = "Checks if the value of the field is `DIV128`"]
214 #[inline(always)]
215 pub fn is_div128(&self) -> bool {
216 *self == CNTPRESC_A::DIV128
217 }
218 #[doc = "Checks if the value of the field is `DIV256`"]
219 #[inline(always)]
220 pub fn is_div256(&self) -> bool {
221 *self == CNTPRESC_A::DIV256
222 }
223 #[doc = "Checks if the value of the field is `DIV512`"]
224 #[inline(always)]
225 pub fn is_div512(&self) -> bool {
226 *self == CNTPRESC_A::DIV512
227 }
228 #[doc = "Checks if the value of the field is `DIV1024`"]
229 #[inline(always)]
230 pub fn is_div1024(&self) -> bool {
231 *self == CNTPRESC_A::DIV1024
232 }
233 #[doc = "Checks if the value of the field is `DIV2048`"]
234 #[inline(always)]
235 pub fn is_div2048(&self) -> bool {
236 *self == CNTPRESC_A::DIV2048
237 }
238 #[doc = "Checks if the value of the field is `DIV4096`"]
239 #[inline(always)]
240 pub fn is_div4096(&self) -> bool {
241 *self == CNTPRESC_A::DIV4096
242 }
243 #[doc = "Checks if the value of the field is `DIV8192`"]
244 #[inline(always)]
245 pub fn is_div8192(&self) -> bool {
246 *self == CNTPRESC_A::DIV8192
247 }
248 #[doc = "Checks if the value of the field is `DIV16384`"]
249 #[inline(always)]
250 pub fn is_div16384(&self) -> bool {
251 *self == CNTPRESC_A::DIV16384
252 }
253 #[doc = "Checks if the value of the field is `DIV32768`"]
254 #[inline(always)]
255 pub fn is_div32768(&self) -> bool {
256 *self == CNTPRESC_A::DIV32768
257 }
258}
259#[doc = "Write proxy for field `CNTPRESC`"]
260pub struct CNTPRESC_W<'a> {
261 w: &'a mut W,
262}
263impl<'a> CNTPRESC_W<'a> {
264 #[doc = r"Writes `variant` to the field"]
265 #[inline(always)]
266 pub fn variant(self, variant: CNTPRESC_A) -> &'a mut W {
267 {
268 self.bits(variant.into())
269 }
270 }
271 #[doc = "CLKCNT = LFECLKRTCC/1"]
272 #[inline(always)]
273 pub fn div1(self) -> &'a mut W {
274 self.variant(CNTPRESC_A::DIV1)
275 }
276 #[doc = "CLKCNT = LFECLKRTCC/2"]
277 #[inline(always)]
278 pub fn div2(self) -> &'a mut W {
279 self.variant(CNTPRESC_A::DIV2)
280 }
281 #[doc = "CLKCNT = LFECLKRTCC/4"]
282 #[inline(always)]
283 pub fn div4(self) -> &'a mut W {
284 self.variant(CNTPRESC_A::DIV4)
285 }
286 #[doc = "CLKCNT = LFECLKRTCC/8"]
287 #[inline(always)]
288 pub fn div8(self) -> &'a mut W {
289 self.variant(CNTPRESC_A::DIV8)
290 }
291 #[doc = "CLKCNT = LFECLKRTCC/16"]
292 #[inline(always)]
293 pub fn div16(self) -> &'a mut W {
294 self.variant(CNTPRESC_A::DIV16)
295 }
296 #[doc = "CLKCNT = LFECLKRTCC/32"]
297 #[inline(always)]
298 pub fn div32(self) -> &'a mut W {
299 self.variant(CNTPRESC_A::DIV32)
300 }
301 #[doc = "CLKCNT = LFECLKRTCC/64"]
302 #[inline(always)]
303 pub fn div64(self) -> &'a mut W {
304 self.variant(CNTPRESC_A::DIV64)
305 }
306 #[doc = "CLKCNT = LFECLKRTCC/128"]
307 #[inline(always)]
308 pub fn div128(self) -> &'a mut W {
309 self.variant(CNTPRESC_A::DIV128)
310 }
311 #[doc = "CLKCNT = LFECLKRTCC/256"]
312 #[inline(always)]
313 pub fn div256(self) -> &'a mut W {
314 self.variant(CNTPRESC_A::DIV256)
315 }
316 #[doc = "CLKCNT = LFECLKRTCC/512"]
317 #[inline(always)]
318 pub fn div512(self) -> &'a mut W {
319 self.variant(CNTPRESC_A::DIV512)
320 }
321 #[doc = "CLKCNT = LFECLKRTCC/1024"]
322 #[inline(always)]
323 pub fn div1024(self) -> &'a mut W {
324 self.variant(CNTPRESC_A::DIV1024)
325 }
326 #[doc = "CLKCNT = LFECLKRTCC/2048"]
327 #[inline(always)]
328 pub fn div2048(self) -> &'a mut W {
329 self.variant(CNTPRESC_A::DIV2048)
330 }
331 #[doc = "CLKCNT = LFECLKRTCC/4096"]
332 #[inline(always)]
333 pub fn div4096(self) -> &'a mut W {
334 self.variant(CNTPRESC_A::DIV4096)
335 }
336 #[doc = "CLKCNT = LFECLKRTCC/8192"]
337 #[inline(always)]
338 pub fn div8192(self) -> &'a mut W {
339 self.variant(CNTPRESC_A::DIV8192)
340 }
341 #[doc = "CLKCNT = LFECLKRTCC/16384"]
342 #[inline(always)]
343 pub fn div16384(self) -> &'a mut W {
344 self.variant(CNTPRESC_A::DIV16384)
345 }
346 #[doc = "CLKCNT = LFECLKRTCC/32768"]
347 #[inline(always)]
348 pub fn div32768(self) -> &'a mut W {
349 self.variant(CNTPRESC_A::DIV32768)
350 }
351 #[doc = r"Writes raw bits to the field"]
352 #[inline(always)]
353 pub fn bits(self, value: u8) -> &'a mut W {
354 self.w.bits = (self.w.bits & !(0x0f << 8)) | (((value as u32) & 0x0f) << 8);
355 self.w
356 }
357}
358#[doc = "Reader of field `CNTTICK`"]
359pub type CNTTICK_R = crate::R<bool, bool>;
360#[doc = "Write proxy for field `CNTTICK`"]
361pub struct CNTTICK_W<'a> {
362 w: &'a mut W,
363}
364impl<'a> CNTTICK_W<'a> {
365 #[doc = r"Sets the field bit"]
366 #[inline(always)]
367 pub fn set_bit(self) -> &'a mut W {
368 self.bit(true)
369 }
370 #[doc = r"Clears the field bit"]
371 #[inline(always)]
372 pub fn clear_bit(self) -> &'a mut W {
373 self.bit(false)
374 }
375 #[doc = r"Writes raw bits to the field"]
376 #[inline(always)]
377 pub fn bit(self, value: bool) -> &'a mut W {
378 self.w.bits = (self.w.bits & !(0x01 << 12)) | (((value as u32) & 0x01) << 12);
379 self.w
380 }
381}
382#[doc = "Reader of field `OSCFDETEN`"]
383pub type OSCFDETEN_R = crate::R<bool, bool>;
384#[doc = "Write proxy for field `OSCFDETEN`"]
385pub struct OSCFDETEN_W<'a> {
386 w: &'a mut W,
387}
388impl<'a> OSCFDETEN_W<'a> {
389 #[doc = r"Sets the field bit"]
390 #[inline(always)]
391 pub fn set_bit(self) -> &'a mut W {
392 self.bit(true)
393 }
394 #[doc = r"Clears the field bit"]
395 #[inline(always)]
396 pub fn clear_bit(self) -> &'a mut W {
397 self.bit(false)
398 }
399 #[doc = r"Writes raw bits to the field"]
400 #[inline(always)]
401 pub fn bit(self, value: bool) -> &'a mut W {
402 self.w.bits = (self.w.bits & !(0x01 << 15)) | (((value as u32) & 0x01) << 15);
403 self.w
404 }
405}
406#[doc = "Reader of field `CNTMODE`"]
407pub type CNTMODE_R = crate::R<bool, bool>;
408#[doc = "Write proxy for field `CNTMODE`"]
409pub struct CNTMODE_W<'a> {
410 w: &'a mut W,
411}
412impl<'a> CNTMODE_W<'a> {
413 #[doc = r"Sets the field bit"]
414 #[inline(always)]
415 pub fn set_bit(self) -> &'a mut W {
416 self.bit(true)
417 }
418 #[doc = r"Clears the field bit"]
419 #[inline(always)]
420 pub fn clear_bit(self) -> &'a mut W {
421 self.bit(false)
422 }
423 #[doc = r"Writes raw bits to the field"]
424 #[inline(always)]
425 pub fn bit(self, value: bool) -> &'a mut W {
426 self.w.bits = (self.w.bits & !(0x01 << 16)) | (((value as u32) & 0x01) << 16);
427 self.w
428 }
429}
430#[doc = "Reader of field `LYEARCORRDIS`"]
431pub type LYEARCORRDIS_R = crate::R<bool, bool>;
432#[doc = "Write proxy for field `LYEARCORRDIS`"]
433pub struct LYEARCORRDIS_W<'a> {
434 w: &'a mut W,
435}
436impl<'a> LYEARCORRDIS_W<'a> {
437 #[doc = r"Sets the field bit"]
438 #[inline(always)]
439 pub fn set_bit(self) -> &'a mut W {
440 self.bit(true)
441 }
442 #[doc = r"Clears the field bit"]
443 #[inline(always)]
444 pub fn clear_bit(self) -> &'a mut W {
445 self.bit(false)
446 }
447 #[doc = r"Writes raw bits to the field"]
448 #[inline(always)]
449 pub fn bit(self, value: bool) -> &'a mut W {
450 self.w.bits = (self.w.bits & !(0x01 << 17)) | (((value as u32) & 0x01) << 17);
451 self.w
452 }
453}
454impl R {
455 #[doc = "Bit 0 - RTCC Enable"]
456 #[inline(always)]
457 pub fn enable(&self) -> ENABLE_R {
458 ENABLE_R::new((self.bits & 0x01) != 0)
459 }
460 #[doc = "Bit 2 - Debug Mode Run Enable"]
461 #[inline(always)]
462 pub fn debugrun(&self) -> DEBUGRUN_R {
463 DEBUGRUN_R::new(((self.bits >> 2) & 0x01) != 0)
464 }
465 #[doc = "Bit 4 - Pre-counter CCV0 Top Value Enable"]
466 #[inline(always)]
467 pub fn preccv0top(&self) -> PRECCV0TOP_R {
468 PRECCV0TOP_R::new(((self.bits >> 4) & 0x01) != 0)
469 }
470 #[doc = "Bit 5 - CCV1 Top Value Enable"]
471 #[inline(always)]
472 pub fn ccv1top(&self) -> CCV1TOP_R {
473 CCV1TOP_R::new(((self.bits >> 5) & 0x01) != 0)
474 }
475 #[doc = "Bits 8:11 - Counter Prescaler Value"]
476 #[inline(always)]
477 pub fn cntpresc(&self) -> CNTPRESC_R {
478 CNTPRESC_R::new(((self.bits >> 8) & 0x0f) as u8)
479 }
480 #[doc = "Bit 12 - Counter Prescaler Mode"]
481 #[inline(always)]
482 pub fn cnttick(&self) -> CNTTICK_R {
483 CNTTICK_R::new(((self.bits >> 12) & 0x01) != 0)
484 }
485 #[doc = "Bit 15 - Oscillator Failure Detection Enable"]
486 #[inline(always)]
487 pub fn oscfdeten(&self) -> OSCFDETEN_R {
488 OSCFDETEN_R::new(((self.bits >> 15) & 0x01) != 0)
489 }
490 #[doc = "Bit 16 - Main Counter Mode"]
491 #[inline(always)]
492 pub fn cntmode(&self) -> CNTMODE_R {
493 CNTMODE_R::new(((self.bits >> 16) & 0x01) != 0)
494 }
495 #[doc = "Bit 17 - Leap Year Correction Disabled"]
496 #[inline(always)]
497 pub fn lyearcorrdis(&self) -> LYEARCORRDIS_R {
498 LYEARCORRDIS_R::new(((self.bits >> 17) & 0x01) != 0)
499 }
500}
501impl W {
502 #[doc = "Bit 0 - RTCC Enable"]
503 #[inline(always)]
504 pub fn enable(&mut self) -> ENABLE_W {
505 ENABLE_W { w: self }
506 }
507 #[doc = "Bit 2 - Debug Mode Run Enable"]
508 #[inline(always)]
509 pub fn debugrun(&mut self) -> DEBUGRUN_W {
510 DEBUGRUN_W { w: self }
511 }
512 #[doc = "Bit 4 - Pre-counter CCV0 Top Value Enable"]
513 #[inline(always)]
514 pub fn preccv0top(&mut self) -> PRECCV0TOP_W {
515 PRECCV0TOP_W { w: self }
516 }
517 #[doc = "Bit 5 - CCV1 Top Value Enable"]
518 #[inline(always)]
519 pub fn ccv1top(&mut self) -> CCV1TOP_W {
520 CCV1TOP_W { w: self }
521 }
522 #[doc = "Bits 8:11 - Counter Prescaler Value"]
523 #[inline(always)]
524 pub fn cntpresc(&mut self) -> CNTPRESC_W {
525 CNTPRESC_W { w: self }
526 }
527 #[doc = "Bit 12 - Counter Prescaler Mode"]
528 #[inline(always)]
529 pub fn cnttick(&mut self) -> CNTTICK_W {
530 CNTTICK_W { w: self }
531 }
532 #[doc = "Bit 15 - Oscillator Failure Detection Enable"]
533 #[inline(always)]
534 pub fn oscfdeten(&mut self) -> OSCFDETEN_W {
535 OSCFDETEN_W { w: self }
536 }
537 #[doc = "Bit 16 - Main Counter Mode"]
538 #[inline(always)]
539 pub fn cntmode(&mut self) -> CNTMODE_W {
540 CNTMODE_W { w: self }
541 }
542 #[doc = "Bit 17 - Leap Year Correction Disabled"]
543 #[inline(always)]
544 pub fn lyearcorrdis(&mut self) -> LYEARCORRDIS_W {
545 LYEARCORRDIS_W { w: self }
546 }
547}