Skip to main content

efm32pg12_pac/letimer0/
ctrl.rs

1#[doc = "Reader of register CTRL"]
2pub type R = crate::R<u32, super::CTRL>;
3#[doc = "Writer for register CTRL"]
4pub type W = crate::W<u32, super::CTRL>;
5#[doc = "Register CTRL `reset()`'s with value 0"]
6impl crate::ResetValue for super::CTRL {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Repeat Mode\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15#[repr(u8)]
16pub enum REPMODE_A {
17    #[doc = "0: When started, the LETIMER counts down until it is stopped by software"]
18    FREE = 0,
19    #[doc = "1: The counter counts REP0 times. When REP0 reaches zero, the counter stops"]
20    ONESHOT = 1,
21    #[doc = "2: The counter counts REP0 times. If REP1 has been written, it is loaded into REP0 when REP0 reaches zero, otherwise the counter stops"]
22    BUFFERED = 2,
23    #[doc = "3: Both REP0 and REP1 are decremented when the LETIMER wraps around. The LETIMER counts until both REP0 and REP1 are zero"]
24    DOUBLE = 3,
25}
26impl From<REPMODE_A> for u8 {
27    #[inline(always)]
28    fn from(variant: REPMODE_A) -> Self {
29        variant as _
30    }
31}
32#[doc = "Reader of field `REPMODE`"]
33pub type REPMODE_R = crate::R<u8, REPMODE_A>;
34impl REPMODE_R {
35    #[doc = r"Get enumerated values variant"]
36    #[inline(always)]
37    pub fn variant(&self) -> REPMODE_A {
38        match self.bits {
39            0 => REPMODE_A::FREE,
40            1 => REPMODE_A::ONESHOT,
41            2 => REPMODE_A::BUFFERED,
42            3 => REPMODE_A::DOUBLE,
43            _ => unreachable!(),
44        }
45    }
46    #[doc = "Checks if the value of the field is `FREE`"]
47    #[inline(always)]
48    pub fn is_free(&self) -> bool {
49        *self == REPMODE_A::FREE
50    }
51    #[doc = "Checks if the value of the field is `ONESHOT`"]
52    #[inline(always)]
53    pub fn is_oneshot(&self) -> bool {
54        *self == REPMODE_A::ONESHOT
55    }
56    #[doc = "Checks if the value of the field is `BUFFERED`"]
57    #[inline(always)]
58    pub fn is_buffered(&self) -> bool {
59        *self == REPMODE_A::BUFFERED
60    }
61    #[doc = "Checks if the value of the field is `DOUBLE`"]
62    #[inline(always)]
63    pub fn is_double(&self) -> bool {
64        *self == REPMODE_A::DOUBLE
65    }
66}
67#[doc = "Write proxy for field `REPMODE`"]
68pub struct REPMODE_W<'a> {
69    w: &'a mut W,
70}
71impl<'a> REPMODE_W<'a> {
72    #[doc = r"Writes `variant` to the field"]
73    #[inline(always)]
74    pub fn variant(self, variant: REPMODE_A) -> &'a mut W {
75        {
76            self.bits(variant.into())
77        }
78    }
79    #[doc = "When started, the LETIMER counts down until it is stopped by software"]
80    #[inline(always)]
81    pub fn free(self) -> &'a mut W {
82        self.variant(REPMODE_A::FREE)
83    }
84    #[doc = "The counter counts REP0 times. When REP0 reaches zero, the counter stops"]
85    #[inline(always)]
86    pub fn oneshot(self) -> &'a mut W {
87        self.variant(REPMODE_A::ONESHOT)
88    }
89    #[doc = "The counter counts REP0 times. If REP1 has been written, it is loaded into REP0 when REP0 reaches zero, otherwise the counter stops"]
90    #[inline(always)]
91    pub fn buffered(self) -> &'a mut W {
92        self.variant(REPMODE_A::BUFFERED)
93    }
94    #[doc = "Both REP0 and REP1 are decremented when the LETIMER wraps around. The LETIMER counts until both REP0 and REP1 are zero"]
95    #[inline(always)]
96    pub fn double(self) -> &'a mut W {
97        self.variant(REPMODE_A::DOUBLE)
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 = "Underflow Output Action 0\n\nValue on reset: 0"]
107#[derive(Clone, Copy, Debug, PartialEq)]
108#[repr(u8)]
109pub enum UFOA0_A {
110    #[doc = "0: LETn_O0 is held at its idle value as defined by OPOL0"]
111    NONE = 0,
112    #[doc = "1: LETn_O0 is toggled on CNT underflow"]
113    TOGGLE = 1,
114    #[doc = "2: LETn_O0 is held active for one LFACLKLETIMER0 clock cycle on CNT underflow. The output then returns to its idle value as defined by OPOL0"]
115    PULSE = 2,
116    #[doc = "3: LETn_O0 is set idle on CNT underflow, and active on compare match with COMP1"]
117    PWM = 3,
118}
119impl From<UFOA0_A> for u8 {
120    #[inline(always)]
121    fn from(variant: UFOA0_A) -> Self {
122        variant as _
123    }
124}
125#[doc = "Reader of field `UFOA0`"]
126pub type UFOA0_R = crate::R<u8, UFOA0_A>;
127impl UFOA0_R {
128    #[doc = r"Get enumerated values variant"]
129    #[inline(always)]
130    pub fn variant(&self) -> UFOA0_A {
131        match self.bits {
132            0 => UFOA0_A::NONE,
133            1 => UFOA0_A::TOGGLE,
134            2 => UFOA0_A::PULSE,
135            3 => UFOA0_A::PWM,
136            _ => unreachable!(),
137        }
138    }
139    #[doc = "Checks if the value of the field is `NONE`"]
140    #[inline(always)]
141    pub fn is_none(&self) -> bool {
142        *self == UFOA0_A::NONE
143    }
144    #[doc = "Checks if the value of the field is `TOGGLE`"]
145    #[inline(always)]
146    pub fn is_toggle(&self) -> bool {
147        *self == UFOA0_A::TOGGLE
148    }
149    #[doc = "Checks if the value of the field is `PULSE`"]
150    #[inline(always)]
151    pub fn is_pulse(&self) -> bool {
152        *self == UFOA0_A::PULSE
153    }
154    #[doc = "Checks if the value of the field is `PWM`"]
155    #[inline(always)]
156    pub fn is_pwm(&self) -> bool {
157        *self == UFOA0_A::PWM
158    }
159}
160#[doc = "Write proxy for field `UFOA0`"]
161pub struct UFOA0_W<'a> {
162    w: &'a mut W,
163}
164impl<'a> UFOA0_W<'a> {
165    #[doc = r"Writes `variant` to the field"]
166    #[inline(always)]
167    pub fn variant(self, variant: UFOA0_A) -> &'a mut W {
168        {
169            self.bits(variant.into())
170        }
171    }
172    #[doc = "LETn_O0 is held at its idle value as defined by OPOL0"]
173    #[inline(always)]
174    pub fn none(self) -> &'a mut W {
175        self.variant(UFOA0_A::NONE)
176    }
177    #[doc = "LETn_O0 is toggled on CNT underflow"]
178    #[inline(always)]
179    pub fn toggle(self) -> &'a mut W {
180        self.variant(UFOA0_A::TOGGLE)
181    }
182    #[doc = "LETn_O0 is held active for one LFACLKLETIMER0 clock cycle on CNT underflow. The output then returns to its idle value as defined by OPOL0"]
183    #[inline(always)]
184    pub fn pulse(self) -> &'a mut W {
185        self.variant(UFOA0_A::PULSE)
186    }
187    #[doc = "LETn_O0 is set idle on CNT underflow, and active on compare match with COMP1"]
188    #[inline(always)]
189    pub fn pwm(self) -> &'a mut W {
190        self.variant(UFOA0_A::PWM)
191    }
192    #[doc = r"Writes raw bits to the field"]
193    #[inline(always)]
194    pub fn bits(self, value: u8) -> &'a mut W {
195        self.w.bits = (self.w.bits & !(0x03 << 2)) | (((value as u32) & 0x03) << 2);
196        self.w
197    }
198}
199#[doc = "Underflow Output Action 1\n\nValue on reset: 0"]
200#[derive(Clone, Copy, Debug, PartialEq)]
201#[repr(u8)]
202pub enum UFOA1_A {
203    #[doc = "0: LETn_O1 is held at its idle value as defined by OPOL1"]
204    NONE = 0,
205    #[doc = "1: LETn_O1 is toggled on CNT underflow"]
206    TOGGLE = 1,
207    #[doc = "2: LETn_O1 is held active for one LFACLKLETIMER0 clock cycle on CNT underflow. The output then returns to its idle value as defined by OPOL1"]
208    PULSE = 2,
209    #[doc = "3: LETn_O1 is set idle on CNT underflow, and active on compare match with COMP1"]
210    PWM = 3,
211}
212impl From<UFOA1_A> for u8 {
213    #[inline(always)]
214    fn from(variant: UFOA1_A) -> Self {
215        variant as _
216    }
217}
218#[doc = "Reader of field `UFOA1`"]
219pub type UFOA1_R = crate::R<u8, UFOA1_A>;
220impl UFOA1_R {
221    #[doc = r"Get enumerated values variant"]
222    #[inline(always)]
223    pub fn variant(&self) -> UFOA1_A {
224        match self.bits {
225            0 => UFOA1_A::NONE,
226            1 => UFOA1_A::TOGGLE,
227            2 => UFOA1_A::PULSE,
228            3 => UFOA1_A::PWM,
229            _ => unreachable!(),
230        }
231    }
232    #[doc = "Checks if the value of the field is `NONE`"]
233    #[inline(always)]
234    pub fn is_none(&self) -> bool {
235        *self == UFOA1_A::NONE
236    }
237    #[doc = "Checks if the value of the field is `TOGGLE`"]
238    #[inline(always)]
239    pub fn is_toggle(&self) -> bool {
240        *self == UFOA1_A::TOGGLE
241    }
242    #[doc = "Checks if the value of the field is `PULSE`"]
243    #[inline(always)]
244    pub fn is_pulse(&self) -> bool {
245        *self == UFOA1_A::PULSE
246    }
247    #[doc = "Checks if the value of the field is `PWM`"]
248    #[inline(always)]
249    pub fn is_pwm(&self) -> bool {
250        *self == UFOA1_A::PWM
251    }
252}
253#[doc = "Write proxy for field `UFOA1`"]
254pub struct UFOA1_W<'a> {
255    w: &'a mut W,
256}
257impl<'a> UFOA1_W<'a> {
258    #[doc = r"Writes `variant` to the field"]
259    #[inline(always)]
260    pub fn variant(self, variant: UFOA1_A) -> &'a mut W {
261        {
262            self.bits(variant.into())
263        }
264    }
265    #[doc = "LETn_O1 is held at its idle value as defined by OPOL1"]
266    #[inline(always)]
267    pub fn none(self) -> &'a mut W {
268        self.variant(UFOA1_A::NONE)
269    }
270    #[doc = "LETn_O1 is toggled on CNT underflow"]
271    #[inline(always)]
272    pub fn toggle(self) -> &'a mut W {
273        self.variant(UFOA1_A::TOGGLE)
274    }
275    #[doc = "LETn_O1 is held active for one LFACLKLETIMER0 clock cycle on CNT underflow. The output then returns to its idle value as defined by OPOL1"]
276    #[inline(always)]
277    pub fn pulse(self) -> &'a mut W {
278        self.variant(UFOA1_A::PULSE)
279    }
280    #[doc = "LETn_O1 is set idle on CNT underflow, and active on compare match with COMP1"]
281    #[inline(always)]
282    pub fn pwm(self) -> &'a mut W {
283        self.variant(UFOA1_A::PWM)
284    }
285    #[doc = r"Writes raw bits to the field"]
286    #[inline(always)]
287    pub fn bits(self, value: u8) -> &'a mut W {
288        self.w.bits = (self.w.bits & !(0x03 << 4)) | (((value as u32) & 0x03) << 4);
289        self.w
290    }
291}
292#[doc = "Reader of field `OPOL0`"]
293pub type OPOL0_R = crate::R<bool, bool>;
294#[doc = "Write proxy for field `OPOL0`"]
295pub struct OPOL0_W<'a> {
296    w: &'a mut W,
297}
298impl<'a> OPOL0_W<'a> {
299    #[doc = r"Sets the field bit"]
300    #[inline(always)]
301    pub fn set_bit(self) -> &'a mut W {
302        self.bit(true)
303    }
304    #[doc = r"Clears the field bit"]
305    #[inline(always)]
306    pub fn clear_bit(self) -> &'a mut W {
307        self.bit(false)
308    }
309    #[doc = r"Writes raw bits to the field"]
310    #[inline(always)]
311    pub fn bit(self, value: bool) -> &'a mut W {
312        self.w.bits = (self.w.bits & !(0x01 << 6)) | (((value as u32) & 0x01) << 6);
313        self.w
314    }
315}
316#[doc = "Reader of field `OPOL1`"]
317pub type OPOL1_R = crate::R<bool, bool>;
318#[doc = "Write proxy for field `OPOL1`"]
319pub struct OPOL1_W<'a> {
320    w: &'a mut W,
321}
322impl<'a> OPOL1_W<'a> {
323    #[doc = r"Sets the field bit"]
324    #[inline(always)]
325    pub fn set_bit(self) -> &'a mut W {
326        self.bit(true)
327    }
328    #[doc = r"Clears the field bit"]
329    #[inline(always)]
330    pub fn clear_bit(self) -> &'a mut W {
331        self.bit(false)
332    }
333    #[doc = r"Writes raw bits to the field"]
334    #[inline(always)]
335    pub fn bit(self, value: bool) -> &'a mut W {
336        self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u32) & 0x01) << 7);
337        self.w
338    }
339}
340#[doc = "Reader of field `BUFTOP`"]
341pub type BUFTOP_R = crate::R<bool, bool>;
342#[doc = "Write proxy for field `BUFTOP`"]
343pub struct BUFTOP_W<'a> {
344    w: &'a mut W,
345}
346impl<'a> BUFTOP_W<'a> {
347    #[doc = r"Sets the field bit"]
348    #[inline(always)]
349    pub fn set_bit(self) -> &'a mut W {
350        self.bit(true)
351    }
352    #[doc = r"Clears the field bit"]
353    #[inline(always)]
354    pub fn clear_bit(self) -> &'a mut W {
355        self.bit(false)
356    }
357    #[doc = r"Writes raw bits to the field"]
358    #[inline(always)]
359    pub fn bit(self, value: bool) -> &'a mut W {
360        self.w.bits = (self.w.bits & !(0x01 << 8)) | (((value as u32) & 0x01) << 8);
361        self.w
362    }
363}
364#[doc = "Reader of field `COMP0TOP`"]
365pub type COMP0TOP_R = crate::R<bool, bool>;
366#[doc = "Write proxy for field `COMP0TOP`"]
367pub struct COMP0TOP_W<'a> {
368    w: &'a mut W,
369}
370impl<'a> COMP0TOP_W<'a> {
371    #[doc = r"Sets the field bit"]
372    #[inline(always)]
373    pub fn set_bit(self) -> &'a mut W {
374        self.bit(true)
375    }
376    #[doc = r"Clears the field bit"]
377    #[inline(always)]
378    pub fn clear_bit(self) -> &'a mut W {
379        self.bit(false)
380    }
381    #[doc = r"Writes raw bits to the field"]
382    #[inline(always)]
383    pub fn bit(self, value: bool) -> &'a mut W {
384        self.w.bits = (self.w.bits & !(0x01 << 9)) | (((value as u32) & 0x01) << 9);
385        self.w
386    }
387}
388#[doc = "Reader of field `DEBUGRUN`"]
389pub type DEBUGRUN_R = crate::R<bool, bool>;
390#[doc = "Write proxy for field `DEBUGRUN`"]
391pub struct DEBUGRUN_W<'a> {
392    w: &'a mut W,
393}
394impl<'a> DEBUGRUN_W<'a> {
395    #[doc = r"Sets the field bit"]
396    #[inline(always)]
397    pub fn set_bit(self) -> &'a mut W {
398        self.bit(true)
399    }
400    #[doc = r"Clears the field bit"]
401    #[inline(always)]
402    pub fn clear_bit(self) -> &'a mut W {
403        self.bit(false)
404    }
405    #[doc = r"Writes raw bits to the field"]
406    #[inline(always)]
407    pub fn bit(self, value: bool) -> &'a mut W {
408        self.w.bits = (self.w.bits & !(0x01 << 12)) | (((value as u32) & 0x01) << 12);
409        self.w
410    }
411}
412impl R {
413    #[doc = "Bits 0:1 - Repeat Mode"]
414    #[inline(always)]
415    pub fn repmode(&self) -> REPMODE_R {
416        REPMODE_R::new((self.bits & 0x03) as u8)
417    }
418    #[doc = "Bits 2:3 - Underflow Output Action 0"]
419    #[inline(always)]
420    pub fn ufoa0(&self) -> UFOA0_R {
421        UFOA0_R::new(((self.bits >> 2) & 0x03) as u8)
422    }
423    #[doc = "Bits 4:5 - Underflow Output Action 1"]
424    #[inline(always)]
425    pub fn ufoa1(&self) -> UFOA1_R {
426        UFOA1_R::new(((self.bits >> 4) & 0x03) as u8)
427    }
428    #[doc = "Bit 6 - Output 0 Polarity"]
429    #[inline(always)]
430    pub fn opol0(&self) -> OPOL0_R {
431        OPOL0_R::new(((self.bits >> 6) & 0x01) != 0)
432    }
433    #[doc = "Bit 7 - Output 1 Polarity"]
434    #[inline(always)]
435    pub fn opol1(&self) -> OPOL1_R {
436        OPOL1_R::new(((self.bits >> 7) & 0x01) != 0)
437    }
438    #[doc = "Bit 8 - Buffered Top"]
439    #[inline(always)]
440    pub fn buftop(&self) -> BUFTOP_R {
441        BUFTOP_R::new(((self.bits >> 8) & 0x01) != 0)
442    }
443    #[doc = "Bit 9 - Compare Value 0 is Top Value"]
444    #[inline(always)]
445    pub fn comp0top(&self) -> COMP0TOP_R {
446        COMP0TOP_R::new(((self.bits >> 9) & 0x01) != 0)
447    }
448    #[doc = "Bit 12 - Debug Mode Run Enable"]
449    #[inline(always)]
450    pub fn debugrun(&self) -> DEBUGRUN_R {
451        DEBUGRUN_R::new(((self.bits >> 12) & 0x01) != 0)
452    }
453}
454impl W {
455    #[doc = "Bits 0:1 - Repeat Mode"]
456    #[inline(always)]
457    pub fn repmode(&mut self) -> REPMODE_W {
458        REPMODE_W { w: self }
459    }
460    #[doc = "Bits 2:3 - Underflow Output Action 0"]
461    #[inline(always)]
462    pub fn ufoa0(&mut self) -> UFOA0_W {
463        UFOA0_W { w: self }
464    }
465    #[doc = "Bits 4:5 - Underflow Output Action 1"]
466    #[inline(always)]
467    pub fn ufoa1(&mut self) -> UFOA1_W {
468        UFOA1_W { w: self }
469    }
470    #[doc = "Bit 6 - Output 0 Polarity"]
471    #[inline(always)]
472    pub fn opol0(&mut self) -> OPOL0_W {
473        OPOL0_W { w: self }
474    }
475    #[doc = "Bit 7 - Output 1 Polarity"]
476    #[inline(always)]
477    pub fn opol1(&mut self) -> OPOL1_W {
478        OPOL1_W { w: self }
479    }
480    #[doc = "Bit 8 - Buffered Top"]
481    #[inline(always)]
482    pub fn buftop(&mut self) -> BUFTOP_W {
483        BUFTOP_W { w: self }
484    }
485    #[doc = "Bit 9 - Compare Value 0 is Top Value"]
486    #[inline(always)]
487    pub fn comp0top(&mut self) -> COMP0TOP_W {
488        COMP0TOP_W { w: self }
489    }
490    #[doc = "Bit 12 - Debug Mode Run Enable"]
491    #[inline(always)]
492    pub fn debugrun(&mut self) -> DEBUGRUN_W {
493        DEBUGRUN_W { w: self }
494    }
495}