efm32pg1b200_pac/rtcc/
ctrl.rs1#[doc = "Register `CTRL` reader"]
2pub struct R(crate::R<CTRL_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<CTRL_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<CTRL_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<CTRL_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `CTRL` writer"]
17pub struct W(crate::W<CTRL_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<CTRL_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<CTRL_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<CTRL_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `ENABLE` reader - RTCC Enable"]
38pub type ENABLE_R = crate::BitReader<bool>;
39#[doc = "Field `ENABLE` writer - RTCC Enable"]
40pub type ENABLE_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 0>;
41#[doc = "Field `DEBUGRUN` reader - Debug Mode Run Enable"]
42pub type DEBUGRUN_R = crate::BitReader<bool>;
43#[doc = "Field `DEBUGRUN` writer - Debug Mode Run Enable"]
44pub type DEBUGRUN_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 2>;
45#[doc = "Field `PRECCV0TOP` reader - Pre-counter CCV0 Top Value Enable"]
46pub type PRECCV0TOP_R = crate::BitReader<bool>;
47#[doc = "Field `PRECCV0TOP` writer - Pre-counter CCV0 Top Value Enable"]
48pub type PRECCV0TOP_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 4>;
49#[doc = "Field `CCV1TOP` reader - CCV1 Top Value Enable"]
50pub type CCV1TOP_R = crate::BitReader<bool>;
51#[doc = "Field `CCV1TOP` writer - CCV1 Top Value Enable"]
52pub type CCV1TOP_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 5>;
53#[doc = "Counter Prescaler Value\n\nValue on reset: 0"]
54#[derive(Clone, Copy, Debug, PartialEq)]
55#[repr(u8)]
56pub enum CNTPRESC_A {
57 #[doc = "0: CLKCNT = LFECLKRTCC/1"]
58 DIV1 = 0,
59 #[doc = "1: CLKCNT = LFECLKRTCC/2"]
60 DIV2 = 1,
61 #[doc = "2: CLKCNT = LFECLKRTCC/4"]
62 DIV4 = 2,
63 #[doc = "3: CLKCNT = LFECLKRTCC/8"]
64 DIV8 = 3,
65 #[doc = "4: CLKCNT = LFECLKRTCC/16"]
66 DIV16 = 4,
67 #[doc = "5: CLKCNT = LFECLKRTCC/32"]
68 DIV32 = 5,
69 #[doc = "6: CLKCNT = LFECLKRTCC/64"]
70 DIV64 = 6,
71 #[doc = "7: CLKCNT = LFECLKRTCC/128"]
72 DIV128 = 7,
73 #[doc = "8: CLKCNT = LFECLKRTCC/256"]
74 DIV256 = 8,
75 #[doc = "9: CLKCNT = LFECLKRTCC/512"]
76 DIV512 = 9,
77 #[doc = "10: CLKCNT = LFECLKRTCC/1024"]
78 DIV1024 = 10,
79 #[doc = "11: CLKCNT = LFECLKRTCC/2048"]
80 DIV2048 = 11,
81 #[doc = "12: CLKCNT = LFECLKRTCC/4096"]
82 DIV4096 = 12,
83 #[doc = "13: CLKCNT = LFECLKRTCC/8192"]
84 DIV8192 = 13,
85 #[doc = "14: CLKCNT = LFECLKRTCC/16384"]
86 DIV16384 = 14,
87 #[doc = "15: CLKCNT = LFECLKRTCC/32768"]
88 DIV32768 = 15,
89}
90impl From<CNTPRESC_A> for u8 {
91 #[inline(always)]
92 fn from(variant: CNTPRESC_A) -> Self {
93 variant as _
94 }
95}
96#[doc = "Field `CNTPRESC` reader - Counter Prescaler Value"]
97pub type CNTPRESC_R = crate::FieldReader<u8, CNTPRESC_A>;
98impl CNTPRESC_R {
99 #[doc = "Get enumerated values variant"]
100 #[inline(always)]
101 pub fn variant(&self) -> CNTPRESC_A {
102 match self.bits {
103 0 => CNTPRESC_A::DIV1,
104 1 => CNTPRESC_A::DIV2,
105 2 => CNTPRESC_A::DIV4,
106 3 => CNTPRESC_A::DIV8,
107 4 => CNTPRESC_A::DIV16,
108 5 => CNTPRESC_A::DIV32,
109 6 => CNTPRESC_A::DIV64,
110 7 => CNTPRESC_A::DIV128,
111 8 => CNTPRESC_A::DIV256,
112 9 => CNTPRESC_A::DIV512,
113 10 => CNTPRESC_A::DIV1024,
114 11 => CNTPRESC_A::DIV2048,
115 12 => CNTPRESC_A::DIV4096,
116 13 => CNTPRESC_A::DIV8192,
117 14 => CNTPRESC_A::DIV16384,
118 15 => CNTPRESC_A::DIV32768,
119 _ => unreachable!(),
120 }
121 }
122 #[doc = "Checks if the value of the field is `DIV1`"]
123 #[inline(always)]
124 pub fn is_div1(&self) -> bool {
125 *self == CNTPRESC_A::DIV1
126 }
127 #[doc = "Checks if the value of the field is `DIV2`"]
128 #[inline(always)]
129 pub fn is_div2(&self) -> bool {
130 *self == CNTPRESC_A::DIV2
131 }
132 #[doc = "Checks if the value of the field is `DIV4`"]
133 #[inline(always)]
134 pub fn is_div4(&self) -> bool {
135 *self == CNTPRESC_A::DIV4
136 }
137 #[doc = "Checks if the value of the field is `DIV8`"]
138 #[inline(always)]
139 pub fn is_div8(&self) -> bool {
140 *self == CNTPRESC_A::DIV8
141 }
142 #[doc = "Checks if the value of the field is `DIV16`"]
143 #[inline(always)]
144 pub fn is_div16(&self) -> bool {
145 *self == CNTPRESC_A::DIV16
146 }
147 #[doc = "Checks if the value of the field is `DIV32`"]
148 #[inline(always)]
149 pub fn is_div32(&self) -> bool {
150 *self == CNTPRESC_A::DIV32
151 }
152 #[doc = "Checks if the value of the field is `DIV64`"]
153 #[inline(always)]
154 pub fn is_div64(&self) -> bool {
155 *self == CNTPRESC_A::DIV64
156 }
157 #[doc = "Checks if the value of the field is `DIV128`"]
158 #[inline(always)]
159 pub fn is_div128(&self) -> bool {
160 *self == CNTPRESC_A::DIV128
161 }
162 #[doc = "Checks if the value of the field is `DIV256`"]
163 #[inline(always)]
164 pub fn is_div256(&self) -> bool {
165 *self == CNTPRESC_A::DIV256
166 }
167 #[doc = "Checks if the value of the field is `DIV512`"]
168 #[inline(always)]
169 pub fn is_div512(&self) -> bool {
170 *self == CNTPRESC_A::DIV512
171 }
172 #[doc = "Checks if the value of the field is `DIV1024`"]
173 #[inline(always)]
174 pub fn is_div1024(&self) -> bool {
175 *self == CNTPRESC_A::DIV1024
176 }
177 #[doc = "Checks if the value of the field is `DIV2048`"]
178 #[inline(always)]
179 pub fn is_div2048(&self) -> bool {
180 *self == CNTPRESC_A::DIV2048
181 }
182 #[doc = "Checks if the value of the field is `DIV4096`"]
183 #[inline(always)]
184 pub fn is_div4096(&self) -> bool {
185 *self == CNTPRESC_A::DIV4096
186 }
187 #[doc = "Checks if the value of the field is `DIV8192`"]
188 #[inline(always)]
189 pub fn is_div8192(&self) -> bool {
190 *self == CNTPRESC_A::DIV8192
191 }
192 #[doc = "Checks if the value of the field is `DIV16384`"]
193 #[inline(always)]
194 pub fn is_div16384(&self) -> bool {
195 *self == CNTPRESC_A::DIV16384
196 }
197 #[doc = "Checks if the value of the field is `DIV32768`"]
198 #[inline(always)]
199 pub fn is_div32768(&self) -> bool {
200 *self == CNTPRESC_A::DIV32768
201 }
202}
203#[doc = "Field `CNTPRESC` writer - Counter Prescaler Value"]
204pub type CNTPRESC_W<'a> = crate::FieldWriterSafe<'a, u32, CTRL_SPEC, u8, CNTPRESC_A, 4, 8>;
205impl<'a> CNTPRESC_W<'a> {
206 #[doc = "CLKCNT = LFECLKRTCC/1"]
207 #[inline(always)]
208 pub fn div1(self) -> &'a mut W {
209 self.variant(CNTPRESC_A::DIV1)
210 }
211 #[doc = "CLKCNT = LFECLKRTCC/2"]
212 #[inline(always)]
213 pub fn div2(self) -> &'a mut W {
214 self.variant(CNTPRESC_A::DIV2)
215 }
216 #[doc = "CLKCNT = LFECLKRTCC/4"]
217 #[inline(always)]
218 pub fn div4(self) -> &'a mut W {
219 self.variant(CNTPRESC_A::DIV4)
220 }
221 #[doc = "CLKCNT = LFECLKRTCC/8"]
222 #[inline(always)]
223 pub fn div8(self) -> &'a mut W {
224 self.variant(CNTPRESC_A::DIV8)
225 }
226 #[doc = "CLKCNT = LFECLKRTCC/16"]
227 #[inline(always)]
228 pub fn div16(self) -> &'a mut W {
229 self.variant(CNTPRESC_A::DIV16)
230 }
231 #[doc = "CLKCNT = LFECLKRTCC/32"]
232 #[inline(always)]
233 pub fn div32(self) -> &'a mut W {
234 self.variant(CNTPRESC_A::DIV32)
235 }
236 #[doc = "CLKCNT = LFECLKRTCC/64"]
237 #[inline(always)]
238 pub fn div64(self) -> &'a mut W {
239 self.variant(CNTPRESC_A::DIV64)
240 }
241 #[doc = "CLKCNT = LFECLKRTCC/128"]
242 #[inline(always)]
243 pub fn div128(self) -> &'a mut W {
244 self.variant(CNTPRESC_A::DIV128)
245 }
246 #[doc = "CLKCNT = LFECLKRTCC/256"]
247 #[inline(always)]
248 pub fn div256(self) -> &'a mut W {
249 self.variant(CNTPRESC_A::DIV256)
250 }
251 #[doc = "CLKCNT = LFECLKRTCC/512"]
252 #[inline(always)]
253 pub fn div512(self) -> &'a mut W {
254 self.variant(CNTPRESC_A::DIV512)
255 }
256 #[doc = "CLKCNT = LFECLKRTCC/1024"]
257 #[inline(always)]
258 pub fn div1024(self) -> &'a mut W {
259 self.variant(CNTPRESC_A::DIV1024)
260 }
261 #[doc = "CLKCNT = LFECLKRTCC/2048"]
262 #[inline(always)]
263 pub fn div2048(self) -> &'a mut W {
264 self.variant(CNTPRESC_A::DIV2048)
265 }
266 #[doc = "CLKCNT = LFECLKRTCC/4096"]
267 #[inline(always)]
268 pub fn div4096(self) -> &'a mut W {
269 self.variant(CNTPRESC_A::DIV4096)
270 }
271 #[doc = "CLKCNT = LFECLKRTCC/8192"]
272 #[inline(always)]
273 pub fn div8192(self) -> &'a mut W {
274 self.variant(CNTPRESC_A::DIV8192)
275 }
276 #[doc = "CLKCNT = LFECLKRTCC/16384"]
277 #[inline(always)]
278 pub fn div16384(self) -> &'a mut W {
279 self.variant(CNTPRESC_A::DIV16384)
280 }
281 #[doc = "CLKCNT = LFECLKRTCC/32768"]
282 #[inline(always)]
283 pub fn div32768(self) -> &'a mut W {
284 self.variant(CNTPRESC_A::DIV32768)
285 }
286}
287#[doc = "Field `CNTTICK` reader - Counter Prescaler Mode"]
288pub type CNTTICK_R = crate::BitReader<bool>;
289#[doc = "Field `CNTTICK` writer - Counter Prescaler Mode"]
290pub type CNTTICK_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 12>;
291#[doc = "Field `OSCFDETEN` reader - Oscillator Failure Detection Enable"]
292pub type OSCFDETEN_R = crate::BitReader<bool>;
293#[doc = "Field `OSCFDETEN` writer - Oscillator Failure Detection Enable"]
294pub type OSCFDETEN_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 15>;
295#[doc = "Field `CNTMODE` reader - Main Counter Mode"]
296pub type CNTMODE_R = crate::BitReader<bool>;
297#[doc = "Field `CNTMODE` writer - Main Counter Mode"]
298pub type CNTMODE_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 16>;
299#[doc = "Field `LYEARCORRDIS` reader - Leap Year Correction Disabled"]
300pub type LYEARCORRDIS_R = crate::BitReader<bool>;
301#[doc = "Field `LYEARCORRDIS` writer - Leap Year Correction Disabled"]
302pub type LYEARCORRDIS_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 17>;
303impl R {
304 #[doc = "Bit 0 - RTCC Enable"]
305 #[inline(always)]
306 pub fn enable(&self) -> ENABLE_R {
307 ENABLE_R::new((self.bits & 1) != 0)
308 }
309 #[doc = "Bit 2 - Debug Mode Run Enable"]
310 #[inline(always)]
311 pub fn debugrun(&self) -> DEBUGRUN_R {
312 DEBUGRUN_R::new(((self.bits >> 2) & 1) != 0)
313 }
314 #[doc = "Bit 4 - Pre-counter CCV0 Top Value Enable"]
315 #[inline(always)]
316 pub fn preccv0top(&self) -> PRECCV0TOP_R {
317 PRECCV0TOP_R::new(((self.bits >> 4) & 1) != 0)
318 }
319 #[doc = "Bit 5 - CCV1 Top Value Enable"]
320 #[inline(always)]
321 pub fn ccv1top(&self) -> CCV1TOP_R {
322 CCV1TOP_R::new(((self.bits >> 5) & 1) != 0)
323 }
324 #[doc = "Bits 8:11 - Counter Prescaler Value"]
325 #[inline(always)]
326 pub fn cntpresc(&self) -> CNTPRESC_R {
327 CNTPRESC_R::new(((self.bits >> 8) & 0x0f) as u8)
328 }
329 #[doc = "Bit 12 - Counter Prescaler Mode"]
330 #[inline(always)]
331 pub fn cnttick(&self) -> CNTTICK_R {
332 CNTTICK_R::new(((self.bits >> 12) & 1) != 0)
333 }
334 #[doc = "Bit 15 - Oscillator Failure Detection Enable"]
335 #[inline(always)]
336 pub fn oscfdeten(&self) -> OSCFDETEN_R {
337 OSCFDETEN_R::new(((self.bits >> 15) & 1) != 0)
338 }
339 #[doc = "Bit 16 - Main Counter Mode"]
340 #[inline(always)]
341 pub fn cntmode(&self) -> CNTMODE_R {
342 CNTMODE_R::new(((self.bits >> 16) & 1) != 0)
343 }
344 #[doc = "Bit 17 - Leap Year Correction Disabled"]
345 #[inline(always)]
346 pub fn lyearcorrdis(&self) -> LYEARCORRDIS_R {
347 LYEARCORRDIS_R::new(((self.bits >> 17) & 1) != 0)
348 }
349}
350impl W {
351 #[doc = "Bit 0 - RTCC Enable"]
352 #[inline(always)]
353 pub fn enable(&mut self) -> ENABLE_W {
354 ENABLE_W::new(self)
355 }
356 #[doc = "Bit 2 - Debug Mode Run Enable"]
357 #[inline(always)]
358 pub fn debugrun(&mut self) -> DEBUGRUN_W {
359 DEBUGRUN_W::new(self)
360 }
361 #[doc = "Bit 4 - Pre-counter CCV0 Top Value Enable"]
362 #[inline(always)]
363 pub fn preccv0top(&mut self) -> PRECCV0TOP_W {
364 PRECCV0TOP_W::new(self)
365 }
366 #[doc = "Bit 5 - CCV1 Top Value Enable"]
367 #[inline(always)]
368 pub fn ccv1top(&mut self) -> CCV1TOP_W {
369 CCV1TOP_W::new(self)
370 }
371 #[doc = "Bits 8:11 - Counter Prescaler Value"]
372 #[inline(always)]
373 pub fn cntpresc(&mut self) -> CNTPRESC_W {
374 CNTPRESC_W::new(self)
375 }
376 #[doc = "Bit 12 - Counter Prescaler Mode"]
377 #[inline(always)]
378 pub fn cnttick(&mut self) -> CNTTICK_W {
379 CNTTICK_W::new(self)
380 }
381 #[doc = "Bit 15 - Oscillator Failure Detection Enable"]
382 #[inline(always)]
383 pub fn oscfdeten(&mut self) -> OSCFDETEN_W {
384 OSCFDETEN_W::new(self)
385 }
386 #[doc = "Bit 16 - Main Counter Mode"]
387 #[inline(always)]
388 pub fn cntmode(&mut self) -> CNTMODE_W {
389 CNTMODE_W::new(self)
390 }
391 #[doc = "Bit 17 - Leap Year Correction Disabled"]
392 #[inline(always)]
393 pub fn lyearcorrdis(&mut self) -> LYEARCORRDIS_W {
394 LYEARCORRDIS_W::new(self)
395 }
396 #[doc = "Writes raw bits to the register."]
397 #[inline(always)]
398 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
399 self.0.bits(bits);
400 self
401 }
402}
403#[doc = "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 [ctrl](index.html) module"]
404pub struct CTRL_SPEC;
405impl crate::RegisterSpec for CTRL_SPEC {
406 type Ux = u32;
407}
408#[doc = "`read()` method returns [ctrl::R](R) reader structure"]
409impl crate::Readable for CTRL_SPEC {
410 type Reader = R;
411}
412#[doc = "`write(|w| ..)` method takes [ctrl::W](W) writer structure"]
413impl crate::Writable for CTRL_SPEC {
414 type Writer = W;
415}
416#[doc = "`reset()` method sets CTRL to value 0"]
417impl crate::Resettable for CTRL_SPEC {
418 #[inline(always)]
419 fn reset_value() -> Self::Ux {
420 0
421 }
422}