ra6t2/gpt320/
gtpc.rs

1#[doc = "Register `GTPC` reader"]
2pub struct R(crate::R<GTPC_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<GTPC_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<GTPC_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<GTPC_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `GTPC` writer"]
17pub struct W(crate::W<GTPC_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<GTPC_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<GTPC_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<GTPC_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `PCEN` reader - Period Count Function Enable"]
38pub type PCEN_R = crate::BitReader<PCEN_A>;
39#[doc = "Period Count Function Enable\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41pub enum PCEN_A {
42    #[doc = "0: Period count function is disabled"]
43    _0 = 0,
44    #[doc = "1: Period count function is enabled"]
45    _1 = 1,
46}
47impl From<PCEN_A> for bool {
48    #[inline(always)]
49    fn from(variant: PCEN_A) -> Self {
50        variant as u8 != 0
51    }
52}
53impl PCEN_R {
54    #[doc = "Get enumerated values variant"]
55    #[inline(always)]
56    pub fn variant(&self) -> PCEN_A {
57        match self.bits {
58            false => PCEN_A::_0,
59            true => PCEN_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 == PCEN_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 == PCEN_A::_1
71    }
72}
73#[doc = "Field `PCEN` writer - Period Count Function Enable"]
74pub type PCEN_W<'a, const O: u8> = crate::BitWriter<'a, u32, GTPC_SPEC, PCEN_A, O>;
75impl<'a, const O: u8> PCEN_W<'a, O> {
76    #[doc = "Period count function is disabled"]
77    #[inline(always)]
78    pub fn _0(self) -> &'a mut W {
79        self.variant(PCEN_A::_0)
80    }
81    #[doc = "Period count function is enabled"]
82    #[inline(always)]
83    pub fn _1(self) -> &'a mut W {
84        self.variant(PCEN_A::_1)
85    }
86}
87#[doc = "Field `ASTP` reader - Automatic Stop Function Enable"]
88pub type ASTP_R = crate::BitReader<ASTP_A>;
89#[doc = "Automatic Stop Function Enable\n\nValue on reset: 0"]
90#[derive(Clone, Copy, Debug, PartialEq, Eq)]
91pub enum ASTP_A {
92    #[doc = "0: Automatic stop function is disabled"]
93    _0 = 0,
94    #[doc = "1: Automatic stop function is enabled"]
95    _1 = 1,
96}
97impl From<ASTP_A> for bool {
98    #[inline(always)]
99    fn from(variant: ASTP_A) -> Self {
100        variant as u8 != 0
101    }
102}
103impl ASTP_R {
104    #[doc = "Get enumerated values variant"]
105    #[inline(always)]
106    pub fn variant(&self) -> ASTP_A {
107        match self.bits {
108            false => ASTP_A::_0,
109            true => ASTP_A::_1,
110        }
111    }
112    #[doc = "Checks if the value of the field is `_0`"]
113    #[inline(always)]
114    pub fn is_0(&self) -> bool {
115        *self == ASTP_A::_0
116    }
117    #[doc = "Checks if the value of the field is `_1`"]
118    #[inline(always)]
119    pub fn is_1(&self) -> bool {
120        *self == ASTP_A::_1
121    }
122}
123#[doc = "Field `ASTP` writer - Automatic Stop Function Enable"]
124pub type ASTP_W<'a, const O: u8> = crate::BitWriter<'a, u32, GTPC_SPEC, ASTP_A, O>;
125impl<'a, const O: u8> ASTP_W<'a, O> {
126    #[doc = "Automatic stop function is disabled"]
127    #[inline(always)]
128    pub fn _0(self) -> &'a mut W {
129        self.variant(ASTP_A::_0)
130    }
131    #[doc = "Automatic stop function is enabled"]
132    #[inline(always)]
133    pub fn _1(self) -> &'a mut W {
134        self.variant(ASTP_A::_1)
135    }
136}
137#[doc = "Field `PCNT` reader - Period Counter"]
138pub type PCNT_R = crate::FieldReader<u16, u16>;
139#[doc = "Field `PCNT` writer - Period Counter"]
140pub type PCNT_W<'a, const O: u8> = crate::FieldWriter<'a, u32, GTPC_SPEC, u16, u16, 12, O>;
141impl R {
142    #[doc = "Bit 0 - Period Count Function Enable"]
143    #[inline(always)]
144    pub fn pcen(&self) -> PCEN_R {
145        PCEN_R::new((self.bits & 1) != 0)
146    }
147    #[doc = "Bit 8 - Automatic Stop Function Enable"]
148    #[inline(always)]
149    pub fn astp(&self) -> ASTP_R {
150        ASTP_R::new(((self.bits >> 8) & 1) != 0)
151    }
152    #[doc = "Bits 16:27 - Period Counter"]
153    #[inline(always)]
154    pub fn pcnt(&self) -> PCNT_R {
155        PCNT_R::new(((self.bits >> 16) & 0x0fff) as u16)
156    }
157}
158impl W {
159    #[doc = "Bit 0 - Period Count Function Enable"]
160    #[inline(always)]
161    #[must_use]
162    pub fn pcen(&mut self) -> PCEN_W<0> {
163        PCEN_W::new(self)
164    }
165    #[doc = "Bit 8 - Automatic Stop Function Enable"]
166    #[inline(always)]
167    #[must_use]
168    pub fn astp(&mut self) -> ASTP_W<8> {
169        ASTP_W::new(self)
170    }
171    #[doc = "Bits 16:27 - Period Counter"]
172    #[inline(always)]
173    #[must_use]
174    pub fn pcnt(&mut self) -> PCNT_W<16> {
175        PCNT_W::new(self)
176    }
177    #[doc = "Writes raw bits to the register."]
178    #[inline(always)]
179    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
180        self.0.bits(bits);
181        self
182    }
183}
184#[doc = "General PWM Timer Period Count 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 [gtpc](index.html) module"]
185pub struct GTPC_SPEC;
186impl crate::RegisterSpec for GTPC_SPEC {
187    type Ux = u32;
188}
189#[doc = "`read()` method returns [gtpc::R](R) reader structure"]
190impl crate::Readable for GTPC_SPEC {
191    type Reader = R;
192}
193#[doc = "`write(|w| ..)` method takes [gtpc::W](W) writer structure"]
194impl crate::Writable for GTPC_SPEC {
195    type Writer = W;
196    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
197    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
198}
199#[doc = "`reset()` method sets GTPC to value 0"]
200impl crate::Resettable for GTPC_SPEC {
201    const RESET_VALUE: Self::Ux = 0;
202}