efm32g230_pac/timer2/
dttime.rs1#[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 = "DTI Prescaler Setting\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum DTPRESC_A {
41 #[doc = "0: The HFPERCLK is undivided"]
42 DIV1 = 0,
43 #[doc = "1: The HFPERCLK is divided by 2"]
44 DIV2 = 1,
45 #[doc = "2: The HFPERCLK is divided by 4"]
46 DIV4 = 2,
47 #[doc = "3: The HFPERCLK is divided by 8"]
48 DIV8 = 3,
49 #[doc = "4: The HFPERCLK is divided by 16"]
50 DIV16 = 4,
51 #[doc = "5: The HFPERCLK is divided by 32"]
52 DIV32 = 5,
53 #[doc = "6: The HFPERCLK is divided by 64"]
54 DIV64 = 6,
55 #[doc = "7: The HFPERCLK is divided by 128"]
56 DIV128 = 7,
57 #[doc = "8: The HFPERCLK is divided by 256"]
58 DIV256 = 8,
59 #[doc = "9: The HFPERCLK is divided by 512"]
60 DIV512 = 9,
61 #[doc = "10: The HFPERCLK is divided by 1024"]
62 DIV1024 = 10,
63}
64impl From<DTPRESC_A> for u8 {
65 #[inline(always)]
66 fn from(variant: DTPRESC_A) -> Self {
67 variant as _
68 }
69}
70#[doc = "Field `DTPRESC` reader - DTI Prescaler Setting"]
71pub type DTPRESC_R = crate::FieldReader<u8, DTPRESC_A>;
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> = crate::FieldWriter<'a, u32, DTTIME_SPEC, u8, DTPRESC_A, 4, 0>;
149impl<'a> DTPRESC_W<'a> {
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> = crate::FieldWriter<'a, u32, DTTIME_SPEC, u8, u8, 6, 8>;
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> = crate::FieldWriter<'a, u32, DTTIME_SPEC, u8, u8, 6, 16>;
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 pub fn dtpresc(&mut self) -> DTPRESC_W {
235 DTPRESC_W::new(self)
236 }
237 #[doc = "Bits 8:13 - DTI Rise-time"]
238 #[inline(always)]
239 pub fn dtriset(&mut self) -> DTRISET_W {
240 DTRISET_W::new(self)
241 }
242 #[doc = "Bits 16:21 - DTI Fall-time"]
243 #[inline(always)]
244 pub fn dtfallt(&mut self) -> DTFALLT_W {
245 DTFALLT_W::new(self)
246 }
247 #[doc = "Writes raw bits to the register."]
248 #[inline(always)]
249 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
250 self.0.bits(bits);
251 self
252 }
253}
254#[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"]
255pub struct DTTIME_SPEC;
256impl crate::RegisterSpec for DTTIME_SPEC {
257 type Ux = u32;
258}
259#[doc = "`read()` method returns [dttime::R](R) reader structure"]
260impl crate::Readable for DTTIME_SPEC {
261 type Reader = R;
262}
263#[doc = "`write(|w| ..)` method takes [dttime::W](W) writer structure"]
264impl crate::Writable for DTTIME_SPEC {
265 type Writer = W;
266}
267#[doc = "`reset()` method sets DTTIME to value 0"]
268impl crate::Resettable for DTTIME_SPEC {
269 #[inline(always)]
270 fn reset_value() -> Self::Ux {
271 0
272 }
273}