stm32f4_staging/stm32f407/tim2/
ccer.rs1pub type R = crate::R<CCERrs>;
3pub type W = crate::W<CCERrs>;
5#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10pub enum CC1E {
11 Disabled = 0,
13 Enabled = 1,
15}
16impl From<CC1E> for bool {
17 #[inline(always)]
18 fn from(variant: CC1E) -> Self {
19 variant as u8 != 0
20 }
21}
22pub type CCE_R = crate::BitReader<CC1E>;
24impl CCE_R {
25 #[inline(always)]
27 pub const fn variant(&self) -> CC1E {
28 match self.bits {
29 false => CC1E::Disabled,
30 true => CC1E::Enabled,
31 }
32 }
33 #[inline(always)]
35 pub fn is_disabled(&self) -> bool {
36 *self == CC1E::Disabled
37 }
38 #[inline(always)]
40 pub fn is_enabled(&self) -> bool {
41 *self == CC1E::Enabled
42 }
43}
44pub type CCE_W<'a, REG> = crate::BitWriter<'a, REG, CC1E>;
46impl<'a, REG> CCE_W<'a, REG>
47where
48 REG: crate::Writable + crate::RegisterSpec,
49{
50 #[inline(always)]
52 pub fn disabled(self) -> &'a mut crate::W<REG> {
53 self.variant(CC1E::Disabled)
54 }
55 #[inline(always)]
57 pub fn enabled(self) -> &'a mut crate::W<REG> {
58 self.variant(CC1E::Enabled)
59 }
60}
61#[cfg_attr(feature = "defmt", derive(defmt::Format))]
65#[derive(Clone, Copy, Debug, PartialEq, Eq)]
66pub enum CC1P {
67 RisingEdge = 0,
69 FallingEdge = 1,
71}
72impl From<CC1P> for bool {
73 #[inline(always)]
74 fn from(variant: CC1P) -> Self {
75 variant as u8 != 0
76 }
77}
78pub type CCP_R = crate::BitReader<CC1P>;
80impl CCP_R {
81 #[inline(always)]
83 pub const fn variant(&self) -> CC1P {
84 match self.bits {
85 false => CC1P::RisingEdge,
86 true => CC1P::FallingEdge,
87 }
88 }
89 #[inline(always)]
91 pub fn is_rising_edge(&self) -> bool {
92 *self == CC1P::RisingEdge
93 }
94 #[inline(always)]
96 pub fn is_falling_edge(&self) -> bool {
97 *self == CC1P::FallingEdge
98 }
99}
100pub type CCP_W<'a, REG> = crate::BitWriter<'a, REG, CC1P>;
102impl<'a, REG> CCP_W<'a, REG>
103where
104 REG: crate::Writable + crate::RegisterSpec,
105{
106 #[inline(always)]
108 pub fn rising_edge(self) -> &'a mut crate::W<REG> {
109 self.variant(CC1P::RisingEdge)
110 }
111 #[inline(always)]
113 pub fn falling_edge(self) -> &'a mut crate::W<REG> {
114 self.variant(CC1P::FallingEdge)
115 }
116}
117pub type CCNP_R = crate::BitReader;
119pub type CCNP_W<'a, REG> = crate::BitWriter<'a, REG>;
121impl R {
122 #[inline(always)]
126 pub fn cce(&self, n: u8) -> CCE_R {
127 #[allow(clippy::no_effect)]
128 [(); 4][n as usize];
129 CCE_R::new(((self.bits >> (n * 4)) & 1) != 0)
130 }
131 #[inline(always)]
134 pub fn cce_iter(&self) -> impl Iterator<Item = CCE_R> + '_ {
135 (0..4).map(move |n| CCE_R::new(((self.bits >> (n * 4)) & 1) != 0))
136 }
137 #[inline(always)]
139 pub fn cc1e(&self) -> CCE_R {
140 CCE_R::new((self.bits & 1) != 0)
141 }
142 #[inline(always)]
144 pub fn cc2e(&self) -> CCE_R {
145 CCE_R::new(((self.bits >> 4) & 1) != 0)
146 }
147 #[inline(always)]
149 pub fn cc3e(&self) -> CCE_R {
150 CCE_R::new(((self.bits >> 8) & 1) != 0)
151 }
152 #[inline(always)]
154 pub fn cc4e(&self) -> CCE_R {
155 CCE_R::new(((self.bits >> 12) & 1) != 0)
156 }
157 #[inline(always)]
161 pub fn ccp(&self, n: u8) -> CCP_R {
162 #[allow(clippy::no_effect)]
163 [(); 4][n as usize];
164 CCP_R::new(((self.bits >> (n * 4 + 1)) & 1) != 0)
165 }
166 #[inline(always)]
169 pub fn ccp_iter(&self) -> impl Iterator<Item = CCP_R> + '_ {
170 (0..4).map(move |n| CCP_R::new(((self.bits >> (n * 4 + 1)) & 1) != 0))
171 }
172 #[inline(always)]
174 pub fn cc1p(&self) -> CCP_R {
175 CCP_R::new(((self.bits >> 1) & 1) != 0)
176 }
177 #[inline(always)]
179 pub fn cc2p(&self) -> CCP_R {
180 CCP_R::new(((self.bits >> 5) & 1) != 0)
181 }
182 #[inline(always)]
184 pub fn cc3p(&self) -> CCP_R {
185 CCP_R::new(((self.bits >> 9) & 1) != 0)
186 }
187 #[inline(always)]
189 pub fn cc4p(&self) -> CCP_R {
190 CCP_R::new(((self.bits >> 13) & 1) != 0)
191 }
192 #[inline(always)]
196 pub fn ccnp(&self, n: u8) -> CCNP_R {
197 #[allow(clippy::no_effect)]
198 [(); 4][n as usize];
199 CCNP_R::new(((self.bits >> (n * 4 + 3)) & 1) != 0)
200 }
201 #[inline(always)]
204 pub fn ccnp_iter(&self) -> impl Iterator<Item = CCNP_R> + '_ {
205 (0..4).map(move |n| CCNP_R::new(((self.bits >> (n * 4 + 3)) & 1) != 0))
206 }
207 #[inline(always)]
209 pub fn cc1np(&self) -> CCNP_R {
210 CCNP_R::new(((self.bits >> 3) & 1) != 0)
211 }
212 #[inline(always)]
214 pub fn cc2np(&self) -> CCNP_R {
215 CCNP_R::new(((self.bits >> 7) & 1) != 0)
216 }
217 #[inline(always)]
219 pub fn cc3np(&self) -> CCNP_R {
220 CCNP_R::new(((self.bits >> 11) & 1) != 0)
221 }
222 #[inline(always)]
224 pub fn cc4np(&self) -> CCNP_R {
225 CCNP_R::new(((self.bits >> 15) & 1) != 0)
226 }
227}
228impl core::fmt::Debug for R {
229 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
230 f.debug_struct("CCER")
231 .field("cc1np", &self.cc1np())
232 .field("cc2np", &self.cc2np())
233 .field("cc3np", &self.cc3np())
234 .field("cc4np", &self.cc4np())
235 .field("cc1p", &self.cc1p())
236 .field("cc2p", &self.cc2p())
237 .field("cc3p", &self.cc3p())
238 .field("cc4p", &self.cc4p())
239 .field("cc1e", &self.cc1e())
240 .field("cc2e", &self.cc2e())
241 .field("cc3e", &self.cc3e())
242 .field("cc4e", &self.cc4e())
243 .finish()
244 }
245}
246impl W {
247 #[inline(always)]
251 pub fn cce(&mut self, n: u8) -> CCE_W<CCERrs> {
252 #[allow(clippy::no_effect)]
253 [(); 4][n as usize];
254 CCE_W::new(self, n * 4)
255 }
256 #[inline(always)]
258 pub fn cc1e(&mut self) -> CCE_W<CCERrs> {
259 CCE_W::new(self, 0)
260 }
261 #[inline(always)]
263 pub fn cc2e(&mut self) -> CCE_W<CCERrs> {
264 CCE_W::new(self, 4)
265 }
266 #[inline(always)]
268 pub fn cc3e(&mut self) -> CCE_W<CCERrs> {
269 CCE_W::new(self, 8)
270 }
271 #[inline(always)]
273 pub fn cc4e(&mut self) -> CCE_W<CCERrs> {
274 CCE_W::new(self, 12)
275 }
276 #[inline(always)]
280 pub fn ccp(&mut self, n: u8) -> CCP_W<CCERrs> {
281 #[allow(clippy::no_effect)]
282 [(); 4][n as usize];
283 CCP_W::new(self, n * 4 + 1)
284 }
285 #[inline(always)]
287 pub fn cc1p(&mut self) -> CCP_W<CCERrs> {
288 CCP_W::new(self, 1)
289 }
290 #[inline(always)]
292 pub fn cc2p(&mut self) -> CCP_W<CCERrs> {
293 CCP_W::new(self, 5)
294 }
295 #[inline(always)]
297 pub fn cc3p(&mut self) -> CCP_W<CCERrs> {
298 CCP_W::new(self, 9)
299 }
300 #[inline(always)]
302 pub fn cc4p(&mut self) -> CCP_W<CCERrs> {
303 CCP_W::new(self, 13)
304 }
305 #[inline(always)]
309 pub fn ccnp(&mut self, n: u8) -> CCNP_W<CCERrs> {
310 #[allow(clippy::no_effect)]
311 [(); 4][n as usize];
312 CCNP_W::new(self, n * 4 + 3)
313 }
314 #[inline(always)]
316 pub fn cc1np(&mut self) -> CCNP_W<CCERrs> {
317 CCNP_W::new(self, 3)
318 }
319 #[inline(always)]
321 pub fn cc2np(&mut self) -> CCNP_W<CCERrs> {
322 CCNP_W::new(self, 7)
323 }
324 #[inline(always)]
326 pub fn cc3np(&mut self) -> CCNP_W<CCERrs> {
327 CCNP_W::new(self, 11)
328 }
329 #[inline(always)]
331 pub fn cc4np(&mut self) -> CCNP_W<CCERrs> {
332 CCNP_W::new(self, 15)
333 }
334}
335pub struct CCERrs;
341impl crate::RegisterSpec for CCERrs {
342 type Ux = u32;
343}
344impl crate::Readable for CCERrs {}
346impl crate::Writable for CCERrs {
348 type Safety = crate::Unsafe;
349}
350impl crate::Resettable for CCERrs {}