lpc11xx/iocon/
iocon_pio2_9.rs

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