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