efm32pg12_pac/lesense/
timctrl.rs

1#[doc = "Reader of register TIMCTRL"]
2pub type R = crate::R<u32, super::TIMCTRL>;
3#[doc = "Writer for register TIMCTRL"]
4pub type W = crate::W<u32, super::TIMCTRL>;
5#[doc = "Register TIMCTRL `reset()`'s with value 0"]
6impl crate::ResetValue for super::TIMCTRL {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Prescaling Factor for High Frequency Timer\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15#[repr(u8)]
16pub enum AUXPRESC_A {
17    #[doc = "0: High frequency timer is clocked with AUXHFRCO/1"]
18    DIV1 = 0,
19    #[doc = "1: High frequency timer is clocked with AUXHFRCO/2"]
20    DIV2 = 1,
21    #[doc = "2: High frequency timer is clocked with AUXHFRCO/4"]
22    DIV4 = 2,
23    #[doc = "3: High frequency timer is clocked with AUXHFRCO/8"]
24    DIV8 = 3,
25}
26impl From<AUXPRESC_A> for u8 {
27    #[inline(always)]
28    fn from(variant: AUXPRESC_A) -> Self {
29        variant as _
30    }
31}
32#[doc = "Reader of field `AUXPRESC`"]
33pub type AUXPRESC_R = crate::R<u8, AUXPRESC_A>;
34impl AUXPRESC_R {
35    #[doc = r"Get enumerated values variant"]
36    #[inline(always)]
37    pub fn variant(&self) -> AUXPRESC_A {
38        match self.bits {
39            0 => AUXPRESC_A::DIV1,
40            1 => AUXPRESC_A::DIV2,
41            2 => AUXPRESC_A::DIV4,
42            3 => AUXPRESC_A::DIV8,
43            _ => unreachable!(),
44        }
45    }
46    #[doc = "Checks if the value of the field is `DIV1`"]
47    #[inline(always)]
48    pub fn is_div1(&self) -> bool {
49        *self == AUXPRESC_A::DIV1
50    }
51    #[doc = "Checks if the value of the field is `DIV2`"]
52    #[inline(always)]
53    pub fn is_div2(&self) -> bool {
54        *self == AUXPRESC_A::DIV2
55    }
56    #[doc = "Checks if the value of the field is `DIV4`"]
57    #[inline(always)]
58    pub fn is_div4(&self) -> bool {
59        *self == AUXPRESC_A::DIV4
60    }
61    #[doc = "Checks if the value of the field is `DIV8`"]
62    #[inline(always)]
63    pub fn is_div8(&self) -> bool {
64        *self == AUXPRESC_A::DIV8
65    }
66}
67#[doc = "Write proxy for field `AUXPRESC`"]
68pub struct AUXPRESC_W<'a> {
69    w: &'a mut W,
70}
71impl<'a> AUXPRESC_W<'a> {
72    #[doc = r"Writes `variant` to the field"]
73    #[inline(always)]
74    pub fn variant(self, variant: AUXPRESC_A) -> &'a mut W {
75        {
76            self.bits(variant.into())
77        }
78    }
79    #[doc = "High frequency timer is clocked with AUXHFRCO/1"]
80    #[inline(always)]
81    pub fn div1(self) -> &'a mut W {
82        self.variant(AUXPRESC_A::DIV1)
83    }
84    #[doc = "High frequency timer is clocked with AUXHFRCO/2"]
85    #[inline(always)]
86    pub fn div2(self) -> &'a mut W {
87        self.variant(AUXPRESC_A::DIV2)
88    }
89    #[doc = "High frequency timer is clocked with AUXHFRCO/4"]
90    #[inline(always)]
91    pub fn div4(self) -> &'a mut W {
92        self.variant(AUXPRESC_A::DIV4)
93    }
94    #[doc = "High frequency timer is clocked with AUXHFRCO/8"]
95    #[inline(always)]
96    pub fn div8(self) -> &'a mut W {
97        self.variant(AUXPRESC_A::DIV8)
98    }
99    #[doc = r"Writes raw bits to the field"]
100    #[inline(always)]
101    pub fn bits(self, value: u8) -> &'a mut W {
102        self.w.bits = (self.w.bits & !0x03) | ((value as u32) & 0x03);
103        self.w
104    }
105}
106#[doc = "Prescaling Factor for Low Frequency Timer\n\nValue on reset: 0"]
107#[derive(Clone, Copy, Debug, PartialEq)]
108#[repr(u8)]
109pub enum LFPRESC_A {
110    #[doc = "0: Low frequency timer is clocked with LFACLKLESENSE/1"]
111    DIV1 = 0,
112    #[doc = "1: Low frequency timer is clocked with LFACLKLESENSE/2"]
113    DIV2 = 1,
114    #[doc = "2: Low frequency timer is clocked with LFACLKLESENSE/4"]
115    DIV4 = 2,
116    #[doc = "3: Low frequency timer is clocked with LFACLKLESENSE/8"]
117    DIV8 = 3,
118    #[doc = "4: Low frequency timer is clocked with LFACLKLESENSE/16"]
119    DIV16 = 4,
120    #[doc = "5: Low frequency timer is clocked with LFACLKLESENSE/32"]
121    DIV32 = 5,
122    #[doc = "6: Low frequency timer is clocked with LFACLKLESENSE/64"]
123    DIV64 = 6,
124    #[doc = "7: Low frequency timer is clocked with LFACLKLESENSE/128"]
125    DIV128 = 7,
126}
127impl From<LFPRESC_A> for u8 {
128    #[inline(always)]
129    fn from(variant: LFPRESC_A) -> Self {
130        variant as _
131    }
132}
133#[doc = "Reader of field `LFPRESC`"]
134pub type LFPRESC_R = crate::R<u8, LFPRESC_A>;
135impl LFPRESC_R {
136    #[doc = r"Get enumerated values variant"]
137    #[inline(always)]
138    pub fn variant(&self) -> LFPRESC_A {
139        match self.bits {
140            0 => LFPRESC_A::DIV1,
141            1 => LFPRESC_A::DIV2,
142            2 => LFPRESC_A::DIV4,
143            3 => LFPRESC_A::DIV8,
144            4 => LFPRESC_A::DIV16,
145            5 => LFPRESC_A::DIV32,
146            6 => LFPRESC_A::DIV64,
147            7 => LFPRESC_A::DIV128,
148            _ => unreachable!(),
149        }
150    }
151    #[doc = "Checks if the value of the field is `DIV1`"]
152    #[inline(always)]
153    pub fn is_div1(&self) -> bool {
154        *self == LFPRESC_A::DIV1
155    }
156    #[doc = "Checks if the value of the field is `DIV2`"]
157    #[inline(always)]
158    pub fn is_div2(&self) -> bool {
159        *self == LFPRESC_A::DIV2
160    }
161    #[doc = "Checks if the value of the field is `DIV4`"]
162    #[inline(always)]
163    pub fn is_div4(&self) -> bool {
164        *self == LFPRESC_A::DIV4
165    }
166    #[doc = "Checks if the value of the field is `DIV8`"]
167    #[inline(always)]
168    pub fn is_div8(&self) -> bool {
169        *self == LFPRESC_A::DIV8
170    }
171    #[doc = "Checks if the value of the field is `DIV16`"]
172    #[inline(always)]
173    pub fn is_div16(&self) -> bool {
174        *self == LFPRESC_A::DIV16
175    }
176    #[doc = "Checks if the value of the field is `DIV32`"]
177    #[inline(always)]
178    pub fn is_div32(&self) -> bool {
179        *self == LFPRESC_A::DIV32
180    }
181    #[doc = "Checks if the value of the field is `DIV64`"]
182    #[inline(always)]
183    pub fn is_div64(&self) -> bool {
184        *self == LFPRESC_A::DIV64
185    }
186    #[doc = "Checks if the value of the field is `DIV128`"]
187    #[inline(always)]
188    pub fn is_div128(&self) -> bool {
189        *self == LFPRESC_A::DIV128
190    }
191}
192#[doc = "Write proxy for field `LFPRESC`"]
193pub struct LFPRESC_W<'a> {
194    w: &'a mut W,
195}
196impl<'a> LFPRESC_W<'a> {
197    #[doc = r"Writes `variant` to the field"]
198    #[inline(always)]
199    pub fn variant(self, variant: LFPRESC_A) -> &'a mut W {
200        {
201            self.bits(variant.into())
202        }
203    }
204    #[doc = "Low frequency timer is clocked with LFACLKLESENSE/1"]
205    #[inline(always)]
206    pub fn div1(self) -> &'a mut W {
207        self.variant(LFPRESC_A::DIV1)
208    }
209    #[doc = "Low frequency timer is clocked with LFACLKLESENSE/2"]
210    #[inline(always)]
211    pub fn div2(self) -> &'a mut W {
212        self.variant(LFPRESC_A::DIV2)
213    }
214    #[doc = "Low frequency timer is clocked with LFACLKLESENSE/4"]
215    #[inline(always)]
216    pub fn div4(self) -> &'a mut W {
217        self.variant(LFPRESC_A::DIV4)
218    }
219    #[doc = "Low frequency timer is clocked with LFACLKLESENSE/8"]
220    #[inline(always)]
221    pub fn div8(self) -> &'a mut W {
222        self.variant(LFPRESC_A::DIV8)
223    }
224    #[doc = "Low frequency timer is clocked with LFACLKLESENSE/16"]
225    #[inline(always)]
226    pub fn div16(self) -> &'a mut W {
227        self.variant(LFPRESC_A::DIV16)
228    }
229    #[doc = "Low frequency timer is clocked with LFACLKLESENSE/32"]
230    #[inline(always)]
231    pub fn div32(self) -> &'a mut W {
232        self.variant(LFPRESC_A::DIV32)
233    }
234    #[doc = "Low frequency timer is clocked with LFACLKLESENSE/64"]
235    #[inline(always)]
236    pub fn div64(self) -> &'a mut W {
237        self.variant(LFPRESC_A::DIV64)
238    }
239    #[doc = "Low frequency timer is clocked with LFACLKLESENSE/128"]
240    #[inline(always)]
241    pub fn div128(self) -> &'a mut W {
242        self.variant(LFPRESC_A::DIV128)
243    }
244    #[doc = r"Writes raw bits to the field"]
245    #[inline(always)]
246    pub fn bits(self, value: u8) -> &'a mut W {
247        self.w.bits = (self.w.bits & !(0x07 << 4)) | (((value as u32) & 0x07) << 4);
248        self.w
249    }
250}
251#[doc = "Period Counter Prescaling\n\nValue on reset: 0"]
252#[derive(Clone, Copy, Debug, PartialEq)]
253#[repr(u8)]
254pub enum PCPRESC_A {
255    #[doc = "0: The period counter clock frequency is LFACLKLESENSE/1"]
256    DIV1 = 0,
257    #[doc = "1: The period counter clock frequency is LFACLKLESENSE/2"]
258    DIV2 = 1,
259    #[doc = "2: The period counter clock frequency is LFACLKLESENSE/4"]
260    DIV4 = 2,
261    #[doc = "3: The period counter clock frequency is LFACLKLESENSE/8"]
262    DIV8 = 3,
263    #[doc = "4: The period counter clock frequency is LFACLKLESENSE/16"]
264    DIV16 = 4,
265    #[doc = "5: The period counter clock frequency is LFACLKLESENSE/32"]
266    DIV32 = 5,
267    #[doc = "6: The period counter clock frequency is LFACLKLESENSE/64"]
268    DIV64 = 6,
269    #[doc = "7: The period counter clock frequency is LFACLKLESENSE/128"]
270    DIV128 = 7,
271}
272impl From<PCPRESC_A> for u8 {
273    #[inline(always)]
274    fn from(variant: PCPRESC_A) -> Self {
275        variant as _
276    }
277}
278#[doc = "Reader of field `PCPRESC`"]
279pub type PCPRESC_R = crate::R<u8, PCPRESC_A>;
280impl PCPRESC_R {
281    #[doc = r"Get enumerated values variant"]
282    #[inline(always)]
283    pub fn variant(&self) -> PCPRESC_A {
284        match self.bits {
285            0 => PCPRESC_A::DIV1,
286            1 => PCPRESC_A::DIV2,
287            2 => PCPRESC_A::DIV4,
288            3 => PCPRESC_A::DIV8,
289            4 => PCPRESC_A::DIV16,
290            5 => PCPRESC_A::DIV32,
291            6 => PCPRESC_A::DIV64,
292            7 => PCPRESC_A::DIV128,
293            _ => unreachable!(),
294        }
295    }
296    #[doc = "Checks if the value of the field is `DIV1`"]
297    #[inline(always)]
298    pub fn is_div1(&self) -> bool {
299        *self == PCPRESC_A::DIV1
300    }
301    #[doc = "Checks if the value of the field is `DIV2`"]
302    #[inline(always)]
303    pub fn is_div2(&self) -> bool {
304        *self == PCPRESC_A::DIV2
305    }
306    #[doc = "Checks if the value of the field is `DIV4`"]
307    #[inline(always)]
308    pub fn is_div4(&self) -> bool {
309        *self == PCPRESC_A::DIV4
310    }
311    #[doc = "Checks if the value of the field is `DIV8`"]
312    #[inline(always)]
313    pub fn is_div8(&self) -> bool {
314        *self == PCPRESC_A::DIV8
315    }
316    #[doc = "Checks if the value of the field is `DIV16`"]
317    #[inline(always)]
318    pub fn is_div16(&self) -> bool {
319        *self == PCPRESC_A::DIV16
320    }
321    #[doc = "Checks if the value of the field is `DIV32`"]
322    #[inline(always)]
323    pub fn is_div32(&self) -> bool {
324        *self == PCPRESC_A::DIV32
325    }
326    #[doc = "Checks if the value of the field is `DIV64`"]
327    #[inline(always)]
328    pub fn is_div64(&self) -> bool {
329        *self == PCPRESC_A::DIV64
330    }
331    #[doc = "Checks if the value of the field is `DIV128`"]
332    #[inline(always)]
333    pub fn is_div128(&self) -> bool {
334        *self == PCPRESC_A::DIV128
335    }
336}
337#[doc = "Write proxy for field `PCPRESC`"]
338pub struct PCPRESC_W<'a> {
339    w: &'a mut W,
340}
341impl<'a> PCPRESC_W<'a> {
342    #[doc = r"Writes `variant` to the field"]
343    #[inline(always)]
344    pub fn variant(self, variant: PCPRESC_A) -> &'a mut W {
345        {
346            self.bits(variant.into())
347        }
348    }
349    #[doc = "The period counter clock frequency is LFACLKLESENSE/1"]
350    #[inline(always)]
351    pub fn div1(self) -> &'a mut W {
352        self.variant(PCPRESC_A::DIV1)
353    }
354    #[doc = "The period counter clock frequency is LFACLKLESENSE/2"]
355    #[inline(always)]
356    pub fn div2(self) -> &'a mut W {
357        self.variant(PCPRESC_A::DIV2)
358    }
359    #[doc = "The period counter clock frequency is LFACLKLESENSE/4"]
360    #[inline(always)]
361    pub fn div4(self) -> &'a mut W {
362        self.variant(PCPRESC_A::DIV4)
363    }
364    #[doc = "The period counter clock frequency is LFACLKLESENSE/8"]
365    #[inline(always)]
366    pub fn div8(self) -> &'a mut W {
367        self.variant(PCPRESC_A::DIV8)
368    }
369    #[doc = "The period counter clock frequency is LFACLKLESENSE/16"]
370    #[inline(always)]
371    pub fn div16(self) -> &'a mut W {
372        self.variant(PCPRESC_A::DIV16)
373    }
374    #[doc = "The period counter clock frequency is LFACLKLESENSE/32"]
375    #[inline(always)]
376    pub fn div32(self) -> &'a mut W {
377        self.variant(PCPRESC_A::DIV32)
378    }
379    #[doc = "The period counter clock frequency is LFACLKLESENSE/64"]
380    #[inline(always)]
381    pub fn div64(self) -> &'a mut W {
382        self.variant(PCPRESC_A::DIV64)
383    }
384    #[doc = "The period counter clock frequency is LFACLKLESENSE/128"]
385    #[inline(always)]
386    pub fn div128(self) -> &'a mut W {
387        self.variant(PCPRESC_A::DIV128)
388    }
389    #[doc = r"Writes raw bits to the field"]
390    #[inline(always)]
391    pub fn bits(self, value: u8) -> &'a mut W {
392        self.w.bits = (self.w.bits & !(0x07 << 8)) | (((value as u32) & 0x07) << 8);
393        self.w
394    }
395}
396#[doc = "Reader of field `PCTOP`"]
397pub type PCTOP_R = crate::R<u8, u8>;
398#[doc = "Write proxy for field `PCTOP`"]
399pub struct PCTOP_W<'a> {
400    w: &'a mut W,
401}
402impl<'a> PCTOP_W<'a> {
403    #[doc = r"Writes raw bits to the field"]
404    #[inline(always)]
405    pub unsafe fn bits(self, value: u8) -> &'a mut W {
406        self.w.bits = (self.w.bits & !(0xff << 12)) | (((value as u32) & 0xff) << 12);
407        self.w
408    }
409}
410#[doc = "Reader of field `STARTDLY`"]
411pub type STARTDLY_R = crate::R<u8, u8>;
412#[doc = "Write proxy for field `STARTDLY`"]
413pub struct STARTDLY_W<'a> {
414    w: &'a mut W,
415}
416impl<'a> STARTDLY_W<'a> {
417    #[doc = r"Writes raw bits to the field"]
418    #[inline(always)]
419    pub unsafe fn bits(self, value: u8) -> &'a mut W {
420        self.w.bits = (self.w.bits & !(0x03 << 22)) | (((value as u32) & 0x03) << 22);
421        self.w
422    }
423}
424#[doc = "Reader of field `AUXSTARTUP`"]
425pub type AUXSTARTUP_R = crate::R<bool, bool>;
426#[doc = "Write proxy for field `AUXSTARTUP`"]
427pub struct AUXSTARTUP_W<'a> {
428    w: &'a mut W,
429}
430impl<'a> AUXSTARTUP_W<'a> {
431    #[doc = r"Sets the field bit"]
432    #[inline(always)]
433    pub fn set_bit(self) -> &'a mut W {
434        self.bit(true)
435    }
436    #[doc = r"Clears the field bit"]
437    #[inline(always)]
438    pub fn clear_bit(self) -> &'a mut W {
439        self.bit(false)
440    }
441    #[doc = r"Writes raw bits to the field"]
442    #[inline(always)]
443    pub fn bit(self, value: bool) -> &'a mut W {
444        self.w.bits = (self.w.bits & !(0x01 << 28)) | (((value as u32) & 0x01) << 28);
445        self.w
446    }
447}
448impl R {
449    #[doc = "Bits 0:1 - Prescaling Factor for High Frequency Timer"]
450    #[inline(always)]
451    pub fn auxpresc(&self) -> AUXPRESC_R {
452        AUXPRESC_R::new((self.bits & 0x03) as u8)
453    }
454    #[doc = "Bits 4:6 - Prescaling Factor for Low Frequency Timer"]
455    #[inline(always)]
456    pub fn lfpresc(&self) -> LFPRESC_R {
457        LFPRESC_R::new(((self.bits >> 4) & 0x07) as u8)
458    }
459    #[doc = "Bits 8:10 - Period Counter Prescaling"]
460    #[inline(always)]
461    pub fn pcpresc(&self) -> PCPRESC_R {
462        PCPRESC_R::new(((self.bits >> 8) & 0x07) as u8)
463    }
464    #[doc = "Bits 12:19 - Period Counter Top Value"]
465    #[inline(always)]
466    pub fn pctop(&self) -> PCTOP_R {
467        PCTOP_R::new(((self.bits >> 12) & 0xff) as u8)
468    }
469    #[doc = "Bits 22:23 - Start Delay Configuration"]
470    #[inline(always)]
471    pub fn startdly(&self) -> STARTDLY_R {
472        STARTDLY_R::new(((self.bits >> 22) & 0x03) as u8)
473    }
474    #[doc = "Bit 28 - AUXHFRCO Startup Configuration"]
475    #[inline(always)]
476    pub fn auxstartup(&self) -> AUXSTARTUP_R {
477        AUXSTARTUP_R::new(((self.bits >> 28) & 0x01) != 0)
478    }
479}
480impl W {
481    #[doc = "Bits 0:1 - Prescaling Factor for High Frequency Timer"]
482    #[inline(always)]
483    pub fn auxpresc(&mut self) -> AUXPRESC_W {
484        AUXPRESC_W { w: self }
485    }
486    #[doc = "Bits 4:6 - Prescaling Factor for Low Frequency Timer"]
487    #[inline(always)]
488    pub fn lfpresc(&mut self) -> LFPRESC_W {
489        LFPRESC_W { w: self }
490    }
491    #[doc = "Bits 8:10 - Period Counter Prescaling"]
492    #[inline(always)]
493    pub fn pcpresc(&mut self) -> PCPRESC_W {
494        PCPRESC_W { w: self }
495    }
496    #[doc = "Bits 12:19 - Period Counter Top Value"]
497    #[inline(always)]
498    pub fn pctop(&mut self) -> PCTOP_W {
499        PCTOP_W { w: self }
500    }
501    #[doc = "Bits 22:23 - Start Delay Configuration"]
502    #[inline(always)]
503    pub fn startdly(&mut self) -> STARTDLY_W {
504        STARTDLY_W { w: self }
505    }
506    #[doc = "Bit 28 - AUXHFRCO Startup Configuration"]
507    #[inline(always)]
508    pub fn auxstartup(&mut self) -> AUXSTARTUP_W {
509        AUXSTARTUP_W { w: self }
510    }
511}