efm32g230_pac/cmu/
lfapresc0.rs

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