efm32g230_pac/letimer0/
ctrl.rs

1#[doc = "Register `CTRL` reader"]
2pub struct R(crate::R<CTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CTRL` writer"]
17pub struct W(crate::W<CTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CTRL_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<CTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Repeat Mode\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum REPMODE_A {
41    #[doc = "0: When started, the LETIMER counts down until it is stopped by software."]
42    FREE = 0,
43    #[doc = "1: The counter counts REP0 times. When REP0 reaches zero, the counter stops."]
44    ONESHOT = 1,
45    #[doc = "2: The counter counts REP0 times. If REP1 has been written, it is loaded into REP0 when REP0 reaches zero. Else the counter stops"]
46    BUFFERED = 2,
47    #[doc = "3: Both REP0 and REP1 are decremented when the LETIMER wraps around. The LETIMER counts until both REP0 and REP1 are zero"]
48    DOUBLE = 3,
49}
50impl From<REPMODE_A> for u8 {
51    #[inline(always)]
52    fn from(variant: REPMODE_A) -> Self {
53        variant as _
54    }
55}
56#[doc = "Field `REPMODE` reader - Repeat Mode"]
57pub type REPMODE_R = crate::FieldReader<u8, REPMODE_A>;
58impl REPMODE_R {
59    #[doc = "Get enumerated values variant"]
60    #[inline(always)]
61    pub fn variant(&self) -> REPMODE_A {
62        match self.bits {
63            0 => REPMODE_A::FREE,
64            1 => REPMODE_A::ONESHOT,
65            2 => REPMODE_A::BUFFERED,
66            3 => REPMODE_A::DOUBLE,
67            _ => unreachable!(),
68        }
69    }
70    #[doc = "Checks if the value of the field is `FREE`"]
71    #[inline(always)]
72    pub fn is_free(&self) -> bool {
73        *self == REPMODE_A::FREE
74    }
75    #[doc = "Checks if the value of the field is `ONESHOT`"]
76    #[inline(always)]
77    pub fn is_oneshot(&self) -> bool {
78        *self == REPMODE_A::ONESHOT
79    }
80    #[doc = "Checks if the value of the field is `BUFFERED`"]
81    #[inline(always)]
82    pub fn is_buffered(&self) -> bool {
83        *self == REPMODE_A::BUFFERED
84    }
85    #[doc = "Checks if the value of the field is `DOUBLE`"]
86    #[inline(always)]
87    pub fn is_double(&self) -> bool {
88        *self == REPMODE_A::DOUBLE
89    }
90}
91#[doc = "Field `REPMODE` writer - Repeat Mode"]
92pub type REPMODE_W<'a> = crate::FieldWriterSafe<'a, u32, CTRL_SPEC, u8, REPMODE_A, 2, 0>;
93impl<'a> REPMODE_W<'a> {
94    #[doc = "When started, the LETIMER counts down until it is stopped by software."]
95    #[inline(always)]
96    pub fn free(self) -> &'a mut W {
97        self.variant(REPMODE_A::FREE)
98    }
99    #[doc = "The counter counts REP0 times. When REP0 reaches zero, the counter stops."]
100    #[inline(always)]
101    pub fn oneshot(self) -> &'a mut W {
102        self.variant(REPMODE_A::ONESHOT)
103    }
104    #[doc = "The counter counts REP0 times. If REP1 has been written, it is loaded into REP0 when REP0 reaches zero. Else the counter stops"]
105    #[inline(always)]
106    pub fn buffered(self) -> &'a mut W {
107        self.variant(REPMODE_A::BUFFERED)
108    }
109    #[doc = "Both REP0 and REP1 are decremented when the LETIMER wraps around. The LETIMER counts until both REP0 and REP1 are zero"]
110    #[inline(always)]
111    pub fn double(self) -> &'a mut W {
112        self.variant(REPMODE_A::DOUBLE)
113    }
114}
115#[doc = "Underflow Output Action 0\n\nValue on reset: 0"]
116#[derive(Clone, Copy, Debug, PartialEq)]
117#[repr(u8)]
118pub enum UFOA0_A {
119    #[doc = "0: LETn_O0 is held at its idle value as defined by OPOL0."]
120    NONE = 0,
121    #[doc = "1: LETn_O0 is toggled on CNT underflow."]
122    TOGGLE = 1,
123    #[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."]
124    PULSE = 2,
125    #[doc = "3: LETn_O0 is set idle on CNT underflow, and active on compare match with COMP1"]
126    PWM = 3,
127}
128impl From<UFOA0_A> for u8 {
129    #[inline(always)]
130    fn from(variant: UFOA0_A) -> Self {
131        variant as _
132    }
133}
134#[doc = "Field `UFOA0` reader - Underflow Output Action 0"]
135pub type UFOA0_R = crate::FieldReader<u8, UFOA0_A>;
136impl UFOA0_R {
137    #[doc = "Get enumerated values variant"]
138    #[inline(always)]
139    pub fn variant(&self) -> UFOA0_A {
140        match self.bits {
141            0 => UFOA0_A::NONE,
142            1 => UFOA0_A::TOGGLE,
143            2 => UFOA0_A::PULSE,
144            3 => UFOA0_A::PWM,
145            _ => unreachable!(),
146        }
147    }
148    #[doc = "Checks if the value of the field is `NONE`"]
149    #[inline(always)]
150    pub fn is_none(&self) -> bool {
151        *self == UFOA0_A::NONE
152    }
153    #[doc = "Checks if the value of the field is `TOGGLE`"]
154    #[inline(always)]
155    pub fn is_toggle(&self) -> bool {
156        *self == UFOA0_A::TOGGLE
157    }
158    #[doc = "Checks if the value of the field is `PULSE`"]
159    #[inline(always)]
160    pub fn is_pulse(&self) -> bool {
161        *self == UFOA0_A::PULSE
162    }
163    #[doc = "Checks if the value of the field is `PWM`"]
164    #[inline(always)]
165    pub fn is_pwm(&self) -> bool {
166        *self == UFOA0_A::PWM
167    }
168}
169#[doc = "Field `UFOA0` writer - Underflow Output Action 0"]
170pub type UFOA0_W<'a> = crate::FieldWriterSafe<'a, u32, CTRL_SPEC, u8, UFOA0_A, 2, 2>;
171impl<'a> UFOA0_W<'a> {
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}
193#[doc = "Underflow Output Action 1\n\nValue on reset: 0"]
194#[derive(Clone, Copy, Debug, PartialEq)]
195#[repr(u8)]
196pub enum UFOA1_A {
197    #[doc = "0: LETn_O1 is held at its idle value as defined by OPOL1."]
198    NONE = 0,
199    #[doc = "1: LETn_O1 is toggled on CNT underflow."]
200    TOGGLE = 1,
201    #[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."]
202    PULSE = 2,
203    #[doc = "3: LETn_O1 is set idle on CNT underflow, and active on compare match with COMP1"]
204    PWM = 3,
205}
206impl From<UFOA1_A> for u8 {
207    #[inline(always)]
208    fn from(variant: UFOA1_A) -> Self {
209        variant as _
210    }
211}
212#[doc = "Field `UFOA1` reader - Underflow Output Action 1"]
213pub type UFOA1_R = crate::FieldReader<u8, UFOA1_A>;
214impl UFOA1_R {
215    #[doc = "Get enumerated values variant"]
216    #[inline(always)]
217    pub fn variant(&self) -> UFOA1_A {
218        match self.bits {
219            0 => UFOA1_A::NONE,
220            1 => UFOA1_A::TOGGLE,
221            2 => UFOA1_A::PULSE,
222            3 => UFOA1_A::PWM,
223            _ => unreachable!(),
224        }
225    }
226    #[doc = "Checks if the value of the field is `NONE`"]
227    #[inline(always)]
228    pub fn is_none(&self) -> bool {
229        *self == UFOA1_A::NONE
230    }
231    #[doc = "Checks if the value of the field is `TOGGLE`"]
232    #[inline(always)]
233    pub fn is_toggle(&self) -> bool {
234        *self == UFOA1_A::TOGGLE
235    }
236    #[doc = "Checks if the value of the field is `PULSE`"]
237    #[inline(always)]
238    pub fn is_pulse(&self) -> bool {
239        *self == UFOA1_A::PULSE
240    }
241    #[doc = "Checks if the value of the field is `PWM`"]
242    #[inline(always)]
243    pub fn is_pwm(&self) -> bool {
244        *self == UFOA1_A::PWM
245    }
246}
247#[doc = "Field `UFOA1` writer - Underflow Output Action 1"]
248pub type UFOA1_W<'a> = crate::FieldWriterSafe<'a, u32, CTRL_SPEC, u8, UFOA1_A, 2, 4>;
249impl<'a> UFOA1_W<'a> {
250    #[doc = "LETn_O1 is held at its idle value as defined by OPOL1."]
251    #[inline(always)]
252    pub fn none(self) -> &'a mut W {
253        self.variant(UFOA1_A::NONE)
254    }
255    #[doc = "LETn_O1 is toggled on CNT underflow."]
256    #[inline(always)]
257    pub fn toggle(self) -> &'a mut W {
258        self.variant(UFOA1_A::TOGGLE)
259    }
260    #[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."]
261    #[inline(always)]
262    pub fn pulse(self) -> &'a mut W {
263        self.variant(UFOA1_A::PULSE)
264    }
265    #[doc = "LETn_O1 is set idle on CNT underflow, and active on compare match with COMP1"]
266    #[inline(always)]
267    pub fn pwm(self) -> &'a mut W {
268        self.variant(UFOA1_A::PWM)
269    }
270}
271#[doc = "Field `OPOL0` reader - Output 0 Polarity"]
272pub type OPOL0_R = crate::BitReader<bool>;
273#[doc = "Field `OPOL0` writer - Output 0 Polarity"]
274pub type OPOL0_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 6>;
275#[doc = "Field `OPOL1` reader - Output 1 Polarity"]
276pub type OPOL1_R = crate::BitReader<bool>;
277#[doc = "Field `OPOL1` writer - Output 1 Polarity"]
278pub type OPOL1_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 7>;
279#[doc = "Field `BUFTOP` reader - Buffered Top"]
280pub type BUFTOP_R = crate::BitReader<bool>;
281#[doc = "Field `BUFTOP` writer - Buffered Top"]
282pub type BUFTOP_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 8>;
283#[doc = "Field `COMP0TOP` reader - Compare Value 0 Is Top Value"]
284pub type COMP0TOP_R = crate::BitReader<bool>;
285#[doc = "Field `COMP0TOP` writer - Compare Value 0 Is Top Value"]
286pub type COMP0TOP_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 9>;
287#[doc = "Field `RTCC0TEN` reader - RTC Compare 0 Trigger Enable"]
288pub type RTCC0TEN_R = crate::BitReader<bool>;
289#[doc = "Field `RTCC0TEN` writer - RTC Compare 0 Trigger Enable"]
290pub type RTCC0TEN_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 10>;
291#[doc = "Field `RTCC1TEN` reader - RTC Compare 1 Trigger Enable"]
292pub type RTCC1TEN_R = crate::BitReader<bool>;
293#[doc = "Field `RTCC1TEN` writer - RTC Compare 1 Trigger Enable"]
294pub type RTCC1TEN_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 11>;
295#[doc = "Field `DEBUGRUN` reader - Debug Mode Run Enable"]
296pub type DEBUGRUN_R = crate::BitReader<bool>;
297#[doc = "Field `DEBUGRUN` writer - Debug Mode Run Enable"]
298pub type DEBUGRUN_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 12>;
299impl R {
300    #[doc = "Bits 0:1 - Repeat Mode"]
301    #[inline(always)]
302    pub fn repmode(&self) -> REPMODE_R {
303        REPMODE_R::new((self.bits & 3) as u8)
304    }
305    #[doc = "Bits 2:3 - Underflow Output Action 0"]
306    #[inline(always)]
307    pub fn ufoa0(&self) -> UFOA0_R {
308        UFOA0_R::new(((self.bits >> 2) & 3) as u8)
309    }
310    #[doc = "Bits 4:5 - Underflow Output Action 1"]
311    #[inline(always)]
312    pub fn ufoa1(&self) -> UFOA1_R {
313        UFOA1_R::new(((self.bits >> 4) & 3) as u8)
314    }
315    #[doc = "Bit 6 - Output 0 Polarity"]
316    #[inline(always)]
317    pub fn opol0(&self) -> OPOL0_R {
318        OPOL0_R::new(((self.bits >> 6) & 1) != 0)
319    }
320    #[doc = "Bit 7 - Output 1 Polarity"]
321    #[inline(always)]
322    pub fn opol1(&self) -> OPOL1_R {
323        OPOL1_R::new(((self.bits >> 7) & 1) != 0)
324    }
325    #[doc = "Bit 8 - Buffered Top"]
326    #[inline(always)]
327    pub fn buftop(&self) -> BUFTOP_R {
328        BUFTOP_R::new(((self.bits >> 8) & 1) != 0)
329    }
330    #[doc = "Bit 9 - Compare Value 0 Is Top Value"]
331    #[inline(always)]
332    pub fn comp0top(&self) -> COMP0TOP_R {
333        COMP0TOP_R::new(((self.bits >> 9) & 1) != 0)
334    }
335    #[doc = "Bit 10 - RTC Compare 0 Trigger Enable"]
336    #[inline(always)]
337    pub fn rtcc0ten(&self) -> RTCC0TEN_R {
338        RTCC0TEN_R::new(((self.bits >> 10) & 1) != 0)
339    }
340    #[doc = "Bit 11 - RTC Compare 1 Trigger Enable"]
341    #[inline(always)]
342    pub fn rtcc1ten(&self) -> RTCC1TEN_R {
343        RTCC1TEN_R::new(((self.bits >> 11) & 1) != 0)
344    }
345    #[doc = "Bit 12 - Debug Mode Run Enable"]
346    #[inline(always)]
347    pub fn debugrun(&self) -> DEBUGRUN_R {
348        DEBUGRUN_R::new(((self.bits >> 12) & 1) != 0)
349    }
350}
351impl W {
352    #[doc = "Bits 0:1 - Repeat Mode"]
353    #[inline(always)]
354    pub fn repmode(&mut self) -> REPMODE_W {
355        REPMODE_W::new(self)
356    }
357    #[doc = "Bits 2:3 - Underflow Output Action 0"]
358    #[inline(always)]
359    pub fn ufoa0(&mut self) -> UFOA0_W {
360        UFOA0_W::new(self)
361    }
362    #[doc = "Bits 4:5 - Underflow Output Action 1"]
363    #[inline(always)]
364    pub fn ufoa1(&mut self) -> UFOA1_W {
365        UFOA1_W::new(self)
366    }
367    #[doc = "Bit 6 - Output 0 Polarity"]
368    #[inline(always)]
369    pub fn opol0(&mut self) -> OPOL0_W {
370        OPOL0_W::new(self)
371    }
372    #[doc = "Bit 7 - Output 1 Polarity"]
373    #[inline(always)]
374    pub fn opol1(&mut self) -> OPOL1_W {
375        OPOL1_W::new(self)
376    }
377    #[doc = "Bit 8 - Buffered Top"]
378    #[inline(always)]
379    pub fn buftop(&mut self) -> BUFTOP_W {
380        BUFTOP_W::new(self)
381    }
382    #[doc = "Bit 9 - Compare Value 0 Is Top Value"]
383    #[inline(always)]
384    pub fn comp0top(&mut self) -> COMP0TOP_W {
385        COMP0TOP_W::new(self)
386    }
387    #[doc = "Bit 10 - RTC Compare 0 Trigger Enable"]
388    #[inline(always)]
389    pub fn rtcc0ten(&mut self) -> RTCC0TEN_W {
390        RTCC0TEN_W::new(self)
391    }
392    #[doc = "Bit 11 - RTC Compare 1 Trigger Enable"]
393    #[inline(always)]
394    pub fn rtcc1ten(&mut self) -> RTCC1TEN_W {
395        RTCC1TEN_W::new(self)
396    }
397    #[doc = "Bit 12 - Debug Mode Run Enable"]
398    #[inline(always)]
399    pub fn debugrun(&mut self) -> DEBUGRUN_W {
400        DEBUGRUN_W::new(self)
401    }
402    #[doc = "Writes raw bits to the register."]
403    #[inline(always)]
404    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
405        self.0.bits(bits);
406        self
407    }
408}
409#[doc = "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 [ctrl](index.html) module"]
410pub struct CTRL_SPEC;
411impl crate::RegisterSpec for CTRL_SPEC {
412    type Ux = u32;
413}
414#[doc = "`read()` method returns [ctrl::R](R) reader structure"]
415impl crate::Readable for CTRL_SPEC {
416    type Reader = R;
417}
418#[doc = "`write(|w| ..)` method takes [ctrl::W](W) writer structure"]
419impl crate::Writable for CTRL_SPEC {
420    type Writer = W;
421}
422#[doc = "`reset()` method sets CTRL to value 0"]
423impl crate::Resettable for CTRL_SPEC {
424    #[inline(always)]
425    fn reset_value() -> Self::Ux {
426        0
427    }
428}