Skip to main content

mcxa_pac/ctimer0/
tcr.rs

1#[doc = "Register `TCR` reader"]
2pub type R = crate::R<TcrSpec>;
3#[doc = "Register `TCR` writer"]
4pub type W = crate::W<TcrSpec>;
5#[doc = "Counter Enable\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum Cen {
9    #[doc = "0: Disable"]
10    Disabled = 0,
11    #[doc = "1: Enable"]
12    Enabled = 1,
13}
14impl From<Cen> for bool {
15    #[inline(always)]
16    fn from(variant: Cen) -> Self {
17        variant as u8 != 0
18    }
19}
20#[doc = "Field `CEN` reader - Counter Enable"]
21pub type CenR = crate::BitReader<Cen>;
22impl CenR {
23    #[doc = "Get enumerated values variant"]
24    #[inline(always)]
25    pub const fn variant(&self) -> Cen {
26        match self.bits {
27            false => Cen::Disabled,
28            true => Cen::Enabled,
29        }
30    }
31    #[doc = "Disable"]
32    #[inline(always)]
33    pub fn is_disabled(&self) -> bool {
34        *self == Cen::Disabled
35    }
36    #[doc = "Enable"]
37    #[inline(always)]
38    pub fn is_enabled(&self) -> bool {
39        *self == Cen::Enabled
40    }
41}
42#[doc = "Field `CEN` writer - Counter Enable"]
43pub type CenW<'a, REG> = crate::BitWriter<'a, REG, Cen>;
44impl<'a, REG> CenW<'a, REG>
45where
46    REG: crate::Writable + crate::RegisterSpec,
47{
48    #[doc = "Disable"]
49    #[inline(always)]
50    pub fn disabled(self) -> &'a mut crate::W<REG> {
51        self.variant(Cen::Disabled)
52    }
53    #[doc = "Enable"]
54    #[inline(always)]
55    pub fn enabled(self) -> &'a mut crate::W<REG> {
56        self.variant(Cen::Enabled)
57    }
58}
59#[doc = "Counter Reset Enable\n\nValue on reset: 0"]
60#[cfg_attr(feature = "defmt", derive(defmt::Format))]
61#[derive(Clone, Copy, Debug, PartialEq, Eq)]
62pub enum Crst {
63    #[doc = "0: Disable"]
64    Disabled = 0,
65    #[doc = "1: Enable"]
66    Enabled = 1,
67}
68impl From<Crst> for bool {
69    #[inline(always)]
70    fn from(variant: Crst) -> Self {
71        variant as u8 != 0
72    }
73}
74#[doc = "Field `CRST` reader - Counter Reset Enable"]
75pub type CrstR = crate::BitReader<Crst>;
76impl CrstR {
77    #[doc = "Get enumerated values variant"]
78    #[inline(always)]
79    pub const fn variant(&self) -> Crst {
80        match self.bits {
81            false => Crst::Disabled,
82            true => Crst::Enabled,
83        }
84    }
85    #[doc = "Disable"]
86    #[inline(always)]
87    pub fn is_disabled(&self) -> bool {
88        *self == Crst::Disabled
89    }
90    #[doc = "Enable"]
91    #[inline(always)]
92    pub fn is_enabled(&self) -> bool {
93        *self == Crst::Enabled
94    }
95}
96#[doc = "Field `CRST` writer - Counter Reset Enable"]
97pub type CrstW<'a, REG> = crate::BitWriter<'a, REG, Crst>;
98impl<'a, REG> CrstW<'a, REG>
99where
100    REG: crate::Writable + crate::RegisterSpec,
101{
102    #[doc = "Disable"]
103    #[inline(always)]
104    pub fn disabled(self) -> &'a mut crate::W<REG> {
105        self.variant(Crst::Disabled)
106    }
107    #[doc = "Enable"]
108    #[inline(always)]
109    pub fn enabled(self) -> &'a mut crate::W<REG> {
110        self.variant(Crst::Enabled)
111    }
112}
113#[doc = "Allow Global Count Enable\n\nValue on reset: 0"]
114#[cfg_attr(feature = "defmt", derive(defmt::Format))]
115#[derive(Clone, Copy, Debug, PartialEq, Eq)]
116pub enum Agcen {
117    #[doc = "0: Disable"]
118    Disable = 0,
119    #[doc = "1: Enable"]
120    Enable = 1,
121}
122impl From<Agcen> for bool {
123    #[inline(always)]
124    fn from(variant: Agcen) -> Self {
125        variant as u8 != 0
126    }
127}
128#[doc = "Field `AGCEN` reader - Allow Global Count Enable"]
129pub type AgcenR = crate::BitReader<Agcen>;
130impl AgcenR {
131    #[doc = "Get enumerated values variant"]
132    #[inline(always)]
133    pub const fn variant(&self) -> Agcen {
134        match self.bits {
135            false => Agcen::Disable,
136            true => Agcen::Enable,
137        }
138    }
139    #[doc = "Disable"]
140    #[inline(always)]
141    pub fn is_disable(&self) -> bool {
142        *self == Agcen::Disable
143    }
144    #[doc = "Enable"]
145    #[inline(always)]
146    pub fn is_enable(&self) -> bool {
147        *self == Agcen::Enable
148    }
149}
150#[doc = "Field `AGCEN` writer - Allow Global Count Enable"]
151pub type AgcenW<'a, REG> = crate::BitWriter<'a, REG, Agcen>;
152impl<'a, REG> AgcenW<'a, REG>
153where
154    REG: crate::Writable + crate::RegisterSpec,
155{
156    #[doc = "Disable"]
157    #[inline(always)]
158    pub fn disable(self) -> &'a mut crate::W<REG> {
159        self.variant(Agcen::Disable)
160    }
161    #[doc = "Enable"]
162    #[inline(always)]
163    pub fn enable(self) -> &'a mut crate::W<REG> {
164        self.variant(Agcen::Enable)
165    }
166}
167#[doc = "Allow Trigger Count Enable\n\nValue on reset: 0"]
168#[cfg_attr(feature = "defmt", derive(defmt::Format))]
169#[derive(Clone, Copy, Debug, PartialEq, Eq)]
170pub enum Atcen {
171    #[doc = "0: Disable"]
172    Disable = 0,
173    #[doc = "1: Enable"]
174    Enable = 1,
175}
176impl From<Atcen> for bool {
177    #[inline(always)]
178    fn from(variant: Atcen) -> Self {
179        variant as u8 != 0
180    }
181}
182#[doc = "Field `ATCEN` reader - Allow Trigger Count Enable"]
183pub type AtcenR = crate::BitReader<Atcen>;
184impl AtcenR {
185    #[doc = "Get enumerated values variant"]
186    #[inline(always)]
187    pub const fn variant(&self) -> Atcen {
188        match self.bits {
189            false => Atcen::Disable,
190            true => Atcen::Enable,
191        }
192    }
193    #[doc = "Disable"]
194    #[inline(always)]
195    pub fn is_disable(&self) -> bool {
196        *self == Atcen::Disable
197    }
198    #[doc = "Enable"]
199    #[inline(always)]
200    pub fn is_enable(&self) -> bool {
201        *self == Atcen::Enable
202    }
203}
204#[doc = "Field `ATCEN` writer - Allow Trigger Count Enable"]
205pub type AtcenW<'a, REG> = crate::BitWriter<'a, REG, Atcen>;
206impl<'a, REG> AtcenW<'a, REG>
207where
208    REG: crate::Writable + crate::RegisterSpec,
209{
210    #[doc = "Disable"]
211    #[inline(always)]
212    pub fn disable(self) -> &'a mut crate::W<REG> {
213        self.variant(Atcen::Disable)
214    }
215    #[doc = "Enable"]
216    #[inline(always)]
217    pub fn enable(self) -> &'a mut crate::W<REG> {
218        self.variant(Atcen::Enable)
219    }
220}
221impl R {
222    #[doc = "Bit 0 - Counter Enable"]
223    #[inline(always)]
224    pub fn cen(&self) -> CenR {
225        CenR::new((self.bits & 1) != 0)
226    }
227    #[doc = "Bit 1 - Counter Reset Enable"]
228    #[inline(always)]
229    pub fn crst(&self) -> CrstR {
230        CrstR::new(((self.bits >> 1) & 1) != 0)
231    }
232    #[doc = "Bit 4 - Allow Global Count Enable"]
233    #[inline(always)]
234    pub fn agcen(&self) -> AgcenR {
235        AgcenR::new(((self.bits >> 4) & 1) != 0)
236    }
237    #[doc = "Bit 5 - Allow Trigger Count Enable"]
238    #[inline(always)]
239    pub fn atcen(&self) -> AtcenR {
240        AtcenR::new(((self.bits >> 5) & 1) != 0)
241    }
242}
243#[cfg(feature = "debug")]
244impl core::fmt::Debug for R {
245    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
246        f.debug_struct("TCR")
247            .field("cen", &self.cen())
248            .field("crst", &self.crst())
249            .field("agcen", &self.agcen())
250            .field("atcen", &self.atcen())
251            .finish()
252    }
253}
254impl W {
255    #[doc = "Bit 0 - Counter Enable"]
256    #[inline(always)]
257    pub fn cen(&mut self) -> CenW<'_, TcrSpec> {
258        CenW::new(self, 0)
259    }
260    #[doc = "Bit 1 - Counter Reset Enable"]
261    #[inline(always)]
262    pub fn crst(&mut self) -> CrstW<'_, TcrSpec> {
263        CrstW::new(self, 1)
264    }
265    #[doc = "Bit 4 - Allow Global Count Enable"]
266    #[inline(always)]
267    pub fn agcen(&mut self) -> AgcenW<'_, TcrSpec> {
268        AgcenW::new(self, 4)
269    }
270    #[doc = "Bit 5 - Allow Trigger Count Enable"]
271    #[inline(always)]
272    pub fn atcen(&mut self) -> AtcenW<'_, TcrSpec> {
273        AtcenW::new(self, 5)
274    }
275}
276#[doc = "Timer Control\n\nYou can [`read`](crate::Reg::read) this register and get [`tcr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`tcr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
277pub struct TcrSpec;
278impl crate::RegisterSpec for TcrSpec {
279    type Ux = u32;
280}
281#[doc = "`read()` method returns [`tcr::R`](R) reader structure"]
282impl crate::Readable for TcrSpec {}
283#[doc = "`write(|w| ..)` method takes [`tcr::W`](W) writer structure"]
284impl crate::Writable for TcrSpec {
285    type Safety = crate::Unsafe;
286}
287#[doc = "`reset()` method sets TCR to value 0"]
288impl crate::Resettable for TcrSpec {}