ra6m4/gpt320/
gtcr.rs

1#[doc = "Register `GTCR` reader"]
2pub struct R(crate::R<GTCR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<GTCR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<GTCR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<GTCR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `GTCR` writer"]
17pub struct W(crate::W<GTCR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<GTCR_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<GTCR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<GTCR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `CST` reader - Count Start"]
38pub type CST_R = crate::BitReader<CST_A>;
39#[doc = "Count Start\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41pub enum CST_A {
42    #[doc = "0: Count operation is stopped"]
43    _0 = 0,
44    #[doc = "1: Count operation is performed"]
45    _1 = 1,
46}
47impl From<CST_A> for bool {
48    #[inline(always)]
49    fn from(variant: CST_A) -> Self {
50        variant as u8 != 0
51    }
52}
53impl CST_R {
54    #[doc = "Get enumerated values variant"]
55    #[inline(always)]
56    pub fn variant(&self) -> CST_A {
57        match self.bits {
58            false => CST_A::_0,
59            true => CST_A::_1,
60        }
61    }
62    #[doc = "Checks if the value of the field is `_0`"]
63    #[inline(always)]
64    pub fn is_0(&self) -> bool {
65        *self == CST_A::_0
66    }
67    #[doc = "Checks if the value of the field is `_1`"]
68    #[inline(always)]
69    pub fn is_1(&self) -> bool {
70        *self == CST_A::_1
71    }
72}
73#[doc = "Field `CST` writer - Count Start"]
74pub type CST_W<'a, const O: u8> = crate::BitWriter<'a, u32, GTCR_SPEC, CST_A, O>;
75impl<'a, const O: u8> CST_W<'a, O> {
76    #[doc = "Count operation is stopped"]
77    #[inline(always)]
78    pub fn _0(self) -> &'a mut W {
79        self.variant(CST_A::_0)
80    }
81    #[doc = "Count operation is performed"]
82    #[inline(always)]
83    pub fn _1(self) -> &'a mut W {
84        self.variant(CST_A::_1)
85    }
86}
87#[doc = "Field `MD` reader - Mode Select"]
88pub type MD_R = crate::FieldReader<u8, MD_A>;
89#[doc = "Mode Select\n\nValue on reset: 0"]
90#[derive(Clone, Copy, Debug, PartialEq, Eq)]
91#[repr(u8)]
92pub enum MD_A {
93    #[doc = "0: Saw-wave PWM mode (single buffer or double buffer possible)"]
94    _000 = 0,
95    #[doc = "1: Saw-wave one-shot pulse mode (fixed buffer operation)"]
96    _001 = 1,
97    #[doc = "2: Setting prohibited"]
98    _010 = 2,
99    #[doc = "3: Setting prohibited"]
100    _011 = 3,
101    #[doc = "4: Triangle-wave PWM mode 1 (32-bit transfer at trough) (single buffer or double buffer is possible)"]
102    _100 = 4,
103    #[doc = "5: Triangle-wave PWM mode 2 (32-bit transfer at crest and trough) (single buffer or double buffer is possible)"]
104    _101 = 5,
105    #[doc = "6: Triangle-wave PWM mode 3 (64-bit transfer at trough) (fixed buffer operation)"]
106    _110 = 6,
107    #[doc = "7: Setting prohibited"]
108    _111 = 7,
109}
110impl From<MD_A> for u8 {
111    #[inline(always)]
112    fn from(variant: MD_A) -> Self {
113        variant as _
114    }
115}
116impl MD_R {
117    #[doc = "Get enumerated values variant"]
118    #[inline(always)]
119    pub fn variant(&self) -> MD_A {
120        match self.bits {
121            0 => MD_A::_000,
122            1 => MD_A::_001,
123            2 => MD_A::_010,
124            3 => MD_A::_011,
125            4 => MD_A::_100,
126            5 => MD_A::_101,
127            6 => MD_A::_110,
128            7 => MD_A::_111,
129            _ => unreachable!(),
130        }
131    }
132    #[doc = "Checks if the value of the field is `_000`"]
133    #[inline(always)]
134    pub fn is_000(&self) -> bool {
135        *self == MD_A::_000
136    }
137    #[doc = "Checks if the value of the field is `_001`"]
138    #[inline(always)]
139    pub fn is_001(&self) -> bool {
140        *self == MD_A::_001
141    }
142    #[doc = "Checks if the value of the field is `_010`"]
143    #[inline(always)]
144    pub fn is_010(&self) -> bool {
145        *self == MD_A::_010
146    }
147    #[doc = "Checks if the value of the field is `_011`"]
148    #[inline(always)]
149    pub fn is_011(&self) -> bool {
150        *self == MD_A::_011
151    }
152    #[doc = "Checks if the value of the field is `_100`"]
153    #[inline(always)]
154    pub fn is_100(&self) -> bool {
155        *self == MD_A::_100
156    }
157    #[doc = "Checks if the value of the field is `_101`"]
158    #[inline(always)]
159    pub fn is_101(&self) -> bool {
160        *self == MD_A::_101
161    }
162    #[doc = "Checks if the value of the field is `_110`"]
163    #[inline(always)]
164    pub fn is_110(&self) -> bool {
165        *self == MD_A::_110
166    }
167    #[doc = "Checks if the value of the field is `_111`"]
168    #[inline(always)]
169    pub fn is_111(&self) -> bool {
170        *self == MD_A::_111
171    }
172}
173#[doc = "Field `MD` writer - Mode Select"]
174pub type MD_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u32, GTCR_SPEC, u8, MD_A, 3, O>;
175impl<'a, const O: u8> MD_W<'a, O> {
176    #[doc = "Saw-wave PWM mode (single buffer or double buffer possible)"]
177    #[inline(always)]
178    pub fn _000(self) -> &'a mut W {
179        self.variant(MD_A::_000)
180    }
181    #[doc = "Saw-wave one-shot pulse mode (fixed buffer operation)"]
182    #[inline(always)]
183    pub fn _001(self) -> &'a mut W {
184        self.variant(MD_A::_001)
185    }
186    #[doc = "Setting prohibited"]
187    #[inline(always)]
188    pub fn _010(self) -> &'a mut W {
189        self.variant(MD_A::_010)
190    }
191    #[doc = "Setting prohibited"]
192    #[inline(always)]
193    pub fn _011(self) -> &'a mut W {
194        self.variant(MD_A::_011)
195    }
196    #[doc = "Triangle-wave PWM mode 1 (32-bit transfer at trough) (single buffer or double buffer is possible)"]
197    #[inline(always)]
198    pub fn _100(self) -> &'a mut W {
199        self.variant(MD_A::_100)
200    }
201    #[doc = "Triangle-wave PWM mode 2 (32-bit transfer at crest and trough) (single buffer or double buffer is possible)"]
202    #[inline(always)]
203    pub fn _101(self) -> &'a mut W {
204        self.variant(MD_A::_101)
205    }
206    #[doc = "Triangle-wave PWM mode 3 (64-bit transfer at trough) (fixed buffer operation)"]
207    #[inline(always)]
208    pub fn _110(self) -> &'a mut W {
209        self.variant(MD_A::_110)
210    }
211    #[doc = "Setting prohibited"]
212    #[inline(always)]
213    pub fn _111(self) -> &'a mut W {
214        self.variant(MD_A::_111)
215    }
216}
217#[doc = "Field `TPCS` reader - Timer Prescaler Select"]
218pub type TPCS_R = crate::FieldReader<u8, TPCS_A>;
219#[doc = "Timer Prescaler Select\n\nValue on reset: 0"]
220#[derive(Clone, Copy, Debug, PartialEq, Eq)]
221#[repr(u8)]
222pub enum TPCS_A {
223    #[doc = "0: PCLKD/1"]
224    _0X0 = 0,
225    #[doc = "1: PCLKD/2"]
226    _0X1 = 1,
227    #[doc = "2: PCLKD/4"]
228    _0X2 = 2,
229    #[doc = "3: PCLKD/8"]
230    _0X3 = 3,
231    #[doc = "4: PCLKD/16"]
232    _0X4 = 4,
233    #[doc = "5: PCLKD/32"]
234    _0X5 = 5,
235    #[doc = "6: PCLKD/64"]
236    _0X6 = 6,
237    #[doc = "7: Setting prohibited"]
238    _0X7 = 7,
239    #[doc = "8: PCLKD/256"]
240    _0X8 = 8,
241    #[doc = "9: Setting prohibited"]
242    _0X9 = 9,
243    #[doc = "10: PCLKD/1024"]
244    _0X_A = 10,
245    #[doc = "11: Setting prohibited"]
246    _0X_B = 11,
247    #[doc = "12: GTETRGA (Via the POEG)"]
248    _0X_C = 12,
249    #[doc = "13: GTETRGB (Via the POEG)"]
250    _0X_D = 13,
251    #[doc = "14: GTETRGC (Via the POEG)"]
252    _0X_E = 14,
253    #[doc = "15: GTETRGD (Via the POEG)"]
254    _0X_F = 15,
255}
256impl From<TPCS_A> for u8 {
257    #[inline(always)]
258    fn from(variant: TPCS_A) -> Self {
259        variant as _
260    }
261}
262impl TPCS_R {
263    #[doc = "Get enumerated values variant"]
264    #[inline(always)]
265    pub fn variant(&self) -> TPCS_A {
266        match self.bits {
267            0 => TPCS_A::_0X0,
268            1 => TPCS_A::_0X1,
269            2 => TPCS_A::_0X2,
270            3 => TPCS_A::_0X3,
271            4 => TPCS_A::_0X4,
272            5 => TPCS_A::_0X5,
273            6 => TPCS_A::_0X6,
274            7 => TPCS_A::_0X7,
275            8 => TPCS_A::_0X8,
276            9 => TPCS_A::_0X9,
277            10 => TPCS_A::_0X_A,
278            11 => TPCS_A::_0X_B,
279            12 => TPCS_A::_0X_C,
280            13 => TPCS_A::_0X_D,
281            14 => TPCS_A::_0X_E,
282            15 => TPCS_A::_0X_F,
283            _ => unreachable!(),
284        }
285    }
286    #[doc = "Checks if the value of the field is `_0X0`"]
287    #[inline(always)]
288    pub fn is_0x0(&self) -> bool {
289        *self == TPCS_A::_0X0
290    }
291    #[doc = "Checks if the value of the field is `_0X1`"]
292    #[inline(always)]
293    pub fn is_0x1(&self) -> bool {
294        *self == TPCS_A::_0X1
295    }
296    #[doc = "Checks if the value of the field is `_0X2`"]
297    #[inline(always)]
298    pub fn is_0x2(&self) -> bool {
299        *self == TPCS_A::_0X2
300    }
301    #[doc = "Checks if the value of the field is `_0X3`"]
302    #[inline(always)]
303    pub fn is_0x3(&self) -> bool {
304        *self == TPCS_A::_0X3
305    }
306    #[doc = "Checks if the value of the field is `_0X4`"]
307    #[inline(always)]
308    pub fn is_0x4(&self) -> bool {
309        *self == TPCS_A::_0X4
310    }
311    #[doc = "Checks if the value of the field is `_0X5`"]
312    #[inline(always)]
313    pub fn is_0x5(&self) -> bool {
314        *self == TPCS_A::_0X5
315    }
316    #[doc = "Checks if the value of the field is `_0X6`"]
317    #[inline(always)]
318    pub fn is_0x6(&self) -> bool {
319        *self == TPCS_A::_0X6
320    }
321    #[doc = "Checks if the value of the field is `_0X7`"]
322    #[inline(always)]
323    pub fn is_0x7(&self) -> bool {
324        *self == TPCS_A::_0X7
325    }
326    #[doc = "Checks if the value of the field is `_0X8`"]
327    #[inline(always)]
328    pub fn is_0x8(&self) -> bool {
329        *self == TPCS_A::_0X8
330    }
331    #[doc = "Checks if the value of the field is `_0X9`"]
332    #[inline(always)]
333    pub fn is_0x9(&self) -> bool {
334        *self == TPCS_A::_0X9
335    }
336    #[doc = "Checks if the value of the field is `_0X_A`"]
337    #[inline(always)]
338    pub fn is_0x_a(&self) -> bool {
339        *self == TPCS_A::_0X_A
340    }
341    #[doc = "Checks if the value of the field is `_0X_B`"]
342    #[inline(always)]
343    pub fn is_0x_b(&self) -> bool {
344        *self == TPCS_A::_0X_B
345    }
346    #[doc = "Checks if the value of the field is `_0X_C`"]
347    #[inline(always)]
348    pub fn is_0x_c(&self) -> bool {
349        *self == TPCS_A::_0X_C
350    }
351    #[doc = "Checks if the value of the field is `_0X_D`"]
352    #[inline(always)]
353    pub fn is_0x_d(&self) -> bool {
354        *self == TPCS_A::_0X_D
355    }
356    #[doc = "Checks if the value of the field is `_0X_E`"]
357    #[inline(always)]
358    pub fn is_0x_e(&self) -> bool {
359        *self == TPCS_A::_0X_E
360    }
361    #[doc = "Checks if the value of the field is `_0X_F`"]
362    #[inline(always)]
363    pub fn is_0x_f(&self) -> bool {
364        *self == TPCS_A::_0X_F
365    }
366}
367#[doc = "Field `TPCS` writer - Timer Prescaler Select"]
368pub type TPCS_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u32, GTCR_SPEC, u8, TPCS_A, 4, O>;
369impl<'a, const O: u8> TPCS_W<'a, O> {
370    #[doc = "PCLKD/1"]
371    #[inline(always)]
372    pub fn _0x0(self) -> &'a mut W {
373        self.variant(TPCS_A::_0X0)
374    }
375    #[doc = "PCLKD/2"]
376    #[inline(always)]
377    pub fn _0x1(self) -> &'a mut W {
378        self.variant(TPCS_A::_0X1)
379    }
380    #[doc = "PCLKD/4"]
381    #[inline(always)]
382    pub fn _0x2(self) -> &'a mut W {
383        self.variant(TPCS_A::_0X2)
384    }
385    #[doc = "PCLKD/8"]
386    #[inline(always)]
387    pub fn _0x3(self) -> &'a mut W {
388        self.variant(TPCS_A::_0X3)
389    }
390    #[doc = "PCLKD/16"]
391    #[inline(always)]
392    pub fn _0x4(self) -> &'a mut W {
393        self.variant(TPCS_A::_0X4)
394    }
395    #[doc = "PCLKD/32"]
396    #[inline(always)]
397    pub fn _0x5(self) -> &'a mut W {
398        self.variant(TPCS_A::_0X5)
399    }
400    #[doc = "PCLKD/64"]
401    #[inline(always)]
402    pub fn _0x6(self) -> &'a mut W {
403        self.variant(TPCS_A::_0X6)
404    }
405    #[doc = "Setting prohibited"]
406    #[inline(always)]
407    pub fn _0x7(self) -> &'a mut W {
408        self.variant(TPCS_A::_0X7)
409    }
410    #[doc = "PCLKD/256"]
411    #[inline(always)]
412    pub fn _0x8(self) -> &'a mut W {
413        self.variant(TPCS_A::_0X8)
414    }
415    #[doc = "Setting prohibited"]
416    #[inline(always)]
417    pub fn _0x9(self) -> &'a mut W {
418        self.variant(TPCS_A::_0X9)
419    }
420    #[doc = "PCLKD/1024"]
421    #[inline(always)]
422    pub fn _0x_a(self) -> &'a mut W {
423        self.variant(TPCS_A::_0X_A)
424    }
425    #[doc = "Setting prohibited"]
426    #[inline(always)]
427    pub fn _0x_b(self) -> &'a mut W {
428        self.variant(TPCS_A::_0X_B)
429    }
430    #[doc = "GTETRGA (Via the POEG)"]
431    #[inline(always)]
432    pub fn _0x_c(self) -> &'a mut W {
433        self.variant(TPCS_A::_0X_C)
434    }
435    #[doc = "GTETRGB (Via the POEG)"]
436    #[inline(always)]
437    pub fn _0x_d(self) -> &'a mut W {
438        self.variant(TPCS_A::_0X_D)
439    }
440    #[doc = "GTETRGC (Via the POEG)"]
441    #[inline(always)]
442    pub fn _0x_e(self) -> &'a mut W {
443        self.variant(TPCS_A::_0X_E)
444    }
445    #[doc = "GTETRGD (Via the POEG)"]
446    #[inline(always)]
447    pub fn _0x_f(self) -> &'a mut W {
448        self.variant(TPCS_A::_0X_F)
449    }
450}
451impl R {
452    #[doc = "Bit 0 - Count Start"]
453    #[inline(always)]
454    pub fn cst(&self) -> CST_R {
455        CST_R::new((self.bits & 1) != 0)
456    }
457    #[doc = "Bits 16:18 - Mode Select"]
458    #[inline(always)]
459    pub fn md(&self) -> MD_R {
460        MD_R::new(((self.bits >> 16) & 7) as u8)
461    }
462    #[doc = "Bits 23:26 - Timer Prescaler Select"]
463    #[inline(always)]
464    pub fn tpcs(&self) -> TPCS_R {
465        TPCS_R::new(((self.bits >> 23) & 0x0f) as u8)
466    }
467}
468impl W {
469    #[doc = "Bit 0 - Count Start"]
470    #[inline(always)]
471    #[must_use]
472    pub fn cst(&mut self) -> CST_W<0> {
473        CST_W::new(self)
474    }
475    #[doc = "Bits 16:18 - Mode Select"]
476    #[inline(always)]
477    #[must_use]
478    pub fn md(&mut self) -> MD_W<16> {
479        MD_W::new(self)
480    }
481    #[doc = "Bits 23:26 - Timer Prescaler Select"]
482    #[inline(always)]
483    #[must_use]
484    pub fn tpcs(&mut self) -> TPCS_W<23> {
485        TPCS_W::new(self)
486    }
487    #[doc = "Writes raw bits to the register."]
488    #[inline(always)]
489    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
490        self.0.bits(bits);
491        self
492    }
493}
494#[doc = "General PWM Timer 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 [gtcr](index.html) module"]
495pub struct GTCR_SPEC;
496impl crate::RegisterSpec for GTCR_SPEC {
497    type Ux = u32;
498}
499#[doc = "`read()` method returns [gtcr::R](R) reader structure"]
500impl crate::Readable for GTCR_SPEC {
501    type Reader = R;
502}
503#[doc = "`write(|w| ..)` method takes [gtcr::W](W) writer structure"]
504impl crate::Writable for GTCR_SPEC {
505    type Writer = W;
506    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
507    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
508}
509#[doc = "`reset()` method sets GTCR to value 0"]
510impl crate::Resettable for GTCR_SPEC {
511    const RESET_VALUE: Self::Ux = 0;
512}