esp32/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 `CNT_RST_U(0-7)` reader - Set this bit to clear unit%s's counter."]
6pub type CNT_RST_U_R = crate::BitReader;
7#[doc = "Field `CNT_RST_U(0-7)` writer - Set this bit to clear unit%s's counter."]
8pub type CNT_RST_U_W<'a, REG> = crate::BitWriter<'a, REG>;
9#[doc = "Field `CNT_PAUSE_U(0-7)` reader - Set this bit to pause unit%s's counter."]
10pub type CNT_PAUSE_U_R = crate::BitReader;
11#[doc = "Field `CNT_PAUSE_U(0-7)` writer - Set this bit to pause unit%s's counter."]
12pub type CNT_PAUSE_U_W<'a, REG> = crate::BitWriter<'a, REG>;
13#[doc = "Field `CLK_EN` reader - "]
14pub type CLK_EN_R = crate::BitReader;
15#[doc = "Field `CLK_EN` writer - "]
16pub type CLK_EN_W<'a, REG> = crate::BitWriter<'a, REG>;
17impl R {
18    #[doc = "Set this bit to clear unit(0-7)'s counter."]
19    #[doc = ""]
20    #[doc = "<div class=\"warning\">`n` is number of field in register. `n == 0` corresponds to `CNT_RST_U0` field.</div>"]
21    #[inline(always)]
22    pub fn cnt_rst_u(&self, n: u8) -> CNT_RST_U_R {
23        #[allow(clippy::no_effect)]
24        [(); 8][n as usize];
25        CNT_RST_U_R::new(((self.bits >> (n * 2)) & 1) != 0)
26    }
27    #[doc = "Iterator for array of:"]
28    #[doc = "Set this bit to clear unit(0-7)'s counter."]
29    #[inline(always)]
30    pub fn cnt_rst_u_iter(&self) -> impl Iterator<Item = CNT_RST_U_R> + '_ {
31        (0..8).map(move |n| CNT_RST_U_R::new(((self.bits >> (n * 2)) & 1) != 0))
32    }
33    #[doc = "Bit 0 - Set this bit to clear unit0's counter."]
34    #[inline(always)]
35    pub fn cnt_rst_u0(&self) -> CNT_RST_U_R {
36        CNT_RST_U_R::new((self.bits & 1) != 0)
37    }
38    #[doc = "Bit 2 - Set this bit to clear unit1's counter."]
39    #[inline(always)]
40    pub fn cnt_rst_u1(&self) -> CNT_RST_U_R {
41        CNT_RST_U_R::new(((self.bits >> 2) & 1) != 0)
42    }
43    #[doc = "Bit 4 - Set this bit to clear unit2's counter."]
44    #[inline(always)]
45    pub fn cnt_rst_u2(&self) -> CNT_RST_U_R {
46        CNT_RST_U_R::new(((self.bits >> 4) & 1) != 0)
47    }
48    #[doc = "Bit 6 - Set this bit to clear unit3's counter."]
49    #[inline(always)]
50    pub fn cnt_rst_u3(&self) -> CNT_RST_U_R {
51        CNT_RST_U_R::new(((self.bits >> 6) & 1) != 0)
52    }
53    #[doc = "Bit 8 - Set this bit to clear unit4's counter."]
54    #[inline(always)]
55    pub fn cnt_rst_u4(&self) -> CNT_RST_U_R {
56        CNT_RST_U_R::new(((self.bits >> 8) & 1) != 0)
57    }
58    #[doc = "Bit 10 - Set this bit to clear unit5's counter."]
59    #[inline(always)]
60    pub fn cnt_rst_u5(&self) -> CNT_RST_U_R {
61        CNT_RST_U_R::new(((self.bits >> 10) & 1) != 0)
62    }
63    #[doc = "Bit 12 - Set this bit to clear unit6's counter."]
64    #[inline(always)]
65    pub fn cnt_rst_u6(&self) -> CNT_RST_U_R {
66        CNT_RST_U_R::new(((self.bits >> 12) & 1) != 0)
67    }
68    #[doc = "Bit 14 - Set this bit to clear unit7's counter."]
69    #[inline(always)]
70    pub fn cnt_rst_u7(&self) -> CNT_RST_U_R {
71        CNT_RST_U_R::new(((self.bits >> 14) & 1) != 0)
72    }
73    #[doc = "Set this bit to pause unit(0-7)'s counter."]
74    #[doc = ""]
75    #[doc = "<div class=\"warning\">`n` is number of field in register. `n == 0` corresponds to `CNT_PAUSE_U0` field.</div>"]
76    #[inline(always)]
77    pub fn cnt_pause_u(&self, n: u8) -> CNT_PAUSE_U_R {
78        #[allow(clippy::no_effect)]
79        [(); 8][n as usize];
80        CNT_PAUSE_U_R::new(((self.bits >> (n * 2 + 1)) & 1) != 0)
81    }
82    #[doc = "Iterator for array of:"]
83    #[doc = "Set this bit to pause unit(0-7)'s counter."]
84    #[inline(always)]
85    pub fn cnt_pause_u_iter(&self) -> impl Iterator<Item = CNT_PAUSE_U_R> + '_ {
86        (0..8).map(move |n| CNT_PAUSE_U_R::new(((self.bits >> (n * 2 + 1)) & 1) != 0))
87    }
88    #[doc = "Bit 1 - Set this bit to pause unit0's counter."]
89    #[inline(always)]
90    pub fn cnt_pause_u0(&self) -> CNT_PAUSE_U_R {
91        CNT_PAUSE_U_R::new(((self.bits >> 1) & 1) != 0)
92    }
93    #[doc = "Bit 3 - Set this bit to pause unit1's counter."]
94    #[inline(always)]
95    pub fn cnt_pause_u1(&self) -> CNT_PAUSE_U_R {
96        CNT_PAUSE_U_R::new(((self.bits >> 3) & 1) != 0)
97    }
98    #[doc = "Bit 5 - Set this bit to pause unit2's counter."]
99    #[inline(always)]
100    pub fn cnt_pause_u2(&self) -> CNT_PAUSE_U_R {
101        CNT_PAUSE_U_R::new(((self.bits >> 5) & 1) != 0)
102    }
103    #[doc = "Bit 7 - Set this bit to pause unit3's counter."]
104    #[inline(always)]
105    pub fn cnt_pause_u3(&self) -> CNT_PAUSE_U_R {
106        CNT_PAUSE_U_R::new(((self.bits >> 7) & 1) != 0)
107    }
108    #[doc = "Bit 9 - Set this bit to pause unit4's counter."]
109    #[inline(always)]
110    pub fn cnt_pause_u4(&self) -> CNT_PAUSE_U_R {
111        CNT_PAUSE_U_R::new(((self.bits >> 9) & 1) != 0)
112    }
113    #[doc = "Bit 11 - Set this bit to pause unit5's counter."]
114    #[inline(always)]
115    pub fn cnt_pause_u5(&self) -> CNT_PAUSE_U_R {
116        CNT_PAUSE_U_R::new(((self.bits >> 11) & 1) != 0)
117    }
118    #[doc = "Bit 13 - Set this bit to pause unit6's counter."]
119    #[inline(always)]
120    pub fn cnt_pause_u6(&self) -> CNT_PAUSE_U_R {
121        CNT_PAUSE_U_R::new(((self.bits >> 13) & 1) != 0)
122    }
123    #[doc = "Bit 15 - Set this bit to pause unit7's counter."]
124    #[inline(always)]
125    pub fn cnt_pause_u7(&self) -> CNT_PAUSE_U_R {
126        CNT_PAUSE_U_R::new(((self.bits >> 15) & 1) != 0)
127    }
128    #[doc = "Bit 16"]
129    #[inline(always)]
130    pub fn clk_en(&self) -> CLK_EN_R {
131        CLK_EN_R::new(((self.bits >> 16) & 1) != 0)
132    }
133}
134#[cfg(feature = "impl-register-debug")]
135impl core::fmt::Debug for R {
136    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
137        f.debug_struct("CTRL")
138            .field("cnt_rst_u0", &self.cnt_rst_u0())
139            .field("cnt_rst_u1", &self.cnt_rst_u1())
140            .field("cnt_rst_u2", &self.cnt_rst_u2())
141            .field("cnt_rst_u3", &self.cnt_rst_u3())
142            .field("cnt_rst_u4", &self.cnt_rst_u4())
143            .field("cnt_rst_u5", &self.cnt_rst_u5())
144            .field("cnt_rst_u6", &self.cnt_rst_u6())
145            .field("cnt_rst_u7", &self.cnt_rst_u7())
146            .field("cnt_pause_u0", &self.cnt_pause_u0())
147            .field("cnt_pause_u1", &self.cnt_pause_u1())
148            .field("cnt_pause_u2", &self.cnt_pause_u2())
149            .field("cnt_pause_u3", &self.cnt_pause_u3())
150            .field("cnt_pause_u4", &self.cnt_pause_u4())
151            .field("cnt_pause_u5", &self.cnt_pause_u5())
152            .field("cnt_pause_u6", &self.cnt_pause_u6())
153            .field("cnt_pause_u7", &self.cnt_pause_u7())
154            .field("clk_en", &self.clk_en())
155            .finish()
156    }
157}
158impl W {
159    #[doc = "Set this bit to clear unit(0-7)'s counter."]
160    #[doc = ""]
161    #[doc = "<div class=\"warning\">`n` is number of field in register. `n == 0` corresponds to `CNT_RST_U0` field.</div>"]
162    #[inline(always)]
163    pub fn cnt_rst_u(&mut self, n: u8) -> CNT_RST_U_W<CTRL_SPEC> {
164        #[allow(clippy::no_effect)]
165        [(); 8][n as usize];
166        CNT_RST_U_W::new(self, n * 2)
167    }
168    #[doc = "Bit 0 - Set this bit to clear unit0's counter."]
169    #[inline(always)]
170    pub fn cnt_rst_u0(&mut self) -> CNT_RST_U_W<CTRL_SPEC> {
171        CNT_RST_U_W::new(self, 0)
172    }
173    #[doc = "Bit 2 - Set this bit to clear unit1's counter."]
174    #[inline(always)]
175    pub fn cnt_rst_u1(&mut self) -> CNT_RST_U_W<CTRL_SPEC> {
176        CNT_RST_U_W::new(self, 2)
177    }
178    #[doc = "Bit 4 - Set this bit to clear unit2's counter."]
179    #[inline(always)]
180    pub fn cnt_rst_u2(&mut self) -> CNT_RST_U_W<CTRL_SPEC> {
181        CNT_RST_U_W::new(self, 4)
182    }
183    #[doc = "Bit 6 - Set this bit to clear unit3's counter."]
184    #[inline(always)]
185    pub fn cnt_rst_u3(&mut self) -> CNT_RST_U_W<CTRL_SPEC> {
186        CNT_RST_U_W::new(self, 6)
187    }
188    #[doc = "Bit 8 - Set this bit to clear unit4's counter."]
189    #[inline(always)]
190    pub fn cnt_rst_u4(&mut self) -> CNT_RST_U_W<CTRL_SPEC> {
191        CNT_RST_U_W::new(self, 8)
192    }
193    #[doc = "Bit 10 - Set this bit to clear unit5's counter."]
194    #[inline(always)]
195    pub fn cnt_rst_u5(&mut self) -> CNT_RST_U_W<CTRL_SPEC> {
196        CNT_RST_U_W::new(self, 10)
197    }
198    #[doc = "Bit 12 - Set this bit to clear unit6's counter."]
199    #[inline(always)]
200    pub fn cnt_rst_u6(&mut self) -> CNT_RST_U_W<CTRL_SPEC> {
201        CNT_RST_U_W::new(self, 12)
202    }
203    #[doc = "Bit 14 - Set this bit to clear unit7's counter."]
204    #[inline(always)]
205    pub fn cnt_rst_u7(&mut self) -> CNT_RST_U_W<CTRL_SPEC> {
206        CNT_RST_U_W::new(self, 14)
207    }
208    #[doc = "Set this bit to pause unit(0-7)'s counter."]
209    #[doc = ""]
210    #[doc = "<div class=\"warning\">`n` is number of field in register. `n == 0` corresponds to `CNT_PAUSE_U0` field.</div>"]
211    #[inline(always)]
212    pub fn cnt_pause_u(&mut self, n: u8) -> CNT_PAUSE_U_W<CTRL_SPEC> {
213        #[allow(clippy::no_effect)]
214        [(); 8][n as usize];
215        CNT_PAUSE_U_W::new(self, n * 2 + 1)
216    }
217    #[doc = "Bit 1 - Set this bit to pause unit0's counter."]
218    #[inline(always)]
219    pub fn cnt_pause_u0(&mut self) -> CNT_PAUSE_U_W<CTRL_SPEC> {
220        CNT_PAUSE_U_W::new(self, 1)
221    }
222    #[doc = "Bit 3 - Set this bit to pause unit1's counter."]
223    #[inline(always)]
224    pub fn cnt_pause_u1(&mut self) -> CNT_PAUSE_U_W<CTRL_SPEC> {
225        CNT_PAUSE_U_W::new(self, 3)
226    }
227    #[doc = "Bit 5 - Set this bit to pause unit2's counter."]
228    #[inline(always)]
229    pub fn cnt_pause_u2(&mut self) -> CNT_PAUSE_U_W<CTRL_SPEC> {
230        CNT_PAUSE_U_W::new(self, 5)
231    }
232    #[doc = "Bit 7 - Set this bit to pause unit3's counter."]
233    #[inline(always)]
234    pub fn cnt_pause_u3(&mut self) -> CNT_PAUSE_U_W<CTRL_SPEC> {
235        CNT_PAUSE_U_W::new(self, 7)
236    }
237    #[doc = "Bit 9 - Set this bit to pause unit4's counter."]
238    #[inline(always)]
239    pub fn cnt_pause_u4(&mut self) -> CNT_PAUSE_U_W<CTRL_SPEC> {
240        CNT_PAUSE_U_W::new(self, 9)
241    }
242    #[doc = "Bit 11 - Set this bit to pause unit5's counter."]
243    #[inline(always)]
244    pub fn cnt_pause_u5(&mut self) -> CNT_PAUSE_U_W<CTRL_SPEC> {
245        CNT_PAUSE_U_W::new(self, 11)
246    }
247    #[doc = "Bit 13 - Set this bit to pause unit6's counter."]
248    #[inline(always)]
249    pub fn cnt_pause_u6(&mut self) -> CNT_PAUSE_U_W<CTRL_SPEC> {
250        CNT_PAUSE_U_W::new(self, 13)
251    }
252    #[doc = "Bit 15 - Set this bit to pause unit7's counter."]
253    #[inline(always)]
254    pub fn cnt_pause_u7(&mut self) -> CNT_PAUSE_U_W<CTRL_SPEC> {
255        CNT_PAUSE_U_W::new(self, 15)
256    }
257    #[doc = "Bit 16"]
258    #[inline(always)]
259    pub fn clk_en(&mut self) -> CLK_EN_W<CTRL_SPEC> {
260        CLK_EN_W::new(self, 16)
261    }
262}
263#[doc = "\n\nYou can [`read`](crate::Reg::read) this register and get [`ctrl::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`ctrl::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
264pub struct CTRL_SPEC;
265impl crate::RegisterSpec for CTRL_SPEC {
266    type Ux = u32;
267}
268#[doc = "`read()` method returns [`ctrl::R`](R) reader structure"]
269impl crate::Readable for CTRL_SPEC {}
270#[doc = "`write(|w| ..)` method takes [`ctrl::W`](W) writer structure"]
271impl crate::Writable for CTRL_SPEC {
272    type Safety = crate::Unsafe;
273    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
274    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
275}
276#[doc = "`reset()` method sets CTRL to value 0x5555"]
277impl crate::Resettable for CTRL_SPEC {
278    const RESET_VALUE: u32 = 0x5555;
279}