ra4m2/sci1/
tmr.rs

1#[doc = "Register `TMR` reader"]
2pub struct R(crate::R<TMR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<TMR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<TMR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<TMR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `TMR` writer"]
17pub struct W(crate::W<TMR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<TMR_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<TMR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<TMR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `TOMS` reader - Timer Operating Mode Select"]
38pub type TOMS_R = crate::FieldReader<u8, TOMS_A>;
39#[doc = "Timer Operating Mode Select\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum TOMS_A {
43    #[doc = "0: Timer mode"]
44    _00 = 0,
45    #[doc = "1: Break Field low width determination mode"]
46    _01 = 1,
47    #[doc = "2: Break Field low width output mode"]
48    _10 = 2,
49    #[doc = "3: Setting prohibited"]
50    _11 = 3,
51}
52impl From<TOMS_A> for u8 {
53    #[inline(always)]
54    fn from(variant: TOMS_A) -> Self {
55        variant as _
56    }
57}
58impl TOMS_R {
59    #[doc = "Get enumerated values variant"]
60    #[inline(always)]
61    pub fn variant(&self) -> TOMS_A {
62        match self.bits {
63            0 => TOMS_A::_00,
64            1 => TOMS_A::_01,
65            2 => TOMS_A::_10,
66            3 => TOMS_A::_11,
67            _ => unreachable!(),
68        }
69    }
70    #[doc = "Checks if the value of the field is `_00`"]
71    #[inline(always)]
72    pub fn is_00(&self) -> bool {
73        *self == TOMS_A::_00
74    }
75    #[doc = "Checks if the value of the field is `_01`"]
76    #[inline(always)]
77    pub fn is_01(&self) -> bool {
78        *self == TOMS_A::_01
79    }
80    #[doc = "Checks if the value of the field is `_10`"]
81    #[inline(always)]
82    pub fn is_10(&self) -> bool {
83        *self == TOMS_A::_10
84    }
85    #[doc = "Checks if the value of the field is `_11`"]
86    #[inline(always)]
87    pub fn is_11(&self) -> bool {
88        *self == TOMS_A::_11
89    }
90}
91#[doc = "Field `TOMS` writer - Timer Operating Mode Select"]
92pub type TOMS_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u8, TMR_SPEC, u8, TOMS_A, 2, O>;
93impl<'a, const O: u8> TOMS_W<'a, O> {
94    #[doc = "Timer mode"]
95    #[inline(always)]
96    pub fn _00(self) -> &'a mut W {
97        self.variant(TOMS_A::_00)
98    }
99    #[doc = "Break Field low width determination mode"]
100    #[inline(always)]
101    pub fn _01(self) -> &'a mut W {
102        self.variant(TOMS_A::_01)
103    }
104    #[doc = "Break Field low width output mode"]
105    #[inline(always)]
106    pub fn _10(self) -> &'a mut W {
107        self.variant(TOMS_A::_10)
108    }
109    #[doc = "Setting prohibited"]
110    #[inline(always)]
111    pub fn _11(self) -> &'a mut W {
112        self.variant(TOMS_A::_11)
113    }
114}
115#[doc = "Field `TWRC` reader - Counter Write Control"]
116pub type TWRC_R = crate::BitReader<TWRC_A>;
117#[doc = "Counter Write Control\n\nValue on reset: 0"]
118#[derive(Clone, Copy, Debug, PartialEq, Eq)]
119pub enum TWRC_A {
120    #[doc = "0: Data is written to the reload register and counter"]
121    _0 = 0,
122    #[doc = "1: Data is written to the reload register only"]
123    _1 = 1,
124}
125impl From<TWRC_A> for bool {
126    #[inline(always)]
127    fn from(variant: TWRC_A) -> Self {
128        variant as u8 != 0
129    }
130}
131impl TWRC_R {
132    #[doc = "Get enumerated values variant"]
133    #[inline(always)]
134    pub fn variant(&self) -> TWRC_A {
135        match self.bits {
136            false => TWRC_A::_0,
137            true => TWRC_A::_1,
138        }
139    }
140    #[doc = "Checks if the value of the field is `_0`"]
141    #[inline(always)]
142    pub fn is_0(&self) -> bool {
143        *self == TWRC_A::_0
144    }
145    #[doc = "Checks if the value of the field is `_1`"]
146    #[inline(always)]
147    pub fn is_1(&self) -> bool {
148        *self == TWRC_A::_1
149    }
150}
151#[doc = "Field `TWRC` writer - Counter Write Control"]
152pub type TWRC_W<'a, const O: u8> = crate::BitWriter<'a, u8, TMR_SPEC, TWRC_A, O>;
153impl<'a, const O: u8> TWRC_W<'a, O> {
154    #[doc = "Data is written to the reload register and counter"]
155    #[inline(always)]
156    pub fn _0(self) -> &'a mut W {
157        self.variant(TWRC_A::_0)
158    }
159    #[doc = "Data is written to the reload register only"]
160    #[inline(always)]
161    pub fn _1(self) -> &'a mut W {
162        self.variant(TWRC_A::_1)
163    }
164}
165#[doc = "Field `TCSS` reader - Timer Count Clock Source Select"]
166pub type TCSS_R = crate::FieldReader<u8, TCSS_A>;
167#[doc = "Timer Count Clock Source Select\n\nValue on reset: 0"]
168#[derive(Clone, Copy, Debug, PartialEq, Eq)]
169#[repr(u8)]
170pub enum TCSS_A {
171    #[doc = "0: PCLK"]
172    _000 = 0,
173    #[doc = "1: PCLK/2"]
174    _001 = 1,
175    #[doc = "2: PCLK/4"]
176    _010 = 2,
177    #[doc = "3: PCLK/8"]
178    _011 = 3,
179    #[doc = "4: PCLK/16"]
180    _100 = 4,
181    #[doc = "5: PCLK/32"]
182    _101 = 5,
183    #[doc = "6: PCLK/64"]
184    _110 = 6,
185    #[doc = "7: PCLK/128"]
186    _111 = 7,
187}
188impl From<TCSS_A> for u8 {
189    #[inline(always)]
190    fn from(variant: TCSS_A) -> Self {
191        variant as _
192    }
193}
194impl TCSS_R {
195    #[doc = "Get enumerated values variant"]
196    #[inline(always)]
197    pub fn variant(&self) -> TCSS_A {
198        match self.bits {
199            0 => TCSS_A::_000,
200            1 => TCSS_A::_001,
201            2 => TCSS_A::_010,
202            3 => TCSS_A::_011,
203            4 => TCSS_A::_100,
204            5 => TCSS_A::_101,
205            6 => TCSS_A::_110,
206            7 => TCSS_A::_111,
207            _ => unreachable!(),
208        }
209    }
210    #[doc = "Checks if the value of the field is `_000`"]
211    #[inline(always)]
212    pub fn is_000(&self) -> bool {
213        *self == TCSS_A::_000
214    }
215    #[doc = "Checks if the value of the field is `_001`"]
216    #[inline(always)]
217    pub fn is_001(&self) -> bool {
218        *self == TCSS_A::_001
219    }
220    #[doc = "Checks if the value of the field is `_010`"]
221    #[inline(always)]
222    pub fn is_010(&self) -> bool {
223        *self == TCSS_A::_010
224    }
225    #[doc = "Checks if the value of the field is `_011`"]
226    #[inline(always)]
227    pub fn is_011(&self) -> bool {
228        *self == TCSS_A::_011
229    }
230    #[doc = "Checks if the value of the field is `_100`"]
231    #[inline(always)]
232    pub fn is_100(&self) -> bool {
233        *self == TCSS_A::_100
234    }
235    #[doc = "Checks if the value of the field is `_101`"]
236    #[inline(always)]
237    pub fn is_101(&self) -> bool {
238        *self == TCSS_A::_101
239    }
240    #[doc = "Checks if the value of the field is `_110`"]
241    #[inline(always)]
242    pub fn is_110(&self) -> bool {
243        *self == TCSS_A::_110
244    }
245    #[doc = "Checks if the value of the field is `_111`"]
246    #[inline(always)]
247    pub fn is_111(&self) -> bool {
248        *self == TCSS_A::_111
249    }
250}
251#[doc = "Field `TCSS` writer - Timer Count Clock Source Select"]
252pub type TCSS_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u8, TMR_SPEC, u8, TCSS_A, 3, O>;
253impl<'a, const O: u8> TCSS_W<'a, O> {
254    #[doc = "PCLK"]
255    #[inline(always)]
256    pub fn _000(self) -> &'a mut W {
257        self.variant(TCSS_A::_000)
258    }
259    #[doc = "PCLK/2"]
260    #[inline(always)]
261    pub fn _001(self) -> &'a mut W {
262        self.variant(TCSS_A::_001)
263    }
264    #[doc = "PCLK/4"]
265    #[inline(always)]
266    pub fn _010(self) -> &'a mut W {
267        self.variant(TCSS_A::_010)
268    }
269    #[doc = "PCLK/8"]
270    #[inline(always)]
271    pub fn _011(self) -> &'a mut W {
272        self.variant(TCSS_A::_011)
273    }
274    #[doc = "PCLK/16"]
275    #[inline(always)]
276    pub fn _100(self) -> &'a mut W {
277        self.variant(TCSS_A::_100)
278    }
279    #[doc = "PCLK/32"]
280    #[inline(always)]
281    pub fn _101(self) -> &'a mut W {
282        self.variant(TCSS_A::_101)
283    }
284    #[doc = "PCLK/64"]
285    #[inline(always)]
286    pub fn _110(self) -> &'a mut W {
287        self.variant(TCSS_A::_110)
288    }
289    #[doc = "PCLK/128"]
290    #[inline(always)]
291    pub fn _111(self) -> &'a mut W {
292        self.variant(TCSS_A::_111)
293    }
294}
295impl R {
296    #[doc = "Bits 0:1 - Timer Operating Mode Select"]
297    #[inline(always)]
298    pub fn toms(&self) -> TOMS_R {
299        TOMS_R::new(self.bits & 3)
300    }
301    #[doc = "Bit 3 - Counter Write Control"]
302    #[inline(always)]
303    pub fn twrc(&self) -> TWRC_R {
304        TWRC_R::new(((self.bits >> 3) & 1) != 0)
305    }
306    #[doc = "Bits 4:6 - Timer Count Clock Source Select"]
307    #[inline(always)]
308    pub fn tcss(&self) -> TCSS_R {
309        TCSS_R::new((self.bits >> 4) & 7)
310    }
311}
312impl W {
313    #[doc = "Bits 0:1 - Timer Operating Mode Select"]
314    #[inline(always)]
315    #[must_use]
316    pub fn toms(&mut self) -> TOMS_W<0> {
317        TOMS_W::new(self)
318    }
319    #[doc = "Bit 3 - Counter Write Control"]
320    #[inline(always)]
321    #[must_use]
322    pub fn twrc(&mut self) -> TWRC_W<3> {
323        TWRC_W::new(self)
324    }
325    #[doc = "Bits 4:6 - Timer Count Clock Source Select"]
326    #[inline(always)]
327    #[must_use]
328    pub fn tcss(&mut self) -> TCSS_W<4> {
329        TCSS_W::new(self)
330    }
331    #[doc = "Writes raw bits to the register."]
332    #[inline(always)]
333    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
334        self.0.bits(bits);
335        self
336    }
337}
338#[doc = "Timer Mode 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 [tmr](index.html) module"]
339pub struct TMR_SPEC;
340impl crate::RegisterSpec for TMR_SPEC {
341    type Ux = u8;
342}
343#[doc = "`read()` method returns [tmr::R](R) reader structure"]
344impl crate::Readable for TMR_SPEC {
345    type Reader = R;
346}
347#[doc = "`write(|w| ..)` method takes [tmr::W](W) writer structure"]
348impl crate::Writable for TMR_SPEC {
349    type Writer = W;
350    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
351    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
352}
353#[doc = "`reset()` method sets TMR to value 0"]
354impl crate::Resettable for TMR_SPEC {
355    const RESET_VALUE: Self::Ux = 0;
356}