nrf52840_pac/gpiote/
config.rs
1#[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\\]
103and OUT\\[n\\]
104tasks and IN\\[n\\]
105event"]
106pub type PSEL_R = crate::FieldReader<u8, u8>;
107#[doc = "Field `PSEL` writer - GPIO number associated with SET\\[n\\], CLR\\[n\\]
108and OUT\\[n\\]
109tasks and IN\\[n\\]
110event"]
111pub type PSEL_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CONFIG_SPEC, u8, u8, 5, O>;
112#[doc = "Field `PORT` reader - Port number"]
113pub type PORT_R = crate::BitReader<bool>;
114#[doc = "Field `PORT` writer - Port number"]
115pub type PORT_W<'a, const O: u8> = crate::BitWriter<'a, u32, CONFIG_SPEC, bool, O>;
116#[doc = "Field `POLARITY` reader - When In task mode: Operation to be performed on output when OUT\\[n\\]
117task is triggered. When In event mode: Operation on input that shall trigger IN\\[n\\]
118event."]
119pub type POLARITY_R = crate::FieldReader<u8, POLARITY_A>;
120#[doc = "When In task mode: Operation to be performed on output when OUT\\[n\\]
121task is triggered. When In event mode: Operation on input that shall trigger IN\\[n\\]
122event.\n\nValue on reset: 0"]
123#[derive(Clone, Copy, Debug, PartialEq)]
124#[repr(u8)]
125pub enum POLARITY_A {
126 #[doc = "0: Task mode: No effect on pin from OUT\\[n\\]
127task. Event mode: no IN\\[n\\]
128event generated on pin activity."]
129 NONE = 0,
130 #[doc = "1: Task mode: Set pin from OUT\\[n\\]
131task. Event mode: Generate IN\\[n\\]
132event when rising edge on pin."]
133 LO_TO_HI = 1,
134 #[doc = "2: Task mode: Clear pin from OUT\\[n\\]
135task. Event mode: Generate IN\\[n\\]
136event when falling edge on pin."]
137 HI_TO_LO = 2,
138 #[doc = "3: Task mode: Toggle pin from OUT\\[n\\]. Event mode: Generate IN\\[n\\]
139when any change on pin."]
140 TOGGLE = 3,
141}
142impl From<POLARITY_A> for u8 {
143 #[inline(always)]
144 fn from(variant: POLARITY_A) -> Self {
145 variant as _
146 }
147}
148impl POLARITY_R {
149 #[doc = "Get enumerated values variant"]
150 #[inline(always)]
151 pub fn variant(&self) -> POLARITY_A {
152 match self.bits {
153 0 => POLARITY_A::NONE,
154 1 => POLARITY_A::LO_TO_HI,
155 2 => POLARITY_A::HI_TO_LO,
156 3 => POLARITY_A::TOGGLE,
157 _ => unreachable!(),
158 }
159 }
160 #[doc = "Checks if the value of the field is `NONE`"]
161 #[inline(always)]
162 pub fn is_none(&self) -> bool {
163 *self == POLARITY_A::NONE
164 }
165 #[doc = "Checks if the value of the field is `LO_TO_HI`"]
166 #[inline(always)]
167 pub fn is_lo_to_hi(&self) -> bool {
168 *self == POLARITY_A::LO_TO_HI
169 }
170 #[doc = "Checks if the value of the field is `HI_TO_LO`"]
171 #[inline(always)]
172 pub fn is_hi_to_lo(&self) -> bool {
173 *self == POLARITY_A::HI_TO_LO
174 }
175 #[doc = "Checks if the value of the field is `TOGGLE`"]
176 #[inline(always)]
177 pub fn is_toggle(&self) -> bool {
178 *self == POLARITY_A::TOGGLE
179 }
180}
181#[doc = "Field `POLARITY` writer - When In task mode: Operation to be performed on output when OUT\\[n\\]
182task is triggered. When In event mode: Operation on input that shall trigger IN\\[n\\]
183event."]
184pub type POLARITY_W<'a, const O: u8> =
185 crate::FieldWriterSafe<'a, u32, CONFIG_SPEC, u8, POLARITY_A, 2, O>;
186impl<'a, const O: u8> POLARITY_W<'a, O> {
187 #[doc = "Task mode: No effect on pin from OUT\\[n\\]
188task. Event mode: no IN\\[n\\]
189event generated on pin activity."]
190 #[inline(always)]
191 pub fn none(self) -> &'a mut W {
192 self.variant(POLARITY_A::NONE)
193 }
194 #[doc = "Task mode: Set pin from OUT\\[n\\]
195task. Event mode: Generate IN\\[n\\]
196event when rising edge on pin."]
197 #[inline(always)]
198 pub fn lo_to_hi(self) -> &'a mut W {
199 self.variant(POLARITY_A::LO_TO_HI)
200 }
201 #[doc = "Task mode: Clear pin from OUT\\[n\\]
202task. Event mode: Generate IN\\[n\\]
203event when falling edge on pin."]
204 #[inline(always)]
205 pub fn hi_to_lo(self) -> &'a mut W {
206 self.variant(POLARITY_A::HI_TO_LO)
207 }
208 #[doc = "Task mode: Toggle pin from OUT\\[n\\]. Event mode: Generate IN\\[n\\]
209when any change on pin."]
210 #[inline(always)]
211 pub fn toggle(self) -> &'a mut W {
212 self.variant(POLARITY_A::TOGGLE)
213 }
214}
215#[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."]
216pub type OUTINIT_R = crate::BitReader<OUTINIT_A>;
217#[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"]
218#[derive(Clone, Copy, Debug, PartialEq)]
219pub enum OUTINIT_A {
220 #[doc = "0: Task mode: Initial value of pin before task triggering is low"]
221 LOW = 0,
222 #[doc = "1: Task mode: Initial value of pin before task triggering is high"]
223 HIGH = 1,
224}
225impl From<OUTINIT_A> for bool {
226 #[inline(always)]
227 fn from(variant: OUTINIT_A) -> Self {
228 variant as u8 != 0
229 }
230}
231impl OUTINIT_R {
232 #[doc = "Get enumerated values variant"]
233 #[inline(always)]
234 pub fn variant(&self) -> OUTINIT_A {
235 match self.bits {
236 false => OUTINIT_A::LOW,
237 true => OUTINIT_A::HIGH,
238 }
239 }
240 #[doc = "Checks if the value of the field is `LOW`"]
241 #[inline(always)]
242 pub fn is_low(&self) -> bool {
243 *self == OUTINIT_A::LOW
244 }
245 #[doc = "Checks if the value of the field is `HIGH`"]
246 #[inline(always)]
247 pub fn is_high(&self) -> bool {
248 *self == OUTINIT_A::HIGH
249 }
250}
251#[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."]
252pub type OUTINIT_W<'a, const O: u8> = crate::BitWriter<'a, u32, CONFIG_SPEC, OUTINIT_A, O>;
253impl<'a, const O: u8> OUTINIT_W<'a, O> {
254 #[doc = "Task mode: Initial value of pin before task triggering is low"]
255 #[inline(always)]
256 pub fn low(self) -> &'a mut W {
257 self.variant(OUTINIT_A::LOW)
258 }
259 #[doc = "Task mode: Initial value of pin before task triggering is high"]
260 #[inline(always)]
261 pub fn high(self) -> &'a mut W {
262 self.variant(OUTINIT_A::HIGH)
263 }
264}
265impl R {
266 #[doc = "Bits 0:1 - Mode"]
267 #[inline(always)]
268 pub fn mode(&self) -> MODE_R {
269 MODE_R::new((self.bits & 3) as u8)
270 }
271 #[doc = "Bits 8:12 - GPIO number associated with SET\\[n\\], CLR\\[n\\]
272and OUT\\[n\\]
273tasks and IN\\[n\\]
274event"]
275 #[inline(always)]
276 pub fn psel(&self) -> PSEL_R {
277 PSEL_R::new(((self.bits >> 8) & 0x1f) as u8)
278 }
279 #[doc = "Bit 13 - Port number"]
280 #[inline(always)]
281 pub fn port(&self) -> PORT_R {
282 PORT_R::new(((self.bits >> 13) & 1) != 0)
283 }
284 #[doc = "Bits 16:17 - When In task mode: Operation to be performed on output when OUT\\[n\\]
285task is triggered. When In event mode: Operation on input that shall trigger IN\\[n\\]
286event."]
287 #[inline(always)]
288 pub fn polarity(&self) -> POLARITY_R {
289 POLARITY_R::new(((self.bits >> 16) & 3) as u8)
290 }
291 #[doc = "Bit 20 - When in task mode: Initial value of the output when the GPIOTE channel is configured. When in event mode: No effect."]
292 #[inline(always)]
293 pub fn outinit(&self) -> OUTINIT_R {
294 OUTINIT_R::new(((self.bits >> 20) & 1) != 0)
295 }
296}
297impl W {
298 #[doc = "Bits 0:1 - Mode"]
299 #[inline(always)]
300 pub fn mode(&mut self) -> MODE_W<0> {
301 MODE_W::new(self)
302 }
303 #[doc = "Bits 8:12 - GPIO number associated with SET\\[n\\], CLR\\[n\\]
304and OUT\\[n\\]
305tasks and IN\\[n\\]
306event"]
307 #[inline(always)]
308 pub fn psel(&mut self) -> PSEL_W<8> {
309 PSEL_W::new(self)
310 }
311 #[doc = "Bit 13 - Port number"]
312 #[inline(always)]
313 pub fn port(&mut self) -> PORT_W<13> {
314 PORT_W::new(self)
315 }
316 #[doc = "Bits 16:17 - When In task mode: Operation to be performed on output when OUT\\[n\\]
317task is triggered. When In event mode: Operation on input that shall trigger IN\\[n\\]
318event."]
319 #[inline(always)]
320 pub fn polarity(&mut self) -> POLARITY_W<16> {
321 POLARITY_W::new(self)
322 }
323 #[doc = "Bit 20 - When in task mode: Initial value of the output when the GPIOTE channel is configured. When in event mode: No effect."]
324 #[inline(always)]
325 pub fn outinit(&mut self) -> OUTINIT_W<20> {
326 OUTINIT_W::new(self)
327 }
328 #[doc = "Writes raw bits to the register."]
329 #[inline(always)]
330 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
331 self.0.bits(bits);
332 self
333 }
334}
335#[doc = "Description collection\\[n\\]: Configuration for OUT\\[n\\], SET\\[n\\]
336and CLR\\[n\\]
337tasks and IN\\[n\\]
338event\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"]
339pub struct CONFIG_SPEC;
340impl crate::RegisterSpec for CONFIG_SPEC {
341 type Ux = u32;
342}
343#[doc = "`read()` method returns [config::R](R) reader structure"]
344impl crate::Readable for CONFIG_SPEC {
345 type Reader = R;
346}
347#[doc = "`write(|w| ..)` method takes [config::W](W) writer structure"]
348impl crate::Writable for CONFIG_SPEC {
349 type Writer = W;
350}
351#[doc = "`reset()` method sets CONFIG[%s]
352to value 0"]
353impl crate::Resettable for CONFIG_SPEC {
354 #[inline(always)]
355 fn reset_value() -> Self::Ux {
356 0
357 }
358}