1#[doc = "Register `SM1CAPTCTRLX` reader"]
2pub type R = crate::R<Sm1captctrlxSpec>;
3#[doc = "Register `SM1CAPTCTRLX` writer"]
4pub type W = crate::W<Sm1captctrlxSpec>;
5#[doc = "Arm X\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum Armx {
9 #[doc = "0: Input capture operation is disabled."]
10 Disabled = 0,
11 #[doc = "1: Input capture operation as specified by CAPTCTRLX\\[EDGXx\\] is enabled."]
12 Enabled = 1,
13}
14impl From<Armx> for bool {
15 #[inline(always)]
16 fn from(variant: Armx) -> Self {
17 variant as u8 != 0
18 }
19}
20#[doc = "Field `ARMX` reader - Arm X"]
21pub type ArmxR = crate::BitReader<Armx>;
22impl ArmxR {
23 #[doc = "Get enumerated values variant"]
24 #[inline(always)]
25 pub const fn variant(&self) -> Armx {
26 match self.bits {
27 false => Armx::Disabled,
28 true => Armx::Enabled,
29 }
30 }
31 #[doc = "Input capture operation is disabled."]
32 #[inline(always)]
33 pub fn is_disabled(&self) -> bool {
34 *self == Armx::Disabled
35 }
36 #[doc = "Input capture operation as specified by CAPTCTRLX\\[EDGXx\\] is enabled."]
37 #[inline(always)]
38 pub fn is_enabled(&self) -> bool {
39 *self == Armx::Enabled
40 }
41}
42#[doc = "Field `ARMX` writer - Arm X"]
43pub type ArmxW<'a, REG> = crate::BitWriter<'a, REG, Armx>;
44impl<'a, REG> ArmxW<'a, REG>
45where
46 REG: crate::Writable + crate::RegisterSpec,
47{
48 #[doc = "Input capture operation is disabled."]
49 #[inline(always)]
50 pub fn disabled(self) -> &'a mut crate::W<REG> {
51 self.variant(Armx::Disabled)
52 }
53 #[doc = "Input capture operation as specified by CAPTCTRLX\\[EDGXx\\] is enabled."]
54 #[inline(always)]
55 pub fn enabled(self) -> &'a mut crate::W<REG> {
56 self.variant(Armx::Enabled)
57 }
58}
59#[doc = "One Shot Mode Aux\n\nValue on reset: 0"]
60#[cfg_attr(feature = "defmt", derive(defmt::Format))]
61#[derive(Clone, Copy, Debug, PartialEq, Eq)]
62pub enum Oneshotx {
63 #[doc = "0: Free Running"]
64 FreeRunning = 0,
65 #[doc = "1: One Shot"]
66 OneShot = 1,
67}
68impl From<Oneshotx> for bool {
69 #[inline(always)]
70 fn from(variant: Oneshotx) -> Self {
71 variant as u8 != 0
72 }
73}
74#[doc = "Field `ONESHOTX` reader - One Shot Mode Aux"]
75pub type OneshotxR = crate::BitReader<Oneshotx>;
76impl OneshotxR {
77 #[doc = "Get enumerated values variant"]
78 #[inline(always)]
79 pub const fn variant(&self) -> Oneshotx {
80 match self.bits {
81 false => Oneshotx::FreeRunning,
82 true => Oneshotx::OneShot,
83 }
84 }
85 #[doc = "Free Running"]
86 #[inline(always)]
87 pub fn is_free_running(&self) -> bool {
88 *self == Oneshotx::FreeRunning
89 }
90 #[doc = "One Shot"]
91 #[inline(always)]
92 pub fn is_one_shot(&self) -> bool {
93 *self == Oneshotx::OneShot
94 }
95}
96#[doc = "Field `ONESHOTX` writer - One Shot Mode Aux"]
97pub type OneshotxW<'a, REG> = crate::BitWriter<'a, REG, Oneshotx>;
98impl<'a, REG> OneshotxW<'a, REG>
99where
100 REG: crate::Writable + crate::RegisterSpec,
101{
102 #[doc = "Free Running"]
103 #[inline(always)]
104 pub fn free_running(self) -> &'a mut crate::W<REG> {
105 self.variant(Oneshotx::FreeRunning)
106 }
107 #[doc = "One Shot"]
108 #[inline(always)]
109 pub fn one_shot(self) -> &'a mut crate::W<REG> {
110 self.variant(Oneshotx::OneShot)
111 }
112}
113#[doc = "Edge X 0\n\nValue on reset: 0"]
114#[cfg_attr(feature = "defmt", derive(defmt::Format))]
115#[derive(Clone, Copy, Debug, PartialEq, Eq)]
116#[repr(u8)]
117pub enum Edgx0 {
118 #[doc = "0: Disabled"]
119 Disabled = 0,
120 #[doc = "1: Capture falling edges"]
121 FallingEdge = 1,
122 #[doc = "2: Capture rising edges"]
123 RisingEdge = 2,
124 #[doc = "3: Capture any edge"]
125 AnyEdge = 3,
126}
127impl From<Edgx0> for u8 {
128 #[inline(always)]
129 fn from(variant: Edgx0) -> Self {
130 variant as _
131 }
132}
133impl crate::FieldSpec for Edgx0 {
134 type Ux = u8;
135}
136impl crate::IsEnum for Edgx0 {}
137#[doc = "Field `EDGX0` reader - Edge X 0"]
138pub type Edgx0R = crate::FieldReader<Edgx0>;
139impl Edgx0R {
140 #[doc = "Get enumerated values variant"]
141 #[inline(always)]
142 pub const fn variant(&self) -> Edgx0 {
143 match self.bits {
144 0 => Edgx0::Disabled,
145 1 => Edgx0::FallingEdge,
146 2 => Edgx0::RisingEdge,
147 3 => Edgx0::AnyEdge,
148 _ => unreachable!(),
149 }
150 }
151 #[doc = "Disabled"]
152 #[inline(always)]
153 pub fn is_disabled(&self) -> bool {
154 *self == Edgx0::Disabled
155 }
156 #[doc = "Capture falling edges"]
157 #[inline(always)]
158 pub fn is_falling_edge(&self) -> bool {
159 *self == Edgx0::FallingEdge
160 }
161 #[doc = "Capture rising edges"]
162 #[inline(always)]
163 pub fn is_rising_edge(&self) -> bool {
164 *self == Edgx0::RisingEdge
165 }
166 #[doc = "Capture any edge"]
167 #[inline(always)]
168 pub fn is_any_edge(&self) -> bool {
169 *self == Edgx0::AnyEdge
170 }
171}
172#[doc = "Field `EDGX0` writer - Edge X 0"]
173pub type Edgx0W<'a, REG> = crate::FieldWriter<'a, REG, 2, Edgx0, crate::Safe>;
174impl<'a, REG> Edgx0W<'a, REG>
175where
176 REG: crate::Writable + crate::RegisterSpec,
177 REG::Ux: From<u8>,
178{
179 #[doc = "Disabled"]
180 #[inline(always)]
181 pub fn disabled(self) -> &'a mut crate::W<REG> {
182 self.variant(Edgx0::Disabled)
183 }
184 #[doc = "Capture falling edges"]
185 #[inline(always)]
186 pub fn falling_edge(self) -> &'a mut crate::W<REG> {
187 self.variant(Edgx0::FallingEdge)
188 }
189 #[doc = "Capture rising edges"]
190 #[inline(always)]
191 pub fn rising_edge(self) -> &'a mut crate::W<REG> {
192 self.variant(Edgx0::RisingEdge)
193 }
194 #[doc = "Capture any edge"]
195 #[inline(always)]
196 pub fn any_edge(self) -> &'a mut crate::W<REG> {
197 self.variant(Edgx0::AnyEdge)
198 }
199}
200#[doc = "Edge X 1\n\nValue on reset: 0"]
201#[cfg_attr(feature = "defmt", derive(defmt::Format))]
202#[derive(Clone, Copy, Debug, PartialEq, Eq)]
203#[repr(u8)]
204pub enum Edgx1 {
205 #[doc = "0: Disabled"]
206 Disabled = 0,
207 #[doc = "1: Capture falling edges"]
208 FallingEdge = 1,
209 #[doc = "2: Capture rising edges"]
210 RisingEdge = 2,
211 #[doc = "3: Capture any edge"]
212 AnyEdge = 3,
213}
214impl From<Edgx1> for u8 {
215 #[inline(always)]
216 fn from(variant: Edgx1) -> Self {
217 variant as _
218 }
219}
220impl crate::FieldSpec for Edgx1 {
221 type Ux = u8;
222}
223impl crate::IsEnum for Edgx1 {}
224#[doc = "Field `EDGX1` reader - Edge X 1"]
225pub type Edgx1R = crate::FieldReader<Edgx1>;
226impl Edgx1R {
227 #[doc = "Get enumerated values variant"]
228 #[inline(always)]
229 pub const fn variant(&self) -> Edgx1 {
230 match self.bits {
231 0 => Edgx1::Disabled,
232 1 => Edgx1::FallingEdge,
233 2 => Edgx1::RisingEdge,
234 3 => Edgx1::AnyEdge,
235 _ => unreachable!(),
236 }
237 }
238 #[doc = "Disabled"]
239 #[inline(always)]
240 pub fn is_disabled(&self) -> bool {
241 *self == Edgx1::Disabled
242 }
243 #[doc = "Capture falling edges"]
244 #[inline(always)]
245 pub fn is_falling_edge(&self) -> bool {
246 *self == Edgx1::FallingEdge
247 }
248 #[doc = "Capture rising edges"]
249 #[inline(always)]
250 pub fn is_rising_edge(&self) -> bool {
251 *self == Edgx1::RisingEdge
252 }
253 #[doc = "Capture any edge"]
254 #[inline(always)]
255 pub fn is_any_edge(&self) -> bool {
256 *self == Edgx1::AnyEdge
257 }
258}
259#[doc = "Field `EDGX1` writer - Edge X 1"]
260pub type Edgx1W<'a, REG> = crate::FieldWriter<'a, REG, 2, Edgx1, crate::Safe>;
261impl<'a, REG> Edgx1W<'a, REG>
262where
263 REG: crate::Writable + crate::RegisterSpec,
264 REG::Ux: From<u8>,
265{
266 #[doc = "Disabled"]
267 #[inline(always)]
268 pub fn disabled(self) -> &'a mut crate::W<REG> {
269 self.variant(Edgx1::Disabled)
270 }
271 #[doc = "Capture falling edges"]
272 #[inline(always)]
273 pub fn falling_edge(self) -> &'a mut crate::W<REG> {
274 self.variant(Edgx1::FallingEdge)
275 }
276 #[doc = "Capture rising edges"]
277 #[inline(always)]
278 pub fn rising_edge(self) -> &'a mut crate::W<REG> {
279 self.variant(Edgx1::RisingEdge)
280 }
281 #[doc = "Capture any edge"]
282 #[inline(always)]
283 pub fn any_edge(self) -> &'a mut crate::W<REG> {
284 self.variant(Edgx1::AnyEdge)
285 }
286}
287#[doc = "Input Select X\n\nValue on reset: 0"]
288#[cfg_attr(feature = "defmt", derive(defmt::Format))]
289#[derive(Clone, Copy, Debug, PartialEq, Eq)]
290pub enum InpSelx {
291 #[doc = "0: Raw PWM_X input signal selected as source."]
292 PwmX = 0,
293 #[doc = "1: Edge Counter"]
294 EdgeCounter = 1,
295}
296impl From<InpSelx> for bool {
297 #[inline(always)]
298 fn from(variant: InpSelx) -> Self {
299 variant as u8 != 0
300 }
301}
302#[doc = "Field `INP_SELX` reader - Input Select X"]
303pub type InpSelxR = crate::BitReader<InpSelx>;
304impl InpSelxR {
305 #[doc = "Get enumerated values variant"]
306 #[inline(always)]
307 pub const fn variant(&self) -> InpSelx {
308 match self.bits {
309 false => InpSelx::PwmX,
310 true => InpSelx::EdgeCounter,
311 }
312 }
313 #[doc = "Raw PWM_X input signal selected as source."]
314 #[inline(always)]
315 pub fn is_pwm_x(&self) -> bool {
316 *self == InpSelx::PwmX
317 }
318 #[doc = "Edge Counter"]
319 #[inline(always)]
320 pub fn is_edge_counter(&self) -> bool {
321 *self == InpSelx::EdgeCounter
322 }
323}
324#[doc = "Field `INP_SELX` writer - Input Select X"]
325pub type InpSelxW<'a, REG> = crate::BitWriter<'a, REG, InpSelx>;
326impl<'a, REG> InpSelxW<'a, REG>
327where
328 REG: crate::Writable + crate::RegisterSpec,
329{
330 #[doc = "Raw PWM_X input signal selected as source."]
331 #[inline(always)]
332 pub fn pwm_x(self) -> &'a mut crate::W<REG> {
333 self.variant(InpSelx::PwmX)
334 }
335 #[doc = "Edge Counter"]
336 #[inline(always)]
337 pub fn edge_counter(self) -> &'a mut crate::W<REG> {
338 self.variant(InpSelx::EdgeCounter)
339 }
340}
341#[doc = "Edge Counter X Enable\n\nValue on reset: 0"]
342#[cfg_attr(feature = "defmt", derive(defmt::Format))]
343#[derive(Clone, Copy, Debug, PartialEq, Eq)]
344pub enum EdgcntxEn {
345 #[doc = "0: Edge counter disabled and held in reset"]
346 Disabled = 0,
347 #[doc = "1: Edge counter enabled"]
348 Enabled = 1,
349}
350impl From<EdgcntxEn> for bool {
351 #[inline(always)]
352 fn from(variant: EdgcntxEn) -> Self {
353 variant as u8 != 0
354 }
355}
356#[doc = "Field `EDGCNTX_EN` reader - Edge Counter X Enable"]
357pub type EdgcntxEnR = crate::BitReader<EdgcntxEn>;
358impl EdgcntxEnR {
359 #[doc = "Get enumerated values variant"]
360 #[inline(always)]
361 pub const fn variant(&self) -> EdgcntxEn {
362 match self.bits {
363 false => EdgcntxEn::Disabled,
364 true => EdgcntxEn::Enabled,
365 }
366 }
367 #[doc = "Edge counter disabled and held in reset"]
368 #[inline(always)]
369 pub fn is_disabled(&self) -> bool {
370 *self == EdgcntxEn::Disabled
371 }
372 #[doc = "Edge counter enabled"]
373 #[inline(always)]
374 pub fn is_enabled(&self) -> bool {
375 *self == EdgcntxEn::Enabled
376 }
377}
378#[doc = "Field `EDGCNTX_EN` writer - Edge Counter X Enable"]
379pub type EdgcntxEnW<'a, REG> = crate::BitWriter<'a, REG, EdgcntxEn>;
380impl<'a, REG> EdgcntxEnW<'a, REG>
381where
382 REG: crate::Writable + crate::RegisterSpec,
383{
384 #[doc = "Edge counter disabled and held in reset"]
385 #[inline(always)]
386 pub fn disabled(self) -> &'a mut crate::W<REG> {
387 self.variant(EdgcntxEn::Disabled)
388 }
389 #[doc = "Edge counter enabled"]
390 #[inline(always)]
391 pub fn enabled(self) -> &'a mut crate::W<REG> {
392 self.variant(EdgcntxEn::Enabled)
393 }
394}
395#[doc = "Field `CFXWM` reader - Capture X FIFOs Water Mark"]
396pub type CfxwmR = crate::FieldReader;
397#[doc = "Field `CFXWM` writer - Capture X FIFOs Water Mark"]
398pub type CfxwmW<'a, REG> = crate::FieldWriter<'a, REG, 2>;
399#[doc = "Field `CX0CNT` reader - Capture X0 FIFO Word Count"]
400pub type Cx0cntR = crate::FieldReader;
401#[doc = "Field `CX1CNT` reader - Capture X1 FIFO Word Count"]
402pub type Cx1cntR = crate::FieldReader;
403impl R {
404 #[doc = "Bit 0 - Arm X"]
405 #[inline(always)]
406 pub fn armx(&self) -> ArmxR {
407 ArmxR::new((self.bits & 1) != 0)
408 }
409 #[doc = "Bit 1 - One Shot Mode Aux"]
410 #[inline(always)]
411 pub fn oneshotx(&self) -> OneshotxR {
412 OneshotxR::new(((self.bits >> 1) & 1) != 0)
413 }
414 #[doc = "Bits 2:3 - Edge X 0"]
415 #[inline(always)]
416 pub fn edgx0(&self) -> Edgx0R {
417 Edgx0R::new(((self.bits >> 2) & 3) as u8)
418 }
419 #[doc = "Bits 4:5 - Edge X 1"]
420 #[inline(always)]
421 pub fn edgx1(&self) -> Edgx1R {
422 Edgx1R::new(((self.bits >> 4) & 3) as u8)
423 }
424 #[doc = "Bit 6 - Input Select X"]
425 #[inline(always)]
426 pub fn inp_selx(&self) -> InpSelxR {
427 InpSelxR::new(((self.bits >> 6) & 1) != 0)
428 }
429 #[doc = "Bit 7 - Edge Counter X Enable"]
430 #[inline(always)]
431 pub fn edgcntx_en(&self) -> EdgcntxEnR {
432 EdgcntxEnR::new(((self.bits >> 7) & 1) != 0)
433 }
434 #[doc = "Bits 8:9 - Capture X FIFOs Water Mark"]
435 #[inline(always)]
436 pub fn cfxwm(&self) -> CfxwmR {
437 CfxwmR::new(((self.bits >> 8) & 3) as u8)
438 }
439 #[doc = "Bits 10:12 - Capture X0 FIFO Word Count"]
440 #[inline(always)]
441 pub fn cx0cnt(&self) -> Cx0cntR {
442 Cx0cntR::new(((self.bits >> 10) & 7) as u8)
443 }
444 #[doc = "Bits 13:15 - Capture X1 FIFO Word Count"]
445 #[inline(always)]
446 pub fn cx1cnt(&self) -> Cx1cntR {
447 Cx1cntR::new(((self.bits >> 13) & 7) as u8)
448 }
449}
450#[cfg(feature = "debug")]
451impl core::fmt::Debug for R {
452 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
453 f.debug_struct("SM1CAPTCTRLX")
454 .field("armx", &self.armx())
455 .field("oneshotx", &self.oneshotx())
456 .field("edgx0", &self.edgx0())
457 .field("edgx1", &self.edgx1())
458 .field("inp_selx", &self.inp_selx())
459 .field("edgcntx_en", &self.edgcntx_en())
460 .field("cfxwm", &self.cfxwm())
461 .field("cx0cnt", &self.cx0cnt())
462 .field("cx1cnt", &self.cx1cnt())
463 .finish()
464 }
465}
466impl W {
467 #[doc = "Bit 0 - Arm X"]
468 #[inline(always)]
469 pub fn armx(&mut self) -> ArmxW<'_, Sm1captctrlxSpec> {
470 ArmxW::new(self, 0)
471 }
472 #[doc = "Bit 1 - One Shot Mode Aux"]
473 #[inline(always)]
474 pub fn oneshotx(&mut self) -> OneshotxW<'_, Sm1captctrlxSpec> {
475 OneshotxW::new(self, 1)
476 }
477 #[doc = "Bits 2:3 - Edge X 0"]
478 #[inline(always)]
479 pub fn edgx0(&mut self) -> Edgx0W<'_, Sm1captctrlxSpec> {
480 Edgx0W::new(self, 2)
481 }
482 #[doc = "Bits 4:5 - Edge X 1"]
483 #[inline(always)]
484 pub fn edgx1(&mut self) -> Edgx1W<'_, Sm1captctrlxSpec> {
485 Edgx1W::new(self, 4)
486 }
487 #[doc = "Bit 6 - Input Select X"]
488 #[inline(always)]
489 pub fn inp_selx(&mut self) -> InpSelxW<'_, Sm1captctrlxSpec> {
490 InpSelxW::new(self, 6)
491 }
492 #[doc = "Bit 7 - Edge Counter X Enable"]
493 #[inline(always)]
494 pub fn edgcntx_en(&mut self) -> EdgcntxEnW<'_, Sm1captctrlxSpec> {
495 EdgcntxEnW::new(self, 7)
496 }
497 #[doc = "Bits 8:9 - Capture X FIFOs Water Mark"]
498 #[inline(always)]
499 pub fn cfxwm(&mut self) -> CfxwmW<'_, Sm1captctrlxSpec> {
500 CfxwmW::new(self, 8)
501 }
502}
503#[doc = "Capture Control X Register\n\nYou can [`read`](crate::Reg::read) this register and get [`sm1captctrlx::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`sm1captctrlx::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
504pub struct Sm1captctrlxSpec;
505impl crate::RegisterSpec for Sm1captctrlxSpec {
506 type Ux = u16;
507}
508#[doc = "`read()` method returns [`sm1captctrlx::R`](R) reader structure"]
509impl crate::Readable for Sm1captctrlxSpec {}
510#[doc = "`write(|w| ..)` method takes [`sm1captctrlx::W`](W) writer structure"]
511impl crate::Writable for Sm1captctrlxSpec {
512 type Safety = crate::Unsafe;
513}
514#[doc = "`reset()` method sets SM1CAPTCTRLX to value 0"]
515impl crate::Resettable for Sm1captctrlxSpec {}