efm32pg12b500_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 = "Low Energy Timer 0 Prescaler\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum LETIMER0_A {
41    #[doc = "0: LFACLKLETIMER0 = LFACLK"]
42    DIV1 = 0,
43    #[doc = "1: LFACLKLETIMER0 = LFACLK/2"]
44    DIV2 = 1,
45    #[doc = "2: LFACLKLETIMER0 = LFACLK/4"]
46    DIV4 = 2,
47    #[doc = "3: LFACLKLETIMER0 = LFACLK/8"]
48    DIV8 = 3,
49    #[doc = "4: LFACLKLETIMER0 = LFACLK/16"]
50    DIV16 = 4,
51    #[doc = "5: LFACLKLETIMER0 = LFACLK/32"]
52    DIV32 = 5,
53    #[doc = "6: LFACLKLETIMER0 = LFACLK/64"]
54    DIV64 = 6,
55    #[doc = "7: LFACLKLETIMER0 = LFACLK/128"]
56    DIV128 = 7,
57    #[doc = "8: LFACLKLETIMER0 = LFACLK/256"]
58    DIV256 = 8,
59    #[doc = "9: LFACLKLETIMER0 = LFACLK/512"]
60    DIV512 = 9,
61    #[doc = "10: LFACLKLETIMER0 = LFACLK/1024"]
62    DIV1024 = 10,
63    #[doc = "11: LFACLKLETIMER0 = LFACLK/2048"]
64    DIV2048 = 11,
65    #[doc = "12: LFACLKLETIMER0 = LFACLK/4096"]
66    DIV4096 = 12,
67    #[doc = "13: LFACLKLETIMER0 = LFACLK/8192"]
68    DIV8192 = 13,
69    #[doc = "14: LFACLKLETIMER0 = LFACLK/16384"]
70    DIV16384 = 14,
71    #[doc = "15: LFACLKLETIMER0 = LFACLK/32768"]
72    DIV32768 = 15,
73}
74impl From<LETIMER0_A> for u8 {
75    #[inline(always)]
76    fn from(variant: LETIMER0_A) -> Self {
77        variant as _
78    }
79}
80#[doc = "Field `LETIMER0` reader - Low Energy Timer 0 Prescaler"]
81pub type LETIMER0_R = crate::FieldReader<u8, LETIMER0_A>;
82impl LETIMER0_R {
83    #[doc = "Get enumerated values variant"]
84    #[inline(always)]
85    pub fn variant(&self) -> LETIMER0_A {
86        match self.bits {
87            0 => LETIMER0_A::DIV1,
88            1 => LETIMER0_A::DIV2,
89            2 => LETIMER0_A::DIV4,
90            3 => LETIMER0_A::DIV8,
91            4 => LETIMER0_A::DIV16,
92            5 => LETIMER0_A::DIV32,
93            6 => LETIMER0_A::DIV64,
94            7 => LETIMER0_A::DIV128,
95            8 => LETIMER0_A::DIV256,
96            9 => LETIMER0_A::DIV512,
97            10 => LETIMER0_A::DIV1024,
98            11 => LETIMER0_A::DIV2048,
99            12 => LETIMER0_A::DIV4096,
100            13 => LETIMER0_A::DIV8192,
101            14 => LETIMER0_A::DIV16384,
102            15 => LETIMER0_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 == LETIMER0_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 == LETIMER0_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 == LETIMER0_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 == LETIMER0_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 == LETIMER0_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 == LETIMER0_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 == LETIMER0_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 == LETIMER0_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 == LETIMER0_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 == LETIMER0_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 == LETIMER0_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 == LETIMER0_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 == LETIMER0_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 == LETIMER0_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 == LETIMER0_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 == LETIMER0_A::DIV32768
185    }
186}
187#[doc = "Field `LETIMER0` writer - Low Energy Timer 0 Prescaler"]
188pub type LETIMER0_W<'a> = crate::FieldWriterSafe<'a, u32, LFAPRESC0_SPEC, u8, LETIMER0_A, 4, 0>;
189impl<'a> LETIMER0_W<'a> {
190    #[doc = "LFACLKLETIMER0 = LFACLK"]
191    #[inline(always)]
192    pub fn div1(self) -> &'a mut W {
193        self.variant(LETIMER0_A::DIV1)
194    }
195    #[doc = "LFACLKLETIMER0 = LFACLK/2"]
196    #[inline(always)]
197    pub fn div2(self) -> &'a mut W {
198        self.variant(LETIMER0_A::DIV2)
199    }
200    #[doc = "LFACLKLETIMER0 = LFACLK/4"]
201    #[inline(always)]
202    pub fn div4(self) -> &'a mut W {
203        self.variant(LETIMER0_A::DIV4)
204    }
205    #[doc = "LFACLKLETIMER0 = LFACLK/8"]
206    #[inline(always)]
207    pub fn div8(self) -> &'a mut W {
208        self.variant(LETIMER0_A::DIV8)
209    }
210    #[doc = "LFACLKLETIMER0 = LFACLK/16"]
211    #[inline(always)]
212    pub fn div16(self) -> &'a mut W {
213        self.variant(LETIMER0_A::DIV16)
214    }
215    #[doc = "LFACLKLETIMER0 = LFACLK/32"]
216    #[inline(always)]
217    pub fn div32(self) -> &'a mut W {
218        self.variant(LETIMER0_A::DIV32)
219    }
220    #[doc = "LFACLKLETIMER0 = LFACLK/64"]
221    #[inline(always)]
222    pub fn div64(self) -> &'a mut W {
223        self.variant(LETIMER0_A::DIV64)
224    }
225    #[doc = "LFACLKLETIMER0 = LFACLK/128"]
226    #[inline(always)]
227    pub fn div128(self) -> &'a mut W {
228        self.variant(LETIMER0_A::DIV128)
229    }
230    #[doc = "LFACLKLETIMER0 = LFACLK/256"]
231    #[inline(always)]
232    pub fn div256(self) -> &'a mut W {
233        self.variant(LETIMER0_A::DIV256)
234    }
235    #[doc = "LFACLKLETIMER0 = LFACLK/512"]
236    #[inline(always)]
237    pub fn div512(self) -> &'a mut W {
238        self.variant(LETIMER0_A::DIV512)
239    }
240    #[doc = "LFACLKLETIMER0 = LFACLK/1024"]
241    #[inline(always)]
242    pub fn div1024(self) -> &'a mut W {
243        self.variant(LETIMER0_A::DIV1024)
244    }
245    #[doc = "LFACLKLETIMER0 = LFACLK/2048"]
246    #[inline(always)]
247    pub fn div2048(self) -> &'a mut W {
248        self.variant(LETIMER0_A::DIV2048)
249    }
250    #[doc = "LFACLKLETIMER0 = LFACLK/4096"]
251    #[inline(always)]
252    pub fn div4096(self) -> &'a mut W {
253        self.variant(LETIMER0_A::DIV4096)
254    }
255    #[doc = "LFACLKLETIMER0 = LFACLK/8192"]
256    #[inline(always)]
257    pub fn div8192(self) -> &'a mut W {
258        self.variant(LETIMER0_A::DIV8192)
259    }
260    #[doc = "LFACLKLETIMER0 = LFACLK/16384"]
261    #[inline(always)]
262    pub fn div16384(self) -> &'a mut W {
263        self.variant(LETIMER0_A::DIV16384)
264    }
265    #[doc = "LFACLKLETIMER0 = LFACLK/32768"]
266    #[inline(always)]
267    pub fn div32768(self) -> &'a mut W {
268        self.variant(LETIMER0_A::DIV32768)
269    }
270}
271#[doc = "Low Energy Sensor Interface Prescaler\n\nValue on reset: 0"]
272#[derive(Clone, Copy, Debug, PartialEq)]
273#[repr(u8)]
274pub enum LESENSE_A {
275    #[doc = "0: LFACLKLESENSE = LFACLK"]
276    DIV1 = 0,
277    #[doc = "1: LFACLKLESENSE = LFACLK/2"]
278    DIV2 = 1,
279    #[doc = "2: LFACLKLESENSE = LFACLK/4"]
280    DIV4 = 2,
281    #[doc = "3: LFACLKLESENSE = LFACLK/8"]
282    DIV8 = 3,
283}
284impl From<LESENSE_A> for u8 {
285    #[inline(always)]
286    fn from(variant: LESENSE_A) -> Self {
287        variant as _
288    }
289}
290#[doc = "Field `LESENSE` reader - Low Energy Sensor Interface Prescaler"]
291pub type LESENSE_R = crate::FieldReader<u8, LESENSE_A>;
292impl LESENSE_R {
293    #[doc = "Get enumerated values variant"]
294    #[inline(always)]
295    pub fn variant(&self) -> LESENSE_A {
296        match self.bits {
297            0 => LESENSE_A::DIV1,
298            1 => LESENSE_A::DIV2,
299            2 => LESENSE_A::DIV4,
300            3 => LESENSE_A::DIV8,
301            _ => unreachable!(),
302        }
303    }
304    #[doc = "Checks if the value of the field is `DIV1`"]
305    #[inline(always)]
306    pub fn is_div1(&self) -> bool {
307        *self == LESENSE_A::DIV1
308    }
309    #[doc = "Checks if the value of the field is `DIV2`"]
310    #[inline(always)]
311    pub fn is_div2(&self) -> bool {
312        *self == LESENSE_A::DIV2
313    }
314    #[doc = "Checks if the value of the field is `DIV4`"]
315    #[inline(always)]
316    pub fn is_div4(&self) -> bool {
317        *self == LESENSE_A::DIV4
318    }
319    #[doc = "Checks if the value of the field is `DIV8`"]
320    #[inline(always)]
321    pub fn is_div8(&self) -> bool {
322        *self == LESENSE_A::DIV8
323    }
324}
325#[doc = "Field `LESENSE` writer - Low Energy Sensor Interface Prescaler"]
326pub type LESENSE_W<'a> = crate::FieldWriterSafe<'a, u32, LFAPRESC0_SPEC, u8, LESENSE_A, 2, 4>;
327impl<'a> LESENSE_W<'a> {
328    #[doc = "LFACLKLESENSE = LFACLK"]
329    #[inline(always)]
330    pub fn div1(self) -> &'a mut W {
331        self.variant(LESENSE_A::DIV1)
332    }
333    #[doc = "LFACLKLESENSE = LFACLK/2"]
334    #[inline(always)]
335    pub fn div2(self) -> &'a mut W {
336        self.variant(LESENSE_A::DIV2)
337    }
338    #[doc = "LFACLKLESENSE = LFACLK/4"]
339    #[inline(always)]
340    pub fn div4(self) -> &'a mut W {
341        self.variant(LESENSE_A::DIV4)
342    }
343    #[doc = "LFACLKLESENSE = LFACLK/8"]
344    #[inline(always)]
345    pub fn div8(self) -> &'a mut W {
346        self.variant(LESENSE_A::DIV8)
347    }
348}
349impl R {
350    #[doc = "Bits 0:3 - Low Energy Timer 0 Prescaler"]
351    #[inline(always)]
352    pub fn letimer0(&self) -> LETIMER0_R {
353        LETIMER0_R::new((self.bits & 0x0f) as u8)
354    }
355    #[doc = "Bits 4:5 - Low Energy Sensor Interface Prescaler"]
356    #[inline(always)]
357    pub fn lesense(&self) -> LESENSE_R {
358        LESENSE_R::new(((self.bits >> 4) & 3) as u8)
359    }
360}
361impl W {
362    #[doc = "Bits 0:3 - Low Energy Timer 0 Prescaler"]
363    #[inline(always)]
364    pub fn letimer0(&mut self) -> LETIMER0_W {
365        LETIMER0_W::new(self)
366    }
367    #[doc = "Bits 4:5 - Low Energy Sensor Interface Prescaler"]
368    #[inline(always)]
369    pub fn lesense(&mut self) -> LESENSE_W {
370        LESENSE_W::new(self)
371    }
372    #[doc = "Writes raw bits to the register."]
373    #[inline(always)]
374    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
375        self.0.bits(bits);
376        self
377    }
378}
379#[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"]
380pub struct LFAPRESC0_SPEC;
381impl crate::RegisterSpec for LFAPRESC0_SPEC {
382    type Ux = u32;
383}
384#[doc = "`read()` method returns [lfapresc0::R](R) reader structure"]
385impl crate::Readable for LFAPRESC0_SPEC {
386    type Reader = R;
387}
388#[doc = "`write(|w| ..)` method takes [lfapresc0::W](W) writer structure"]
389impl crate::Writable for LFAPRESC0_SPEC {
390    type Writer = W;
391}
392#[doc = "`reset()` method sets LFAPRESC0 to value 0"]
393impl crate::Resettable for LFAPRESC0_SPEC {
394    #[inline(always)]
395    fn reset_value() -> Self::Ux {
396        0
397    }
398}