esp32s2/gpio/
pin.rs

1#[doc = "Register `PIN%s` reader"]
2pub type R = crate::R<PIN_SPEC>;
3#[doc = "Register `PIN%s` writer"]
4pub type W = crate::W<PIN_SPEC>;
5#[doc = "Field `SYNC2_BYPASS` reader - For the second stage synchronization, GPIO input data can be syn- chronized on either edge of the APB clock. 0: no synchronization; 1: synchronized on falling edge; 2 and 3: synchronized on rising edge."]
6pub type SYNC2_BYPASS_R = crate::FieldReader;
7#[doc = "Field `SYNC2_BYPASS` writer - For the second stage synchronization, GPIO input data can be syn- chronized on either edge of the APB clock. 0: no synchronization; 1: synchronized on falling edge; 2 and 3: synchronized on rising edge."]
8pub type SYNC2_BYPASS_W<'a, REG> = crate::FieldWriter<'a, REG, 2>;
9#[doc = "Field `PAD_DRIVER` reader - Pad driver selection. 0: normal output; 1: open drain output.."]
10pub type PAD_DRIVER_R = crate::BitReader;
11#[doc = "Field `PAD_DRIVER` writer - Pad driver selection. 0: normal output; 1: open drain output.."]
12pub type PAD_DRIVER_W<'a, REG> = crate::BitWriter<'a, REG>;
13#[doc = "Field `SYNC1_BYPASS` reader - For the first stage synchronization, GPIO input data can be synchro- nized on either edge of the APB clock. 0: no synchronization; 1: synchronized on falling edge; 2 and 3: synchronized on rising edge."]
14pub type SYNC1_BYPASS_R = crate::FieldReader;
15#[doc = "Field `SYNC1_BYPASS` writer - For the first stage synchronization, GPIO input data can be synchro- nized on either edge of the APB clock. 0: no synchronization; 1: synchronized on falling edge; 2 and 3: synchronized on rising edge."]
16pub type SYNC1_BYPASS_W<'a, REG> = crate::FieldWriter<'a, REG, 2>;
17#[doc = "Field `INT_TYPE` reader - Interrupt type selection. 0: GPIO interrupt disabled; 1: rising edge trigger; 2: falling edge trigger; 3: any edge trigger; 4: low level trigger; 5: high level trigger. (R/W)"]
18pub type INT_TYPE_R = crate::FieldReader;
19#[doc = "Field `INT_TYPE` writer - Interrupt type selection. 0: GPIO interrupt disabled; 1: rising edge trigger; 2: falling edge trigger; 3: any edge trigger; 4: low level trigger; 5: high level trigger. (R/W)"]
20pub type INT_TYPE_W<'a, REG> = crate::FieldWriter<'a, REG, 3>;
21#[doc = "Field `WAKEUP_ENABLE` reader - GPIO wake-up enable bit, only wakes up the CPU from Light-sleep."]
22pub type WAKEUP_ENABLE_R = crate::BitReader;
23#[doc = "Field `WAKEUP_ENABLE` writer - GPIO wake-up enable bit, only wakes up the CPU from Light-sleep."]
24pub type WAKEUP_ENABLE_W<'a, REG> = crate::BitWriter<'a, REG>;
25#[doc = "Field `CONFIG` reader - Reserved"]
26pub type CONFIG_R = crate::FieldReader;
27#[doc = "Field `CONFIG` writer - Reserved"]
28pub type CONFIG_W<'a, REG> = crate::FieldWriter<'a, REG, 2>;
29#[doc = "Field `INT_ENA` reader - Interrupt enable bits. bit13: CPU interrupt enabled; bit14: CPU non-maskable interrupt enabled."]
30pub type INT_ENA_R = crate::FieldReader;
31#[doc = "Field `INT_ENA` writer - Interrupt enable bits. bit13: CPU interrupt enabled; bit14: CPU non-maskable interrupt enabled."]
32pub type INT_ENA_W<'a, REG> = crate::FieldWriter<'a, REG, 5>;
33impl R {
34    #[doc = "Bits 0:1 - For the second stage synchronization, GPIO input data can be syn- chronized on either edge of the APB clock. 0: no synchronization; 1: synchronized on falling edge; 2 and 3: synchronized on rising edge."]
35    #[inline(always)]
36    pub fn sync2_bypass(&self) -> SYNC2_BYPASS_R {
37        SYNC2_BYPASS_R::new((self.bits & 3) as u8)
38    }
39    #[doc = "Bit 2 - Pad driver selection. 0: normal output; 1: open drain output.."]
40    #[inline(always)]
41    pub fn pad_driver(&self) -> PAD_DRIVER_R {
42        PAD_DRIVER_R::new(((self.bits >> 2) & 1) != 0)
43    }
44    #[doc = "Bits 3:4 - For the first stage synchronization, GPIO input data can be synchro- nized on either edge of the APB clock. 0: no synchronization; 1: synchronized on falling edge; 2 and 3: synchronized on rising edge."]
45    #[inline(always)]
46    pub fn sync1_bypass(&self) -> SYNC1_BYPASS_R {
47        SYNC1_BYPASS_R::new(((self.bits >> 3) & 3) as u8)
48    }
49    #[doc = "Bits 7:9 - Interrupt type selection. 0: GPIO interrupt disabled; 1: rising edge trigger; 2: falling edge trigger; 3: any edge trigger; 4: low level trigger; 5: high level trigger. (R/W)"]
50    #[inline(always)]
51    pub fn int_type(&self) -> INT_TYPE_R {
52        INT_TYPE_R::new(((self.bits >> 7) & 7) as u8)
53    }
54    #[doc = "Bit 10 - GPIO wake-up enable bit, only wakes up the CPU from Light-sleep."]
55    #[inline(always)]
56    pub fn wakeup_enable(&self) -> WAKEUP_ENABLE_R {
57        WAKEUP_ENABLE_R::new(((self.bits >> 10) & 1) != 0)
58    }
59    #[doc = "Bits 11:12 - Reserved"]
60    #[inline(always)]
61    pub fn config(&self) -> CONFIG_R {
62        CONFIG_R::new(((self.bits >> 11) & 3) as u8)
63    }
64    #[doc = "Bits 13:17 - Interrupt enable bits. bit13: CPU interrupt enabled; bit14: CPU non-maskable interrupt enabled."]
65    #[inline(always)]
66    pub fn int_ena(&self) -> INT_ENA_R {
67        INT_ENA_R::new(((self.bits >> 13) & 0x1f) as u8)
68    }
69}
70#[cfg(feature = "impl-register-debug")]
71impl core::fmt::Debug for R {
72    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
73        f.debug_struct("PIN")
74            .field("sync2_bypass", &self.sync2_bypass())
75            .field("pad_driver", &self.pad_driver())
76            .field("sync1_bypass", &self.sync1_bypass())
77            .field("int_type", &self.int_type())
78            .field("wakeup_enable", &self.wakeup_enable())
79            .field("config", &self.config())
80            .field("int_ena", &self.int_ena())
81            .finish()
82    }
83}
84impl W {
85    #[doc = "Bits 0:1 - For the second stage synchronization, GPIO input data can be syn- chronized on either edge of the APB clock. 0: no synchronization; 1: synchronized on falling edge; 2 and 3: synchronized on rising edge."]
86    #[inline(always)]
87    pub fn sync2_bypass(&mut self) -> SYNC2_BYPASS_W<PIN_SPEC> {
88        SYNC2_BYPASS_W::new(self, 0)
89    }
90    #[doc = "Bit 2 - Pad driver selection. 0: normal output; 1: open drain output.."]
91    #[inline(always)]
92    pub fn pad_driver(&mut self) -> PAD_DRIVER_W<PIN_SPEC> {
93        PAD_DRIVER_W::new(self, 2)
94    }
95    #[doc = "Bits 3:4 - For the first stage synchronization, GPIO input data can be synchro- nized on either edge of the APB clock. 0: no synchronization; 1: synchronized on falling edge; 2 and 3: synchronized on rising edge."]
96    #[inline(always)]
97    pub fn sync1_bypass(&mut self) -> SYNC1_BYPASS_W<PIN_SPEC> {
98        SYNC1_BYPASS_W::new(self, 3)
99    }
100    #[doc = "Bits 7:9 - Interrupt type selection. 0: GPIO interrupt disabled; 1: rising edge trigger; 2: falling edge trigger; 3: any edge trigger; 4: low level trigger; 5: high level trigger. (R/W)"]
101    #[inline(always)]
102    pub fn int_type(&mut self) -> INT_TYPE_W<PIN_SPEC> {
103        INT_TYPE_W::new(self, 7)
104    }
105    #[doc = "Bit 10 - GPIO wake-up enable bit, only wakes up the CPU from Light-sleep."]
106    #[inline(always)]
107    pub fn wakeup_enable(&mut self) -> WAKEUP_ENABLE_W<PIN_SPEC> {
108        WAKEUP_ENABLE_W::new(self, 10)
109    }
110    #[doc = "Bits 11:12 - Reserved"]
111    #[inline(always)]
112    pub fn config(&mut self) -> CONFIG_W<PIN_SPEC> {
113        CONFIG_W::new(self, 11)
114    }
115    #[doc = "Bits 13:17 - Interrupt enable bits. bit13: CPU interrupt enabled; bit14: CPU non-maskable interrupt enabled."]
116    #[inline(always)]
117    pub fn int_ena(&mut self) -> INT_ENA_W<PIN_SPEC> {
118        INT_ENA_W::new(self, 13)
119    }
120}
121#[doc = "Configuration for GPIO pin %s\n\nYou can [`read`](crate::Reg::read) this register and get [`pin::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`pin::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
122pub struct PIN_SPEC;
123impl crate::RegisterSpec for PIN_SPEC {
124    type Ux = u32;
125}
126#[doc = "`read()` method returns [`pin::R`](R) reader structure"]
127impl crate::Readable for PIN_SPEC {}
128#[doc = "`write(|w| ..)` method takes [`pin::W`](W) writer structure"]
129impl crate::Writable for PIN_SPEC {
130    type Safety = crate::Unsafe;
131}
132#[doc = "`reset()` method sets PIN%s to value 0"]
133impl crate::Resettable for PIN_SPEC {}