efm32wg230_pac/lesense/
timctrl.rs

1#[doc = "Register `TIMCTRL` reader"]
2pub struct R(crate::R<TIMCTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<TIMCTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<TIMCTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<TIMCTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `TIMCTRL` writer"]
17pub struct W(crate::W<TIMCTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<TIMCTRL_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<TIMCTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<TIMCTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Prescaling factor for high frequency timer\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum AUXPRESC_A {
41    #[doc = "0: High frequency timer is clocked with AUXHFRCO/1"]
42    DIV1 = 0,
43    #[doc = "1: High frequency timer is clocked with AUXHFRCO/2"]
44    DIV2 = 1,
45    #[doc = "2: High frequency timer is clocked with AUXHFRCO/4"]
46    DIV4 = 2,
47    #[doc = "3: High frequency timer is clocked with AUXHFRCO/8"]
48    DIV8 = 3,
49}
50impl From<AUXPRESC_A> for u8 {
51    #[inline(always)]
52    fn from(variant: AUXPRESC_A) -> Self {
53        variant as _
54    }
55}
56#[doc = "Field `AUXPRESC` reader - Prescaling factor for high frequency timer"]
57pub type AUXPRESC_R = crate::FieldReader<u8, AUXPRESC_A>;
58impl AUXPRESC_R {
59    #[doc = "Get enumerated values variant"]
60    #[inline(always)]
61    pub fn variant(&self) -> AUXPRESC_A {
62        match self.bits {
63            0 => AUXPRESC_A::DIV1,
64            1 => AUXPRESC_A::DIV2,
65            2 => AUXPRESC_A::DIV4,
66            3 => AUXPRESC_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 == AUXPRESC_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 == AUXPRESC_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 == AUXPRESC_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 == AUXPRESC_A::DIV8
89    }
90}
91#[doc = "Field `AUXPRESC` writer - Prescaling factor for high frequency timer"]
92pub type AUXPRESC_W<'a> = crate::FieldWriterSafe<'a, u32, TIMCTRL_SPEC, u8, AUXPRESC_A, 2, 0>;
93impl<'a> AUXPRESC_W<'a> {
94    #[doc = "High frequency timer is clocked with AUXHFRCO/1"]
95    #[inline(always)]
96    pub fn div1(self) -> &'a mut W {
97        self.variant(AUXPRESC_A::DIV1)
98    }
99    #[doc = "High frequency timer is clocked with AUXHFRCO/2"]
100    #[inline(always)]
101    pub fn div2(self) -> &'a mut W {
102        self.variant(AUXPRESC_A::DIV2)
103    }
104    #[doc = "High frequency timer is clocked with AUXHFRCO/4"]
105    #[inline(always)]
106    pub fn div4(self) -> &'a mut W {
107        self.variant(AUXPRESC_A::DIV4)
108    }
109    #[doc = "High frequency timer is clocked with AUXHFRCO/8"]
110    #[inline(always)]
111    pub fn div8(self) -> &'a mut W {
112        self.variant(AUXPRESC_A::DIV8)
113    }
114}
115#[doc = "Prescaling factor for low frequency timer\n\nValue on reset: 0"]
116#[derive(Clone, Copy, Debug, PartialEq)]
117#[repr(u8)]
118pub enum LFPRESC_A {
119    #[doc = "0: Low frequency timer is clocked with LFACLKLESENSE/1"]
120    DIV1 = 0,
121    #[doc = "1: Low frequency timer is clocked with LFACLKLESENSE/2"]
122    DIV2 = 1,
123    #[doc = "2: Low frequency timer is clocked with LFACLKLESENSE/4"]
124    DIV4 = 2,
125    #[doc = "3: Low frequency timer is clocked with LFACLKLESENSE/8"]
126    DIV8 = 3,
127    #[doc = "4: Low frequency timer is clocked with LFACLKLESENSE/16"]
128    DIV16 = 4,
129    #[doc = "5: Low frequency timer is clocked with LFACLKLESENSE/32"]
130    DIV32 = 5,
131    #[doc = "6: Low frequency timer is clocked with LFACLKLESENSE/64"]
132    DIV64 = 6,
133    #[doc = "7: Low frequency timer is clocked with LFACLKLESENSE/128"]
134    DIV128 = 7,
135}
136impl From<LFPRESC_A> for u8 {
137    #[inline(always)]
138    fn from(variant: LFPRESC_A) -> Self {
139        variant as _
140    }
141}
142#[doc = "Field `LFPRESC` reader - Prescaling factor for low frequency timer"]
143pub type LFPRESC_R = crate::FieldReader<u8, LFPRESC_A>;
144impl LFPRESC_R {
145    #[doc = "Get enumerated values variant"]
146    #[inline(always)]
147    pub fn variant(&self) -> LFPRESC_A {
148        match self.bits {
149            0 => LFPRESC_A::DIV1,
150            1 => LFPRESC_A::DIV2,
151            2 => LFPRESC_A::DIV4,
152            3 => LFPRESC_A::DIV8,
153            4 => LFPRESC_A::DIV16,
154            5 => LFPRESC_A::DIV32,
155            6 => LFPRESC_A::DIV64,
156            7 => LFPRESC_A::DIV128,
157            _ => unreachable!(),
158        }
159    }
160    #[doc = "Checks if the value of the field is `DIV1`"]
161    #[inline(always)]
162    pub fn is_div1(&self) -> bool {
163        *self == LFPRESC_A::DIV1
164    }
165    #[doc = "Checks if the value of the field is `DIV2`"]
166    #[inline(always)]
167    pub fn is_div2(&self) -> bool {
168        *self == LFPRESC_A::DIV2
169    }
170    #[doc = "Checks if the value of the field is `DIV4`"]
171    #[inline(always)]
172    pub fn is_div4(&self) -> bool {
173        *self == LFPRESC_A::DIV4
174    }
175    #[doc = "Checks if the value of the field is `DIV8`"]
176    #[inline(always)]
177    pub fn is_div8(&self) -> bool {
178        *self == LFPRESC_A::DIV8
179    }
180    #[doc = "Checks if the value of the field is `DIV16`"]
181    #[inline(always)]
182    pub fn is_div16(&self) -> bool {
183        *self == LFPRESC_A::DIV16
184    }
185    #[doc = "Checks if the value of the field is `DIV32`"]
186    #[inline(always)]
187    pub fn is_div32(&self) -> bool {
188        *self == LFPRESC_A::DIV32
189    }
190    #[doc = "Checks if the value of the field is `DIV64`"]
191    #[inline(always)]
192    pub fn is_div64(&self) -> bool {
193        *self == LFPRESC_A::DIV64
194    }
195    #[doc = "Checks if the value of the field is `DIV128`"]
196    #[inline(always)]
197    pub fn is_div128(&self) -> bool {
198        *self == LFPRESC_A::DIV128
199    }
200}
201#[doc = "Field `LFPRESC` writer - Prescaling factor for low frequency timer"]
202pub type LFPRESC_W<'a> = crate::FieldWriterSafe<'a, u32, TIMCTRL_SPEC, u8, LFPRESC_A, 3, 4>;
203impl<'a> LFPRESC_W<'a> {
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}
245#[doc = "Period counter prescaling\n\nValue on reset: 0"]
246#[derive(Clone, Copy, Debug, PartialEq)]
247#[repr(u8)]
248pub enum PCPRESC_A {
249    #[doc = "0: The period counter clock frequency is LFACLKLESENSE/1"]
250    DIV1 = 0,
251    #[doc = "1: The period counter clock frequency is LFACLKLESENSE/2"]
252    DIV2 = 1,
253    #[doc = "2: The period counter clock frequency is LFACLKLESENSE/4"]
254    DIV4 = 2,
255    #[doc = "3: The period counter clock frequency is LFACLKLESENSE/8"]
256    DIV8 = 3,
257    #[doc = "4: The period counter clock frequency is LFACLKLESENSE/16"]
258    DIV16 = 4,
259    #[doc = "5: The period counter clock frequency is LFACLKLESENSE/32"]
260    DIV32 = 5,
261    #[doc = "6: The period counter clock frequency is LFACLKLESENSE/64"]
262    DIV64 = 6,
263    #[doc = "7: The period counter clock frequency is LFACLKLESENSE/128"]
264    DIV128 = 7,
265}
266impl From<PCPRESC_A> for u8 {
267    #[inline(always)]
268    fn from(variant: PCPRESC_A) -> Self {
269        variant as _
270    }
271}
272#[doc = "Field `PCPRESC` reader - Period counter prescaling"]
273pub type PCPRESC_R = crate::FieldReader<u8, PCPRESC_A>;
274impl PCPRESC_R {
275    #[doc = "Get enumerated values variant"]
276    #[inline(always)]
277    pub fn variant(&self) -> PCPRESC_A {
278        match self.bits {
279            0 => PCPRESC_A::DIV1,
280            1 => PCPRESC_A::DIV2,
281            2 => PCPRESC_A::DIV4,
282            3 => PCPRESC_A::DIV8,
283            4 => PCPRESC_A::DIV16,
284            5 => PCPRESC_A::DIV32,
285            6 => PCPRESC_A::DIV64,
286            7 => PCPRESC_A::DIV128,
287            _ => unreachable!(),
288        }
289    }
290    #[doc = "Checks if the value of the field is `DIV1`"]
291    #[inline(always)]
292    pub fn is_div1(&self) -> bool {
293        *self == PCPRESC_A::DIV1
294    }
295    #[doc = "Checks if the value of the field is `DIV2`"]
296    #[inline(always)]
297    pub fn is_div2(&self) -> bool {
298        *self == PCPRESC_A::DIV2
299    }
300    #[doc = "Checks if the value of the field is `DIV4`"]
301    #[inline(always)]
302    pub fn is_div4(&self) -> bool {
303        *self == PCPRESC_A::DIV4
304    }
305    #[doc = "Checks if the value of the field is `DIV8`"]
306    #[inline(always)]
307    pub fn is_div8(&self) -> bool {
308        *self == PCPRESC_A::DIV8
309    }
310    #[doc = "Checks if the value of the field is `DIV16`"]
311    #[inline(always)]
312    pub fn is_div16(&self) -> bool {
313        *self == PCPRESC_A::DIV16
314    }
315    #[doc = "Checks if the value of the field is `DIV32`"]
316    #[inline(always)]
317    pub fn is_div32(&self) -> bool {
318        *self == PCPRESC_A::DIV32
319    }
320    #[doc = "Checks if the value of the field is `DIV64`"]
321    #[inline(always)]
322    pub fn is_div64(&self) -> bool {
323        *self == PCPRESC_A::DIV64
324    }
325    #[doc = "Checks if the value of the field is `DIV128`"]
326    #[inline(always)]
327    pub fn is_div128(&self) -> bool {
328        *self == PCPRESC_A::DIV128
329    }
330}
331#[doc = "Field `PCPRESC` writer - Period counter prescaling"]
332pub type PCPRESC_W<'a> = crate::FieldWriterSafe<'a, u32, TIMCTRL_SPEC, u8, PCPRESC_A, 3, 8>;
333impl<'a> PCPRESC_W<'a> {
334    #[doc = "The period counter clock frequency is LFACLKLESENSE/1"]
335    #[inline(always)]
336    pub fn div1(self) -> &'a mut W {
337        self.variant(PCPRESC_A::DIV1)
338    }
339    #[doc = "The period counter clock frequency is LFACLKLESENSE/2"]
340    #[inline(always)]
341    pub fn div2(self) -> &'a mut W {
342        self.variant(PCPRESC_A::DIV2)
343    }
344    #[doc = "The period counter clock frequency is LFACLKLESENSE/4"]
345    #[inline(always)]
346    pub fn div4(self) -> &'a mut W {
347        self.variant(PCPRESC_A::DIV4)
348    }
349    #[doc = "The period counter clock frequency is LFACLKLESENSE/8"]
350    #[inline(always)]
351    pub fn div8(self) -> &'a mut W {
352        self.variant(PCPRESC_A::DIV8)
353    }
354    #[doc = "The period counter clock frequency is LFACLKLESENSE/16"]
355    #[inline(always)]
356    pub fn div16(self) -> &'a mut W {
357        self.variant(PCPRESC_A::DIV16)
358    }
359    #[doc = "The period counter clock frequency is LFACLKLESENSE/32"]
360    #[inline(always)]
361    pub fn div32(self) -> &'a mut W {
362        self.variant(PCPRESC_A::DIV32)
363    }
364    #[doc = "The period counter clock frequency is LFACLKLESENSE/64"]
365    #[inline(always)]
366    pub fn div64(self) -> &'a mut W {
367        self.variant(PCPRESC_A::DIV64)
368    }
369    #[doc = "The period counter clock frequency is LFACLKLESENSE/128"]
370    #[inline(always)]
371    pub fn div128(self) -> &'a mut W {
372        self.variant(PCPRESC_A::DIV128)
373    }
374}
375#[doc = "Field `PCTOP` reader - Period counter top value"]
376pub type PCTOP_R = crate::FieldReader<u8, u8>;
377#[doc = "Field `PCTOP` writer - Period counter top value"]
378pub type PCTOP_W<'a> = crate::FieldWriter<'a, u32, TIMCTRL_SPEC, u8, u8, 8, 12>;
379#[doc = "Field `STARTDLY` reader - Start delay configuration"]
380pub type STARTDLY_R = crate::FieldReader<u8, u8>;
381#[doc = "Field `STARTDLY` writer - Start delay configuration"]
382pub type STARTDLY_W<'a> = crate::FieldWriter<'a, u32, TIMCTRL_SPEC, u8, u8, 2, 22>;
383impl R {
384    #[doc = "Bits 0:1 - Prescaling factor for high frequency timer"]
385    #[inline(always)]
386    pub fn auxpresc(&self) -> AUXPRESC_R {
387        AUXPRESC_R::new((self.bits & 3) as u8)
388    }
389    #[doc = "Bits 4:6 - Prescaling factor for low frequency timer"]
390    #[inline(always)]
391    pub fn lfpresc(&self) -> LFPRESC_R {
392        LFPRESC_R::new(((self.bits >> 4) & 7) as u8)
393    }
394    #[doc = "Bits 8:10 - Period counter prescaling"]
395    #[inline(always)]
396    pub fn pcpresc(&self) -> PCPRESC_R {
397        PCPRESC_R::new(((self.bits >> 8) & 7) as u8)
398    }
399    #[doc = "Bits 12:19 - Period counter top value"]
400    #[inline(always)]
401    pub fn pctop(&self) -> PCTOP_R {
402        PCTOP_R::new(((self.bits >> 12) & 0xff) as u8)
403    }
404    #[doc = "Bits 22:23 - Start delay configuration"]
405    #[inline(always)]
406    pub fn startdly(&self) -> STARTDLY_R {
407        STARTDLY_R::new(((self.bits >> 22) & 3) as u8)
408    }
409}
410impl W {
411    #[doc = "Bits 0:1 - Prescaling factor for high frequency timer"]
412    #[inline(always)]
413    pub fn auxpresc(&mut self) -> AUXPRESC_W {
414        AUXPRESC_W::new(self)
415    }
416    #[doc = "Bits 4:6 - Prescaling factor for low frequency timer"]
417    #[inline(always)]
418    pub fn lfpresc(&mut self) -> LFPRESC_W {
419        LFPRESC_W::new(self)
420    }
421    #[doc = "Bits 8:10 - Period counter prescaling"]
422    #[inline(always)]
423    pub fn pcpresc(&mut self) -> PCPRESC_W {
424        PCPRESC_W::new(self)
425    }
426    #[doc = "Bits 12:19 - Period counter top value"]
427    #[inline(always)]
428    pub fn pctop(&mut self) -> PCTOP_W {
429        PCTOP_W::new(self)
430    }
431    #[doc = "Bits 22:23 - Start delay configuration"]
432    #[inline(always)]
433    pub fn startdly(&mut self) -> STARTDLY_W {
434        STARTDLY_W::new(self)
435    }
436    #[doc = "Writes raw bits to the register."]
437    #[inline(always)]
438    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
439        self.0.bits(bits);
440        self
441    }
442}
443#[doc = "Timing Control Register\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 [timctrl](index.html) module"]
444pub struct TIMCTRL_SPEC;
445impl crate::RegisterSpec for TIMCTRL_SPEC {
446    type Ux = u32;
447}
448#[doc = "`read()` method returns [timctrl::R](R) reader structure"]
449impl crate::Readable for TIMCTRL_SPEC {
450    type Reader = R;
451}
452#[doc = "`write(|w| ..)` method takes [timctrl::W](W) writer structure"]
453impl crate::Writable for TIMCTRL_SPEC {
454    type Writer = W;
455}
456#[doc = "`reset()` method sets TIMCTRL to value 0"]
457impl crate::Resettable for TIMCTRL_SPEC {
458    #[inline(always)]
459    fn reset_value() -> Self::Ux {
460        0
461    }
462}