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