lpc11xx/iocon/
iocon_pio3_3.rs

1#[doc = "Reader of register IOCON_PIO3_3"]
2pub type R = crate::R<u32, super::IOCON_PIO3_3>;
3#[doc = "Writer for register IOCON_PIO3_3"]
4pub type W = crate::W<u32, super::IOCON_PIO3_3>;
5#[doc = "Register IOCON_PIO3_3 `reset()`'s with value 0xd0"]
6impl crate::ResetValue for super::IOCON_PIO3_3 {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0xd0
11    }
12}
13#[doc = "Configure pin function.\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15pub enum FUNC_A {
16    #[doc = "0: Pin function PIO3_3"]
17    PIO3_3,
18    #[doc = "1: Pin function RI"]
19    RI,
20    #[doc = "2: Pin function CT16B0_CAP0"]
21    CT16B0_CAP0,
22}
23impl From<FUNC_A> for u8 {
24    #[inline(always)]
25    fn from(variant: FUNC_A) -> Self {
26        match variant {
27            FUNC_A::PIO3_3 => 0,
28            FUNC_A::RI => 1,
29            FUNC_A::CT16B0_CAP0 => 2,
30        }
31    }
32}
33#[doc = "Reader of field `FUNC`"]
34pub type FUNC_R = crate::R<u8, FUNC_A>;
35impl FUNC_R {
36    #[doc = r"Get enumerated values variant"]
37    #[inline(always)]
38    pub fn variant(&self) -> crate::Variant<u8, FUNC_A> {
39        use crate::Variant::*;
40        match self.bits {
41            0 => Val(FUNC_A::PIO3_3),
42            1 => Val(FUNC_A::RI),
43            2 => Val(FUNC_A::CT16B0_CAP0),
44            i => Res(i),
45        }
46    }
47    #[doc = "Checks if the value of the field is `PIO3_3`"]
48    #[inline(always)]
49    pub fn is_pio3_3(&self) -> bool {
50        *self == FUNC_A::PIO3_3
51    }
52    #[doc = "Checks if the value of the field is `RI`"]
53    #[inline(always)]
54    pub fn is_ri(&self) -> bool {
55        *self == FUNC_A::RI
56    }
57    #[doc = "Checks if the value of the field is `CT16B0_CAP0`"]
58    #[inline(always)]
59    pub fn is_ct16b0_cap0(&self) -> bool {
60        *self == FUNC_A::CT16B0_CAP0
61    }
62}
63#[doc = "Write proxy for field `FUNC`"]
64pub struct FUNC_W<'a> {
65    w: &'a mut W,
66}
67impl<'a> FUNC_W<'a> {
68    #[doc = r"Writes `variant` to the field"]
69    #[inline(always)]
70    pub fn variant(self, variant: FUNC_A) -> &'a mut W {
71        unsafe { self.bits(variant.into()) }
72    }
73    #[doc = "Pin function PIO3_3"]
74    #[inline(always)]
75    pub fn pio3_3(self) -> &'a mut W {
76        self.variant(FUNC_A::PIO3_3)
77    }
78    #[doc = "Pin function RI"]
79    #[inline(always)]
80    pub fn ri(self) -> &'a mut W {
81        self.variant(FUNC_A::RI)
82    }
83    #[doc = "Pin function CT16B0_CAP0"]
84    #[inline(always)]
85    pub fn ct16b0_cap0(self) -> &'a mut W {
86        self.variant(FUNC_A::CT16B0_CAP0)
87    }
88    #[doc = r"Writes raw bits to the field"]
89    #[inline(always)]
90    pub unsafe fn bits(self, value: u8) -> &'a mut W {
91        self.w.bits = (self.w.bits & !0x07) | ((value as u32) & 0x07);
92        self.w
93    }
94}
95#[doc = "Pin function mode (on-chip pull-up/pull-down resistor control).\n\nValue on reset: 2"]
96#[derive(Clone, Copy, Debug, PartialEq)]
97pub enum MODE_A {
98    #[doc = "0: Inactive (no pull-down/pull-up resistor enabled)"]
99    INACTIVE_NO_PULL_DO,
100    #[doc = "1: Pull-down resistor enabled"]
101    PULL_DOWN_RESISTOR_E,
102    #[doc = "2: Pull-up resistor enabled"]
103    PULL_UP_RESISTOR_ENA,
104    #[doc = "3: Repeater mode"]
105    REPEATER_MODE_,
106}
107impl From<MODE_A> for u8 {
108    #[inline(always)]
109    fn from(variant: MODE_A) -> Self {
110        match variant {
111            MODE_A::INACTIVE_NO_PULL_DO => 0,
112            MODE_A::PULL_DOWN_RESISTOR_E => 1,
113            MODE_A::PULL_UP_RESISTOR_ENA => 2,
114            MODE_A::REPEATER_MODE_ => 3,
115        }
116    }
117}
118#[doc = "Reader of field `MODE`"]
119pub type MODE_R = crate::R<u8, MODE_A>;
120impl MODE_R {
121    #[doc = r"Get enumerated values variant"]
122    #[inline(always)]
123    pub fn variant(&self) -> MODE_A {
124        match self.bits {
125            0 => MODE_A::INACTIVE_NO_PULL_DO,
126            1 => MODE_A::PULL_DOWN_RESISTOR_E,
127            2 => MODE_A::PULL_UP_RESISTOR_ENA,
128            3 => MODE_A::REPEATER_MODE_,
129            _ => unreachable!(),
130        }
131    }
132    #[doc = "Checks if the value of the field is `INACTIVE_NO_PULL_DO`"]
133    #[inline(always)]
134    pub fn is_inactive_no_pull_do(&self) -> bool {
135        *self == MODE_A::INACTIVE_NO_PULL_DO
136    }
137    #[doc = "Checks if the value of the field is `PULL_DOWN_RESISTOR_E`"]
138    #[inline(always)]
139    pub fn is_pull_down_resistor_e(&self) -> bool {
140        *self == MODE_A::PULL_DOWN_RESISTOR_E
141    }
142    #[doc = "Checks if the value of the field is `PULL_UP_RESISTOR_ENA`"]
143    #[inline(always)]
144    pub fn is_pull_up_resistor_ena(&self) -> bool {
145        *self == MODE_A::PULL_UP_RESISTOR_ENA
146    }
147    #[doc = "Checks if the value of the field is `REPEATER_MODE_`"]
148    #[inline(always)]
149    pub fn is_repeater_mode_(&self) -> bool {
150        *self == MODE_A::REPEATER_MODE_
151    }
152}
153#[doc = "Write proxy for field `MODE`"]
154pub struct MODE_W<'a> {
155    w: &'a mut W,
156}
157impl<'a> MODE_W<'a> {
158    #[doc = r"Writes `variant` to the field"]
159    #[inline(always)]
160    pub fn variant(self, variant: MODE_A) -> &'a mut W {
161        {
162            self.bits(variant.into())
163        }
164    }
165    #[doc = "Inactive (no pull-down/pull-up resistor enabled)"]
166    #[inline(always)]
167    pub fn inactive_no_pull_do(self) -> &'a mut W {
168        self.variant(MODE_A::INACTIVE_NO_PULL_DO)
169    }
170    #[doc = "Pull-down resistor enabled"]
171    #[inline(always)]
172    pub fn pull_down_resistor_e(self) -> &'a mut W {
173        self.variant(MODE_A::PULL_DOWN_RESISTOR_E)
174    }
175    #[doc = "Pull-up resistor enabled"]
176    #[inline(always)]
177    pub fn pull_up_resistor_ena(self) -> &'a mut W {
178        self.variant(MODE_A::PULL_UP_RESISTOR_ENA)
179    }
180    #[doc = "Repeater mode"]
181    #[inline(always)]
182    pub fn repeater_mode_(self) -> &'a mut W {
183        self.variant(MODE_A::REPEATER_MODE_)
184    }
185    #[doc = r"Writes raw bits to the field"]
186    #[inline(always)]
187    pub fn bits(self, value: u8) -> &'a mut W {
188        self.w.bits = (self.w.bits & !(0x03 << 3)) | (((value as u32) & 0x03) << 3);
189        self.w
190    }
191}
192#[doc = "Hysteresis.\n\nValue on reset: 0"]
193#[derive(Clone, Copy, Debug, PartialEq)]
194pub enum HYSTERESIS_A {
195    #[doc = "0: Disable"]
196    DISABLE,
197    #[doc = "1: Enable"]
198    ENABLE,
199}
200impl From<HYSTERESIS_A> for bool {
201    #[inline(always)]
202    fn from(variant: HYSTERESIS_A) -> Self {
203        match variant {
204            HYSTERESIS_A::DISABLE => false,
205            HYSTERESIS_A::ENABLE => true,
206        }
207    }
208}
209#[doc = "Reader of field `HYSTERESIS`"]
210pub type HYSTERESIS_R = crate::R<bool, HYSTERESIS_A>;
211impl HYSTERESIS_R {
212    #[doc = r"Get enumerated values variant"]
213    #[inline(always)]
214    pub fn variant(&self) -> HYSTERESIS_A {
215        match self.bits {
216            false => HYSTERESIS_A::DISABLE,
217            true => HYSTERESIS_A::ENABLE,
218        }
219    }
220    #[doc = "Checks if the value of the field is `DISABLE`"]
221    #[inline(always)]
222    pub fn is_disable(&self) -> bool {
223        *self == HYSTERESIS_A::DISABLE
224    }
225    #[doc = "Checks if the value of the field is `ENABLE`"]
226    #[inline(always)]
227    pub fn is_enable(&self) -> bool {
228        *self == HYSTERESIS_A::ENABLE
229    }
230}
231#[doc = "Write proxy for field `HYSTERESIS`"]
232pub struct HYSTERESIS_W<'a> {
233    w: &'a mut W,
234}
235impl<'a> HYSTERESIS_W<'a> {
236    #[doc = r"Writes `variant` to the field"]
237    #[inline(always)]
238    pub fn variant(self, variant: HYSTERESIS_A) -> &'a mut W {
239        {
240            self.bit(variant.into())
241        }
242    }
243    #[doc = "Disable"]
244    #[inline(always)]
245    pub fn disable(self) -> &'a mut W {
246        self.variant(HYSTERESIS_A::DISABLE)
247    }
248    #[doc = "Enable"]
249    #[inline(always)]
250    pub fn enable(self) -> &'a mut W {
251        self.variant(HYSTERESIS_A::ENABLE)
252    }
253    #[doc = r"Sets the field bit"]
254    #[inline(always)]
255    pub fn set_bit(self) -> &'a mut W {
256        self.bit(true)
257    }
258    #[doc = r"Clears the field bit"]
259    #[inline(always)]
260    pub fn clear_bit(self) -> &'a mut W {
261        self.bit(false)
262    }
263    #[doc = r"Writes raw bits to the field"]
264    #[inline(always)]
265    pub fn bit(self, value: bool) -> &'a mut W {
266        self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u32) & 0x01) << 5);
267        self.w
268    }
269}
270#[doc = "Selects pseudo open-drain mode.\n\nValue on reset: 0"]
271#[derive(Clone, Copy, Debug, PartialEq)]
272pub enum OPEN_DRAIN_A {
273    #[doc = "0: Standard GPIO output"]
274    GPIO_OUTPUT,
275    #[doc = "1: Open-drain output"]
276    OPEN_DRAIN_OUTPUT,
277}
278impl From<OPEN_DRAIN_A> for bool {
279    #[inline(always)]
280    fn from(variant: OPEN_DRAIN_A) -> Self {
281        match variant {
282            OPEN_DRAIN_A::GPIO_OUTPUT => false,
283            OPEN_DRAIN_A::OPEN_DRAIN_OUTPUT => true,
284        }
285    }
286}
287#[doc = "Reader of field `OPEN_DRAIN`"]
288pub type OPEN_DRAIN_R = crate::R<bool, OPEN_DRAIN_A>;
289impl OPEN_DRAIN_R {
290    #[doc = r"Get enumerated values variant"]
291    #[inline(always)]
292    pub fn variant(&self) -> OPEN_DRAIN_A {
293        match self.bits {
294            false => OPEN_DRAIN_A::GPIO_OUTPUT,
295            true => OPEN_DRAIN_A::OPEN_DRAIN_OUTPUT,
296        }
297    }
298    #[doc = "Checks if the value of the field is `GPIO_OUTPUT`"]
299    #[inline(always)]
300    pub fn is_gpio_output(&self) -> bool {
301        *self == OPEN_DRAIN_A::GPIO_OUTPUT
302    }
303    #[doc = "Checks if the value of the field is `OPEN_DRAIN_OUTPUT`"]
304    #[inline(always)]
305    pub fn is_open_drain_output(&self) -> bool {
306        *self == OPEN_DRAIN_A::OPEN_DRAIN_OUTPUT
307    }
308}
309#[doc = "Write proxy for field `OPEN_DRAIN`"]
310pub struct OPEN_DRAIN_W<'a> {
311    w: &'a mut W,
312}
313impl<'a> OPEN_DRAIN_W<'a> {
314    #[doc = r"Writes `variant` to the field"]
315    #[inline(always)]
316    pub fn variant(self, variant: OPEN_DRAIN_A) -> &'a mut W {
317        {
318            self.bit(variant.into())
319        }
320    }
321    #[doc = "Standard GPIO output"]
322    #[inline(always)]
323    pub fn gpio_output(self) -> &'a mut W {
324        self.variant(OPEN_DRAIN_A::GPIO_OUTPUT)
325    }
326    #[doc = "Open-drain output"]
327    #[inline(always)]
328    pub fn open_drain_output(self) -> &'a mut W {
329        self.variant(OPEN_DRAIN_A::OPEN_DRAIN_OUTPUT)
330    }
331    #[doc = r"Sets the field bit"]
332    #[inline(always)]
333    pub fn set_bit(self) -> &'a mut W {
334        self.bit(true)
335    }
336    #[doc = r"Clears the field bit"]
337    #[inline(always)]
338    pub fn clear_bit(self) -> &'a mut W {
339        self.bit(false)
340    }
341    #[doc = r"Writes raw bits to the field"]
342    #[inline(always)]
343    pub fn bit(self, value: bool) -> &'a mut W {
344        self.w.bits = (self.w.bits & !(0x01 << 10)) | (((value as u32) & 0x01) << 10);
345        self.w
346    }
347}
348impl R {
349    #[doc = "Bits 0:2 - Configure pin function."]
350    #[inline(always)]
351    pub fn func(&self) -> FUNC_R {
352        FUNC_R::new((self.bits & 0x07) as u8)
353    }
354    #[doc = "Bits 3:4 - Pin function mode (on-chip pull-up/pull-down resistor control)."]
355    #[inline(always)]
356    pub fn mode(&self) -> MODE_R {
357        MODE_R::new(((self.bits >> 3) & 0x03) as u8)
358    }
359    #[doc = "Bit 5 - Hysteresis."]
360    #[inline(always)]
361    pub fn hysteresis(&self) -> HYSTERESIS_R {
362        HYSTERESIS_R::new(((self.bits >> 5) & 0x01) != 0)
363    }
364    #[doc = "Bit 10 - Selects pseudo open-drain mode."]
365    #[inline(always)]
366    pub fn open_drain(&self) -> OPEN_DRAIN_R {
367        OPEN_DRAIN_R::new(((self.bits >> 10) & 0x01) != 0)
368    }
369}
370impl W {
371    #[doc = "Bits 0:2 - Configure pin function."]
372    #[inline(always)]
373    pub fn func(&mut self) -> FUNC_W {
374        FUNC_W { w: self }
375    }
376    #[doc = "Bits 3:4 - Pin function mode (on-chip pull-up/pull-down resistor control)."]
377    #[inline(always)]
378    pub fn mode(&mut self) -> MODE_W {
379        MODE_W { w: self }
380    }
381    #[doc = "Bit 5 - Hysteresis."]
382    #[inline(always)]
383    pub fn hysteresis(&mut self) -> HYSTERESIS_W {
384        HYSTERESIS_W { w: self }
385    }
386    #[doc = "Bit 10 - Selects pseudo open-drain mode."]
387    #[inline(always)]
388    pub fn open_drain(&mut self) -> OPEN_DRAIN_W {
389        OPEN_DRAIN_W { w: self }
390    }
391}