efm32pg22_pac/efm32pg22c200/timer2_s/
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 = "Field `RISEA` reader - Timer Rising Input Edge Action"]
38pub type RISEA_R = crate::FieldReader<u8, RISEA_A>;
39#[doc = "Timer Rising Input Edge Action\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum RISEA_A {
43    #[doc = "0: No action"]
44    NONE = 0,
45    #[doc = "1: Start counter without reload"]
46    START = 1,
47    #[doc = "2: Stop counter without reload"]
48    STOP = 2,
49    #[doc = "3: Reload and start counter"]
50    RELOADSTART = 3,
51}
52impl From<RISEA_A> for u8 {
53    #[inline(always)]
54    fn from(variant: RISEA_A) -> Self {
55        variant as _
56    }
57}
58impl RISEA_R {
59    #[doc = "Get enumerated values variant"]
60    #[inline(always)]
61    pub fn variant(&self) -> RISEA_A {
62        match self.bits {
63            0 => RISEA_A::NONE,
64            1 => RISEA_A::START,
65            2 => RISEA_A::STOP,
66            3 => RISEA_A::RELOADSTART,
67            _ => unreachable!(),
68        }
69    }
70    #[doc = "Checks if the value of the field is `NONE`"]
71    #[inline(always)]
72    pub fn is_none(&self) -> bool {
73        *self == RISEA_A::NONE
74    }
75    #[doc = "Checks if the value of the field is `START`"]
76    #[inline(always)]
77    pub fn is_start(&self) -> bool {
78        *self == RISEA_A::START
79    }
80    #[doc = "Checks if the value of the field is `STOP`"]
81    #[inline(always)]
82    pub fn is_stop(&self) -> bool {
83        *self == RISEA_A::STOP
84    }
85    #[doc = "Checks if the value of the field is `RELOADSTART`"]
86    #[inline(always)]
87    pub fn is_reloadstart(&self) -> bool {
88        *self == RISEA_A::RELOADSTART
89    }
90}
91#[doc = "Field `RISEA` writer - Timer Rising Input Edge Action"]
92pub type RISEA_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u32, CTRL_SPEC, u8, RISEA_A, 2, O>;
93impl<'a, const O: u8> RISEA_W<'a, O> {
94    #[doc = "No action"]
95    #[inline(always)]
96    pub fn none(self) -> &'a mut W {
97        self.variant(RISEA_A::NONE)
98    }
99    #[doc = "Start counter without reload"]
100    #[inline(always)]
101    pub fn start(self) -> &'a mut W {
102        self.variant(RISEA_A::START)
103    }
104    #[doc = "Stop counter without reload"]
105    #[inline(always)]
106    pub fn stop(self) -> &'a mut W {
107        self.variant(RISEA_A::STOP)
108    }
109    #[doc = "Reload and start counter"]
110    #[inline(always)]
111    pub fn reloadstart(self) -> &'a mut W {
112        self.variant(RISEA_A::RELOADSTART)
113    }
114}
115#[doc = "Field `FALLA` reader - Timer Falling Input Edge Action"]
116pub type FALLA_R = crate::FieldReader<u8, FALLA_A>;
117#[doc = "Timer Falling Input Edge Action\n\nValue on reset: 0"]
118#[derive(Clone, Copy, Debug, PartialEq, Eq)]
119#[repr(u8)]
120pub enum FALLA_A {
121    #[doc = "0: No action"]
122    NONE = 0,
123    #[doc = "1: Start counter without reload"]
124    START = 1,
125    #[doc = "2: Stop counter without reload"]
126    STOP = 2,
127    #[doc = "3: Reload and start counter"]
128    RELOADSTART = 3,
129}
130impl From<FALLA_A> for u8 {
131    #[inline(always)]
132    fn from(variant: FALLA_A) -> Self {
133        variant as _
134    }
135}
136impl FALLA_R {
137    #[doc = "Get enumerated values variant"]
138    #[inline(always)]
139    pub fn variant(&self) -> FALLA_A {
140        match self.bits {
141            0 => FALLA_A::NONE,
142            1 => FALLA_A::START,
143            2 => FALLA_A::STOP,
144            3 => FALLA_A::RELOADSTART,
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 == FALLA_A::NONE
152    }
153    #[doc = "Checks if the value of the field is `START`"]
154    #[inline(always)]
155    pub fn is_start(&self) -> bool {
156        *self == FALLA_A::START
157    }
158    #[doc = "Checks if the value of the field is `STOP`"]
159    #[inline(always)]
160    pub fn is_stop(&self) -> bool {
161        *self == FALLA_A::STOP
162    }
163    #[doc = "Checks if the value of the field is `RELOADSTART`"]
164    #[inline(always)]
165    pub fn is_reloadstart(&self) -> bool {
166        *self == FALLA_A::RELOADSTART
167    }
168}
169#[doc = "Field `FALLA` writer - Timer Falling Input Edge Action"]
170pub type FALLA_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u32, CTRL_SPEC, u8, FALLA_A, 2, O>;
171impl<'a, const O: u8> FALLA_W<'a, O> {
172    #[doc = "No action"]
173    #[inline(always)]
174    pub fn none(self) -> &'a mut W {
175        self.variant(FALLA_A::NONE)
176    }
177    #[doc = "Start counter without reload"]
178    #[inline(always)]
179    pub fn start(self) -> &'a mut W {
180        self.variant(FALLA_A::START)
181    }
182    #[doc = "Stop counter without reload"]
183    #[inline(always)]
184    pub fn stop(self) -> &'a mut W {
185        self.variant(FALLA_A::STOP)
186    }
187    #[doc = "Reload and start counter"]
188    #[inline(always)]
189    pub fn reloadstart(self) -> &'a mut W {
190        self.variant(FALLA_A::RELOADSTART)
191    }
192}
193#[doc = "Field `X2CNT` reader - 2x Count Mode"]
194pub type X2CNT_R = crate::BitReader<bool>;
195#[doc = "Field `X2CNT` writer - 2x Count Mode"]
196pub type X2CNT_W<'a, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
197impl R {
198    #[doc = "Bits 0:1 - Timer Rising Input Edge Action"]
199    #[inline(always)]
200    pub fn risea(&self) -> RISEA_R {
201        RISEA_R::new((self.bits & 3) as u8)
202    }
203    #[doc = "Bits 2:3 - Timer Falling Input Edge Action"]
204    #[inline(always)]
205    pub fn falla(&self) -> FALLA_R {
206        FALLA_R::new(((self.bits >> 2) & 3) as u8)
207    }
208    #[doc = "Bit 4 - 2x Count Mode"]
209    #[inline(always)]
210    pub fn x2cnt(&self) -> X2CNT_R {
211        X2CNT_R::new(((self.bits >> 4) & 1) != 0)
212    }
213}
214impl W {
215    #[doc = "Bits 0:1 - Timer Rising Input Edge Action"]
216    #[inline(always)]
217    #[must_use]
218    pub fn risea(&mut self) -> RISEA_W<0> {
219        RISEA_W::new(self)
220    }
221    #[doc = "Bits 2:3 - Timer Falling Input Edge Action"]
222    #[inline(always)]
223    #[must_use]
224    pub fn falla(&mut self) -> FALLA_W<2> {
225        FALLA_W::new(self)
226    }
227    #[doc = "Bit 4 - 2x Count Mode"]
228    #[inline(always)]
229    #[must_use]
230    pub fn x2cnt(&mut self) -> X2CNT_W<4> {
231        X2CNT_W::new(self)
232    }
233    #[doc = "Writes raw bits to the register."]
234    #[inline(always)]
235    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
236        self.0.bits(bits);
237        self
238    }
239}
240#[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 [ctrl](index.html) module"]
241pub struct CTRL_SPEC;
242impl crate::RegisterSpec for CTRL_SPEC {
243    type Ux = u32;
244}
245#[doc = "`read()` method returns [ctrl::R](R) reader structure"]
246impl crate::Readable for CTRL_SPEC {
247    type Reader = R;
248}
249#[doc = "`write(|w| ..)` method takes [ctrl::W](W) writer structure"]
250impl crate::Writable for CTRL_SPEC {
251    type Writer = W;
252    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
253    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
254}
255#[doc = "`reset()` method sets CTRL to value 0"]
256impl crate::Resettable for CTRL_SPEC {
257    const RESET_VALUE: Self::Ux = 0;
258}