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