d1_pac/gpio/
pe_eint_cfg2.rs1#[doc = "Register `pe_eint_cfg2` reader"]
2pub type R = crate::R<PE_EINT_CFG2_SPEC>;
3#[doc = "Register `pe_eint_cfg2` writer"]
4pub type W = crate::W<PE_EINT_CFG2_SPEC>;
5#[doc = "Field `eint_cfg[16-17]` reader - External INT Mode"]
6pub type EINT_CFG_R = crate::FieldReader<EINT_CFG_A>;
7#[doc = "External INT Mode\n\nValue on reset: 0"]
8#[derive(Clone, Copy, Debug, PartialEq, Eq)]
9#[repr(u8)]
10pub enum EINT_CFG_A {
11 #[doc = "0: `0`"]
12 POSITIVE_EDGE = 0,
13 #[doc = "1: `1`"]
14 NEGATIVE_EDGE = 1,
15 #[doc = "2: `10`"]
16 HIGH_LEVEL = 2,
17 #[doc = "3: `11`"]
18 LOW_LEVEL = 3,
19 #[doc = "4: `100`"]
20 DOUBLE_EDGE = 4,
21}
22impl From<EINT_CFG_A> for u8 {
23 #[inline(always)]
24 fn from(variant: EINT_CFG_A) -> Self {
25 variant as _
26 }
27}
28impl crate::FieldSpec for EINT_CFG_A {
29 type Ux = u8;
30}
31impl EINT_CFG_R {
32 #[doc = "Get enumerated values variant"]
33 #[inline(always)]
34 pub const fn variant(&self) -> Option<EINT_CFG_A> {
35 match self.bits {
36 0 => Some(EINT_CFG_A::POSITIVE_EDGE),
37 1 => Some(EINT_CFG_A::NEGATIVE_EDGE),
38 2 => Some(EINT_CFG_A::HIGH_LEVEL),
39 3 => Some(EINT_CFG_A::LOW_LEVEL),
40 4 => Some(EINT_CFG_A::DOUBLE_EDGE),
41 _ => None,
42 }
43 }
44 #[doc = "`0`"]
45 #[inline(always)]
46 pub fn is_positive_edge(&self) -> bool {
47 *self == EINT_CFG_A::POSITIVE_EDGE
48 }
49 #[doc = "`1`"]
50 #[inline(always)]
51 pub fn is_negative_edge(&self) -> bool {
52 *self == EINT_CFG_A::NEGATIVE_EDGE
53 }
54 #[doc = "`10`"]
55 #[inline(always)]
56 pub fn is_high_level(&self) -> bool {
57 *self == EINT_CFG_A::HIGH_LEVEL
58 }
59 #[doc = "`11`"]
60 #[inline(always)]
61 pub fn is_low_level(&self) -> bool {
62 *self == EINT_CFG_A::LOW_LEVEL
63 }
64 #[doc = "`100`"]
65 #[inline(always)]
66 pub fn is_double_edge(&self) -> bool {
67 *self == EINT_CFG_A::DOUBLE_EDGE
68 }
69}
70#[doc = "Field `eint_cfg[16-17]` writer - External INT Mode"]
71pub type EINT_CFG_W<'a, REG> = crate::FieldWriter<'a, REG, 4, EINT_CFG_A>;
72impl<'a, REG> EINT_CFG_W<'a, REG>
73where
74 REG: crate::Writable + crate::RegisterSpec,
75 REG::Ux: From<u8>,
76{
77 #[doc = "`0`"]
78 #[inline(always)]
79 pub fn positive_edge(self) -> &'a mut crate::W<REG> {
80 self.variant(EINT_CFG_A::POSITIVE_EDGE)
81 }
82 #[doc = "`1`"]
83 #[inline(always)]
84 pub fn negative_edge(self) -> &'a mut crate::W<REG> {
85 self.variant(EINT_CFG_A::NEGATIVE_EDGE)
86 }
87 #[doc = "`10`"]
88 #[inline(always)]
89 pub fn high_level(self) -> &'a mut crate::W<REG> {
90 self.variant(EINT_CFG_A::HIGH_LEVEL)
91 }
92 #[doc = "`11`"]
93 #[inline(always)]
94 pub fn low_level(self) -> &'a mut crate::W<REG> {
95 self.variant(EINT_CFG_A::LOW_LEVEL)
96 }
97 #[doc = "`100`"]
98 #[inline(always)]
99 pub fn double_edge(self) -> &'a mut crate::W<REG> {
100 self.variant(EINT_CFG_A::DOUBLE_EDGE)
101 }
102}
103impl R {
104 #[doc = "External INT Mode\n\nNOTE: `n` is number of field in register. `n == 0` corresponds to `eint16_cfg` field"]
105 #[inline(always)]
106 pub fn eint_cfg(&self, n: u8) -> EINT_CFG_R {
107 #[allow(clippy::no_effect)]
108 [(); 2][n as usize];
109 EINT_CFG_R::new(((self.bits >> (n * 4)) & 0x0f) as u8)
110 }
111 #[doc = "Bits 0:3 - External INT Mode"]
112 #[inline(always)]
113 pub fn eint16_cfg(&self) -> EINT_CFG_R {
114 EINT_CFG_R::new((self.bits & 0x0f) as u8)
115 }
116 #[doc = "Bits 4:7 - External INT Mode"]
117 #[inline(always)]
118 pub fn eint17_cfg(&self) -> EINT_CFG_R {
119 EINT_CFG_R::new(((self.bits >> 4) & 0x0f) as u8)
120 }
121}
122impl W {
123 #[doc = "External INT Mode\n\nNOTE: `n` is number of field in register. `n == 0` corresponds to `eint16_cfg` field"]
124 #[inline(always)]
125 #[must_use]
126 pub fn eint_cfg(&mut self, n: u8) -> EINT_CFG_W<PE_EINT_CFG2_SPEC> {
127 #[allow(clippy::no_effect)]
128 [(); 2][n as usize];
129 EINT_CFG_W::new(self, n * 4)
130 }
131 #[doc = "Bits 0:3 - External INT Mode"]
132 #[inline(always)]
133 #[must_use]
134 pub fn eint16_cfg(&mut self) -> EINT_CFG_W<PE_EINT_CFG2_SPEC> {
135 EINT_CFG_W::new(self, 0)
136 }
137 #[doc = "Bits 4:7 - External INT Mode"]
138 #[inline(always)]
139 #[must_use]
140 pub fn eint17_cfg(&mut self) -> EINT_CFG_W<PE_EINT_CFG2_SPEC> {
141 EINT_CFG_W::new(self, 4)
142 }
143 #[doc = r" Writes raw bits to the register."]
144 #[doc = r""]
145 #[doc = r" # Safety"]
146 #[doc = r""]
147 #[doc = r" Passing incorrect value can cause undefined behaviour. See reference manual"]
148 #[inline(always)]
149 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
150 self.bits = bits;
151 self
152 }
153}
154#[doc = "PE External Interrupt Configure Register 2\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`pe_eint_cfg2::R`](R). You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`pe_eint_cfg2::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
155pub struct PE_EINT_CFG2_SPEC;
156impl crate::RegisterSpec for PE_EINT_CFG2_SPEC {
157 type Ux = u32;
158}
159#[doc = "`read()` method returns [`pe_eint_cfg2::R`](R) reader structure"]
160impl crate::Readable for PE_EINT_CFG2_SPEC {}
161#[doc = "`write(|w| ..)` method takes [`pe_eint_cfg2::W`](W) writer structure"]
162impl crate::Writable for PE_EINT_CFG2_SPEC {
163 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
164 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
165}
166#[doc = "`reset()` method sets pe_eint_cfg2 to value 0"]
167impl crate::Resettable for PE_EINT_CFG2_SPEC {
168 const RESET_VALUE: Self::Ux = 0;
169}