max78000_pac/gpio0/
padctrl0.rs

1#[doc = "Register `PADCTRL0` reader"]
2pub type R = crate::R<Padctrl0Spec>;
3#[doc = "Register `PADCTRL0` writer"]
4pub type W = crate::W<Padctrl0Spec>;
5#[doc = "The two bits in GPIO_PAD_CFG1 and GPIO_PAD_CFG2 for each GPIO pin work together to determine the pad mode when the GPIO is set to input mode.\n\nValue on reset: 0"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7#[repr(u32)]
8pub enum GpioPadctrl0 {
9    #[doc = "0: High Impedance."]
10    Impedance = 0,
11    #[doc = "1: Weak pull-up mode."]
12    Pu = 1,
13    #[doc = "2: weak pull-down mode."]
14    Pd = 2,
15}
16impl From<GpioPadctrl0> for u32 {
17    #[inline(always)]
18    fn from(variant: GpioPadctrl0) -> Self {
19        variant as _
20    }
21}
22impl crate::FieldSpec for GpioPadctrl0 {
23    type Ux = u32;
24}
25impl crate::IsEnum for GpioPadctrl0 {}
26#[doc = "Field `GPIO_PADCTRL0` reader - The two bits in GPIO_PAD_CFG1 and GPIO_PAD_CFG2 for each GPIO pin work together to determine the pad mode when the GPIO is set to input mode."]
27pub type GpioPadctrl0R = crate::FieldReader<GpioPadctrl0>;
28impl GpioPadctrl0R {
29    #[doc = "Get enumerated values variant"]
30    #[inline(always)]
31    pub const fn variant(&self) -> Option<GpioPadctrl0> {
32        match self.bits {
33            0 => Some(GpioPadctrl0::Impedance),
34            1 => Some(GpioPadctrl0::Pu),
35            2 => Some(GpioPadctrl0::Pd),
36            _ => None,
37        }
38    }
39    #[doc = "High Impedance."]
40    #[inline(always)]
41    pub fn is_impedance(&self) -> bool {
42        *self == GpioPadctrl0::Impedance
43    }
44    #[doc = "Weak pull-up mode."]
45    #[inline(always)]
46    pub fn is_pu(&self) -> bool {
47        *self == GpioPadctrl0::Pu
48    }
49    #[doc = "weak pull-down mode."]
50    #[inline(always)]
51    pub fn is_pd(&self) -> bool {
52        *self == GpioPadctrl0::Pd
53    }
54}
55#[doc = "Field `GPIO_PADCTRL0` writer - The two bits in GPIO_PAD_CFG1 and GPIO_PAD_CFG2 for each GPIO pin work together to determine the pad mode when the GPIO is set to input mode."]
56pub type GpioPadctrl0W<'a, REG> = crate::FieldWriter<'a, REG, 32, GpioPadctrl0>;
57impl<'a, REG> GpioPadctrl0W<'a, REG>
58where
59    REG: crate::Writable + crate::RegisterSpec,
60    REG::Ux: From<u32>,
61{
62    #[doc = "High Impedance."]
63    #[inline(always)]
64    pub fn impedance(self) -> &'a mut crate::W<REG> {
65        self.variant(GpioPadctrl0::Impedance)
66    }
67    #[doc = "Weak pull-up mode."]
68    #[inline(always)]
69    pub fn pu(self) -> &'a mut crate::W<REG> {
70        self.variant(GpioPadctrl0::Pu)
71    }
72    #[doc = "weak pull-down mode."]
73    #[inline(always)]
74    pub fn pd(self) -> &'a mut crate::W<REG> {
75        self.variant(GpioPadctrl0::Pd)
76    }
77}
78impl R {
79    #[doc = "Bits 0:31 - The two bits in GPIO_PAD_CFG1 and GPIO_PAD_CFG2 for each GPIO pin work together to determine the pad mode when the GPIO is set to input mode."]
80    #[inline(always)]
81    pub fn gpio_padctrl0(&self) -> GpioPadctrl0R {
82        GpioPadctrl0R::new(self.bits)
83    }
84}
85impl W {
86    #[doc = "Bits 0:31 - The two bits in GPIO_PAD_CFG1 and GPIO_PAD_CFG2 for each GPIO pin work together to determine the pad mode when the GPIO is set to input mode."]
87    #[inline(always)]
88    pub fn gpio_padctrl0(&mut self) -> GpioPadctrl0W<Padctrl0Spec> {
89        GpioPadctrl0W::new(self, 0)
90    }
91}
92#[doc = "GPIO Input Mode Config 1. Each bit in this register enables the weak pull-up for the associated GPIO pin in this port.\n\nYou can [`read`](crate::Reg::read) this register and get [`padctrl0::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`padctrl0::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
93pub struct Padctrl0Spec;
94impl crate::RegisterSpec for Padctrl0Spec {
95    type Ux = u32;
96}
97#[doc = "`read()` method returns [`padctrl0::R`](R) reader structure"]
98impl crate::Readable for Padctrl0Spec {}
99#[doc = "`write(|w| ..)` method takes [`padctrl0::W`](W) writer structure"]
100impl crate::Writable for Padctrl0Spec {
101    type Safety = crate::Unsafe;
102    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
103    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
104}
105#[doc = "`reset()` method sets PADCTRL0 to value 0"]
106impl crate::Resettable for Padctrl0Spec {
107    const RESET_VALUE: u32 = 0;
108}