efm32gg_pac/efm32gg230/timer2/
dttime.rs

1#[doc = "Register `DTTIME` reader"]
2pub struct R(crate::R<DTTIME_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<DTTIME_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<DTTIME_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<DTTIME_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `DTTIME` writer"]
17pub struct W(crate::W<DTTIME_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<DTTIME_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<DTTIME_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<DTTIME_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `DTPRESC` reader - DTI Prescaler Setting"]
38pub type DTPRESC_R = crate::FieldReader<u8, DTPRESC_A>;
39#[doc = "DTI Prescaler Setting\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum DTPRESC_A {
43    #[doc = "0: The HFPERCLK is undivided"]
44    DIV1 = 0,
45    #[doc = "1: The HFPERCLK is divided by 2"]
46    DIV2 = 1,
47    #[doc = "2: The HFPERCLK is divided by 4"]
48    DIV4 = 2,
49    #[doc = "3: The HFPERCLK is divided by 8"]
50    DIV8 = 3,
51    #[doc = "4: The HFPERCLK is divided by 16"]
52    DIV16 = 4,
53    #[doc = "5: The HFPERCLK is divided by 32"]
54    DIV32 = 5,
55    #[doc = "6: The HFPERCLK is divided by 64"]
56    DIV64 = 6,
57    #[doc = "7: The HFPERCLK is divided by 128"]
58    DIV128 = 7,
59    #[doc = "8: The HFPERCLK is divided by 256"]
60    DIV256 = 8,
61    #[doc = "9: The HFPERCLK is divided by 512"]
62    DIV512 = 9,
63    #[doc = "10: The HFPERCLK is divided by 1024"]
64    DIV1024 = 10,
65}
66impl From<DTPRESC_A> for u8 {
67    #[inline(always)]
68    fn from(variant: DTPRESC_A) -> Self {
69        variant as _
70    }
71}
72impl DTPRESC_R {
73    #[doc = "Get enumerated values variant"]
74    #[inline(always)]
75    pub fn variant(&self) -> Option<DTPRESC_A> {
76        match self.bits {
77            0 => Some(DTPRESC_A::DIV1),
78            1 => Some(DTPRESC_A::DIV2),
79            2 => Some(DTPRESC_A::DIV4),
80            3 => Some(DTPRESC_A::DIV8),
81            4 => Some(DTPRESC_A::DIV16),
82            5 => Some(DTPRESC_A::DIV32),
83            6 => Some(DTPRESC_A::DIV64),
84            7 => Some(DTPRESC_A::DIV128),
85            8 => Some(DTPRESC_A::DIV256),
86            9 => Some(DTPRESC_A::DIV512),
87            10 => Some(DTPRESC_A::DIV1024),
88            _ => None,
89        }
90    }
91    #[doc = "Checks if the value of the field is `DIV1`"]
92    #[inline(always)]
93    pub fn is_div1(&self) -> bool {
94        *self == DTPRESC_A::DIV1
95    }
96    #[doc = "Checks if the value of the field is `DIV2`"]
97    #[inline(always)]
98    pub fn is_div2(&self) -> bool {
99        *self == DTPRESC_A::DIV2
100    }
101    #[doc = "Checks if the value of the field is `DIV4`"]
102    #[inline(always)]
103    pub fn is_div4(&self) -> bool {
104        *self == DTPRESC_A::DIV4
105    }
106    #[doc = "Checks if the value of the field is `DIV8`"]
107    #[inline(always)]
108    pub fn is_div8(&self) -> bool {
109        *self == DTPRESC_A::DIV8
110    }
111    #[doc = "Checks if the value of the field is `DIV16`"]
112    #[inline(always)]
113    pub fn is_div16(&self) -> bool {
114        *self == DTPRESC_A::DIV16
115    }
116    #[doc = "Checks if the value of the field is `DIV32`"]
117    #[inline(always)]
118    pub fn is_div32(&self) -> bool {
119        *self == DTPRESC_A::DIV32
120    }
121    #[doc = "Checks if the value of the field is `DIV64`"]
122    #[inline(always)]
123    pub fn is_div64(&self) -> bool {
124        *self == DTPRESC_A::DIV64
125    }
126    #[doc = "Checks if the value of the field is `DIV128`"]
127    #[inline(always)]
128    pub fn is_div128(&self) -> bool {
129        *self == DTPRESC_A::DIV128
130    }
131    #[doc = "Checks if the value of the field is `DIV256`"]
132    #[inline(always)]
133    pub fn is_div256(&self) -> bool {
134        *self == DTPRESC_A::DIV256
135    }
136    #[doc = "Checks if the value of the field is `DIV512`"]
137    #[inline(always)]
138    pub fn is_div512(&self) -> bool {
139        *self == DTPRESC_A::DIV512
140    }
141    #[doc = "Checks if the value of the field is `DIV1024`"]
142    #[inline(always)]
143    pub fn is_div1024(&self) -> bool {
144        *self == DTPRESC_A::DIV1024
145    }
146}
147#[doc = "Field `DTPRESC` writer - DTI Prescaler Setting"]
148pub type DTPRESC_W<'a, const O: u8> = crate::FieldWriter<'a, u32, DTTIME_SPEC, u8, DTPRESC_A, 4, O>;
149impl<'a, const O: u8> DTPRESC_W<'a, O> {
150    #[doc = "The HFPERCLK is undivided"]
151    #[inline(always)]
152    pub fn div1(self) -> &'a mut W {
153        self.variant(DTPRESC_A::DIV1)
154    }
155    #[doc = "The HFPERCLK is divided by 2"]
156    #[inline(always)]
157    pub fn div2(self) -> &'a mut W {
158        self.variant(DTPRESC_A::DIV2)
159    }
160    #[doc = "The HFPERCLK is divided by 4"]
161    #[inline(always)]
162    pub fn div4(self) -> &'a mut W {
163        self.variant(DTPRESC_A::DIV4)
164    }
165    #[doc = "The HFPERCLK is divided by 8"]
166    #[inline(always)]
167    pub fn div8(self) -> &'a mut W {
168        self.variant(DTPRESC_A::DIV8)
169    }
170    #[doc = "The HFPERCLK is divided by 16"]
171    #[inline(always)]
172    pub fn div16(self) -> &'a mut W {
173        self.variant(DTPRESC_A::DIV16)
174    }
175    #[doc = "The HFPERCLK is divided by 32"]
176    #[inline(always)]
177    pub fn div32(self) -> &'a mut W {
178        self.variant(DTPRESC_A::DIV32)
179    }
180    #[doc = "The HFPERCLK is divided by 64"]
181    #[inline(always)]
182    pub fn div64(self) -> &'a mut W {
183        self.variant(DTPRESC_A::DIV64)
184    }
185    #[doc = "The HFPERCLK is divided by 128"]
186    #[inline(always)]
187    pub fn div128(self) -> &'a mut W {
188        self.variant(DTPRESC_A::DIV128)
189    }
190    #[doc = "The HFPERCLK is divided by 256"]
191    #[inline(always)]
192    pub fn div256(self) -> &'a mut W {
193        self.variant(DTPRESC_A::DIV256)
194    }
195    #[doc = "The HFPERCLK is divided by 512"]
196    #[inline(always)]
197    pub fn div512(self) -> &'a mut W {
198        self.variant(DTPRESC_A::DIV512)
199    }
200    #[doc = "The HFPERCLK is divided by 1024"]
201    #[inline(always)]
202    pub fn div1024(self) -> &'a mut W {
203        self.variant(DTPRESC_A::DIV1024)
204    }
205}
206#[doc = "Field `DTRISET` reader - DTI Rise-time"]
207pub type DTRISET_R = crate::FieldReader<u8, u8>;
208#[doc = "Field `DTRISET` writer - DTI Rise-time"]
209pub type DTRISET_W<'a, const O: u8> = crate::FieldWriter<'a, u32, DTTIME_SPEC, u8, u8, 6, O>;
210#[doc = "Field `DTFALLT` reader - DTI Fall-time"]
211pub type DTFALLT_R = crate::FieldReader<u8, u8>;
212#[doc = "Field `DTFALLT` writer - DTI Fall-time"]
213pub type DTFALLT_W<'a, const O: u8> = crate::FieldWriter<'a, u32, DTTIME_SPEC, u8, u8, 6, O>;
214impl R {
215    #[doc = "Bits 0:3 - DTI Prescaler Setting"]
216    #[inline(always)]
217    pub fn dtpresc(&self) -> DTPRESC_R {
218        DTPRESC_R::new((self.bits & 0x0f) as u8)
219    }
220    #[doc = "Bits 8:13 - DTI Rise-time"]
221    #[inline(always)]
222    pub fn dtriset(&self) -> DTRISET_R {
223        DTRISET_R::new(((self.bits >> 8) & 0x3f) as u8)
224    }
225    #[doc = "Bits 16:21 - DTI Fall-time"]
226    #[inline(always)]
227    pub fn dtfallt(&self) -> DTFALLT_R {
228        DTFALLT_R::new(((self.bits >> 16) & 0x3f) as u8)
229    }
230}
231impl W {
232    #[doc = "Bits 0:3 - DTI Prescaler Setting"]
233    #[inline(always)]
234    #[must_use]
235    pub fn dtpresc(&mut self) -> DTPRESC_W<0> {
236        DTPRESC_W::new(self)
237    }
238    #[doc = "Bits 8:13 - DTI Rise-time"]
239    #[inline(always)]
240    #[must_use]
241    pub fn dtriset(&mut self) -> DTRISET_W<8> {
242        DTRISET_W::new(self)
243    }
244    #[doc = "Bits 16:21 - DTI Fall-time"]
245    #[inline(always)]
246    #[must_use]
247    pub fn dtfallt(&mut self) -> DTFALLT_W<16> {
248        DTFALLT_W::new(self)
249    }
250    #[doc = "Writes raw bits to the register."]
251    #[inline(always)]
252    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
253        self.0.bits(bits);
254        self
255    }
256}
257#[doc = "DTI Time Control Register\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dttime](index.html) module"]
258pub struct DTTIME_SPEC;
259impl crate::RegisterSpec for DTTIME_SPEC {
260    type Ux = u32;
261}
262#[doc = "`read()` method returns [dttime::R](R) reader structure"]
263impl crate::Readable for DTTIME_SPEC {
264    type Reader = R;
265}
266#[doc = "`write(|w| ..)` method takes [dttime::W](W) writer structure"]
267impl crate::Writable for DTTIME_SPEC {
268    type Writer = W;
269    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
270    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
271}
272#[doc = "`reset()` method sets DTTIME to value 0"]
273impl crate::Resettable for DTTIME_SPEC {
274    const RESET_VALUE: Self::Ux = 0;
275}