ra4m1/agt0/
agtioc.rs

1#[doc = "Register `AGTIOC` reader"]
2pub struct R(crate::R<AGTIOC_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<AGTIOC_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<AGTIOC_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<AGTIOC_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `AGTIOC` writer"]
17pub struct W(crate::W<AGTIOC_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<AGTIOC_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<AGTIOC_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<AGTIOC_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `TEDGSEL` reader - I/O polarity switch Function varies depending on the operating mode."]
38pub type TEDGSEL_R = crate::BitReader<bool>;
39#[doc = "Field `TEDGSEL` writer - I/O polarity switch Function varies depending on the operating mode."]
40pub type TEDGSEL_W<'a, const O: u8> = crate::BitWriter<'a, u8, AGTIOC_SPEC, bool, O>;
41#[doc = "Field `TOE` reader - AGTOn output enable"]
42pub type TOE_R = crate::BitReader<TOE_A>;
43#[doc = "AGTOn output enable\n\nValue on reset: 0"]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45pub enum TOE_A {
46    #[doc = "0: AGTOn output disabled"]
47    _0 = 0,
48    #[doc = "1: AGTOn output enabled."]
49    _1 = 1,
50}
51impl From<TOE_A> for bool {
52    #[inline(always)]
53    fn from(variant: TOE_A) -> Self {
54        variant as u8 != 0
55    }
56}
57impl TOE_R {
58    #[doc = "Get enumerated values variant"]
59    #[inline(always)]
60    pub fn variant(&self) -> TOE_A {
61        match self.bits {
62            false => TOE_A::_0,
63            true => TOE_A::_1,
64        }
65    }
66    #[doc = "Checks if the value of the field is `_0`"]
67    #[inline(always)]
68    pub fn is_0(&self) -> bool {
69        *self == TOE_A::_0
70    }
71    #[doc = "Checks if the value of the field is `_1`"]
72    #[inline(always)]
73    pub fn is_1(&self) -> bool {
74        *self == TOE_A::_1
75    }
76}
77#[doc = "Field `TOE` writer - AGTOn output enable"]
78pub type TOE_W<'a, const O: u8> = crate::BitWriter<'a, u8, AGTIOC_SPEC, TOE_A, O>;
79impl<'a, const O: u8> TOE_W<'a, O> {
80    #[doc = "AGTOn output disabled"]
81    #[inline(always)]
82    pub fn _0(self) -> &'a mut W {
83        self.variant(TOE_A::_0)
84    }
85    #[doc = "AGTOn output enabled."]
86    #[inline(always)]
87    pub fn _1(self) -> &'a mut W {
88        self.variant(TOE_A::_1)
89    }
90}
91#[doc = "Field `TIPF` reader - Input filter"]
92pub type TIPF_R = crate::FieldReader<u8, TIPF_A>;
93#[doc = "Input filter\n\nValue on reset: 0"]
94#[derive(Clone, Copy, Debug, PartialEq, Eq)]
95#[repr(u8)]
96pub enum TIPF_A {
97    #[doc = "0: No filter"]
98    _00 = 0,
99    #[doc = "1: Filter sampled at PCLKB"]
100    _01 = 1,
101    #[doc = "2: Filter sampled at PCLKB/8"]
102    _10 = 2,
103    #[doc = "3: Filter sampled at PCLKB/32"]
104    _11 = 3,
105}
106impl From<TIPF_A> for u8 {
107    #[inline(always)]
108    fn from(variant: TIPF_A) -> Self {
109        variant as _
110    }
111}
112impl TIPF_R {
113    #[doc = "Get enumerated values variant"]
114    #[inline(always)]
115    pub fn variant(&self) -> TIPF_A {
116        match self.bits {
117            0 => TIPF_A::_00,
118            1 => TIPF_A::_01,
119            2 => TIPF_A::_10,
120            3 => TIPF_A::_11,
121            _ => unreachable!(),
122        }
123    }
124    #[doc = "Checks if the value of the field is `_00`"]
125    #[inline(always)]
126    pub fn is_00(&self) -> bool {
127        *self == TIPF_A::_00
128    }
129    #[doc = "Checks if the value of the field is `_01`"]
130    #[inline(always)]
131    pub fn is_01(&self) -> bool {
132        *self == TIPF_A::_01
133    }
134    #[doc = "Checks if the value of the field is `_10`"]
135    #[inline(always)]
136    pub fn is_10(&self) -> bool {
137        *self == TIPF_A::_10
138    }
139    #[doc = "Checks if the value of the field is `_11`"]
140    #[inline(always)]
141    pub fn is_11(&self) -> bool {
142        *self == TIPF_A::_11
143    }
144}
145#[doc = "Field `TIPF` writer - Input filter"]
146pub type TIPF_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u8, AGTIOC_SPEC, u8, TIPF_A, 2, O>;
147impl<'a, const O: u8> TIPF_W<'a, O> {
148    #[doc = "No filter"]
149    #[inline(always)]
150    pub fn _00(self) -> &'a mut W {
151        self.variant(TIPF_A::_00)
152    }
153    #[doc = "Filter sampled at PCLKB"]
154    #[inline(always)]
155    pub fn _01(self) -> &'a mut W {
156        self.variant(TIPF_A::_01)
157    }
158    #[doc = "Filter sampled at PCLKB/8"]
159    #[inline(always)]
160    pub fn _10(self) -> &'a mut W {
161        self.variant(TIPF_A::_10)
162    }
163    #[doc = "Filter sampled at PCLKB/32"]
164    #[inline(always)]
165    pub fn _11(self) -> &'a mut W {
166        self.variant(TIPF_A::_11)
167    }
168}
169#[doc = "Field `TIOGT` reader - Count control"]
170pub type TIOGT_R = crate::FieldReader<u8, TIOGT_A>;
171#[doc = "Count control\n\nValue on reset: 0"]
172#[derive(Clone, Copy, Debug, PartialEq, Eq)]
173#[repr(u8)]
174pub enum TIOGT_A {
175    #[doc = "0: Event is always counted"]
176    _00 = 0,
177    #[doc = "1: Event is counted during polarity period specified for AGTEEn."]
178    _01 = 1,
179}
180impl From<TIOGT_A> for u8 {
181    #[inline(always)]
182    fn from(variant: TIOGT_A) -> Self {
183        variant as _
184    }
185}
186impl TIOGT_R {
187    #[doc = "Get enumerated values variant"]
188    #[inline(always)]
189    pub fn variant(&self) -> Option<TIOGT_A> {
190        match self.bits {
191            0 => Some(TIOGT_A::_00),
192            1 => Some(TIOGT_A::_01),
193            _ => None,
194        }
195    }
196    #[doc = "Checks if the value of the field is `_00`"]
197    #[inline(always)]
198    pub fn is_00(&self) -> bool {
199        *self == TIOGT_A::_00
200    }
201    #[doc = "Checks if the value of the field is `_01`"]
202    #[inline(always)]
203    pub fn is_01(&self) -> bool {
204        *self == TIOGT_A::_01
205    }
206}
207#[doc = "Field `TIOGT` writer - Count control"]
208pub type TIOGT_W<'a, const O: u8> = crate::FieldWriter<'a, u8, AGTIOC_SPEC, u8, TIOGT_A, 2, O>;
209impl<'a, const O: u8> TIOGT_W<'a, O> {
210    #[doc = "Event is always counted"]
211    #[inline(always)]
212    pub fn _00(self) -> &'a mut W {
213        self.variant(TIOGT_A::_00)
214    }
215    #[doc = "Event is counted during polarity period specified for AGTEEn."]
216    #[inline(always)]
217    pub fn _01(self) -> &'a mut W {
218        self.variant(TIOGT_A::_01)
219    }
220}
221impl R {
222    #[doc = "Bit 0 - I/O polarity switch Function varies depending on the operating mode."]
223    #[inline(always)]
224    pub fn tedgsel(&self) -> TEDGSEL_R {
225        TEDGSEL_R::new((self.bits & 1) != 0)
226    }
227    #[doc = "Bit 2 - AGTOn output enable"]
228    #[inline(always)]
229    pub fn toe(&self) -> TOE_R {
230        TOE_R::new(((self.bits >> 2) & 1) != 0)
231    }
232    #[doc = "Bits 4:5 - Input filter"]
233    #[inline(always)]
234    pub fn tipf(&self) -> TIPF_R {
235        TIPF_R::new((self.bits >> 4) & 3)
236    }
237    #[doc = "Bits 6:7 - Count control"]
238    #[inline(always)]
239    pub fn tiogt(&self) -> TIOGT_R {
240        TIOGT_R::new((self.bits >> 6) & 3)
241    }
242}
243impl W {
244    #[doc = "Bit 0 - I/O polarity switch Function varies depending on the operating mode."]
245    #[inline(always)]
246    #[must_use]
247    pub fn tedgsel(&mut self) -> TEDGSEL_W<0> {
248        TEDGSEL_W::new(self)
249    }
250    #[doc = "Bit 2 - AGTOn output enable"]
251    #[inline(always)]
252    #[must_use]
253    pub fn toe(&mut self) -> TOE_W<2> {
254        TOE_W::new(self)
255    }
256    #[doc = "Bits 4:5 - Input filter"]
257    #[inline(always)]
258    #[must_use]
259    pub fn tipf(&mut self) -> TIPF_W<4> {
260        TIPF_W::new(self)
261    }
262    #[doc = "Bits 6:7 - Count control"]
263    #[inline(always)]
264    #[must_use]
265    pub fn tiogt(&mut self) -> TIOGT_W<6> {
266        TIOGT_W::new(self)
267    }
268    #[doc = "Writes raw bits to the register."]
269    #[inline(always)]
270    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
271        self.0.bits(bits);
272        self
273    }
274}
275#[doc = "AGT I/O 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 [agtioc](index.html) module"]
276pub struct AGTIOC_SPEC;
277impl crate::RegisterSpec for AGTIOC_SPEC {
278    type Ux = u8;
279}
280#[doc = "`read()` method returns [agtioc::R](R) reader structure"]
281impl crate::Readable for AGTIOC_SPEC {
282    type Reader = R;
283}
284#[doc = "`write(|w| ..)` method takes [agtioc::W](W) writer structure"]
285impl crate::Writable for AGTIOC_SPEC {
286    type Writer = W;
287    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
288    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
289}
290#[doc = "`reset()` method sets AGTIOC to value 0"]
291impl crate::Resettable for AGTIOC_SPEC {
292    const RESET_VALUE: Self::Ux = 0;
293}