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