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