nrf51_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."]
44    DISABLED = 0,
45    #[doc = "1: Channel configure in event mode."]
46    EVENT = 1,
47    #[doc = "3: Channel configure in 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."]
87    #[inline(always)]
88    pub fn disabled(self) -> &'a mut W {
89        self.variant(MODE_A::DISABLED)
90    }
91    #[doc = "Channel configure in event mode."]
92    #[inline(always)]
93    pub fn event(self) -> &'a mut W {
94        self.variant(MODE_A::EVENT)
95    }
96    #[doc = "Channel configure in 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 - Pin select."]
103pub type PSEL_R = crate::FieldReader<u8, u8>;
104#[doc = "Field `PSEL` writer - Pin select."]
105pub type PSEL_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CONFIG_SPEC, u8, u8, 5, O>;
106#[doc = "Field `POLARITY` reader - Effects on output when in Task mode, or events on input that generates an event."]
107pub type POLARITY_R = crate::FieldReader<u8, POLARITY_A>;
108#[doc = "Effects on output when in Task mode, or events on input that generates an event.\n\nValue on reset: 0"]
109#[derive(Clone, Copy, Debug, PartialEq)]
110#[repr(u8)]
111pub enum POLARITY_A {
112    #[doc = "0: No task or event."]
113    NONE = 0,
114    #[doc = "1: Low to high."]
115    LO_TO_HI = 1,
116    #[doc = "2: High to low."]
117    HI_TO_LO = 2,
118    #[doc = "3: Toggle."]
119    TOGGLE = 3,
120}
121impl From<POLARITY_A> for u8 {
122    #[inline(always)]
123    fn from(variant: POLARITY_A) -> Self {
124        variant as _
125    }
126}
127impl POLARITY_R {
128    #[doc = "Get enumerated values variant"]
129    #[inline(always)]
130    pub fn variant(&self) -> POLARITY_A {
131        match self.bits {
132            0 => POLARITY_A::NONE,
133            1 => POLARITY_A::LO_TO_HI,
134            2 => POLARITY_A::HI_TO_LO,
135            3 => POLARITY_A::TOGGLE,
136            _ => unreachable!(),
137        }
138    }
139    #[doc = "Checks if the value of the field is `NONE`"]
140    #[inline(always)]
141    pub fn is_none(&self) -> bool {
142        *self == POLARITY_A::NONE
143    }
144    #[doc = "Checks if the value of the field is `LO_TO_HI`"]
145    #[inline(always)]
146    pub fn is_lo_to_hi(&self) -> bool {
147        *self == POLARITY_A::LO_TO_HI
148    }
149    #[doc = "Checks if the value of the field is `HI_TO_LO`"]
150    #[inline(always)]
151    pub fn is_hi_to_lo(&self) -> bool {
152        *self == POLARITY_A::HI_TO_LO
153    }
154    #[doc = "Checks if the value of the field is `TOGGLE`"]
155    #[inline(always)]
156    pub fn is_toggle(&self) -> bool {
157        *self == POLARITY_A::TOGGLE
158    }
159}
160#[doc = "Field `POLARITY` writer - Effects on output when in Task mode, or events on input that generates an event."]
161pub type POLARITY_W<'a, const O: u8> =
162    crate::FieldWriterSafe<'a, u32, CONFIG_SPEC, u8, POLARITY_A, 2, O>;
163impl<'a, const O: u8> POLARITY_W<'a, O> {
164    #[doc = "No task or event."]
165    #[inline(always)]
166    pub fn none(self) -> &'a mut W {
167        self.variant(POLARITY_A::NONE)
168    }
169    #[doc = "Low to high."]
170    #[inline(always)]
171    pub fn lo_to_hi(self) -> &'a mut W {
172        self.variant(POLARITY_A::LO_TO_HI)
173    }
174    #[doc = "High to low."]
175    #[inline(always)]
176    pub fn hi_to_lo(self) -> &'a mut W {
177        self.variant(POLARITY_A::HI_TO_LO)
178    }
179    #[doc = "Toggle."]
180    #[inline(always)]
181    pub fn toggle(self) -> &'a mut W {
182        self.variant(POLARITY_A::TOGGLE)
183    }
184}
185#[doc = "Field `OUTINIT` reader - Initial value of the output when the GPIOTE channel is configured as a Task."]
186pub type OUTINIT_R = crate::BitReader<OUTINIT_A>;
187#[doc = "Initial value of the output when the GPIOTE channel is configured as a Task.\n\nValue on reset: 0"]
188#[derive(Clone, Copy, Debug, PartialEq)]
189pub enum OUTINIT_A {
190    #[doc = "0: Initial low output when in task mode."]
191    LOW = 0,
192    #[doc = "1: Initial high output when in task mode."]
193    HIGH = 1,
194}
195impl From<OUTINIT_A> for bool {
196    #[inline(always)]
197    fn from(variant: OUTINIT_A) -> Self {
198        variant as u8 != 0
199    }
200}
201impl OUTINIT_R {
202    #[doc = "Get enumerated values variant"]
203    #[inline(always)]
204    pub fn variant(&self) -> OUTINIT_A {
205        match self.bits {
206            false => OUTINIT_A::LOW,
207            true => OUTINIT_A::HIGH,
208        }
209    }
210    #[doc = "Checks if the value of the field is `LOW`"]
211    #[inline(always)]
212    pub fn is_low(&self) -> bool {
213        *self == OUTINIT_A::LOW
214    }
215    #[doc = "Checks if the value of the field is `HIGH`"]
216    #[inline(always)]
217    pub fn is_high(&self) -> bool {
218        *self == OUTINIT_A::HIGH
219    }
220}
221#[doc = "Field `OUTINIT` writer - Initial value of the output when the GPIOTE channel is configured as a Task."]
222pub type OUTINIT_W<'a, const O: u8> = crate::BitWriter<'a, u32, CONFIG_SPEC, OUTINIT_A, O>;
223impl<'a, const O: u8> OUTINIT_W<'a, O> {
224    #[doc = "Initial low output when in task mode."]
225    #[inline(always)]
226    pub fn low(self) -> &'a mut W {
227        self.variant(OUTINIT_A::LOW)
228    }
229    #[doc = "Initial high output when in task mode."]
230    #[inline(always)]
231    pub fn high(self) -> &'a mut W {
232        self.variant(OUTINIT_A::HIGH)
233    }
234}
235impl R {
236    #[doc = "Bits 0:1 - Mode"]
237    #[inline(always)]
238    pub fn mode(&self) -> MODE_R {
239        MODE_R::new((self.bits & 3) as u8)
240    }
241    #[doc = "Bits 8:12 - Pin select."]
242    #[inline(always)]
243    pub fn psel(&self) -> PSEL_R {
244        PSEL_R::new(((self.bits >> 8) & 0x1f) as u8)
245    }
246    #[doc = "Bits 16:17 - Effects on output when in Task mode, or events on input that generates an event."]
247    #[inline(always)]
248    pub fn polarity(&self) -> POLARITY_R {
249        POLARITY_R::new(((self.bits >> 16) & 3) as u8)
250    }
251    #[doc = "Bit 20 - Initial value of the output when the GPIOTE channel is configured as a Task."]
252    #[inline(always)]
253    pub fn outinit(&self) -> OUTINIT_R {
254        OUTINIT_R::new(((self.bits >> 20) & 1) != 0)
255    }
256}
257impl W {
258    #[doc = "Bits 0:1 - Mode"]
259    #[inline(always)]
260    pub fn mode(&mut self) -> MODE_W<0> {
261        MODE_W::new(self)
262    }
263    #[doc = "Bits 8:12 - Pin select."]
264    #[inline(always)]
265    pub fn psel(&mut self) -> PSEL_W<8> {
266        PSEL_W::new(self)
267    }
268    #[doc = "Bits 16:17 - Effects on output when in Task mode, or events on input that generates an event."]
269    #[inline(always)]
270    pub fn polarity(&mut self) -> POLARITY_W<16> {
271        POLARITY_W::new(self)
272    }
273    #[doc = "Bit 20 - Initial value of the output when the GPIOTE channel is configured as a Task."]
274    #[inline(always)]
275    pub fn outinit(&mut self) -> OUTINIT_W<20> {
276        OUTINIT_W::new(self)
277    }
278    #[doc = "Writes raw bits to the register."]
279    #[inline(always)]
280    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
281        self.0.bits(bits);
282        self
283    }
284}
285#[doc = "Channel configuration registers.\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"]
286pub struct CONFIG_SPEC;
287impl crate::RegisterSpec for CONFIG_SPEC {
288    type Ux = u32;
289}
290#[doc = "`read()` method returns [config::R](R) reader structure"]
291impl crate::Readable for CONFIG_SPEC {
292    type Reader = R;
293}
294#[doc = "`write(|w| ..)` method takes [config::W](W) writer structure"]
295impl crate::Writable for CONFIG_SPEC {
296    type Writer = W;
297}
298#[doc = "`reset()` method sets CONFIG[%s]
299to value 0"]
300impl crate::Resettable for CONFIG_SPEC {
301    #[inline(always)]
302    fn reset_value() -> Self::Ux {
303        0
304    }
305}