efm32pg1b200_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, otherwise 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, otherwise 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 `DEBUGRUN` reader - Debug Mode Run Enable"]
288pub type DEBUGRUN_R = crate::BitReader<bool>;
289#[doc = "Field `DEBUGRUN` writer - Debug Mode Run Enable"]
290pub type DEBUGRUN_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 12>;
291impl R {
292    #[doc = "Bits 0:1 - Repeat Mode"]
293    #[inline(always)]
294    pub fn repmode(&self) -> REPMODE_R {
295        REPMODE_R::new((self.bits & 3) as u8)
296    }
297    #[doc = "Bits 2:3 - Underflow Output Action 0"]
298    #[inline(always)]
299    pub fn ufoa0(&self) -> UFOA0_R {
300        UFOA0_R::new(((self.bits >> 2) & 3) as u8)
301    }
302    #[doc = "Bits 4:5 - Underflow Output Action 1"]
303    #[inline(always)]
304    pub fn ufoa1(&self) -> UFOA1_R {
305        UFOA1_R::new(((self.bits >> 4) & 3) as u8)
306    }
307    #[doc = "Bit 6 - Output 0 Polarity"]
308    #[inline(always)]
309    pub fn opol0(&self) -> OPOL0_R {
310        OPOL0_R::new(((self.bits >> 6) & 1) != 0)
311    }
312    #[doc = "Bit 7 - Output 1 Polarity"]
313    #[inline(always)]
314    pub fn opol1(&self) -> OPOL1_R {
315        OPOL1_R::new(((self.bits >> 7) & 1) != 0)
316    }
317    #[doc = "Bit 8 - Buffered Top"]
318    #[inline(always)]
319    pub fn buftop(&self) -> BUFTOP_R {
320        BUFTOP_R::new(((self.bits >> 8) & 1) != 0)
321    }
322    #[doc = "Bit 9 - Compare Value 0 is Top Value"]
323    #[inline(always)]
324    pub fn comp0top(&self) -> COMP0TOP_R {
325        COMP0TOP_R::new(((self.bits >> 9) & 1) != 0)
326    }
327    #[doc = "Bit 12 - Debug Mode Run Enable"]
328    #[inline(always)]
329    pub fn debugrun(&self) -> DEBUGRUN_R {
330        DEBUGRUN_R::new(((self.bits >> 12) & 1) != 0)
331    }
332}
333impl W {
334    #[doc = "Bits 0:1 - Repeat Mode"]
335    #[inline(always)]
336    pub fn repmode(&mut self) -> REPMODE_W {
337        REPMODE_W::new(self)
338    }
339    #[doc = "Bits 2:3 - Underflow Output Action 0"]
340    #[inline(always)]
341    pub fn ufoa0(&mut self) -> UFOA0_W {
342        UFOA0_W::new(self)
343    }
344    #[doc = "Bits 4:5 - Underflow Output Action 1"]
345    #[inline(always)]
346    pub fn ufoa1(&mut self) -> UFOA1_W {
347        UFOA1_W::new(self)
348    }
349    #[doc = "Bit 6 - Output 0 Polarity"]
350    #[inline(always)]
351    pub fn opol0(&mut self) -> OPOL0_W {
352        OPOL0_W::new(self)
353    }
354    #[doc = "Bit 7 - Output 1 Polarity"]
355    #[inline(always)]
356    pub fn opol1(&mut self) -> OPOL1_W {
357        OPOL1_W::new(self)
358    }
359    #[doc = "Bit 8 - Buffered Top"]
360    #[inline(always)]
361    pub fn buftop(&mut self) -> BUFTOP_W {
362        BUFTOP_W::new(self)
363    }
364    #[doc = "Bit 9 - Compare Value 0 is Top Value"]
365    #[inline(always)]
366    pub fn comp0top(&mut self) -> COMP0TOP_W {
367        COMP0TOP_W::new(self)
368    }
369    #[doc = "Bit 12 - Debug Mode Run Enable"]
370    #[inline(always)]
371    pub fn debugrun(&mut self) -> DEBUGRUN_W {
372        DEBUGRUN_W::new(self)
373    }
374    #[doc = "Writes raw bits to the register."]
375    #[inline(always)]
376    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
377        self.0.bits(bits);
378        self
379    }
380}
381#[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"]
382pub struct CTRL_SPEC;
383impl crate::RegisterSpec for CTRL_SPEC {
384    type Ux = u32;
385}
386#[doc = "`read()` method returns [ctrl::R](R) reader structure"]
387impl crate::Readable for CTRL_SPEC {
388    type Reader = R;
389}
390#[doc = "`write(|w| ..)` method takes [ctrl::W](W) writer structure"]
391impl crate::Writable for CTRL_SPEC {
392    type Writer = W;
393}
394#[doc = "`reset()` method sets CTRL to value 0"]
395impl crate::Resettable for CTRL_SPEC {
396    #[inline(always)]
397    fn reset_value() -> Self::Ux {
398        0
399    }
400}