Skip to main content

k22f/ftm3/
qdctrl.rs

1#[doc = "Reader of register QDCTRL"]
2pub type R = crate::R<u32, super::QDCTRL>;
3#[doc = "Writer for register QDCTRL"]
4pub type W = crate::W<u32, super::QDCTRL>;
5#[doc = "Register QDCTRL `reset()`'s with value 0"]
6impl crate::ResetValue for super::QDCTRL {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Quadrature Decoder Mode Enable\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15pub enum QUADEN_A {
16    #[doc = "0: Quadrature Decoder mode is disabled."]
17    _0 = 0,
18    #[doc = "1: Quadrature Decoder mode is enabled."]
19    _1 = 1,
20}
21impl From<QUADEN_A> for bool {
22    #[inline(always)]
23    fn from(variant: QUADEN_A) -> Self {
24        variant as u8 != 0
25    }
26}
27#[doc = "Reader of field `QUADEN`"]
28pub type QUADEN_R = crate::R<bool, QUADEN_A>;
29impl QUADEN_R {
30    #[doc = r"Get enumerated values variant"]
31    #[inline(always)]
32    pub fn variant(&self) -> QUADEN_A {
33        match self.bits {
34            false => QUADEN_A::_0,
35            true => QUADEN_A::_1,
36        }
37    }
38    #[doc = "Checks if the value of the field is `_0`"]
39    #[inline(always)]
40    pub fn is_0(&self) -> bool {
41        *self == QUADEN_A::_0
42    }
43    #[doc = "Checks if the value of the field is `_1`"]
44    #[inline(always)]
45    pub fn is_1(&self) -> bool {
46        *self == QUADEN_A::_1
47    }
48}
49#[doc = "Write proxy for field `QUADEN`"]
50pub struct QUADEN_W<'a> {
51    w: &'a mut W,
52}
53impl<'a> QUADEN_W<'a> {
54    #[doc = r"Writes `variant` to the field"]
55    #[inline(always)]
56    pub fn variant(self, variant: QUADEN_A) -> &'a mut W {
57        {
58            self.bit(variant.into())
59        }
60    }
61    #[doc = "Quadrature Decoder mode is disabled."]
62    #[inline(always)]
63    pub fn _0(self) -> &'a mut W {
64        self.variant(QUADEN_A::_0)
65    }
66    #[doc = "Quadrature Decoder mode is enabled."]
67    #[inline(always)]
68    pub fn _1(self) -> &'a mut W {
69        self.variant(QUADEN_A::_1)
70    }
71    #[doc = r"Sets the field bit"]
72    #[inline(always)]
73    pub fn set_bit(self) -> &'a mut W {
74        self.bit(true)
75    }
76    #[doc = r"Clears the field bit"]
77    #[inline(always)]
78    pub fn clear_bit(self) -> &'a mut W {
79        self.bit(false)
80    }
81    #[doc = r"Writes raw bits to the field"]
82    #[inline(always)]
83    pub fn bit(self, value: bool) -> &'a mut W {
84        self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01);
85        self.w
86    }
87}
88#[doc = "Timer Overflow Direction In Quadrature Decoder Mode\n\nValue on reset: 0"]
89#[derive(Clone, Copy, Debug, PartialEq)]
90pub enum TOFDIR_A {
91    #[doc = "0: TOF bit was set on the bottom of counting. There was an FTM counter decrement and FTM counter changes from its minimum value (CNTIN register) to its maximum value (MOD register)."]
92    _0 = 0,
93    #[doc = "1: TOF bit was set on the top of counting. There was an FTM counter increment and FTM counter changes from its maximum value (MOD register) to its minimum value (CNTIN register)."]
94    _1 = 1,
95}
96impl From<TOFDIR_A> for bool {
97    #[inline(always)]
98    fn from(variant: TOFDIR_A) -> Self {
99        variant as u8 != 0
100    }
101}
102#[doc = "Reader of field `TOFDIR`"]
103pub type TOFDIR_R = crate::R<bool, TOFDIR_A>;
104impl TOFDIR_R {
105    #[doc = r"Get enumerated values variant"]
106    #[inline(always)]
107    pub fn variant(&self) -> TOFDIR_A {
108        match self.bits {
109            false => TOFDIR_A::_0,
110            true => TOFDIR_A::_1,
111        }
112    }
113    #[doc = "Checks if the value of the field is `_0`"]
114    #[inline(always)]
115    pub fn is_0(&self) -> bool {
116        *self == TOFDIR_A::_0
117    }
118    #[doc = "Checks if the value of the field is `_1`"]
119    #[inline(always)]
120    pub fn is_1(&self) -> bool {
121        *self == TOFDIR_A::_1
122    }
123}
124#[doc = "FTM Counter Direction In Quadrature Decoder Mode\n\nValue on reset: 0"]
125#[derive(Clone, Copy, Debug, PartialEq)]
126pub enum QUADIR_A {
127    #[doc = "0: Counting direction is decreasing (FTM counter decrement)."]
128    _0 = 0,
129    #[doc = "1: Counting direction is increasing (FTM counter increment)."]
130    _1 = 1,
131}
132impl From<QUADIR_A> for bool {
133    #[inline(always)]
134    fn from(variant: QUADIR_A) -> Self {
135        variant as u8 != 0
136    }
137}
138#[doc = "Reader of field `QUADIR`"]
139pub type QUADIR_R = crate::R<bool, QUADIR_A>;
140impl QUADIR_R {
141    #[doc = r"Get enumerated values variant"]
142    #[inline(always)]
143    pub fn variant(&self) -> QUADIR_A {
144        match self.bits {
145            false => QUADIR_A::_0,
146            true => QUADIR_A::_1,
147        }
148    }
149    #[doc = "Checks if the value of the field is `_0`"]
150    #[inline(always)]
151    pub fn is_0(&self) -> bool {
152        *self == QUADIR_A::_0
153    }
154    #[doc = "Checks if the value of the field is `_1`"]
155    #[inline(always)]
156    pub fn is_1(&self) -> bool {
157        *self == QUADIR_A::_1
158    }
159}
160#[doc = "Quadrature Decoder Mode\n\nValue on reset: 0"]
161#[derive(Clone, Copy, Debug, PartialEq)]
162pub enum QUADMODE_A {
163    #[doc = "0: Phase A and phase B encoding mode."]
164    _0 = 0,
165    #[doc = "1: Count and direction encoding mode."]
166    _1 = 1,
167}
168impl From<QUADMODE_A> for bool {
169    #[inline(always)]
170    fn from(variant: QUADMODE_A) -> Self {
171        variant as u8 != 0
172    }
173}
174#[doc = "Reader of field `QUADMODE`"]
175pub type QUADMODE_R = crate::R<bool, QUADMODE_A>;
176impl QUADMODE_R {
177    #[doc = r"Get enumerated values variant"]
178    #[inline(always)]
179    pub fn variant(&self) -> QUADMODE_A {
180        match self.bits {
181            false => QUADMODE_A::_0,
182            true => QUADMODE_A::_1,
183        }
184    }
185    #[doc = "Checks if the value of the field is `_0`"]
186    #[inline(always)]
187    pub fn is_0(&self) -> bool {
188        *self == QUADMODE_A::_0
189    }
190    #[doc = "Checks if the value of the field is `_1`"]
191    #[inline(always)]
192    pub fn is_1(&self) -> bool {
193        *self == QUADMODE_A::_1
194    }
195}
196#[doc = "Write proxy for field `QUADMODE`"]
197pub struct QUADMODE_W<'a> {
198    w: &'a mut W,
199}
200impl<'a> QUADMODE_W<'a> {
201    #[doc = r"Writes `variant` to the field"]
202    #[inline(always)]
203    pub fn variant(self, variant: QUADMODE_A) -> &'a mut W {
204        {
205            self.bit(variant.into())
206        }
207    }
208    #[doc = "Phase A and phase B encoding mode."]
209    #[inline(always)]
210    pub fn _0(self) -> &'a mut W {
211        self.variant(QUADMODE_A::_0)
212    }
213    #[doc = "Count and direction encoding mode."]
214    #[inline(always)]
215    pub fn _1(self) -> &'a mut W {
216        self.variant(QUADMODE_A::_1)
217    }
218    #[doc = r"Sets the field bit"]
219    #[inline(always)]
220    pub fn set_bit(self) -> &'a mut W {
221        self.bit(true)
222    }
223    #[doc = r"Clears the field bit"]
224    #[inline(always)]
225    pub fn clear_bit(self) -> &'a mut W {
226        self.bit(false)
227    }
228    #[doc = r"Writes raw bits to the field"]
229    #[inline(always)]
230    pub fn bit(self, value: bool) -> &'a mut W {
231        self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3);
232        self.w
233    }
234}
235#[doc = "Phase B Input Polarity\n\nValue on reset: 0"]
236#[derive(Clone, Copy, Debug, PartialEq)]
237pub enum PHBPOL_A {
238    #[doc = "0: Normal polarity. Phase B input signal is not inverted before identifying the rising and falling edges of this signal."]
239    _0 = 0,
240    #[doc = "1: Inverted polarity. Phase B input signal is inverted before identifying the rising and falling edges of this signal."]
241    _1 = 1,
242}
243impl From<PHBPOL_A> for bool {
244    #[inline(always)]
245    fn from(variant: PHBPOL_A) -> Self {
246        variant as u8 != 0
247    }
248}
249#[doc = "Reader of field `PHBPOL`"]
250pub type PHBPOL_R = crate::R<bool, PHBPOL_A>;
251impl PHBPOL_R {
252    #[doc = r"Get enumerated values variant"]
253    #[inline(always)]
254    pub fn variant(&self) -> PHBPOL_A {
255        match self.bits {
256            false => PHBPOL_A::_0,
257            true => PHBPOL_A::_1,
258        }
259    }
260    #[doc = "Checks if the value of the field is `_0`"]
261    #[inline(always)]
262    pub fn is_0(&self) -> bool {
263        *self == PHBPOL_A::_0
264    }
265    #[doc = "Checks if the value of the field is `_1`"]
266    #[inline(always)]
267    pub fn is_1(&self) -> bool {
268        *self == PHBPOL_A::_1
269    }
270}
271#[doc = "Write proxy for field `PHBPOL`"]
272pub struct PHBPOL_W<'a> {
273    w: &'a mut W,
274}
275impl<'a> PHBPOL_W<'a> {
276    #[doc = r"Writes `variant` to the field"]
277    #[inline(always)]
278    pub fn variant(self, variant: PHBPOL_A) -> &'a mut W {
279        {
280            self.bit(variant.into())
281        }
282    }
283    #[doc = "Normal polarity. Phase B input signal is not inverted before identifying the rising and falling edges of this signal."]
284    #[inline(always)]
285    pub fn _0(self) -> &'a mut W {
286        self.variant(PHBPOL_A::_0)
287    }
288    #[doc = "Inverted polarity. Phase B input signal is inverted before identifying the rising and falling edges of this signal."]
289    #[inline(always)]
290    pub fn _1(self) -> &'a mut W {
291        self.variant(PHBPOL_A::_1)
292    }
293    #[doc = r"Sets the field bit"]
294    #[inline(always)]
295    pub fn set_bit(self) -> &'a mut W {
296        self.bit(true)
297    }
298    #[doc = r"Clears the field bit"]
299    #[inline(always)]
300    pub fn clear_bit(self) -> &'a mut W {
301        self.bit(false)
302    }
303    #[doc = r"Writes raw bits to the field"]
304    #[inline(always)]
305    pub fn bit(self, value: bool) -> &'a mut W {
306        self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u32) & 0x01) << 4);
307        self.w
308    }
309}
310#[doc = "Phase A Input Polarity\n\nValue on reset: 0"]
311#[derive(Clone, Copy, Debug, PartialEq)]
312pub enum PHAPOL_A {
313    #[doc = "0: Normal polarity. Phase A input signal is not inverted before identifying the rising and falling edges of this signal."]
314    _0 = 0,
315    #[doc = "1: Inverted polarity. Phase A input signal is inverted before identifying the rising and falling edges of this signal."]
316    _1 = 1,
317}
318impl From<PHAPOL_A> for bool {
319    #[inline(always)]
320    fn from(variant: PHAPOL_A) -> Self {
321        variant as u8 != 0
322    }
323}
324#[doc = "Reader of field `PHAPOL`"]
325pub type PHAPOL_R = crate::R<bool, PHAPOL_A>;
326impl PHAPOL_R {
327    #[doc = r"Get enumerated values variant"]
328    #[inline(always)]
329    pub fn variant(&self) -> PHAPOL_A {
330        match self.bits {
331            false => PHAPOL_A::_0,
332            true => PHAPOL_A::_1,
333        }
334    }
335    #[doc = "Checks if the value of the field is `_0`"]
336    #[inline(always)]
337    pub fn is_0(&self) -> bool {
338        *self == PHAPOL_A::_0
339    }
340    #[doc = "Checks if the value of the field is `_1`"]
341    #[inline(always)]
342    pub fn is_1(&self) -> bool {
343        *self == PHAPOL_A::_1
344    }
345}
346#[doc = "Write proxy for field `PHAPOL`"]
347pub struct PHAPOL_W<'a> {
348    w: &'a mut W,
349}
350impl<'a> PHAPOL_W<'a> {
351    #[doc = r"Writes `variant` to the field"]
352    #[inline(always)]
353    pub fn variant(self, variant: PHAPOL_A) -> &'a mut W {
354        {
355            self.bit(variant.into())
356        }
357    }
358    #[doc = "Normal polarity. Phase A input signal is not inverted before identifying the rising and falling edges of this signal."]
359    #[inline(always)]
360    pub fn _0(self) -> &'a mut W {
361        self.variant(PHAPOL_A::_0)
362    }
363    #[doc = "Inverted polarity. Phase A input signal is inverted before identifying the rising and falling edges of this signal."]
364    #[inline(always)]
365    pub fn _1(self) -> &'a mut W {
366        self.variant(PHAPOL_A::_1)
367    }
368    #[doc = r"Sets the field bit"]
369    #[inline(always)]
370    pub fn set_bit(self) -> &'a mut W {
371        self.bit(true)
372    }
373    #[doc = r"Clears the field bit"]
374    #[inline(always)]
375    pub fn clear_bit(self) -> &'a mut W {
376        self.bit(false)
377    }
378    #[doc = r"Writes raw bits to the field"]
379    #[inline(always)]
380    pub fn bit(self, value: bool) -> &'a mut W {
381        self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u32) & 0x01) << 5);
382        self.w
383    }
384}
385#[doc = "Phase B Input Filter Enable\n\nValue on reset: 0"]
386#[derive(Clone, Copy, Debug, PartialEq)]
387pub enum PHBFLTREN_A {
388    #[doc = "0: Phase B input filter is disabled."]
389    _0 = 0,
390    #[doc = "1: Phase B input filter is enabled."]
391    _1 = 1,
392}
393impl From<PHBFLTREN_A> for bool {
394    #[inline(always)]
395    fn from(variant: PHBFLTREN_A) -> Self {
396        variant as u8 != 0
397    }
398}
399#[doc = "Reader of field `PHBFLTREN`"]
400pub type PHBFLTREN_R = crate::R<bool, PHBFLTREN_A>;
401impl PHBFLTREN_R {
402    #[doc = r"Get enumerated values variant"]
403    #[inline(always)]
404    pub fn variant(&self) -> PHBFLTREN_A {
405        match self.bits {
406            false => PHBFLTREN_A::_0,
407            true => PHBFLTREN_A::_1,
408        }
409    }
410    #[doc = "Checks if the value of the field is `_0`"]
411    #[inline(always)]
412    pub fn is_0(&self) -> bool {
413        *self == PHBFLTREN_A::_0
414    }
415    #[doc = "Checks if the value of the field is `_1`"]
416    #[inline(always)]
417    pub fn is_1(&self) -> bool {
418        *self == PHBFLTREN_A::_1
419    }
420}
421#[doc = "Write proxy for field `PHBFLTREN`"]
422pub struct PHBFLTREN_W<'a> {
423    w: &'a mut W,
424}
425impl<'a> PHBFLTREN_W<'a> {
426    #[doc = r"Writes `variant` to the field"]
427    #[inline(always)]
428    pub fn variant(self, variant: PHBFLTREN_A) -> &'a mut W {
429        {
430            self.bit(variant.into())
431        }
432    }
433    #[doc = "Phase B input filter is disabled."]
434    #[inline(always)]
435    pub fn _0(self) -> &'a mut W {
436        self.variant(PHBFLTREN_A::_0)
437    }
438    #[doc = "Phase B input filter is enabled."]
439    #[inline(always)]
440    pub fn _1(self) -> &'a mut W {
441        self.variant(PHBFLTREN_A::_1)
442    }
443    #[doc = r"Sets the field bit"]
444    #[inline(always)]
445    pub fn set_bit(self) -> &'a mut W {
446        self.bit(true)
447    }
448    #[doc = r"Clears the field bit"]
449    #[inline(always)]
450    pub fn clear_bit(self) -> &'a mut W {
451        self.bit(false)
452    }
453    #[doc = r"Writes raw bits to the field"]
454    #[inline(always)]
455    pub fn bit(self, value: bool) -> &'a mut W {
456        self.w.bits = (self.w.bits & !(0x01 << 6)) | (((value as u32) & 0x01) << 6);
457        self.w
458    }
459}
460#[doc = "Phase A Input Filter Enable\n\nValue on reset: 0"]
461#[derive(Clone, Copy, Debug, PartialEq)]
462pub enum PHAFLTREN_A {
463    #[doc = "0: Phase A input filter is disabled."]
464    _0 = 0,
465    #[doc = "1: Phase A input filter is enabled."]
466    _1 = 1,
467}
468impl From<PHAFLTREN_A> for bool {
469    #[inline(always)]
470    fn from(variant: PHAFLTREN_A) -> Self {
471        variant as u8 != 0
472    }
473}
474#[doc = "Reader of field `PHAFLTREN`"]
475pub type PHAFLTREN_R = crate::R<bool, PHAFLTREN_A>;
476impl PHAFLTREN_R {
477    #[doc = r"Get enumerated values variant"]
478    #[inline(always)]
479    pub fn variant(&self) -> PHAFLTREN_A {
480        match self.bits {
481            false => PHAFLTREN_A::_0,
482            true => PHAFLTREN_A::_1,
483        }
484    }
485    #[doc = "Checks if the value of the field is `_0`"]
486    #[inline(always)]
487    pub fn is_0(&self) -> bool {
488        *self == PHAFLTREN_A::_0
489    }
490    #[doc = "Checks if the value of the field is `_1`"]
491    #[inline(always)]
492    pub fn is_1(&self) -> bool {
493        *self == PHAFLTREN_A::_1
494    }
495}
496#[doc = "Write proxy for field `PHAFLTREN`"]
497pub struct PHAFLTREN_W<'a> {
498    w: &'a mut W,
499}
500impl<'a> PHAFLTREN_W<'a> {
501    #[doc = r"Writes `variant` to the field"]
502    #[inline(always)]
503    pub fn variant(self, variant: PHAFLTREN_A) -> &'a mut W {
504        {
505            self.bit(variant.into())
506        }
507    }
508    #[doc = "Phase A input filter is disabled."]
509    #[inline(always)]
510    pub fn _0(self) -> &'a mut W {
511        self.variant(PHAFLTREN_A::_0)
512    }
513    #[doc = "Phase A input filter is enabled."]
514    #[inline(always)]
515    pub fn _1(self) -> &'a mut W {
516        self.variant(PHAFLTREN_A::_1)
517    }
518    #[doc = r"Sets the field bit"]
519    #[inline(always)]
520    pub fn set_bit(self) -> &'a mut W {
521        self.bit(true)
522    }
523    #[doc = r"Clears the field bit"]
524    #[inline(always)]
525    pub fn clear_bit(self) -> &'a mut W {
526        self.bit(false)
527    }
528    #[doc = r"Writes raw bits to the field"]
529    #[inline(always)]
530    pub fn bit(self, value: bool) -> &'a mut W {
531        self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u32) & 0x01) << 7);
532        self.w
533    }
534}
535impl R {
536    #[doc = "Bit 0 - Quadrature Decoder Mode Enable"]
537    #[inline(always)]
538    pub fn quaden(&self) -> QUADEN_R {
539        QUADEN_R::new((self.bits & 0x01) != 0)
540    }
541    #[doc = "Bit 1 - Timer Overflow Direction In Quadrature Decoder Mode"]
542    #[inline(always)]
543    pub fn tofdir(&self) -> TOFDIR_R {
544        TOFDIR_R::new(((self.bits >> 1) & 0x01) != 0)
545    }
546    #[doc = "Bit 2 - FTM Counter Direction In Quadrature Decoder Mode"]
547    #[inline(always)]
548    pub fn quadir(&self) -> QUADIR_R {
549        QUADIR_R::new(((self.bits >> 2) & 0x01) != 0)
550    }
551    #[doc = "Bit 3 - Quadrature Decoder Mode"]
552    #[inline(always)]
553    pub fn quadmode(&self) -> QUADMODE_R {
554        QUADMODE_R::new(((self.bits >> 3) & 0x01) != 0)
555    }
556    #[doc = "Bit 4 - Phase B Input Polarity"]
557    #[inline(always)]
558    pub fn phbpol(&self) -> PHBPOL_R {
559        PHBPOL_R::new(((self.bits >> 4) & 0x01) != 0)
560    }
561    #[doc = "Bit 5 - Phase A Input Polarity"]
562    #[inline(always)]
563    pub fn phapol(&self) -> PHAPOL_R {
564        PHAPOL_R::new(((self.bits >> 5) & 0x01) != 0)
565    }
566    #[doc = "Bit 6 - Phase B Input Filter Enable"]
567    #[inline(always)]
568    pub fn phbfltren(&self) -> PHBFLTREN_R {
569        PHBFLTREN_R::new(((self.bits >> 6) & 0x01) != 0)
570    }
571    #[doc = "Bit 7 - Phase A Input Filter Enable"]
572    #[inline(always)]
573    pub fn phafltren(&self) -> PHAFLTREN_R {
574        PHAFLTREN_R::new(((self.bits >> 7) & 0x01) != 0)
575    }
576}
577impl W {
578    #[doc = "Bit 0 - Quadrature Decoder Mode Enable"]
579    #[inline(always)]
580    pub fn quaden(&mut self) -> QUADEN_W {
581        QUADEN_W { w: self }
582    }
583    #[doc = "Bit 3 - Quadrature Decoder Mode"]
584    #[inline(always)]
585    pub fn quadmode(&mut self) -> QUADMODE_W {
586        QUADMODE_W { w: self }
587    }
588    #[doc = "Bit 4 - Phase B Input Polarity"]
589    #[inline(always)]
590    pub fn phbpol(&mut self) -> PHBPOL_W {
591        PHBPOL_W { w: self }
592    }
593    #[doc = "Bit 5 - Phase A Input Polarity"]
594    #[inline(always)]
595    pub fn phapol(&mut self) -> PHAPOL_W {
596        PHAPOL_W { w: self }
597    }
598    #[doc = "Bit 6 - Phase B Input Filter Enable"]
599    #[inline(always)]
600    pub fn phbfltren(&mut self) -> PHBFLTREN_W {
601        PHBFLTREN_W { w: self }
602    }
603    #[doc = "Bit 7 - Phase A Input Filter Enable"]
604    #[inline(always)]
605    pub fn phafltren(&mut self) -> PHAFLTREN_W {
606        PHAFLTREN_W { w: self }
607    }
608}