lpc550x/iocon/
pio0_28.rs

1#[doc = "Register `PIO0_28` reader"]
2pub struct R(crate::R<PIO0_28_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<PIO0_28_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<PIO0_28_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<PIO0_28_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `PIO0_28` writer"]
17pub struct W(crate::W<PIO0_28_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<PIO0_28_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<PIO0_28_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<PIO0_28_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `FUNC` reader - Selects pin function."]
38pub type FUNC_R = crate::FieldReader<u8, FUNC_A>;
39#[doc = "Selects pin function.\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum FUNC_A {
43    #[doc = "0: General-purpose digital input/output pin."]
44    PIO0_28 = 0,
45    #[doc = "1: Flexcomm 0 USART, SPI or I2S clock."]
46    FC0_SCK = 1,
47    #[doc = "3: Capture input to CTimer input multiplexers."]
48    CTIMER_INP11 = 3,
49    #[doc = "4: SCTimer/PWM output 7."]
50    SCT0_OUT7 = 4,
51    #[doc = "9: PLU output 1."]
52    PLU_OUT1 = 9,
53    #[doc = "10: Secure GPIO pin."]
54    SEC_PIO0_28 = 10,
55}
56impl From<FUNC_A> for u8 {
57    #[inline(always)]
58    fn from(variant: FUNC_A) -> Self {
59        variant as _
60    }
61}
62impl FUNC_R {
63    #[doc = "Get enumerated values variant"]
64    #[inline(always)]
65    pub fn variant(&self) -> Option<FUNC_A> {
66        match self.bits {
67            0 => Some(FUNC_A::PIO0_28),
68            1 => Some(FUNC_A::FC0_SCK),
69            3 => Some(FUNC_A::CTIMER_INP11),
70            4 => Some(FUNC_A::SCT0_OUT7),
71            9 => Some(FUNC_A::PLU_OUT1),
72            10 => Some(FUNC_A::SEC_PIO0_28),
73            _ => None,
74        }
75    }
76    #[doc = "Checks if the value of the field is `PIO0_28`"]
77    #[inline(always)]
78    pub fn is_pio0_28(&self) -> bool {
79        *self == FUNC_A::PIO0_28
80    }
81    #[doc = "Checks if the value of the field is `FC0_SCK`"]
82    #[inline(always)]
83    pub fn is_fc0_sck(&self) -> bool {
84        *self == FUNC_A::FC0_SCK
85    }
86    #[doc = "Checks if the value of the field is `CTIMER_INP11`"]
87    #[inline(always)]
88    pub fn is_ctimer_inp11(&self) -> bool {
89        *self == FUNC_A::CTIMER_INP11
90    }
91    #[doc = "Checks if the value of the field is `SCT0_OUT7`"]
92    #[inline(always)]
93    pub fn is_sct0_out7(&self) -> bool {
94        *self == FUNC_A::SCT0_OUT7
95    }
96    #[doc = "Checks if the value of the field is `PLU_OUT1`"]
97    #[inline(always)]
98    pub fn is_plu_out1(&self) -> bool {
99        *self == FUNC_A::PLU_OUT1
100    }
101    #[doc = "Checks if the value of the field is `SEC_PIO0_28`"]
102    #[inline(always)]
103    pub fn is_sec_pio0_28(&self) -> bool {
104        *self == FUNC_A::SEC_PIO0_28
105    }
106}
107#[doc = "Field `FUNC` writer - Selects pin function."]
108pub type FUNC_W<'a, const O: u8> = crate::FieldWriter<'a, u32, PIO0_28_SPEC, u8, FUNC_A, 4, O>;
109impl<'a, const O: u8> FUNC_W<'a, O> {
110    #[doc = "General-purpose digital input/output pin."]
111    #[inline(always)]
112    pub fn pio0_28(self) -> &'a mut W {
113        self.variant(FUNC_A::PIO0_28)
114    }
115    #[doc = "Flexcomm 0 USART, SPI or I2S clock."]
116    #[inline(always)]
117    pub fn fc0_sck(self) -> &'a mut W {
118        self.variant(FUNC_A::FC0_SCK)
119    }
120    #[doc = "Capture input to CTimer input multiplexers."]
121    #[inline(always)]
122    pub fn ctimer_inp11(self) -> &'a mut W {
123        self.variant(FUNC_A::CTIMER_INP11)
124    }
125    #[doc = "SCTimer/PWM output 7."]
126    #[inline(always)]
127    pub fn sct0_out7(self) -> &'a mut W {
128        self.variant(FUNC_A::SCT0_OUT7)
129    }
130    #[doc = "PLU output 1."]
131    #[inline(always)]
132    pub fn plu_out1(self) -> &'a mut W {
133        self.variant(FUNC_A::PLU_OUT1)
134    }
135    #[doc = "Secure GPIO pin."]
136    #[inline(always)]
137    pub fn sec_pio0_28(self) -> &'a mut W {
138        self.variant(FUNC_A::SEC_PIO0_28)
139    }
140}
141#[doc = "Field `MODE` reader - Selects function mode (on-chip pull-up/pull-down resistor control)."]
142pub type MODE_R = crate::FieldReader<u8, MODE_A>;
143#[doc = "Selects function mode (on-chip pull-up/pull-down resistor control).\n\nValue on reset: 0"]
144#[derive(Clone, Copy, Debug, PartialEq, Eq)]
145#[repr(u8)]
146pub enum MODE_A {
147    #[doc = "0: Inactive. Inactive (no pull-down/pull-up resistor enabled)."]
148    INACTIVE = 0,
149    #[doc = "1: Pull-down. Pull-down resistor enabled."]
150    PULL_DOWN = 1,
151    #[doc = "2: Pull-up. Pull-up resistor enabled."]
152    PULL_UP = 2,
153    #[doc = "3: Repeater. Repeater mode."]
154    REPEATER = 3,
155}
156impl From<MODE_A> for u8 {
157    #[inline(always)]
158    fn from(variant: MODE_A) -> Self {
159        variant as _
160    }
161}
162impl MODE_R {
163    #[doc = "Get enumerated values variant"]
164    #[inline(always)]
165    pub fn variant(&self) -> MODE_A {
166        match self.bits {
167            0 => MODE_A::INACTIVE,
168            1 => MODE_A::PULL_DOWN,
169            2 => MODE_A::PULL_UP,
170            3 => MODE_A::REPEATER,
171            _ => unreachable!(),
172        }
173    }
174    #[doc = "Checks if the value of the field is `INACTIVE`"]
175    #[inline(always)]
176    pub fn is_inactive(&self) -> bool {
177        *self == MODE_A::INACTIVE
178    }
179    #[doc = "Checks if the value of the field is `PULL_DOWN`"]
180    #[inline(always)]
181    pub fn is_pull_down(&self) -> bool {
182        *self == MODE_A::PULL_DOWN
183    }
184    #[doc = "Checks if the value of the field is `PULL_UP`"]
185    #[inline(always)]
186    pub fn is_pull_up(&self) -> bool {
187        *self == MODE_A::PULL_UP
188    }
189    #[doc = "Checks if the value of the field is `REPEATER`"]
190    #[inline(always)]
191    pub fn is_repeater(&self) -> bool {
192        *self == MODE_A::REPEATER
193    }
194}
195#[doc = "Field `MODE` writer - Selects function mode (on-chip pull-up/pull-down resistor control)."]
196pub type MODE_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u32, PIO0_28_SPEC, u8, MODE_A, 2, O>;
197impl<'a, const O: u8> MODE_W<'a, O> {
198    #[doc = "Inactive. Inactive (no pull-down/pull-up resistor enabled)."]
199    #[inline(always)]
200    pub fn inactive(self) -> &'a mut W {
201        self.variant(MODE_A::INACTIVE)
202    }
203    #[doc = "Pull-down. Pull-down resistor enabled."]
204    #[inline(always)]
205    pub fn pull_down(self) -> &'a mut W {
206        self.variant(MODE_A::PULL_DOWN)
207    }
208    #[doc = "Pull-up. Pull-up resistor enabled."]
209    #[inline(always)]
210    pub fn pull_up(self) -> &'a mut W {
211        self.variant(MODE_A::PULL_UP)
212    }
213    #[doc = "Repeater. Repeater mode."]
214    #[inline(always)]
215    pub fn repeater(self) -> &'a mut W {
216        self.variant(MODE_A::REPEATER)
217    }
218}
219#[doc = "Field `SLEW` reader - Driver slew rate."]
220pub type SLEW_R = crate::BitReader<SLEW_A>;
221#[doc = "Driver slew rate.\n\nValue on reset: 0"]
222#[derive(Clone, Copy, Debug, PartialEq, Eq)]
223pub enum SLEW_A {
224    #[doc = "0: Standard-mode, output slew rate is slower. More outputs can be switched simultaneously."]
225    STANDARD = 0,
226    #[doc = "1: Fast-mode, output slew rate is faster. Refer to the appropriate specific device data sheet for details."]
227    FAST = 1,
228}
229impl From<SLEW_A> for bool {
230    #[inline(always)]
231    fn from(variant: SLEW_A) -> Self {
232        variant as u8 != 0
233    }
234}
235impl SLEW_R {
236    #[doc = "Get enumerated values variant"]
237    #[inline(always)]
238    pub fn variant(&self) -> SLEW_A {
239        match self.bits {
240            false => SLEW_A::STANDARD,
241            true => SLEW_A::FAST,
242        }
243    }
244    #[doc = "Checks if the value of the field is `STANDARD`"]
245    #[inline(always)]
246    pub fn is_standard(&self) -> bool {
247        *self == SLEW_A::STANDARD
248    }
249    #[doc = "Checks if the value of the field is `FAST`"]
250    #[inline(always)]
251    pub fn is_fast(&self) -> bool {
252        *self == SLEW_A::FAST
253    }
254}
255#[doc = "Field `SLEW` writer - Driver slew rate."]
256pub type SLEW_W<'a, const O: u8> = crate::BitWriter<'a, u32, PIO0_28_SPEC, SLEW_A, O>;
257impl<'a, const O: u8> SLEW_W<'a, O> {
258    #[doc = "Standard-mode, output slew rate is slower. More outputs can be switched simultaneously."]
259    #[inline(always)]
260    pub fn standard(self) -> &'a mut W {
261        self.variant(SLEW_A::STANDARD)
262    }
263    #[doc = "Fast-mode, output slew rate is faster. Refer to the appropriate specific device data sheet for details."]
264    #[inline(always)]
265    pub fn fast(self) -> &'a mut W {
266        self.variant(SLEW_A::FAST)
267    }
268}
269#[doc = "Field `INVERT` reader - Input polarity."]
270pub type INVERT_R = crate::BitReader<INVERT_A>;
271#[doc = "Input polarity.\n\nValue on reset: 0"]
272#[derive(Clone, Copy, Debug, PartialEq, Eq)]
273pub enum INVERT_A {
274    #[doc = "0: Disabled. Input function is not inverted."]
275    DISABLED = 0,
276    #[doc = "1: Enabled. Input is function inverted."]
277    ENABLED = 1,
278}
279impl From<INVERT_A> for bool {
280    #[inline(always)]
281    fn from(variant: INVERT_A) -> Self {
282        variant as u8 != 0
283    }
284}
285impl INVERT_R {
286    #[doc = "Get enumerated values variant"]
287    #[inline(always)]
288    pub fn variant(&self) -> INVERT_A {
289        match self.bits {
290            false => INVERT_A::DISABLED,
291            true => INVERT_A::ENABLED,
292        }
293    }
294    #[doc = "Checks if the value of the field is `DISABLED`"]
295    #[inline(always)]
296    pub fn is_disabled(&self) -> bool {
297        *self == INVERT_A::DISABLED
298    }
299    #[doc = "Checks if the value of the field is `ENABLED`"]
300    #[inline(always)]
301    pub fn is_enabled(&self) -> bool {
302        *self == INVERT_A::ENABLED
303    }
304}
305#[doc = "Field `INVERT` writer - Input polarity."]
306pub type INVERT_W<'a, const O: u8> = crate::BitWriter<'a, u32, PIO0_28_SPEC, INVERT_A, O>;
307impl<'a, const O: u8> INVERT_W<'a, O> {
308    #[doc = "Disabled. Input function is not inverted."]
309    #[inline(always)]
310    pub fn disabled(self) -> &'a mut W {
311        self.variant(INVERT_A::DISABLED)
312    }
313    #[doc = "Enabled. Input is function inverted."]
314    #[inline(always)]
315    pub fn enabled(self) -> &'a mut W {
316        self.variant(INVERT_A::ENABLED)
317    }
318}
319#[doc = "Field `DIGIMODE` reader - Select Digital mode."]
320pub type DIGIMODE_R = crate::BitReader<DIGIMODE_A>;
321#[doc = "Select Digital mode.\n\nValue on reset: 0"]
322#[derive(Clone, Copy, Debug, PartialEq, Eq)]
323pub enum DIGIMODE_A {
324    #[doc = "0: Disable digital mode. Digital input set to 0."]
325    ANALOG = 0,
326    #[doc = "1: Enable Digital mode. Digital input is enabled."]
327    DIGITAL = 1,
328}
329impl From<DIGIMODE_A> for bool {
330    #[inline(always)]
331    fn from(variant: DIGIMODE_A) -> Self {
332        variant as u8 != 0
333    }
334}
335impl DIGIMODE_R {
336    #[doc = "Get enumerated values variant"]
337    #[inline(always)]
338    pub fn variant(&self) -> DIGIMODE_A {
339        match self.bits {
340            false => DIGIMODE_A::ANALOG,
341            true => DIGIMODE_A::DIGITAL,
342        }
343    }
344    #[doc = "Checks if the value of the field is `ANALOG`"]
345    #[inline(always)]
346    pub fn is_analog(&self) -> bool {
347        *self == DIGIMODE_A::ANALOG
348    }
349    #[doc = "Checks if the value of the field is `DIGITAL`"]
350    #[inline(always)]
351    pub fn is_digital(&self) -> bool {
352        *self == DIGIMODE_A::DIGITAL
353    }
354}
355#[doc = "Field `DIGIMODE` writer - Select Digital mode."]
356pub type DIGIMODE_W<'a, const O: u8> = crate::BitWriter<'a, u32, PIO0_28_SPEC, DIGIMODE_A, O>;
357impl<'a, const O: u8> DIGIMODE_W<'a, O> {
358    #[doc = "Disable digital mode. Digital input set to 0."]
359    #[inline(always)]
360    pub fn analog(self) -> &'a mut W {
361        self.variant(DIGIMODE_A::ANALOG)
362    }
363    #[doc = "Enable Digital mode. Digital input is enabled."]
364    #[inline(always)]
365    pub fn digital(self) -> &'a mut W {
366        self.variant(DIGIMODE_A::DIGITAL)
367    }
368}
369#[doc = "Field `OD` reader - Controls open-drain mode."]
370pub type OD_R = crate::BitReader<OD_A>;
371#[doc = "Controls open-drain mode.\n\nValue on reset: 0"]
372#[derive(Clone, Copy, Debug, PartialEq, Eq)]
373pub enum OD_A {
374    #[doc = "0: Normal. Normal push-pull output."]
375    NORMAL = 0,
376    #[doc = "1: Open-drain. Simulated open-drain output (high drive disabled)."]
377    OPEN_DRAIN = 1,
378}
379impl From<OD_A> for bool {
380    #[inline(always)]
381    fn from(variant: OD_A) -> Self {
382        variant as u8 != 0
383    }
384}
385impl OD_R {
386    #[doc = "Get enumerated values variant"]
387    #[inline(always)]
388    pub fn variant(&self) -> OD_A {
389        match self.bits {
390            false => OD_A::NORMAL,
391            true => OD_A::OPEN_DRAIN,
392        }
393    }
394    #[doc = "Checks if the value of the field is `NORMAL`"]
395    #[inline(always)]
396    pub fn is_normal(&self) -> bool {
397        *self == OD_A::NORMAL
398    }
399    #[doc = "Checks if the value of the field is `OPEN_DRAIN`"]
400    #[inline(always)]
401    pub fn is_open_drain(&self) -> bool {
402        *self == OD_A::OPEN_DRAIN
403    }
404}
405#[doc = "Field `OD` writer - Controls open-drain mode."]
406pub type OD_W<'a, const O: u8> = crate::BitWriter<'a, u32, PIO0_28_SPEC, OD_A, O>;
407impl<'a, const O: u8> OD_W<'a, O> {
408    #[doc = "Normal. Normal push-pull output."]
409    #[inline(always)]
410    pub fn normal(self) -> &'a mut W {
411        self.variant(OD_A::NORMAL)
412    }
413    #[doc = "Open-drain. Simulated open-drain output (high drive disabled)."]
414    #[inline(always)]
415    pub fn open_drain(self) -> &'a mut W {
416        self.variant(OD_A::OPEN_DRAIN)
417    }
418}
419impl R {
420    #[doc = "Bits 0:3 - Selects pin function."]
421    #[inline(always)]
422    pub fn func(&self) -> FUNC_R {
423        FUNC_R::new((self.bits & 0x0f) as u8)
424    }
425    #[doc = "Bits 4:5 - Selects function mode (on-chip pull-up/pull-down resistor control)."]
426    #[inline(always)]
427    pub fn mode(&self) -> MODE_R {
428        MODE_R::new(((self.bits >> 4) & 3) as u8)
429    }
430    #[doc = "Bit 6 - Driver slew rate."]
431    #[inline(always)]
432    pub fn slew(&self) -> SLEW_R {
433        SLEW_R::new(((self.bits >> 6) & 1) != 0)
434    }
435    #[doc = "Bit 7 - Input polarity."]
436    #[inline(always)]
437    pub fn invert(&self) -> INVERT_R {
438        INVERT_R::new(((self.bits >> 7) & 1) != 0)
439    }
440    #[doc = "Bit 8 - Select Digital mode."]
441    #[inline(always)]
442    pub fn digimode(&self) -> DIGIMODE_R {
443        DIGIMODE_R::new(((self.bits >> 8) & 1) != 0)
444    }
445    #[doc = "Bit 9 - Controls open-drain mode."]
446    #[inline(always)]
447    pub fn od(&self) -> OD_R {
448        OD_R::new(((self.bits >> 9) & 1) != 0)
449    }
450}
451impl W {
452    #[doc = "Bits 0:3 - Selects pin function."]
453    #[inline(always)]
454    pub fn func(&mut self) -> FUNC_W<0> {
455        FUNC_W::new(self)
456    }
457    #[doc = "Bits 4:5 - Selects function mode (on-chip pull-up/pull-down resistor control)."]
458    #[inline(always)]
459    pub fn mode(&mut self) -> MODE_W<4> {
460        MODE_W::new(self)
461    }
462    #[doc = "Bit 6 - Driver slew rate."]
463    #[inline(always)]
464    pub fn slew(&mut self) -> SLEW_W<6> {
465        SLEW_W::new(self)
466    }
467    #[doc = "Bit 7 - Input polarity."]
468    #[inline(always)]
469    pub fn invert(&mut self) -> INVERT_W<7> {
470        INVERT_W::new(self)
471    }
472    #[doc = "Bit 8 - Select Digital mode."]
473    #[inline(always)]
474    pub fn digimode(&mut self) -> DIGIMODE_W<8> {
475        DIGIMODE_W::new(self)
476    }
477    #[doc = "Bit 9 - Controls open-drain mode."]
478    #[inline(always)]
479    pub fn od(&mut self) -> OD_W<9> {
480        OD_W::new(self)
481    }
482    #[doc = "Writes raw bits to the register."]
483    #[inline(always)]
484    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
485        self.0.bits(bits);
486        self
487    }
488}
489#[doc = "Digital I/O control for port 0 pins PIO0_28.\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 [pio0_28](index.html) module"]
490pub struct PIO0_28_SPEC;
491impl crate::RegisterSpec for PIO0_28_SPEC {
492    type Ux = u32;
493}
494#[doc = "`read()` method returns [pio0_28::R](R) reader structure"]
495impl crate::Readable for PIO0_28_SPEC {
496    type Reader = R;
497}
498#[doc = "`write(|w| ..)` method takes [pio0_28::W](W) writer structure"]
499impl crate::Writable for PIO0_28_SPEC {
500    type Writer = W;
501}
502#[doc = "`reset()` method sets PIO0_28 to value 0"]
503impl crate::Resettable for PIO0_28_SPEC {
504    #[inline(always)]
505    fn reset_value() -> Self::Ux {
506        0
507    }
508}