k22f/gpiod/
pddr.rs

1#[doc = "Reader of register PDDR"]
2pub type R = crate::R<u32, super::PDDR>;
3#[doc = "Writer for register PDDR"]
4pub type W = crate::W<u32, super::PDDR>;
5#[doc = "Register PDDR `reset()`'s with value 0"]
6impl crate::ResetValue for super::PDDR {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Port Data Direction\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15#[repr(u32)]
16pub enum PDD_A {
17    #[doc = "0: Pin is configured as general-purpose input, for the GPIO function."]
18    _0 = 0,
19    #[doc = "1: Pin is configured as general-purpose output, for the GPIO function."]
20    _1 = 1,
21}
22impl From<PDD_A> for u32 {
23    #[inline(always)]
24    fn from(variant: PDD_A) -> Self {
25        variant as _
26    }
27}
28#[doc = "Reader of field `PDD`"]
29pub type PDD_R = crate::R<u32, PDD_A>;
30impl PDD_R {
31    #[doc = r"Get enumerated values variant"]
32    #[inline(always)]
33    pub fn variant(&self) -> crate::Variant<u32, PDD_A> {
34        use crate::Variant::*;
35        match self.bits {
36            0 => Val(PDD_A::_0),
37            1 => Val(PDD_A::_1),
38            i => Res(i),
39        }
40    }
41    #[doc = "Checks if the value of the field is `_0`"]
42    #[inline(always)]
43    pub fn is_0(&self) -> bool {
44        *self == PDD_A::_0
45    }
46    #[doc = "Checks if the value of the field is `_1`"]
47    #[inline(always)]
48    pub fn is_1(&self) -> bool {
49        *self == PDD_A::_1
50    }
51}
52#[doc = "Write proxy for field `PDD`"]
53pub struct PDD_W<'a> {
54    w: &'a mut W,
55}
56impl<'a> PDD_W<'a> {
57    #[doc = r"Writes `variant` to the field"]
58    #[inline(always)]
59    pub fn variant(self, variant: PDD_A) -> &'a mut W {
60        unsafe { self.bits(variant.into()) }
61    }
62    #[doc = "Pin is configured as general-purpose input, for the GPIO function."]
63    #[inline(always)]
64    pub fn _0(self) -> &'a mut W {
65        self.variant(PDD_A::_0)
66    }
67    #[doc = "Pin is configured as general-purpose output, for the GPIO function."]
68    #[inline(always)]
69    pub fn _1(self) -> &'a mut W {
70        self.variant(PDD_A::_1)
71    }
72    #[doc = r"Writes raw bits to the field"]
73    #[inline(always)]
74    pub unsafe fn bits(self, value: u32) -> &'a mut W {
75        self.w.bits = (self.w.bits & !0xffff_ffff) | ((value as u32) & 0xffff_ffff);
76        self.w
77    }
78}
79impl R {
80    #[doc = "Bits 0:31 - Port Data Direction"]
81    #[inline(always)]
82    pub fn pdd(&self) -> PDD_R {
83        PDD_R::new((self.bits & 0xffff_ffff) as u32)
84    }
85}
86impl W {
87    #[doc = "Bits 0:31 - Port Data Direction"]
88    #[inline(always)]
89    pub fn pdd(&mut self) -> PDD_W {
90        PDD_W { w: self }
91    }
92}