esp32p4/pcnt/
ctrl.rs

1#[doc = "Register `CTRL` reader"]
2pub type R = crate::R<CTRL_SPEC>;
3#[doc = "Register `CTRL` writer"]
4pub type W = crate::W<CTRL_SPEC>;
5#[doc = "Field `PULSE_CNT_RST_U0` reader - Set this bit to clear unit 0's counter."]
6pub type PULSE_CNT_RST_U0_R = crate::BitReader;
7#[doc = "Field `PULSE_CNT_RST_U0` writer - Set this bit to clear unit 0's counter."]
8pub type PULSE_CNT_RST_U0_W<'a, REG> = crate::BitWriter<'a, REG>;
9#[doc = "Field `CNT_PAUSE_U0` reader - Set this bit to freeze unit 0's counter."]
10pub type CNT_PAUSE_U0_R = crate::BitReader;
11#[doc = "Field `CNT_PAUSE_U0` writer - Set this bit to freeze unit 0's counter."]
12pub type CNT_PAUSE_U0_W<'a, REG> = crate::BitWriter<'a, REG>;
13#[doc = "Field `PULSE_CNT_RST_U1` reader - Set this bit to clear unit 1's counter."]
14pub type PULSE_CNT_RST_U1_R = crate::BitReader;
15#[doc = "Field `PULSE_CNT_RST_U1` writer - Set this bit to clear unit 1's counter."]
16pub type PULSE_CNT_RST_U1_W<'a, REG> = crate::BitWriter<'a, REG>;
17#[doc = "Field `CNT_PAUSE_U1` reader - Set this bit to freeze unit 1's counter."]
18pub type CNT_PAUSE_U1_R = crate::BitReader;
19#[doc = "Field `CNT_PAUSE_U1` writer - Set this bit to freeze unit 1's counter."]
20pub type CNT_PAUSE_U1_W<'a, REG> = crate::BitWriter<'a, REG>;
21#[doc = "Field `PULSE_CNT_RST_U2` reader - Set this bit to clear unit 2's counter."]
22pub type PULSE_CNT_RST_U2_R = crate::BitReader;
23#[doc = "Field `PULSE_CNT_RST_U2` writer - Set this bit to clear unit 2's counter."]
24pub type PULSE_CNT_RST_U2_W<'a, REG> = crate::BitWriter<'a, REG>;
25#[doc = "Field `CNT_PAUSE_U2` reader - Set this bit to freeze unit 2's counter."]
26pub type CNT_PAUSE_U2_R = crate::BitReader;
27#[doc = "Field `CNT_PAUSE_U2` writer - Set this bit to freeze unit 2's counter."]
28pub type CNT_PAUSE_U2_W<'a, REG> = crate::BitWriter<'a, REG>;
29#[doc = "Field `PULSE_CNT_RST_U3` reader - Set this bit to clear unit 3's counter."]
30pub type PULSE_CNT_RST_U3_R = crate::BitReader;
31#[doc = "Field `PULSE_CNT_RST_U3` writer - Set this bit to clear unit 3's counter."]
32pub type PULSE_CNT_RST_U3_W<'a, REG> = crate::BitWriter<'a, REG>;
33#[doc = "Field `CNT_PAUSE_U3` reader - Set this bit to freeze unit 3's counter."]
34pub type CNT_PAUSE_U3_R = crate::BitReader;
35#[doc = "Field `CNT_PAUSE_U3` writer - Set this bit to freeze unit 3's counter."]
36pub type CNT_PAUSE_U3_W<'a, REG> = crate::BitWriter<'a, REG>;
37#[doc = "Field `DALTA_CHANGE_EN_U0` reader - Configures this bit to enable unit 0's step comparator."]
38pub type DALTA_CHANGE_EN_U0_R = crate::BitReader;
39#[doc = "Field `DALTA_CHANGE_EN_U0` writer - Configures this bit to enable unit 0's step comparator."]
40pub type DALTA_CHANGE_EN_U0_W<'a, REG> = crate::BitWriter<'a, REG>;
41#[doc = "Field `DALTA_CHANGE_EN_U1` reader - Configures this bit to enable unit 1's step comparator."]
42pub type DALTA_CHANGE_EN_U1_R = crate::BitReader;
43#[doc = "Field `DALTA_CHANGE_EN_U1` writer - Configures this bit to enable unit 1's step comparator."]
44pub type DALTA_CHANGE_EN_U1_W<'a, REG> = crate::BitWriter<'a, REG>;
45#[doc = "Field `DALTA_CHANGE_EN_U2` reader - Configures this bit to enable unit 2's step comparator."]
46pub type DALTA_CHANGE_EN_U2_R = crate::BitReader;
47#[doc = "Field `DALTA_CHANGE_EN_U2` writer - Configures this bit to enable unit 2's step comparator."]
48pub type DALTA_CHANGE_EN_U2_W<'a, REG> = crate::BitWriter<'a, REG>;
49#[doc = "Field `DALTA_CHANGE_EN_U3` reader - Configures this bit to enable unit 3's step comparator."]
50pub type DALTA_CHANGE_EN_U3_R = crate::BitReader;
51#[doc = "Field `DALTA_CHANGE_EN_U3` writer - Configures this bit to enable unit 3's step comparator."]
52pub type DALTA_CHANGE_EN_U3_W<'a, REG> = crate::BitWriter<'a, REG>;
53#[doc = "Field `CLK_EN` reader - The registers clock gate enable signal of PCNT module. 1: the registers can be read and written by application. 0: the registers can not be read or written by application"]
54pub type CLK_EN_R = crate::BitReader;
55#[doc = "Field `CLK_EN` writer - The registers clock gate enable signal of PCNT module. 1: the registers can be read and written by application. 0: the registers can not be read or written by application"]
56pub type CLK_EN_W<'a, REG> = crate::BitWriter<'a, REG>;
57impl R {
58    #[doc = "Bit 0 - Set this bit to clear unit 0's counter."]
59    #[inline(always)]
60    pub fn pulse_cnt_rst_u0(&self) -> PULSE_CNT_RST_U0_R {
61        PULSE_CNT_RST_U0_R::new((self.bits & 1) != 0)
62    }
63    #[doc = "Bit 1 - Set this bit to freeze unit 0's counter."]
64    #[inline(always)]
65    pub fn cnt_pause_u0(&self) -> CNT_PAUSE_U0_R {
66        CNT_PAUSE_U0_R::new(((self.bits >> 1) & 1) != 0)
67    }
68    #[doc = "Bit 2 - Set this bit to clear unit 1's counter."]
69    #[inline(always)]
70    pub fn pulse_cnt_rst_u1(&self) -> PULSE_CNT_RST_U1_R {
71        PULSE_CNT_RST_U1_R::new(((self.bits >> 2) & 1) != 0)
72    }
73    #[doc = "Bit 3 - Set this bit to freeze unit 1's counter."]
74    #[inline(always)]
75    pub fn cnt_pause_u1(&self) -> CNT_PAUSE_U1_R {
76        CNT_PAUSE_U1_R::new(((self.bits >> 3) & 1) != 0)
77    }
78    #[doc = "Bit 4 - Set this bit to clear unit 2's counter."]
79    #[inline(always)]
80    pub fn pulse_cnt_rst_u2(&self) -> PULSE_CNT_RST_U2_R {
81        PULSE_CNT_RST_U2_R::new(((self.bits >> 4) & 1) != 0)
82    }
83    #[doc = "Bit 5 - Set this bit to freeze unit 2's counter."]
84    #[inline(always)]
85    pub fn cnt_pause_u2(&self) -> CNT_PAUSE_U2_R {
86        CNT_PAUSE_U2_R::new(((self.bits >> 5) & 1) != 0)
87    }
88    #[doc = "Bit 6 - Set this bit to clear unit 3's counter."]
89    #[inline(always)]
90    pub fn pulse_cnt_rst_u3(&self) -> PULSE_CNT_RST_U3_R {
91        PULSE_CNT_RST_U3_R::new(((self.bits >> 6) & 1) != 0)
92    }
93    #[doc = "Bit 7 - Set this bit to freeze unit 3's counter."]
94    #[inline(always)]
95    pub fn cnt_pause_u3(&self) -> CNT_PAUSE_U3_R {
96        CNT_PAUSE_U3_R::new(((self.bits >> 7) & 1) != 0)
97    }
98    #[doc = "Bit 8 - Configures this bit to enable unit 0's step comparator."]
99    #[inline(always)]
100    pub fn dalta_change_en_u0(&self) -> DALTA_CHANGE_EN_U0_R {
101        DALTA_CHANGE_EN_U0_R::new(((self.bits >> 8) & 1) != 0)
102    }
103    #[doc = "Bit 9 - Configures this bit to enable unit 1's step comparator."]
104    #[inline(always)]
105    pub fn dalta_change_en_u1(&self) -> DALTA_CHANGE_EN_U1_R {
106        DALTA_CHANGE_EN_U1_R::new(((self.bits >> 9) & 1) != 0)
107    }
108    #[doc = "Bit 10 - Configures this bit to enable unit 2's step comparator."]
109    #[inline(always)]
110    pub fn dalta_change_en_u2(&self) -> DALTA_CHANGE_EN_U2_R {
111        DALTA_CHANGE_EN_U2_R::new(((self.bits >> 10) & 1) != 0)
112    }
113    #[doc = "Bit 11 - Configures this bit to enable unit 3's step comparator."]
114    #[inline(always)]
115    pub fn dalta_change_en_u3(&self) -> DALTA_CHANGE_EN_U3_R {
116        DALTA_CHANGE_EN_U3_R::new(((self.bits >> 11) & 1) != 0)
117    }
118    #[doc = "Bit 16 - The registers clock gate enable signal of PCNT module. 1: the registers can be read and written by application. 0: the registers can not be read or written by application"]
119    #[inline(always)]
120    pub fn clk_en(&self) -> CLK_EN_R {
121        CLK_EN_R::new(((self.bits >> 16) & 1) != 0)
122    }
123}
124#[cfg(feature = "impl-register-debug")]
125impl core::fmt::Debug for R {
126    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
127        f.debug_struct("CTRL")
128            .field(
129                "pulse_cnt_rst_u0",
130                &format_args!("{}", self.pulse_cnt_rst_u0().bit()),
131            )
132            .field(
133                "cnt_pause_u0",
134                &format_args!("{}", self.cnt_pause_u0().bit()),
135            )
136            .field(
137                "pulse_cnt_rst_u1",
138                &format_args!("{}", self.pulse_cnt_rst_u1().bit()),
139            )
140            .field(
141                "cnt_pause_u1",
142                &format_args!("{}", self.cnt_pause_u1().bit()),
143            )
144            .field(
145                "pulse_cnt_rst_u2",
146                &format_args!("{}", self.pulse_cnt_rst_u2().bit()),
147            )
148            .field(
149                "cnt_pause_u2",
150                &format_args!("{}", self.cnt_pause_u2().bit()),
151            )
152            .field(
153                "pulse_cnt_rst_u3",
154                &format_args!("{}", self.pulse_cnt_rst_u3().bit()),
155            )
156            .field(
157                "cnt_pause_u3",
158                &format_args!("{}", self.cnt_pause_u3().bit()),
159            )
160            .field(
161                "dalta_change_en_u0",
162                &format_args!("{}", self.dalta_change_en_u0().bit()),
163            )
164            .field(
165                "dalta_change_en_u1",
166                &format_args!("{}", self.dalta_change_en_u1().bit()),
167            )
168            .field(
169                "dalta_change_en_u2",
170                &format_args!("{}", self.dalta_change_en_u2().bit()),
171            )
172            .field(
173                "dalta_change_en_u3",
174                &format_args!("{}", self.dalta_change_en_u3().bit()),
175            )
176            .field("clk_en", &format_args!("{}", self.clk_en().bit()))
177            .finish()
178    }
179}
180#[cfg(feature = "impl-register-debug")]
181impl core::fmt::Debug for crate::generic::Reg<CTRL_SPEC> {
182    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
183        core::fmt::Debug::fmt(&self.read(), f)
184    }
185}
186impl W {
187    #[doc = "Bit 0 - Set this bit to clear unit 0's counter."]
188    #[inline(always)]
189    #[must_use]
190    pub fn pulse_cnt_rst_u0(&mut self) -> PULSE_CNT_RST_U0_W<CTRL_SPEC> {
191        PULSE_CNT_RST_U0_W::new(self, 0)
192    }
193    #[doc = "Bit 1 - Set this bit to freeze unit 0's counter."]
194    #[inline(always)]
195    #[must_use]
196    pub fn cnt_pause_u0(&mut self) -> CNT_PAUSE_U0_W<CTRL_SPEC> {
197        CNT_PAUSE_U0_W::new(self, 1)
198    }
199    #[doc = "Bit 2 - Set this bit to clear unit 1's counter."]
200    #[inline(always)]
201    #[must_use]
202    pub fn pulse_cnt_rst_u1(&mut self) -> PULSE_CNT_RST_U1_W<CTRL_SPEC> {
203        PULSE_CNT_RST_U1_W::new(self, 2)
204    }
205    #[doc = "Bit 3 - Set this bit to freeze unit 1's counter."]
206    #[inline(always)]
207    #[must_use]
208    pub fn cnt_pause_u1(&mut self) -> CNT_PAUSE_U1_W<CTRL_SPEC> {
209        CNT_PAUSE_U1_W::new(self, 3)
210    }
211    #[doc = "Bit 4 - Set this bit to clear unit 2's counter."]
212    #[inline(always)]
213    #[must_use]
214    pub fn pulse_cnt_rst_u2(&mut self) -> PULSE_CNT_RST_U2_W<CTRL_SPEC> {
215        PULSE_CNT_RST_U2_W::new(self, 4)
216    }
217    #[doc = "Bit 5 - Set this bit to freeze unit 2's counter."]
218    #[inline(always)]
219    #[must_use]
220    pub fn cnt_pause_u2(&mut self) -> CNT_PAUSE_U2_W<CTRL_SPEC> {
221        CNT_PAUSE_U2_W::new(self, 5)
222    }
223    #[doc = "Bit 6 - Set this bit to clear unit 3's counter."]
224    #[inline(always)]
225    #[must_use]
226    pub fn pulse_cnt_rst_u3(&mut self) -> PULSE_CNT_RST_U3_W<CTRL_SPEC> {
227        PULSE_CNT_RST_U3_W::new(self, 6)
228    }
229    #[doc = "Bit 7 - Set this bit to freeze unit 3's counter."]
230    #[inline(always)]
231    #[must_use]
232    pub fn cnt_pause_u3(&mut self) -> CNT_PAUSE_U3_W<CTRL_SPEC> {
233        CNT_PAUSE_U3_W::new(self, 7)
234    }
235    #[doc = "Bit 8 - Configures this bit to enable unit 0's step comparator."]
236    #[inline(always)]
237    #[must_use]
238    pub fn dalta_change_en_u0(&mut self) -> DALTA_CHANGE_EN_U0_W<CTRL_SPEC> {
239        DALTA_CHANGE_EN_U0_W::new(self, 8)
240    }
241    #[doc = "Bit 9 - Configures this bit to enable unit 1's step comparator."]
242    #[inline(always)]
243    #[must_use]
244    pub fn dalta_change_en_u1(&mut self) -> DALTA_CHANGE_EN_U1_W<CTRL_SPEC> {
245        DALTA_CHANGE_EN_U1_W::new(self, 9)
246    }
247    #[doc = "Bit 10 - Configures this bit to enable unit 2's step comparator."]
248    #[inline(always)]
249    #[must_use]
250    pub fn dalta_change_en_u2(&mut self) -> DALTA_CHANGE_EN_U2_W<CTRL_SPEC> {
251        DALTA_CHANGE_EN_U2_W::new(self, 10)
252    }
253    #[doc = "Bit 11 - Configures this bit to enable unit 3's step comparator."]
254    #[inline(always)]
255    #[must_use]
256    pub fn dalta_change_en_u3(&mut self) -> DALTA_CHANGE_EN_U3_W<CTRL_SPEC> {
257        DALTA_CHANGE_EN_U3_W::new(self, 11)
258    }
259    #[doc = "Bit 16 - The registers clock gate enable signal of PCNT module. 1: the registers can be read and written by application. 0: the registers can not be read or written by application"]
260    #[inline(always)]
261    #[must_use]
262    pub fn clk_en(&mut self) -> CLK_EN_W<CTRL_SPEC> {
263        CLK_EN_W::new(self, 16)
264    }
265}
266#[doc = "Control register for all counters\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`ctrl::R`](R).  You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`ctrl::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
267pub struct CTRL_SPEC;
268impl crate::RegisterSpec for CTRL_SPEC {
269    type Ux = u32;
270}
271#[doc = "`read()` method returns [`ctrl::R`](R) reader structure"]
272impl crate::Readable for CTRL_SPEC {}
273#[doc = "`write(|w| ..)` method takes [`ctrl::W`](W) writer structure"]
274impl crate::Writable for CTRL_SPEC {
275    type Safety = crate::Unsafe;
276    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
277    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
278}
279#[doc = "`reset()` method sets CTRL to value 0x01"]
280impl crate::Resettable for CTRL_SPEC {
281    const RESET_VALUE: u32 = 0x01;
282}