r528_pac/gpio/
pg_eint_cfg2.rs

1#[doc = "Register `pg_eint_cfg2` reader"]
2pub struct R(crate::R<PG_EINT_CFG2_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<PG_EINT_CFG2_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<PG_EINT_CFG2_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<PG_EINT_CFG2_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `pg_eint_cfg2` writer"]
17pub struct W(crate::W<PG_EINT_CFG2_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<PG_EINT_CFG2_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<PG_EINT_CFG2_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<PG_EINT_CFG2_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "External INT Mode\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum EINT_CFG_A {
41    #[doc = "0: `0`"]
42    POSITIVE_EDGE = 0,
43    #[doc = "1: `1`"]
44    NEGATIVE_EDGE = 1,
45    #[doc = "2: `10`"]
46    HIGH_LEVEL = 2,
47    #[doc = "3: `11`"]
48    LOW_LEVEL = 3,
49    #[doc = "4: `100`"]
50    DOUBLE_EDGE = 4,
51}
52impl From<EINT_CFG_A> for u8 {
53    #[inline(always)]
54    fn from(variant: EINT_CFG_A) -> Self {
55        variant as _
56    }
57}
58#[doc = "Fields `EINT(16-18)_CFG` reader - External INT Mode"]
59pub type EINT_CFG_R = crate::FieldReader<u8, EINT_CFG_A>;
60impl EINT_CFG_R {
61    #[doc = "Get enumerated values variant"]
62    #[inline(always)]
63    pub fn variant(&self) -> Option<EINT_CFG_A> {
64        match self.bits {
65            0 => Some(EINT_CFG_A::POSITIVE_EDGE),
66            1 => Some(EINT_CFG_A::NEGATIVE_EDGE),
67            2 => Some(EINT_CFG_A::HIGH_LEVEL),
68            3 => Some(EINT_CFG_A::LOW_LEVEL),
69            4 => Some(EINT_CFG_A::DOUBLE_EDGE),
70            _ => None,
71        }
72    }
73    #[doc = "Checks if the value of the field is `POSITIVE_EDGE`"]
74    #[inline(always)]
75    pub fn is_positive_edge(&self) -> bool {
76        *self == EINT_CFG_A::POSITIVE_EDGE
77    }
78    #[doc = "Checks if the value of the field is `NEGATIVE_EDGE`"]
79    #[inline(always)]
80    pub fn is_negative_edge(&self) -> bool {
81        *self == EINT_CFG_A::NEGATIVE_EDGE
82    }
83    #[doc = "Checks if the value of the field is `HIGH_LEVEL`"]
84    #[inline(always)]
85    pub fn is_high_level(&self) -> bool {
86        *self == EINT_CFG_A::HIGH_LEVEL
87    }
88    #[doc = "Checks if the value of the field is `LOW_LEVEL`"]
89    #[inline(always)]
90    pub fn is_low_level(&self) -> bool {
91        *self == EINT_CFG_A::LOW_LEVEL
92    }
93    #[doc = "Checks if the value of the field is `DOUBLE_EDGE`"]
94    #[inline(always)]
95    pub fn is_double_edge(&self) -> bool {
96        *self == EINT_CFG_A::DOUBLE_EDGE
97    }
98}
99#[doc = "Fields `EINT(16-18)_CFG` writer - External INT Mode"]
100pub type EINT_CFG_W<'a, const O: u8> =
101    crate::FieldWriter<'a, u32, PG_EINT_CFG2_SPEC, u8, EINT_CFG_A, 4, O>;
102impl<'a, const O: u8> EINT_CFG_W<'a, O> {
103    #[doc = "`0`"]
104    #[inline(always)]
105    pub fn positive_edge(self) -> &'a mut W {
106        self.variant(EINT_CFG_A::POSITIVE_EDGE)
107    }
108    #[doc = "`1`"]
109    #[inline(always)]
110    pub fn negative_edge(self) -> &'a mut W {
111        self.variant(EINT_CFG_A::NEGATIVE_EDGE)
112    }
113    #[doc = "`10`"]
114    #[inline(always)]
115    pub fn high_level(self) -> &'a mut W {
116        self.variant(EINT_CFG_A::HIGH_LEVEL)
117    }
118    #[doc = "`11`"]
119    #[inline(always)]
120    pub fn low_level(self) -> &'a mut W {
121        self.variant(EINT_CFG_A::LOW_LEVEL)
122    }
123    #[doc = "`100`"]
124    #[inline(always)]
125    pub fn double_edge(self) -> &'a mut W {
126        self.variant(EINT_CFG_A::DOUBLE_EDGE)
127    }
128}
129impl R {
130    #[doc = "External INT Mode"]
131    #[inline(always)]
132    pub unsafe fn eint_cfg(&self, n: u8) -> EINT_CFG_R {
133        EINT_CFG_R::new(((self.bits >> ((n - 16) * 4)) & 0x0f) as u8)
134    }
135    #[doc = "Bits 0:3 - External INT Mode"]
136    #[inline(always)]
137    pub fn eint16_cfg(&self) -> EINT_CFG_R {
138        EINT_CFG_R::new((self.bits & 0x0f) as u8)
139    }
140    #[doc = "Bits 4:7 - External INT Mode"]
141    #[inline(always)]
142    pub fn eint17_cfg(&self) -> EINT_CFG_R {
143        EINT_CFG_R::new(((self.bits >> 4) & 0x0f) as u8)
144    }
145    #[doc = "Bits 8:11 - External INT Mode"]
146    #[inline(always)]
147    pub fn eint18_cfg(&self) -> EINT_CFG_R {
148        EINT_CFG_R::new(((self.bits >> 8) & 0x0f) as u8)
149    }
150}
151impl W {
152    #[doc = "External INT Mode"]
153    #[inline(always)]
154    pub unsafe fn eint_cfg<const O: u8>(&mut self) -> EINT_CFG_W<O> {
155        EINT_CFG_W::new(self)
156    }
157    #[doc = "Bits 0:3 - External INT Mode"]
158    #[inline(always)]
159    pub fn eint16_cfg(&mut self) -> EINT_CFG_W<0> {
160        EINT_CFG_W::new(self)
161    }
162    #[doc = "Bits 4:7 - External INT Mode"]
163    #[inline(always)]
164    pub fn eint17_cfg(&mut self) -> EINT_CFG_W<4> {
165        EINT_CFG_W::new(self)
166    }
167    #[doc = "Bits 8:11 - External INT Mode"]
168    #[inline(always)]
169    pub fn eint18_cfg(&mut self) -> EINT_CFG_W<8> {
170        EINT_CFG_W::new(self)
171    }
172    #[doc = "Writes raw bits to the register."]
173    #[inline(always)]
174    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
175        self.0.bits(bits);
176        self
177    }
178}
179#[doc = "PG External Interrupt Configure Register 2\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 [pg_eint_cfg2](index.html) module"]
180pub struct PG_EINT_CFG2_SPEC;
181impl crate::RegisterSpec for PG_EINT_CFG2_SPEC {
182    type Ux = u32;
183}
184#[doc = "`read()` method returns [pg_eint_cfg2::R](R) reader structure"]
185impl crate::Readable for PG_EINT_CFG2_SPEC {
186    type Reader = R;
187}
188#[doc = "`write(|w| ..)` method takes [pg_eint_cfg2::W](W) writer structure"]
189impl crate::Writable for PG_EINT_CFG2_SPEC {
190    type Writer = W;
191}
192#[doc = "`reset()` method sets pg_eint_cfg2 to value 0"]
193impl crate::Resettable for PG_EINT_CFG2_SPEC {
194    #[inline(always)]
195    fn reset_value() -> Self::Ux {
196        0
197    }
198}