ra6m2/gpt32eh0/
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 crest) (single buffer or double buffer possible)"]
102    _100 = 4,
103    #[doc = "5: Triangle-wave PWM mode 2 (32-bit transfer at crest and trough) (single buffer or double buffer 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 crest) (single buffer or double buffer 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 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: PCLK/1"]
224    _000 = 0,
225    #[doc = "1: PCLK/4"]
226    _001 = 1,
227    #[doc = "2: PCLK/16"]
228    _010 = 2,
229    #[doc = "3: PCLK/64"]
230    _011 = 3,
231    #[doc = "4: PCLK/256"]
232    _100 = 4,
233    #[doc = "5: PCLK/1024"]
234    _101 = 5,
235}
236impl From<TPCS_A> for u8 {
237    #[inline(always)]
238    fn from(variant: TPCS_A) -> Self {
239        variant as _
240    }
241}
242impl TPCS_R {
243    #[doc = "Get enumerated values variant"]
244    #[inline(always)]
245    pub fn variant(&self) -> Option<TPCS_A> {
246        match self.bits {
247            0 => Some(TPCS_A::_000),
248            1 => Some(TPCS_A::_001),
249            2 => Some(TPCS_A::_010),
250            3 => Some(TPCS_A::_011),
251            4 => Some(TPCS_A::_100),
252            5 => Some(TPCS_A::_101),
253            _ => None,
254        }
255    }
256    #[doc = "Checks if the value of the field is `_000`"]
257    #[inline(always)]
258    pub fn is_000(&self) -> bool {
259        *self == TPCS_A::_000
260    }
261    #[doc = "Checks if the value of the field is `_001`"]
262    #[inline(always)]
263    pub fn is_001(&self) -> bool {
264        *self == TPCS_A::_001
265    }
266    #[doc = "Checks if the value of the field is `_010`"]
267    #[inline(always)]
268    pub fn is_010(&self) -> bool {
269        *self == TPCS_A::_010
270    }
271    #[doc = "Checks if the value of the field is `_011`"]
272    #[inline(always)]
273    pub fn is_011(&self) -> bool {
274        *self == TPCS_A::_011
275    }
276    #[doc = "Checks if the value of the field is `_100`"]
277    #[inline(always)]
278    pub fn is_100(&self) -> bool {
279        *self == TPCS_A::_100
280    }
281    #[doc = "Checks if the value of the field is `_101`"]
282    #[inline(always)]
283    pub fn is_101(&self) -> bool {
284        *self == TPCS_A::_101
285    }
286}
287#[doc = "Field `TPCS` writer - Timer Prescaler Select"]
288pub type TPCS_W<'a, const O: u8> = crate::FieldWriter<'a, u32, GTCR_SPEC, u8, TPCS_A, 3, O>;
289impl<'a, const O: u8> TPCS_W<'a, O> {
290    #[doc = "PCLK/1"]
291    #[inline(always)]
292    pub fn _000(self) -> &'a mut W {
293        self.variant(TPCS_A::_000)
294    }
295    #[doc = "PCLK/4"]
296    #[inline(always)]
297    pub fn _001(self) -> &'a mut W {
298        self.variant(TPCS_A::_001)
299    }
300    #[doc = "PCLK/16"]
301    #[inline(always)]
302    pub fn _010(self) -> &'a mut W {
303        self.variant(TPCS_A::_010)
304    }
305    #[doc = "PCLK/64"]
306    #[inline(always)]
307    pub fn _011(self) -> &'a mut W {
308        self.variant(TPCS_A::_011)
309    }
310    #[doc = "PCLK/256"]
311    #[inline(always)]
312    pub fn _100(self) -> &'a mut W {
313        self.variant(TPCS_A::_100)
314    }
315    #[doc = "PCLK/1024"]
316    #[inline(always)]
317    pub fn _101(self) -> &'a mut W {
318        self.variant(TPCS_A::_101)
319    }
320}
321impl R {
322    #[doc = "Bit 0 - Count Start"]
323    #[inline(always)]
324    pub fn cst(&self) -> CST_R {
325        CST_R::new((self.bits & 1) != 0)
326    }
327    #[doc = "Bits 16:18 - Mode Select"]
328    #[inline(always)]
329    pub fn md(&self) -> MD_R {
330        MD_R::new(((self.bits >> 16) & 7) as u8)
331    }
332    #[doc = "Bits 24:26 - Timer Prescaler Select"]
333    #[inline(always)]
334    pub fn tpcs(&self) -> TPCS_R {
335        TPCS_R::new(((self.bits >> 24) & 7) as u8)
336    }
337}
338impl W {
339    #[doc = "Bit 0 - Count Start"]
340    #[inline(always)]
341    #[must_use]
342    pub fn cst(&mut self) -> CST_W<0> {
343        CST_W::new(self)
344    }
345    #[doc = "Bits 16:18 - Mode Select"]
346    #[inline(always)]
347    #[must_use]
348    pub fn md(&mut self) -> MD_W<16> {
349        MD_W::new(self)
350    }
351    #[doc = "Bits 24:26 - Timer Prescaler Select"]
352    #[inline(always)]
353    #[must_use]
354    pub fn tpcs(&mut self) -> TPCS_W<24> {
355        TPCS_W::new(self)
356    }
357    #[doc = "Writes raw bits to the register."]
358    #[inline(always)]
359    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
360        self.0.bits(bits);
361        self
362    }
363}
364#[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"]
365pub struct GTCR_SPEC;
366impl crate::RegisterSpec for GTCR_SPEC {
367    type Ux = u32;
368}
369#[doc = "`read()` method returns [gtcr::R](R) reader structure"]
370impl crate::Readable for GTCR_SPEC {
371    type Reader = R;
372}
373#[doc = "`write(|w| ..)` method takes [gtcr::W](W) writer structure"]
374impl crate::Writable for GTCR_SPEC {
375    type Writer = W;
376    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
377    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
378}
379#[doc = "`reset()` method sets GTCR to value 0"]
380impl crate::Resettable for GTCR_SPEC {
381    const RESET_VALUE: Self::Ux = 0;
382}