efm32pg22_pac/efm32pg22c200/timer0_s/
cc1_ctrl.rs

1#[doc = "Register `CC1_CTRL` reader"]
2pub struct R(crate::R<CC1_CTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CC1_CTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CC1_CTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CC1_CTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CC1_CTRL` writer"]
17pub struct W(crate::W<CC1_CTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CC1_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<CC1_CTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CC1_CTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `OUTINV` reader - Output Invert"]
38pub type OUTINV_R = crate::BitReader<bool>;
39#[doc = "Field `OUTINV` writer - Output Invert"]
40pub type OUTINV_W<'a, const O: u8> = crate::BitWriter<'a, u32, CC1_CTRL_SPEC, bool, O>;
41#[doc = "Field `CMOA` reader - Compare Match Output Action"]
42pub type CMOA_R = crate::FieldReader<u8, CMOA_A>;
43#[doc = "Compare Match Output Action\n\nValue on reset: 0"]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45#[repr(u8)]
46pub enum CMOA_A {
47    #[doc = "0: No action on compare match"]
48    NONE = 0,
49    #[doc = "1: Toggle output on compare match"]
50    TOGGLE = 1,
51    #[doc = "2: Clear output on compare match"]
52    CLEAR = 2,
53    #[doc = "3: Set output on compare match"]
54    SET = 3,
55}
56impl From<CMOA_A> for u8 {
57    #[inline(always)]
58    fn from(variant: CMOA_A) -> Self {
59        variant as _
60    }
61}
62impl CMOA_R {
63    #[doc = "Get enumerated values variant"]
64    #[inline(always)]
65    pub fn variant(&self) -> CMOA_A {
66        match self.bits {
67            0 => CMOA_A::NONE,
68            1 => CMOA_A::TOGGLE,
69            2 => CMOA_A::CLEAR,
70            3 => CMOA_A::SET,
71            _ => unreachable!(),
72        }
73    }
74    #[doc = "Checks if the value of the field is `NONE`"]
75    #[inline(always)]
76    pub fn is_none(&self) -> bool {
77        *self == CMOA_A::NONE
78    }
79    #[doc = "Checks if the value of the field is `TOGGLE`"]
80    #[inline(always)]
81    pub fn is_toggle(&self) -> bool {
82        *self == CMOA_A::TOGGLE
83    }
84    #[doc = "Checks if the value of the field is `CLEAR`"]
85    #[inline(always)]
86    pub fn is_clear(&self) -> bool {
87        *self == CMOA_A::CLEAR
88    }
89    #[doc = "Checks if the value of the field is `SET`"]
90    #[inline(always)]
91    pub fn is_set(&self) -> bool {
92        *self == CMOA_A::SET
93    }
94}
95#[doc = "Field `CMOA` writer - Compare Match Output Action"]
96pub type CMOA_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u32, CC1_CTRL_SPEC, u8, CMOA_A, 2, O>;
97impl<'a, const O: u8> CMOA_W<'a, O> {
98    #[doc = "No action on compare match"]
99    #[inline(always)]
100    pub fn none(self) -> &'a mut W {
101        self.variant(CMOA_A::NONE)
102    }
103    #[doc = "Toggle output on compare match"]
104    #[inline(always)]
105    pub fn toggle(self) -> &'a mut W {
106        self.variant(CMOA_A::TOGGLE)
107    }
108    #[doc = "Clear output on compare match"]
109    #[inline(always)]
110    pub fn clear(self) -> &'a mut W {
111        self.variant(CMOA_A::CLEAR)
112    }
113    #[doc = "Set output on compare match"]
114    #[inline(always)]
115    pub fn set(self) -> &'a mut W {
116        self.variant(CMOA_A::SET)
117    }
118}
119#[doc = "Field `COFOA` reader - Counter Overflow Output Action"]
120pub type COFOA_R = crate::FieldReader<u8, COFOA_A>;
121#[doc = "Counter Overflow Output Action\n\nValue on reset: 0"]
122#[derive(Clone, Copy, Debug, PartialEq, Eq)]
123#[repr(u8)]
124pub enum COFOA_A {
125    #[doc = "0: No action on counter overflow"]
126    NONE = 0,
127    #[doc = "1: Toggle output on counter overflow"]
128    TOGGLE = 1,
129    #[doc = "2: Clear output on counter overflow"]
130    CLEAR = 2,
131    #[doc = "3: Set output on counter overflow"]
132    SET = 3,
133}
134impl From<COFOA_A> for u8 {
135    #[inline(always)]
136    fn from(variant: COFOA_A) -> Self {
137        variant as _
138    }
139}
140impl COFOA_R {
141    #[doc = "Get enumerated values variant"]
142    #[inline(always)]
143    pub fn variant(&self) -> COFOA_A {
144        match self.bits {
145            0 => COFOA_A::NONE,
146            1 => COFOA_A::TOGGLE,
147            2 => COFOA_A::CLEAR,
148            3 => COFOA_A::SET,
149            _ => unreachable!(),
150        }
151    }
152    #[doc = "Checks if the value of the field is `NONE`"]
153    #[inline(always)]
154    pub fn is_none(&self) -> bool {
155        *self == COFOA_A::NONE
156    }
157    #[doc = "Checks if the value of the field is `TOGGLE`"]
158    #[inline(always)]
159    pub fn is_toggle(&self) -> bool {
160        *self == COFOA_A::TOGGLE
161    }
162    #[doc = "Checks if the value of the field is `CLEAR`"]
163    #[inline(always)]
164    pub fn is_clear(&self) -> bool {
165        *self == COFOA_A::CLEAR
166    }
167    #[doc = "Checks if the value of the field is `SET`"]
168    #[inline(always)]
169    pub fn is_set(&self) -> bool {
170        *self == COFOA_A::SET
171    }
172}
173#[doc = "Field `COFOA` writer - Counter Overflow Output Action"]
174pub type COFOA_W<'a, const O: u8> =
175    crate::FieldWriterSafe<'a, u32, CC1_CTRL_SPEC, u8, COFOA_A, 2, O>;
176impl<'a, const O: u8> COFOA_W<'a, O> {
177    #[doc = "No action on counter overflow"]
178    #[inline(always)]
179    pub fn none(self) -> &'a mut W {
180        self.variant(COFOA_A::NONE)
181    }
182    #[doc = "Toggle output on counter overflow"]
183    #[inline(always)]
184    pub fn toggle(self) -> &'a mut W {
185        self.variant(COFOA_A::TOGGLE)
186    }
187    #[doc = "Clear output on counter overflow"]
188    #[inline(always)]
189    pub fn clear(self) -> &'a mut W {
190        self.variant(COFOA_A::CLEAR)
191    }
192    #[doc = "Set output on counter overflow"]
193    #[inline(always)]
194    pub fn set(self) -> &'a mut W {
195        self.variant(COFOA_A::SET)
196    }
197}
198#[doc = "Field `CUFOA` reader - Counter Underflow Output Action"]
199pub type CUFOA_R = crate::FieldReader<u8, CUFOA_A>;
200#[doc = "Counter Underflow Output Action\n\nValue on reset: 0"]
201#[derive(Clone, Copy, Debug, PartialEq, Eq)]
202#[repr(u8)]
203pub enum CUFOA_A {
204    #[doc = "0: No action on counter underflow"]
205    NONE = 0,
206    #[doc = "1: Toggle output on counter underflow"]
207    TOGGLE = 1,
208    #[doc = "2: Clear output on counter underflow"]
209    CLEAR = 2,
210    #[doc = "3: Set output on counter underflow"]
211    SET = 3,
212}
213impl From<CUFOA_A> for u8 {
214    #[inline(always)]
215    fn from(variant: CUFOA_A) -> Self {
216        variant as _
217    }
218}
219impl CUFOA_R {
220    #[doc = "Get enumerated values variant"]
221    #[inline(always)]
222    pub fn variant(&self) -> CUFOA_A {
223        match self.bits {
224            0 => CUFOA_A::NONE,
225            1 => CUFOA_A::TOGGLE,
226            2 => CUFOA_A::CLEAR,
227            3 => CUFOA_A::SET,
228            _ => unreachable!(),
229        }
230    }
231    #[doc = "Checks if the value of the field is `NONE`"]
232    #[inline(always)]
233    pub fn is_none(&self) -> bool {
234        *self == CUFOA_A::NONE
235    }
236    #[doc = "Checks if the value of the field is `TOGGLE`"]
237    #[inline(always)]
238    pub fn is_toggle(&self) -> bool {
239        *self == CUFOA_A::TOGGLE
240    }
241    #[doc = "Checks if the value of the field is `CLEAR`"]
242    #[inline(always)]
243    pub fn is_clear(&self) -> bool {
244        *self == CUFOA_A::CLEAR
245    }
246    #[doc = "Checks if the value of the field is `SET`"]
247    #[inline(always)]
248    pub fn is_set(&self) -> bool {
249        *self == CUFOA_A::SET
250    }
251}
252#[doc = "Field `CUFOA` writer - Counter Underflow Output Action"]
253pub type CUFOA_W<'a, const O: u8> =
254    crate::FieldWriterSafe<'a, u32, CC1_CTRL_SPEC, u8, CUFOA_A, 2, O>;
255impl<'a, const O: u8> CUFOA_W<'a, O> {
256    #[doc = "No action on counter underflow"]
257    #[inline(always)]
258    pub fn none(self) -> &'a mut W {
259        self.variant(CUFOA_A::NONE)
260    }
261    #[doc = "Toggle output on counter underflow"]
262    #[inline(always)]
263    pub fn toggle(self) -> &'a mut W {
264        self.variant(CUFOA_A::TOGGLE)
265    }
266    #[doc = "Clear output on counter underflow"]
267    #[inline(always)]
268    pub fn clear(self) -> &'a mut W {
269        self.variant(CUFOA_A::CLEAR)
270    }
271    #[doc = "Set output on counter underflow"]
272    #[inline(always)]
273    pub fn set(self) -> &'a mut W {
274        self.variant(CUFOA_A::SET)
275    }
276}
277#[doc = "Field `ICEDGE` reader - Input Capture Edge Select"]
278pub type ICEDGE_R = crate::FieldReader<u8, ICEDGE_A>;
279#[doc = "Input Capture Edge Select\n\nValue on reset: 0"]
280#[derive(Clone, Copy, Debug, PartialEq, Eq)]
281#[repr(u8)]
282pub enum ICEDGE_A {
283    #[doc = "0: Rising edges detected"]
284    RISING = 0,
285    #[doc = "1: Falling edges detected"]
286    FALLING = 1,
287    #[doc = "2: Both edges detected"]
288    BOTH = 2,
289    #[doc = "3: No edge detection, signal is left as it is"]
290    NONE = 3,
291}
292impl From<ICEDGE_A> for u8 {
293    #[inline(always)]
294    fn from(variant: ICEDGE_A) -> Self {
295        variant as _
296    }
297}
298impl ICEDGE_R {
299    #[doc = "Get enumerated values variant"]
300    #[inline(always)]
301    pub fn variant(&self) -> ICEDGE_A {
302        match self.bits {
303            0 => ICEDGE_A::RISING,
304            1 => ICEDGE_A::FALLING,
305            2 => ICEDGE_A::BOTH,
306            3 => ICEDGE_A::NONE,
307            _ => unreachable!(),
308        }
309    }
310    #[doc = "Checks if the value of the field is `RISING`"]
311    #[inline(always)]
312    pub fn is_rising(&self) -> bool {
313        *self == ICEDGE_A::RISING
314    }
315    #[doc = "Checks if the value of the field is `FALLING`"]
316    #[inline(always)]
317    pub fn is_falling(&self) -> bool {
318        *self == ICEDGE_A::FALLING
319    }
320    #[doc = "Checks if the value of the field is `BOTH`"]
321    #[inline(always)]
322    pub fn is_both(&self) -> bool {
323        *self == ICEDGE_A::BOTH
324    }
325    #[doc = "Checks if the value of the field is `NONE`"]
326    #[inline(always)]
327    pub fn is_none(&self) -> bool {
328        *self == ICEDGE_A::NONE
329    }
330}
331#[doc = "Field `ICEDGE` writer - Input Capture Edge Select"]
332pub type ICEDGE_W<'a, const O: u8> =
333    crate::FieldWriterSafe<'a, u32, CC1_CTRL_SPEC, u8, ICEDGE_A, 2, O>;
334impl<'a, const O: u8> ICEDGE_W<'a, O> {
335    #[doc = "Rising edges detected"]
336    #[inline(always)]
337    pub fn rising(self) -> &'a mut W {
338        self.variant(ICEDGE_A::RISING)
339    }
340    #[doc = "Falling edges detected"]
341    #[inline(always)]
342    pub fn falling(self) -> &'a mut W {
343        self.variant(ICEDGE_A::FALLING)
344    }
345    #[doc = "Both edges detected"]
346    #[inline(always)]
347    pub fn both(self) -> &'a mut W {
348        self.variant(ICEDGE_A::BOTH)
349    }
350    #[doc = "No edge detection, signal is left as it is"]
351    #[inline(always)]
352    pub fn none(self) -> &'a mut W {
353        self.variant(ICEDGE_A::NONE)
354    }
355}
356#[doc = "Field `ICEVCTRL` reader - Input Capture Event Control"]
357pub type ICEVCTRL_R = crate::FieldReader<u8, ICEVCTRL_A>;
358#[doc = "Input Capture Event Control\n\nValue on reset: 0"]
359#[derive(Clone, Copy, Debug, PartialEq, Eq)]
360#[repr(u8)]
361pub enum ICEVCTRL_A {
362    #[doc = "0: PRS output pulse and interrupt flag set on every capture"]
363    EVERYEDGE = 0,
364    #[doc = "1: PRS output pulse and interrupt flag set on every second capture"]
365    EVERYSECONDEDGE = 1,
366    #[doc = "2: PRS output pulse and interrupt flag set on rising edge only (if ICEDGE = BOTH)"]
367    RISING = 2,
368    #[doc = "3: PRS output pulse and interrupt flag set on falling edge only (if ICEDGE = BOTH)"]
369    FALLING = 3,
370}
371impl From<ICEVCTRL_A> for u8 {
372    #[inline(always)]
373    fn from(variant: ICEVCTRL_A) -> Self {
374        variant as _
375    }
376}
377impl ICEVCTRL_R {
378    #[doc = "Get enumerated values variant"]
379    #[inline(always)]
380    pub fn variant(&self) -> ICEVCTRL_A {
381        match self.bits {
382            0 => ICEVCTRL_A::EVERYEDGE,
383            1 => ICEVCTRL_A::EVERYSECONDEDGE,
384            2 => ICEVCTRL_A::RISING,
385            3 => ICEVCTRL_A::FALLING,
386            _ => unreachable!(),
387        }
388    }
389    #[doc = "Checks if the value of the field is `EVERYEDGE`"]
390    #[inline(always)]
391    pub fn is_everyedge(&self) -> bool {
392        *self == ICEVCTRL_A::EVERYEDGE
393    }
394    #[doc = "Checks if the value of the field is `EVERYSECONDEDGE`"]
395    #[inline(always)]
396    pub fn is_everysecondedge(&self) -> bool {
397        *self == ICEVCTRL_A::EVERYSECONDEDGE
398    }
399    #[doc = "Checks if the value of the field is `RISING`"]
400    #[inline(always)]
401    pub fn is_rising(&self) -> bool {
402        *self == ICEVCTRL_A::RISING
403    }
404    #[doc = "Checks if the value of the field is `FALLING`"]
405    #[inline(always)]
406    pub fn is_falling(&self) -> bool {
407        *self == ICEVCTRL_A::FALLING
408    }
409}
410#[doc = "Field `ICEVCTRL` writer - Input Capture Event Control"]
411pub type ICEVCTRL_W<'a, const O: u8> =
412    crate::FieldWriterSafe<'a, u32, CC1_CTRL_SPEC, u8, ICEVCTRL_A, 2, O>;
413impl<'a, const O: u8> ICEVCTRL_W<'a, O> {
414    #[doc = "PRS output pulse and interrupt flag set on every capture"]
415    #[inline(always)]
416    pub fn everyedge(self) -> &'a mut W {
417        self.variant(ICEVCTRL_A::EVERYEDGE)
418    }
419    #[doc = "PRS output pulse and interrupt flag set on every second capture"]
420    #[inline(always)]
421    pub fn everysecondedge(self) -> &'a mut W {
422        self.variant(ICEVCTRL_A::EVERYSECONDEDGE)
423    }
424    #[doc = "PRS output pulse and interrupt flag set on rising edge only (if ICEDGE = BOTH)"]
425    #[inline(always)]
426    pub fn rising(self) -> &'a mut W {
427        self.variant(ICEVCTRL_A::RISING)
428    }
429    #[doc = "PRS output pulse and interrupt flag set on falling edge only (if ICEDGE = BOTH)"]
430    #[inline(always)]
431    pub fn falling(self) -> &'a mut W {
432        self.variant(ICEVCTRL_A::FALLING)
433    }
434}
435impl R {
436    #[doc = "Bit 2 - Output Invert"]
437    #[inline(always)]
438    pub fn outinv(&self) -> OUTINV_R {
439        OUTINV_R::new(((self.bits >> 2) & 1) != 0)
440    }
441    #[doc = "Bits 8:9 - Compare Match Output Action"]
442    #[inline(always)]
443    pub fn cmoa(&self) -> CMOA_R {
444        CMOA_R::new(((self.bits >> 8) & 3) as u8)
445    }
446    #[doc = "Bits 10:11 - Counter Overflow Output Action"]
447    #[inline(always)]
448    pub fn cofoa(&self) -> COFOA_R {
449        COFOA_R::new(((self.bits >> 10) & 3) as u8)
450    }
451    #[doc = "Bits 12:13 - Counter Underflow Output Action"]
452    #[inline(always)]
453    pub fn cufoa(&self) -> CUFOA_R {
454        CUFOA_R::new(((self.bits >> 12) & 3) as u8)
455    }
456    #[doc = "Bits 24:25 - Input Capture Edge Select"]
457    #[inline(always)]
458    pub fn icedge(&self) -> ICEDGE_R {
459        ICEDGE_R::new(((self.bits >> 24) & 3) as u8)
460    }
461    #[doc = "Bits 26:27 - Input Capture Event Control"]
462    #[inline(always)]
463    pub fn icevctrl(&self) -> ICEVCTRL_R {
464        ICEVCTRL_R::new(((self.bits >> 26) & 3) as u8)
465    }
466}
467impl W {
468    #[doc = "Bit 2 - Output Invert"]
469    #[inline(always)]
470    #[must_use]
471    pub fn outinv(&mut self) -> OUTINV_W<2> {
472        OUTINV_W::new(self)
473    }
474    #[doc = "Bits 8:9 - Compare Match Output Action"]
475    #[inline(always)]
476    #[must_use]
477    pub fn cmoa(&mut self) -> CMOA_W<8> {
478        CMOA_W::new(self)
479    }
480    #[doc = "Bits 10:11 - Counter Overflow Output Action"]
481    #[inline(always)]
482    #[must_use]
483    pub fn cofoa(&mut self) -> COFOA_W<10> {
484        COFOA_W::new(self)
485    }
486    #[doc = "Bits 12:13 - Counter Underflow Output Action"]
487    #[inline(always)]
488    #[must_use]
489    pub fn cufoa(&mut self) -> CUFOA_W<12> {
490        CUFOA_W::new(self)
491    }
492    #[doc = "Bits 24:25 - Input Capture Edge Select"]
493    #[inline(always)]
494    #[must_use]
495    pub fn icedge(&mut self) -> ICEDGE_W<24> {
496        ICEDGE_W::new(self)
497    }
498    #[doc = "Bits 26:27 - Input Capture Event Control"]
499    #[inline(always)]
500    #[must_use]
501    pub fn icevctrl(&mut self) -> ICEVCTRL_W<26> {
502        ICEVCTRL_W::new(self)
503    }
504    #[doc = "Writes raw bits to the register."]
505    #[inline(always)]
506    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
507        self.0.bits(bits);
508        self
509    }
510}
511#[doc = "No Description\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 [cc1_ctrl](index.html) module"]
512pub struct CC1_CTRL_SPEC;
513impl crate::RegisterSpec for CC1_CTRL_SPEC {
514    type Ux = u32;
515}
516#[doc = "`read()` method returns [cc1_ctrl::R](R) reader structure"]
517impl crate::Readable for CC1_CTRL_SPEC {
518    type Reader = R;
519}
520#[doc = "`write(|w| ..)` method takes [cc1_ctrl::W](W) writer structure"]
521impl crate::Writable for CC1_CTRL_SPEC {
522    type Writer = W;
523    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
524    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
525}
526#[doc = "`reset()` method sets CC1_CTRL to value 0"]
527impl crate::Resettable for CC1_CTRL_SPEC {
528    const RESET_VALUE: Self::Ux = 0;
529}