mk66f18/ftm2/
deadtime.rs

1#[doc = "Reader of register DEADTIME"]
2pub type R = crate::R<u32, super::DEADTIME>;
3#[doc = "Writer for register DEADTIME"]
4pub type W = crate::W<u32, super::DEADTIME>;
5#[doc = "Register DEADTIME `reset()`'s with value 0"]
6impl crate::ResetValue for super::DEADTIME {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Reader of field `DTVAL`"]
14pub type DTVAL_R = crate::R<u8, u8>;
15#[doc = "Write proxy for field `DTVAL`"]
16pub struct DTVAL_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> DTVAL_W<'a> {
20    #[doc = r"Writes raw bits to the field"]
21    #[inline(always)]
22    pub unsafe fn bits(self, value: u8) -> &'a mut W {
23        self.w.bits = (self.w.bits & !0x3f) | ((value as u32) & 0x3f);
24        self.w
25    }
26}
27#[doc = "Deadtime Prescaler Value\n\nValue on reset: 0"]
28#[derive(Clone, Copy, Debug, PartialEq)]
29pub enum DTPS_A {
30    #[doc = "2: Divide the system clock by 4."]
31    _10,
32    #[doc = "3: Divide the system clock by 16."]
33    _11,
34}
35impl From<DTPS_A> for u8 {
36    #[inline(always)]
37    fn from(variant: DTPS_A) -> Self {
38        match variant {
39            DTPS_A::_10 => 2,
40            DTPS_A::_11 => 3,
41        }
42    }
43}
44#[doc = "Reader of field `DTPS`"]
45pub type DTPS_R = crate::R<u8, DTPS_A>;
46impl DTPS_R {
47    #[doc = r"Get enumerated values variant"]
48    #[inline(always)]
49    pub fn variant(&self) -> crate::Variant<u8, DTPS_A> {
50        use crate::Variant::*;
51        match self.bits {
52            2 => Val(DTPS_A::_10),
53            3 => Val(DTPS_A::_11),
54            i => Res(i),
55        }
56    }
57    #[doc = "Checks if the value of the field is `_10`"]
58    #[inline(always)]
59    pub fn is_10(&self) -> bool {
60        *self == DTPS_A::_10
61    }
62    #[doc = "Checks if the value of the field is `_11`"]
63    #[inline(always)]
64    pub fn is_11(&self) -> bool {
65        *self == DTPS_A::_11
66    }
67}
68#[doc = "Write proxy for field `DTPS`"]
69pub struct DTPS_W<'a> {
70    w: &'a mut W,
71}
72impl<'a> DTPS_W<'a> {
73    #[doc = r"Writes `variant` to the field"]
74    #[inline(always)]
75    pub fn variant(self, variant: DTPS_A) -> &'a mut W {
76        unsafe { self.bits(variant.into()) }
77    }
78    #[doc = "Divide the system clock by 4."]
79    #[inline(always)]
80    pub fn _10(self) -> &'a mut W {
81        self.variant(DTPS_A::_10)
82    }
83    #[doc = "Divide the system clock by 16."]
84    #[inline(always)]
85    pub fn _11(self) -> &'a mut W {
86        self.variant(DTPS_A::_11)
87    }
88    #[doc = r"Writes raw bits to the field"]
89    #[inline(always)]
90    pub unsafe fn bits(self, value: u8) -> &'a mut W {
91        self.w.bits = (self.w.bits & !(0x03 << 6)) | (((value as u32) & 0x03) << 6);
92        self.w
93    }
94}
95impl R {
96    #[doc = "Bits 0:5 - Deadtime Value"]
97    #[inline(always)]
98    pub fn dtval(&self) -> DTVAL_R {
99        DTVAL_R::new((self.bits & 0x3f) as u8)
100    }
101    #[doc = "Bits 6:7 - Deadtime Prescaler Value"]
102    #[inline(always)]
103    pub fn dtps(&self) -> DTPS_R {
104        DTPS_R::new(((self.bits >> 6) & 0x03) as u8)
105    }
106}
107impl W {
108    #[doc = "Bits 0:5 - Deadtime Value"]
109    #[inline(always)]
110    pub fn dtval(&mut self) -> DTVAL_W {
111        DTVAL_W { w: self }
112    }
113    #[doc = "Bits 6:7 - Deadtime Prescaler Value"]
114    #[inline(always)]
115    pub fn dtps(&mut self) -> DTPS_W {
116        DTPS_W { w: self }
117    }
118}