efm32jg12b_pac/efm32jg12b500/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, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
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, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
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, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
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, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
53#[doc = "Field `CNTPRESC` reader - Counter Prescaler Value"]
54pub type CNTPRESC_R = crate::FieldReader<u8, CNTPRESC_A>;
55#[doc = "Counter Prescaler Value\n\nValue on reset: 0"]
56#[derive(Clone, Copy, Debug, PartialEq, Eq)]
57#[repr(u8)]
58pub enum CNTPRESC_A {
59 #[doc = "0: CLKCNT = LFECLKRTCC/1"]
60 DIV1 = 0,
61 #[doc = "1: CLKCNT = LFECLKRTCC/2"]
62 DIV2 = 1,
63 #[doc = "2: CLKCNT = LFECLKRTCC/4"]
64 DIV4 = 2,
65 #[doc = "3: CLKCNT = LFECLKRTCC/8"]
66 DIV8 = 3,
67 #[doc = "4: CLKCNT = LFECLKRTCC/16"]
68 DIV16 = 4,
69 #[doc = "5: CLKCNT = LFECLKRTCC/32"]
70 DIV32 = 5,
71 #[doc = "6: CLKCNT = LFECLKRTCC/64"]
72 DIV64 = 6,
73 #[doc = "7: CLKCNT = LFECLKRTCC/128"]
74 DIV128 = 7,
75 #[doc = "8: CLKCNT = LFECLKRTCC/256"]
76 DIV256 = 8,
77 #[doc = "9: CLKCNT = LFECLKRTCC/512"]
78 DIV512 = 9,
79 #[doc = "10: CLKCNT = LFECLKRTCC/1024"]
80 DIV1024 = 10,
81 #[doc = "11: CLKCNT = LFECLKRTCC/2048"]
82 DIV2048 = 11,
83 #[doc = "12: CLKCNT = LFECLKRTCC/4096"]
84 DIV4096 = 12,
85 #[doc = "13: CLKCNT = LFECLKRTCC/8192"]
86 DIV8192 = 13,
87 #[doc = "14: CLKCNT = LFECLKRTCC/16384"]
88 DIV16384 = 14,
89 #[doc = "15: CLKCNT = LFECLKRTCC/32768"]
90 DIV32768 = 15,
91}
92impl From<CNTPRESC_A> for u8 {
93 #[inline(always)]
94 fn from(variant: CNTPRESC_A) -> Self {
95 variant as _
96 }
97}
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, const O: u8> =
205 crate::FieldWriterSafe<'a, u32, CTRL_SPEC, u8, CNTPRESC_A, 4, O>;
206impl<'a, const O: u8> CNTPRESC_W<'a, O> {
207 #[doc = "CLKCNT = LFECLKRTCC/1"]
208 #[inline(always)]
209 pub fn div1(self) -> &'a mut W {
210 self.variant(CNTPRESC_A::DIV1)
211 }
212 #[doc = "CLKCNT = LFECLKRTCC/2"]
213 #[inline(always)]
214 pub fn div2(self) -> &'a mut W {
215 self.variant(CNTPRESC_A::DIV2)
216 }
217 #[doc = "CLKCNT = LFECLKRTCC/4"]
218 #[inline(always)]
219 pub fn div4(self) -> &'a mut W {
220 self.variant(CNTPRESC_A::DIV4)
221 }
222 #[doc = "CLKCNT = LFECLKRTCC/8"]
223 #[inline(always)]
224 pub fn div8(self) -> &'a mut W {
225 self.variant(CNTPRESC_A::DIV8)
226 }
227 #[doc = "CLKCNT = LFECLKRTCC/16"]
228 #[inline(always)]
229 pub fn div16(self) -> &'a mut W {
230 self.variant(CNTPRESC_A::DIV16)
231 }
232 #[doc = "CLKCNT = LFECLKRTCC/32"]
233 #[inline(always)]
234 pub fn div32(self) -> &'a mut W {
235 self.variant(CNTPRESC_A::DIV32)
236 }
237 #[doc = "CLKCNT = LFECLKRTCC/64"]
238 #[inline(always)]
239 pub fn div64(self) -> &'a mut W {
240 self.variant(CNTPRESC_A::DIV64)
241 }
242 #[doc = "CLKCNT = LFECLKRTCC/128"]
243 #[inline(always)]
244 pub fn div128(self) -> &'a mut W {
245 self.variant(CNTPRESC_A::DIV128)
246 }
247 #[doc = "CLKCNT = LFECLKRTCC/256"]
248 #[inline(always)]
249 pub fn div256(self) -> &'a mut W {
250 self.variant(CNTPRESC_A::DIV256)
251 }
252 #[doc = "CLKCNT = LFECLKRTCC/512"]
253 #[inline(always)]
254 pub fn div512(self) -> &'a mut W {
255 self.variant(CNTPRESC_A::DIV512)
256 }
257 #[doc = "CLKCNT = LFECLKRTCC/1024"]
258 #[inline(always)]
259 pub fn div1024(self) -> &'a mut W {
260 self.variant(CNTPRESC_A::DIV1024)
261 }
262 #[doc = "CLKCNT = LFECLKRTCC/2048"]
263 #[inline(always)]
264 pub fn div2048(self) -> &'a mut W {
265 self.variant(CNTPRESC_A::DIV2048)
266 }
267 #[doc = "CLKCNT = LFECLKRTCC/4096"]
268 #[inline(always)]
269 pub fn div4096(self) -> &'a mut W {
270 self.variant(CNTPRESC_A::DIV4096)
271 }
272 #[doc = "CLKCNT = LFECLKRTCC/8192"]
273 #[inline(always)]
274 pub fn div8192(self) -> &'a mut W {
275 self.variant(CNTPRESC_A::DIV8192)
276 }
277 #[doc = "CLKCNT = LFECLKRTCC/16384"]
278 #[inline(always)]
279 pub fn div16384(self) -> &'a mut W {
280 self.variant(CNTPRESC_A::DIV16384)
281 }
282 #[doc = "CLKCNT = LFECLKRTCC/32768"]
283 #[inline(always)]
284 pub fn div32768(self) -> &'a mut W {
285 self.variant(CNTPRESC_A::DIV32768)
286 }
287}
288#[doc = "Field `CNTTICK` reader - Counter Prescaler Mode"]
289pub type CNTTICK_R = crate::BitReader<bool>;
290#[doc = "Field `CNTTICK` writer - Counter Prescaler Mode"]
291pub type CNTTICK_W<'a, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
292#[doc = "Field `OSCFDETEN` reader - Oscillator Failure Detection Enable"]
293pub type OSCFDETEN_R = crate::BitReader<bool>;
294#[doc = "Field `OSCFDETEN` writer - Oscillator Failure Detection Enable"]
295pub type OSCFDETEN_W<'a, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
296#[doc = "Field `CNTMODE` reader - Main Counter Mode"]
297pub type CNTMODE_R = crate::BitReader<bool>;
298#[doc = "Field `CNTMODE` writer - Main Counter Mode"]
299pub type CNTMODE_W<'a, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
300#[doc = "Field `LYEARCORRDIS` reader - Leap Year Correction Disabled"]
301pub type LYEARCORRDIS_R = crate::BitReader<bool>;
302#[doc = "Field `LYEARCORRDIS` writer - Leap Year Correction Disabled"]
303pub type LYEARCORRDIS_W<'a, const O: u8> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, O>;
304impl R {
305 #[doc = "Bit 0 - RTCC Enable"]
306 #[inline(always)]
307 pub fn enable(&self) -> ENABLE_R {
308 ENABLE_R::new((self.bits & 1) != 0)
309 }
310 #[doc = "Bit 2 - Debug Mode Run Enable"]
311 #[inline(always)]
312 pub fn debugrun(&self) -> DEBUGRUN_R {
313 DEBUGRUN_R::new(((self.bits >> 2) & 1) != 0)
314 }
315 #[doc = "Bit 4 - Pre-counter CCV0 Top Value Enable"]
316 #[inline(always)]
317 pub fn preccv0top(&self) -> PRECCV0TOP_R {
318 PRECCV0TOP_R::new(((self.bits >> 4) & 1) != 0)
319 }
320 #[doc = "Bit 5 - CCV1 Top Value Enable"]
321 #[inline(always)]
322 pub fn ccv1top(&self) -> CCV1TOP_R {
323 CCV1TOP_R::new(((self.bits >> 5) & 1) != 0)
324 }
325 #[doc = "Bits 8:11 - Counter Prescaler Value"]
326 #[inline(always)]
327 pub fn cntpresc(&self) -> CNTPRESC_R {
328 CNTPRESC_R::new(((self.bits >> 8) & 0x0f) as u8)
329 }
330 #[doc = "Bit 12 - Counter Prescaler Mode"]
331 #[inline(always)]
332 pub fn cnttick(&self) -> CNTTICK_R {
333 CNTTICK_R::new(((self.bits >> 12) & 1) != 0)
334 }
335 #[doc = "Bit 15 - Oscillator Failure Detection Enable"]
336 #[inline(always)]
337 pub fn oscfdeten(&self) -> OSCFDETEN_R {
338 OSCFDETEN_R::new(((self.bits >> 15) & 1) != 0)
339 }
340 #[doc = "Bit 16 - Main Counter Mode"]
341 #[inline(always)]
342 pub fn cntmode(&self) -> CNTMODE_R {
343 CNTMODE_R::new(((self.bits >> 16) & 1) != 0)
344 }
345 #[doc = "Bit 17 - Leap Year Correction Disabled"]
346 #[inline(always)]
347 pub fn lyearcorrdis(&self) -> LYEARCORRDIS_R {
348 LYEARCORRDIS_R::new(((self.bits >> 17) & 1) != 0)
349 }
350}
351impl W {
352 #[doc = "Bit 0 - RTCC Enable"]
353 #[inline(always)]
354 #[must_use]
355 pub fn enable(&mut self) -> ENABLE_W<0> {
356 ENABLE_W::new(self)
357 }
358 #[doc = "Bit 2 - Debug Mode Run Enable"]
359 #[inline(always)]
360 #[must_use]
361 pub fn debugrun(&mut self) -> DEBUGRUN_W<2> {
362 DEBUGRUN_W::new(self)
363 }
364 #[doc = "Bit 4 - Pre-counter CCV0 Top Value Enable"]
365 #[inline(always)]
366 #[must_use]
367 pub fn preccv0top(&mut self) -> PRECCV0TOP_W<4> {
368 PRECCV0TOP_W::new(self)
369 }
370 #[doc = "Bit 5 - CCV1 Top Value Enable"]
371 #[inline(always)]
372 #[must_use]
373 pub fn ccv1top(&mut self) -> CCV1TOP_W<5> {
374 CCV1TOP_W::new(self)
375 }
376 #[doc = "Bits 8:11 - Counter Prescaler Value"]
377 #[inline(always)]
378 #[must_use]
379 pub fn cntpresc(&mut self) -> CNTPRESC_W<8> {
380 CNTPRESC_W::new(self)
381 }
382 #[doc = "Bit 12 - Counter Prescaler Mode"]
383 #[inline(always)]
384 #[must_use]
385 pub fn cnttick(&mut self) -> CNTTICK_W<12> {
386 CNTTICK_W::new(self)
387 }
388 #[doc = "Bit 15 - Oscillator Failure Detection Enable"]
389 #[inline(always)]
390 #[must_use]
391 pub fn oscfdeten(&mut self) -> OSCFDETEN_W<15> {
392 OSCFDETEN_W::new(self)
393 }
394 #[doc = "Bit 16 - Main Counter Mode"]
395 #[inline(always)]
396 #[must_use]
397 pub fn cntmode(&mut self) -> CNTMODE_W<16> {
398 CNTMODE_W::new(self)
399 }
400 #[doc = "Bit 17 - Leap Year Correction Disabled"]
401 #[inline(always)]
402 #[must_use]
403 pub fn lyearcorrdis(&mut self) -> LYEARCORRDIS_W<17> {
404 LYEARCORRDIS_W::new(self)
405 }
406 #[doc = "Writes raw bits to the register."]
407 #[inline(always)]
408 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
409 self.0.bits(bits);
410 self
411 }
412}
413#[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"]
414pub struct CTRL_SPEC;
415impl crate::RegisterSpec for CTRL_SPEC {
416 type Ux = u32;
417}
418#[doc = "`read()` method returns [ctrl::R](R) reader structure"]
419impl crate::Readable for CTRL_SPEC {
420 type Reader = R;
421}
422#[doc = "`write(|w| ..)` method takes [ctrl::W](W) writer structure"]
423impl crate::Writable for CTRL_SPEC {
424 type Writer = W;
425 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
426 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
427}
428#[doc = "`reset()` method sets CTRL to value 0"]
429impl crate::Resettable for CTRL_SPEC {
430 const RESET_VALUE: Self::Ux = 0;
431}