nrf52820_pac/gpiote/
config.rs1#[doc = "Register `CONFIG[%s]` reader"]
2pub struct R(crate::R<CONFIG_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<CONFIG_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<CONFIG_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<CONFIG_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `CONFIG[%s]` writer"]
17pub struct W(crate::W<CONFIG_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<CONFIG_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<CONFIG_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<CONFIG_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `MODE` reader - Mode"]
38pub type MODE_R = crate::FieldReader<u8, MODE_A>;
39#[doc = "Mode\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq)]
41#[repr(u8)]
42pub enum MODE_A {
43 #[doc = "0: Disabled. Pin specified by PSEL will not be acquired by the GPIOTE module."]
44 DISABLED = 0,
45 #[doc = "1: Event mode"]
46 EVENT = 1,
47 #[doc = "3: Task mode"]
48 TASK = 3,
49}
50impl From<MODE_A> for u8 {
51 #[inline(always)]
52 fn from(variant: MODE_A) -> Self {
53 variant as _
54 }
55}
56impl MODE_R {
57 #[doc = "Get enumerated values variant"]
58 #[inline(always)]
59 pub fn variant(&self) -> Option<MODE_A> {
60 match self.bits {
61 0 => Some(MODE_A::DISABLED),
62 1 => Some(MODE_A::EVENT),
63 3 => Some(MODE_A::TASK),
64 _ => None,
65 }
66 }
67 #[doc = "Checks if the value of the field is `DISABLED`"]
68 #[inline(always)]
69 pub fn is_disabled(&self) -> bool {
70 *self == MODE_A::DISABLED
71 }
72 #[doc = "Checks if the value of the field is `EVENT`"]
73 #[inline(always)]
74 pub fn is_event(&self) -> bool {
75 *self == MODE_A::EVENT
76 }
77 #[doc = "Checks if the value of the field is `TASK`"]
78 #[inline(always)]
79 pub fn is_task(&self) -> bool {
80 *self == MODE_A::TASK
81 }
82}
83#[doc = "Field `MODE` writer - Mode"]
84pub type MODE_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CONFIG_SPEC, u8, MODE_A, 2, O>;
85impl<'a, const O: u8> MODE_W<'a, O> {
86 #[doc = "Disabled. Pin specified by PSEL will not be acquired by the GPIOTE module."]
87 #[inline(always)]
88 pub fn disabled(self) -> &'a mut W {
89 self.variant(MODE_A::DISABLED)
90 }
91 #[doc = "Event mode"]
92 #[inline(always)]
93 pub fn event(self) -> &'a mut W {
94 self.variant(MODE_A::EVENT)
95 }
96 #[doc = "Task mode"]
97 #[inline(always)]
98 pub fn task(self) -> &'a mut W {
99 self.variant(MODE_A::TASK)
100 }
101}
102#[doc = "Field `PSEL` reader - GPIO number associated with SET\\[n\\], CLR\\[n\\], and OUT\\[n\\]
103tasks and IN\\[n\\]
104event"]
105pub type PSEL_R = crate::FieldReader<u8, u8>;
106#[doc = "Field `PSEL` writer - GPIO number associated with SET\\[n\\], CLR\\[n\\], and OUT\\[n\\]
107tasks and IN\\[n\\]
108event"]
109pub type PSEL_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CONFIG_SPEC, u8, u8, 5, O>;
110#[doc = "Field `POLARITY` reader - When In task mode: Operation to be performed on output when OUT\\[n\\]
111task is triggered. When In event mode: Operation on input that shall trigger IN\\[n\\]
112event."]
113pub type POLARITY_R = crate::FieldReader<u8, POLARITY_A>;
114#[doc = "When In task mode: Operation to be performed on output when OUT\\[n\\]
115task is triggered. When In event mode: Operation on input that shall trigger IN\\[n\\]
116event.\n\nValue on reset: 0"]
117#[derive(Clone, Copy, Debug, PartialEq)]
118#[repr(u8)]
119pub enum POLARITY_A {
120 #[doc = "0: Task mode: No effect on pin from OUT\\[n\\]
121task. Event mode: no IN\\[n\\]
122event generated on pin activity."]
123 NONE = 0,
124 #[doc = "1: Task mode: Set pin from OUT\\[n\\]
125task. Event mode: Generate IN\\[n\\]
126event when rising edge on pin."]
127 LO_TO_HI = 1,
128 #[doc = "2: Task mode: Clear pin from OUT\\[n\\]
129task. Event mode: Generate IN\\[n\\]
130event when falling edge on pin."]
131 HI_TO_LO = 2,
132 #[doc = "3: Task mode: Toggle pin from OUT\\[n\\]. Event mode: Generate IN\\[n\\]
133when any change on pin."]
134 TOGGLE = 3,
135}
136impl From<POLARITY_A> for u8 {
137 #[inline(always)]
138 fn from(variant: POLARITY_A) -> Self {
139 variant as _
140 }
141}
142impl POLARITY_R {
143 #[doc = "Get enumerated values variant"]
144 #[inline(always)]
145 pub fn variant(&self) -> POLARITY_A {
146 match self.bits {
147 0 => POLARITY_A::NONE,
148 1 => POLARITY_A::LO_TO_HI,
149 2 => POLARITY_A::HI_TO_LO,
150 3 => POLARITY_A::TOGGLE,
151 _ => unreachable!(),
152 }
153 }
154 #[doc = "Checks if the value of the field is `NONE`"]
155 #[inline(always)]
156 pub fn is_none(&self) -> bool {
157 *self == POLARITY_A::NONE
158 }
159 #[doc = "Checks if the value of the field is `LO_TO_HI`"]
160 #[inline(always)]
161 pub fn is_lo_to_hi(&self) -> bool {
162 *self == POLARITY_A::LO_TO_HI
163 }
164 #[doc = "Checks if the value of the field is `HI_TO_LO`"]
165 #[inline(always)]
166 pub fn is_hi_to_lo(&self) -> bool {
167 *self == POLARITY_A::HI_TO_LO
168 }
169 #[doc = "Checks if the value of the field is `TOGGLE`"]
170 #[inline(always)]
171 pub fn is_toggle(&self) -> bool {
172 *self == POLARITY_A::TOGGLE
173 }
174}
175#[doc = "Field `POLARITY` writer - When In task mode: Operation to be performed on output when OUT\\[n\\]
176task is triggered. When In event mode: Operation on input that shall trigger IN\\[n\\]
177event."]
178pub type POLARITY_W<'a, const O: u8> =
179 crate::FieldWriterSafe<'a, u32, CONFIG_SPEC, u8, POLARITY_A, 2, O>;
180impl<'a, const O: u8> POLARITY_W<'a, O> {
181 #[doc = "Task mode: No effect on pin from OUT\\[n\\]
182task. Event mode: no IN\\[n\\]
183event generated on pin activity."]
184 #[inline(always)]
185 pub fn none(self) -> &'a mut W {
186 self.variant(POLARITY_A::NONE)
187 }
188 #[doc = "Task mode: Set pin from OUT\\[n\\]
189task. Event mode: Generate IN\\[n\\]
190event when rising edge on pin."]
191 #[inline(always)]
192 pub fn lo_to_hi(self) -> &'a mut W {
193 self.variant(POLARITY_A::LO_TO_HI)
194 }
195 #[doc = "Task mode: Clear pin from OUT\\[n\\]
196task. Event mode: Generate IN\\[n\\]
197event when falling edge on pin."]
198 #[inline(always)]
199 pub fn hi_to_lo(self) -> &'a mut W {
200 self.variant(POLARITY_A::HI_TO_LO)
201 }
202 #[doc = "Task mode: Toggle pin from OUT\\[n\\]. Event mode: Generate IN\\[n\\]
203when any change on pin."]
204 #[inline(always)]
205 pub fn toggle(self) -> &'a mut W {
206 self.variant(POLARITY_A::TOGGLE)
207 }
208}
209#[doc = "Field `OUTINIT` reader - When in task mode: Initial value of the output when the GPIOTE channel is configured. When in event mode: No effect."]
210pub type OUTINIT_R = crate::BitReader<OUTINIT_A>;
211#[doc = "When in task mode: Initial value of the output when the GPIOTE channel is configured. When in event mode: No effect.\n\nValue on reset: 0"]
212#[derive(Clone, Copy, Debug, PartialEq)]
213pub enum OUTINIT_A {
214 #[doc = "0: Task mode: Initial value of pin before task triggering is low"]
215 LOW = 0,
216 #[doc = "1: Task mode: Initial value of pin before task triggering is high"]
217 HIGH = 1,
218}
219impl From<OUTINIT_A> for bool {
220 #[inline(always)]
221 fn from(variant: OUTINIT_A) -> Self {
222 variant as u8 != 0
223 }
224}
225impl OUTINIT_R {
226 #[doc = "Get enumerated values variant"]
227 #[inline(always)]
228 pub fn variant(&self) -> OUTINIT_A {
229 match self.bits {
230 false => OUTINIT_A::LOW,
231 true => OUTINIT_A::HIGH,
232 }
233 }
234 #[doc = "Checks if the value of the field is `LOW`"]
235 #[inline(always)]
236 pub fn is_low(&self) -> bool {
237 *self == OUTINIT_A::LOW
238 }
239 #[doc = "Checks if the value of the field is `HIGH`"]
240 #[inline(always)]
241 pub fn is_high(&self) -> bool {
242 *self == OUTINIT_A::HIGH
243 }
244}
245#[doc = "Field `OUTINIT` writer - When in task mode: Initial value of the output when the GPIOTE channel is configured. When in event mode: No effect."]
246pub type OUTINIT_W<'a, const O: u8> = crate::BitWriter<'a, u32, CONFIG_SPEC, OUTINIT_A, O>;
247impl<'a, const O: u8> OUTINIT_W<'a, O> {
248 #[doc = "Task mode: Initial value of pin before task triggering is low"]
249 #[inline(always)]
250 pub fn low(self) -> &'a mut W {
251 self.variant(OUTINIT_A::LOW)
252 }
253 #[doc = "Task mode: Initial value of pin before task triggering is high"]
254 #[inline(always)]
255 pub fn high(self) -> &'a mut W {
256 self.variant(OUTINIT_A::HIGH)
257 }
258}
259impl R {
260 #[doc = "Bits 0:1 - Mode"]
261 #[inline(always)]
262 pub fn mode(&self) -> MODE_R {
263 MODE_R::new((self.bits & 3) as u8)
264 }
265 #[doc = "Bits 8:12 - GPIO number associated with SET\\[n\\], CLR\\[n\\], and OUT\\[n\\]
266tasks and IN\\[n\\]
267event"]
268 #[inline(always)]
269 pub fn psel(&self) -> PSEL_R {
270 PSEL_R::new(((self.bits >> 8) & 0x1f) as u8)
271 }
272 #[doc = "Bits 16:17 - When In task mode: Operation to be performed on output when OUT\\[n\\]
273task is triggered. When In event mode: Operation on input that shall trigger IN\\[n\\]
274event."]
275 #[inline(always)]
276 pub fn polarity(&self) -> POLARITY_R {
277 POLARITY_R::new(((self.bits >> 16) & 3) as u8)
278 }
279 #[doc = "Bit 20 - When in task mode: Initial value of the output when the GPIOTE channel is configured. When in event mode: No effect."]
280 #[inline(always)]
281 pub fn outinit(&self) -> OUTINIT_R {
282 OUTINIT_R::new(((self.bits >> 20) & 1) != 0)
283 }
284}
285impl W {
286 #[doc = "Bits 0:1 - Mode"]
287 #[inline(always)]
288 pub fn mode(&mut self) -> MODE_W<0> {
289 MODE_W::new(self)
290 }
291 #[doc = "Bits 8:12 - GPIO number associated with SET\\[n\\], CLR\\[n\\], and OUT\\[n\\]
292tasks and IN\\[n\\]
293event"]
294 #[inline(always)]
295 pub fn psel(&mut self) -> PSEL_W<8> {
296 PSEL_W::new(self)
297 }
298 #[doc = "Bits 16:17 - When In task mode: Operation to be performed on output when OUT\\[n\\]
299task is triggered. When In event mode: Operation on input that shall trigger IN\\[n\\]
300event."]
301 #[inline(always)]
302 pub fn polarity(&mut self) -> POLARITY_W<16> {
303 POLARITY_W::new(self)
304 }
305 #[doc = "Bit 20 - When in task mode: Initial value of the output when the GPIOTE channel is configured. When in event mode: No effect."]
306 #[inline(always)]
307 pub fn outinit(&mut self) -> OUTINIT_W<20> {
308 OUTINIT_W::new(self)
309 }
310 #[doc = "Writes raw bits to the register."]
311 #[inline(always)]
312 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
313 self.0.bits(bits);
314 self
315 }
316}
317#[doc = "Description collection: Configuration for OUT\\[n\\], SET\\[n\\], and CLR\\[n\\]
318tasks and IN\\[n\\]
319event\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 [config](index.html) module"]
320pub struct CONFIG_SPEC;
321impl crate::RegisterSpec for CONFIG_SPEC {
322 type Ux = u32;
323}
324#[doc = "`read()` method returns [config::R](R) reader structure"]
325impl crate::Readable for CONFIG_SPEC {
326 type Reader = R;
327}
328#[doc = "`write(|w| ..)` method takes [config::W](W) writer structure"]
329impl crate::Writable for CONFIG_SPEC {
330 type Writer = W;
331}
332#[doc = "`reset()` method sets CONFIG[%s]
333to value 0"]
334impl crate::Resettable for CONFIG_SPEC {
335 #[inline(always)]
336 fn reset_value() -> Self::Ux {
337 0
338 }
339}