efm32jg12b_pac/efm32jg12b500/rtcc/
cc2_ctrl.rs1#[doc = "Register `CC2_CTRL` reader"]
2pub struct R(crate::R<CC2_CTRL_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<CC2_CTRL_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<CC2_CTRL_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<CC2_CTRL_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `CC2_CTRL` writer"]
17pub struct W(crate::W<CC2_CTRL_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<CC2_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<CC2_CTRL_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<CC2_CTRL_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `MODE` reader - CC Channel Mode"]
38pub type MODE_R = crate::FieldReader<u8, MODE_A>;
39#[doc = "CC Channel Mode\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum MODE_A {
43 #[doc = "0: Compare/Capture channel turned off"]
44 OFF = 0,
45 #[doc = "1: Input capture"]
46 INPUTCAPTURE = 1,
47 #[doc = "2: Output compare"]
48 OUTPUTCOMPARE = 2,
49}
50impl From<MODE_A> for u8 {
51 #[inline(always)]
52 fn from(variant: MODE_A) -> Self {
53 variant as _
54 }
55}
56impl MODE_R {
57 #[doc = "Get enumerated values variant"]
58 #[inline(always)]
59 pub fn variant(&self) -> Option<MODE_A> {
60 match self.bits {
61 0 => Some(MODE_A::OFF),
62 1 => Some(MODE_A::INPUTCAPTURE),
63 2 => Some(MODE_A::OUTPUTCOMPARE),
64 _ => None,
65 }
66 }
67 #[doc = "Checks if the value of the field is `OFF`"]
68 #[inline(always)]
69 pub fn is_off(&self) -> bool {
70 *self == MODE_A::OFF
71 }
72 #[doc = "Checks if the value of the field is `INPUTCAPTURE`"]
73 #[inline(always)]
74 pub fn is_inputcapture(&self) -> bool {
75 *self == MODE_A::INPUTCAPTURE
76 }
77 #[doc = "Checks if the value of the field is `OUTPUTCOMPARE`"]
78 #[inline(always)]
79 pub fn is_outputcompare(&self) -> bool {
80 *self == MODE_A::OUTPUTCOMPARE
81 }
82}
83#[doc = "Field `MODE` writer - CC Channel Mode"]
84pub type MODE_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CC2_CTRL_SPEC, u8, MODE_A, 2, O>;
85impl<'a, const O: u8> MODE_W<'a, O> {
86 #[doc = "Compare/Capture channel turned off"]
87 #[inline(always)]
88 pub fn off(self) -> &'a mut W {
89 self.variant(MODE_A::OFF)
90 }
91 #[doc = "Input capture"]
92 #[inline(always)]
93 pub fn inputcapture(self) -> &'a mut W {
94 self.variant(MODE_A::INPUTCAPTURE)
95 }
96 #[doc = "Output compare"]
97 #[inline(always)]
98 pub fn outputcompare(self) -> &'a mut W {
99 self.variant(MODE_A::OUTPUTCOMPARE)
100 }
101}
102#[doc = "Field `CMOA` reader - Compare Match Output Action"]
103pub type CMOA_R = crate::FieldReader<u8, CMOA_A>;
104#[doc = "Compare Match Output Action\n\nValue on reset: 0"]
105#[derive(Clone, Copy, Debug, PartialEq, Eq)]
106#[repr(u8)]
107pub enum CMOA_A {
108 #[doc = "0: A single clock cycle pulse is generated on output"]
109 PULSE = 0,
110 #[doc = "1: Toggle output on compare match"]
111 TOGGLE = 1,
112 #[doc = "2: Clear output on compare match"]
113 CLEAR = 2,
114 #[doc = "3: Set output on compare match"]
115 SET = 3,
116}
117impl From<CMOA_A> for u8 {
118 #[inline(always)]
119 fn from(variant: CMOA_A) -> Self {
120 variant as _
121 }
122}
123impl CMOA_R {
124 #[doc = "Get enumerated values variant"]
125 #[inline(always)]
126 pub fn variant(&self) -> CMOA_A {
127 match self.bits {
128 0 => CMOA_A::PULSE,
129 1 => CMOA_A::TOGGLE,
130 2 => CMOA_A::CLEAR,
131 3 => CMOA_A::SET,
132 _ => unreachable!(),
133 }
134 }
135 #[doc = "Checks if the value of the field is `PULSE`"]
136 #[inline(always)]
137 pub fn is_pulse(&self) -> bool {
138 *self == CMOA_A::PULSE
139 }
140 #[doc = "Checks if the value of the field is `TOGGLE`"]
141 #[inline(always)]
142 pub fn is_toggle(&self) -> bool {
143 *self == CMOA_A::TOGGLE
144 }
145 #[doc = "Checks if the value of the field is `CLEAR`"]
146 #[inline(always)]
147 pub fn is_clear(&self) -> bool {
148 *self == CMOA_A::CLEAR
149 }
150 #[doc = "Checks if the value of the field is `SET`"]
151 #[inline(always)]
152 pub fn is_set(&self) -> bool {
153 *self == CMOA_A::SET
154 }
155}
156#[doc = "Field `CMOA` writer - Compare Match Output Action"]
157pub type CMOA_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u32, CC2_CTRL_SPEC, u8, CMOA_A, 2, O>;
158impl<'a, const O: u8> CMOA_W<'a, O> {
159 #[doc = "A single clock cycle pulse is generated on output"]
160 #[inline(always)]
161 pub fn pulse(self) -> &'a mut W {
162 self.variant(CMOA_A::PULSE)
163 }
164 #[doc = "Toggle output on compare match"]
165 #[inline(always)]
166 pub fn toggle(self) -> &'a mut W {
167 self.variant(CMOA_A::TOGGLE)
168 }
169 #[doc = "Clear output on compare match"]
170 #[inline(always)]
171 pub fn clear(self) -> &'a mut W {
172 self.variant(CMOA_A::CLEAR)
173 }
174 #[doc = "Set output on compare match"]
175 #[inline(always)]
176 pub fn set(self) -> &'a mut W {
177 self.variant(CMOA_A::SET)
178 }
179}
180#[doc = "Field `ICEDGE` reader - Input Capture Edge Select"]
181pub type ICEDGE_R = crate::FieldReader<u8, ICEDGE_A>;
182#[doc = "Input Capture Edge Select\n\nValue on reset: 0"]
183#[derive(Clone, Copy, Debug, PartialEq, Eq)]
184#[repr(u8)]
185pub enum ICEDGE_A {
186 #[doc = "0: Rising edges detected"]
187 RISING = 0,
188 #[doc = "1: Falling edges detected"]
189 FALLING = 1,
190 #[doc = "2: Both edges detected"]
191 BOTH = 2,
192 #[doc = "3: No edge detection, signal is left as it is"]
193 NONE = 3,
194}
195impl From<ICEDGE_A> for u8 {
196 #[inline(always)]
197 fn from(variant: ICEDGE_A) -> Self {
198 variant as _
199 }
200}
201impl ICEDGE_R {
202 #[doc = "Get enumerated values variant"]
203 #[inline(always)]
204 pub fn variant(&self) -> ICEDGE_A {
205 match self.bits {
206 0 => ICEDGE_A::RISING,
207 1 => ICEDGE_A::FALLING,
208 2 => ICEDGE_A::BOTH,
209 3 => ICEDGE_A::NONE,
210 _ => unreachable!(),
211 }
212 }
213 #[doc = "Checks if the value of the field is `RISING`"]
214 #[inline(always)]
215 pub fn is_rising(&self) -> bool {
216 *self == ICEDGE_A::RISING
217 }
218 #[doc = "Checks if the value of the field is `FALLING`"]
219 #[inline(always)]
220 pub fn is_falling(&self) -> bool {
221 *self == ICEDGE_A::FALLING
222 }
223 #[doc = "Checks if the value of the field is `BOTH`"]
224 #[inline(always)]
225 pub fn is_both(&self) -> bool {
226 *self == ICEDGE_A::BOTH
227 }
228 #[doc = "Checks if the value of the field is `NONE`"]
229 #[inline(always)]
230 pub fn is_none(&self) -> bool {
231 *self == ICEDGE_A::NONE
232 }
233}
234#[doc = "Field `ICEDGE` writer - Input Capture Edge Select"]
235pub type ICEDGE_W<'a, const O: u8> =
236 crate::FieldWriterSafe<'a, u32, CC2_CTRL_SPEC, u8, ICEDGE_A, 2, O>;
237impl<'a, const O: u8> ICEDGE_W<'a, O> {
238 #[doc = "Rising edges detected"]
239 #[inline(always)]
240 pub fn rising(self) -> &'a mut W {
241 self.variant(ICEDGE_A::RISING)
242 }
243 #[doc = "Falling edges detected"]
244 #[inline(always)]
245 pub fn falling(self) -> &'a mut W {
246 self.variant(ICEDGE_A::FALLING)
247 }
248 #[doc = "Both edges detected"]
249 #[inline(always)]
250 pub fn both(self) -> &'a mut W {
251 self.variant(ICEDGE_A::BOTH)
252 }
253 #[doc = "No edge detection, signal is left as it is"]
254 #[inline(always)]
255 pub fn none(self) -> &'a mut W {
256 self.variant(ICEDGE_A::NONE)
257 }
258}
259#[doc = "Field `PRSSEL` reader - Compare/Capture Channel PRS Input Channel Selection"]
260pub type PRSSEL_R = crate::FieldReader<u8, PRSSEL_A>;
261#[doc = "Compare/Capture Channel PRS Input Channel Selection\n\nValue on reset: 0"]
262#[derive(Clone, Copy, Debug, PartialEq, Eq)]
263#[repr(u8)]
264pub enum PRSSEL_A {
265 #[doc = "0: PRS Channel 0 selected as input"]
266 PRSCH0 = 0,
267 #[doc = "1: PRS Channel 1 selected as input"]
268 PRSCH1 = 1,
269 #[doc = "2: PRS Channel 2 selected as input"]
270 PRSCH2 = 2,
271 #[doc = "3: PRS Channel 3 selected as input"]
272 PRSCH3 = 3,
273 #[doc = "4: PRS Channel 4 selected as input"]
274 PRSCH4 = 4,
275 #[doc = "5: PRS Channel 5 selected as input"]
276 PRSCH5 = 5,
277 #[doc = "6: PRS Channel 6 selected as input"]
278 PRSCH6 = 6,
279 #[doc = "7: PRS Channel 7 selected as input"]
280 PRSCH7 = 7,
281 #[doc = "8: PRS Channel 8 selected as input"]
282 PRSCH8 = 8,
283 #[doc = "9: PRS Channel 9 selected as input"]
284 PRSCH9 = 9,
285 #[doc = "10: PRS Channel 10 selected as input"]
286 PRSCH10 = 10,
287 #[doc = "11: PRS Channel 11 selected as input"]
288 PRSCH11 = 11,
289}
290impl From<PRSSEL_A> for u8 {
291 #[inline(always)]
292 fn from(variant: PRSSEL_A) -> Self {
293 variant as _
294 }
295}
296impl PRSSEL_R {
297 #[doc = "Get enumerated values variant"]
298 #[inline(always)]
299 pub fn variant(&self) -> Option<PRSSEL_A> {
300 match self.bits {
301 0 => Some(PRSSEL_A::PRSCH0),
302 1 => Some(PRSSEL_A::PRSCH1),
303 2 => Some(PRSSEL_A::PRSCH2),
304 3 => Some(PRSSEL_A::PRSCH3),
305 4 => Some(PRSSEL_A::PRSCH4),
306 5 => Some(PRSSEL_A::PRSCH5),
307 6 => Some(PRSSEL_A::PRSCH6),
308 7 => Some(PRSSEL_A::PRSCH7),
309 8 => Some(PRSSEL_A::PRSCH8),
310 9 => Some(PRSSEL_A::PRSCH9),
311 10 => Some(PRSSEL_A::PRSCH10),
312 11 => Some(PRSSEL_A::PRSCH11),
313 _ => None,
314 }
315 }
316 #[doc = "Checks if the value of the field is `PRSCH0`"]
317 #[inline(always)]
318 pub fn is_prsch0(&self) -> bool {
319 *self == PRSSEL_A::PRSCH0
320 }
321 #[doc = "Checks if the value of the field is `PRSCH1`"]
322 #[inline(always)]
323 pub fn is_prsch1(&self) -> bool {
324 *self == PRSSEL_A::PRSCH1
325 }
326 #[doc = "Checks if the value of the field is `PRSCH2`"]
327 #[inline(always)]
328 pub fn is_prsch2(&self) -> bool {
329 *self == PRSSEL_A::PRSCH2
330 }
331 #[doc = "Checks if the value of the field is `PRSCH3`"]
332 #[inline(always)]
333 pub fn is_prsch3(&self) -> bool {
334 *self == PRSSEL_A::PRSCH3
335 }
336 #[doc = "Checks if the value of the field is `PRSCH4`"]
337 #[inline(always)]
338 pub fn is_prsch4(&self) -> bool {
339 *self == PRSSEL_A::PRSCH4
340 }
341 #[doc = "Checks if the value of the field is `PRSCH5`"]
342 #[inline(always)]
343 pub fn is_prsch5(&self) -> bool {
344 *self == PRSSEL_A::PRSCH5
345 }
346 #[doc = "Checks if the value of the field is `PRSCH6`"]
347 #[inline(always)]
348 pub fn is_prsch6(&self) -> bool {
349 *self == PRSSEL_A::PRSCH6
350 }
351 #[doc = "Checks if the value of the field is `PRSCH7`"]
352 #[inline(always)]
353 pub fn is_prsch7(&self) -> bool {
354 *self == PRSSEL_A::PRSCH7
355 }
356 #[doc = "Checks if the value of the field is `PRSCH8`"]
357 #[inline(always)]
358 pub fn is_prsch8(&self) -> bool {
359 *self == PRSSEL_A::PRSCH8
360 }
361 #[doc = "Checks if the value of the field is `PRSCH9`"]
362 #[inline(always)]
363 pub fn is_prsch9(&self) -> bool {
364 *self == PRSSEL_A::PRSCH9
365 }
366 #[doc = "Checks if the value of the field is `PRSCH10`"]
367 #[inline(always)]
368 pub fn is_prsch10(&self) -> bool {
369 *self == PRSSEL_A::PRSCH10
370 }
371 #[doc = "Checks if the value of the field is `PRSCH11`"]
372 #[inline(always)]
373 pub fn is_prsch11(&self) -> bool {
374 *self == PRSSEL_A::PRSCH11
375 }
376}
377#[doc = "Field `PRSSEL` writer - Compare/Capture Channel PRS Input Channel Selection"]
378pub type PRSSEL_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CC2_CTRL_SPEC, u8, PRSSEL_A, 4, O>;
379impl<'a, const O: u8> PRSSEL_W<'a, O> {
380 #[doc = "PRS Channel 0 selected as input"]
381 #[inline(always)]
382 pub fn prsch0(self) -> &'a mut W {
383 self.variant(PRSSEL_A::PRSCH0)
384 }
385 #[doc = "PRS Channel 1 selected as input"]
386 #[inline(always)]
387 pub fn prsch1(self) -> &'a mut W {
388 self.variant(PRSSEL_A::PRSCH1)
389 }
390 #[doc = "PRS Channel 2 selected as input"]
391 #[inline(always)]
392 pub fn prsch2(self) -> &'a mut W {
393 self.variant(PRSSEL_A::PRSCH2)
394 }
395 #[doc = "PRS Channel 3 selected as input"]
396 #[inline(always)]
397 pub fn prsch3(self) -> &'a mut W {
398 self.variant(PRSSEL_A::PRSCH3)
399 }
400 #[doc = "PRS Channel 4 selected as input"]
401 #[inline(always)]
402 pub fn prsch4(self) -> &'a mut W {
403 self.variant(PRSSEL_A::PRSCH4)
404 }
405 #[doc = "PRS Channel 5 selected as input"]
406 #[inline(always)]
407 pub fn prsch5(self) -> &'a mut W {
408 self.variant(PRSSEL_A::PRSCH5)
409 }
410 #[doc = "PRS Channel 6 selected as input"]
411 #[inline(always)]
412 pub fn prsch6(self) -> &'a mut W {
413 self.variant(PRSSEL_A::PRSCH6)
414 }
415 #[doc = "PRS Channel 7 selected as input"]
416 #[inline(always)]
417 pub fn prsch7(self) -> &'a mut W {
418 self.variant(PRSSEL_A::PRSCH7)
419 }
420 #[doc = "PRS Channel 8 selected as input"]
421 #[inline(always)]
422 pub fn prsch8(self) -> &'a mut W {
423 self.variant(PRSSEL_A::PRSCH8)
424 }
425 #[doc = "PRS Channel 9 selected as input"]
426 #[inline(always)]
427 pub fn prsch9(self) -> &'a mut W {
428 self.variant(PRSSEL_A::PRSCH9)
429 }
430 #[doc = "PRS Channel 10 selected as input"]
431 #[inline(always)]
432 pub fn prsch10(self) -> &'a mut W {
433 self.variant(PRSSEL_A::PRSCH10)
434 }
435 #[doc = "PRS Channel 11 selected as input"]
436 #[inline(always)]
437 pub fn prsch11(self) -> &'a mut W {
438 self.variant(PRSSEL_A::PRSCH11)
439 }
440}
441#[doc = "Field `COMPBASE` reader - Capture Compare Channel Comparison Base"]
442pub type COMPBASE_R = crate::BitReader<bool>;
443#[doc = "Field `COMPBASE` writer - Capture Compare Channel Comparison Base"]
444pub type COMPBASE_W<'a, const O: u8> = crate::BitWriter<'a, u32, CC2_CTRL_SPEC, bool, O>;
445#[doc = "Field `COMPMASK` reader - Capture Compare Channel Comparison Mask"]
446pub type COMPMASK_R = crate::FieldReader<u8, u8>;
447#[doc = "Field `COMPMASK` writer - Capture Compare Channel Comparison Mask"]
448pub type COMPMASK_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CC2_CTRL_SPEC, u8, u8, 5, O>;
449#[doc = "Field `DAYCC` reader - Day Capture/Compare Selection"]
450pub type DAYCC_R = crate::BitReader<bool>;
451#[doc = "Field `DAYCC` writer - Day Capture/Compare Selection"]
452pub type DAYCC_W<'a, const O: u8> = crate::BitWriter<'a, u32, CC2_CTRL_SPEC, bool, O>;
453impl R {
454 #[doc = "Bits 0:1 - CC Channel Mode"]
455 #[inline(always)]
456 pub fn mode(&self) -> MODE_R {
457 MODE_R::new((self.bits & 3) as u8)
458 }
459 #[doc = "Bits 2:3 - Compare Match Output Action"]
460 #[inline(always)]
461 pub fn cmoa(&self) -> CMOA_R {
462 CMOA_R::new(((self.bits >> 2) & 3) as u8)
463 }
464 #[doc = "Bits 4:5 - Input Capture Edge Select"]
465 #[inline(always)]
466 pub fn icedge(&self) -> ICEDGE_R {
467 ICEDGE_R::new(((self.bits >> 4) & 3) as u8)
468 }
469 #[doc = "Bits 6:9 - Compare/Capture Channel PRS Input Channel Selection"]
470 #[inline(always)]
471 pub fn prssel(&self) -> PRSSEL_R {
472 PRSSEL_R::new(((self.bits >> 6) & 0x0f) as u8)
473 }
474 #[doc = "Bit 11 - Capture Compare Channel Comparison Base"]
475 #[inline(always)]
476 pub fn compbase(&self) -> COMPBASE_R {
477 COMPBASE_R::new(((self.bits >> 11) & 1) != 0)
478 }
479 #[doc = "Bits 12:16 - Capture Compare Channel Comparison Mask"]
480 #[inline(always)]
481 pub fn compmask(&self) -> COMPMASK_R {
482 COMPMASK_R::new(((self.bits >> 12) & 0x1f) as u8)
483 }
484 #[doc = "Bit 17 - Day Capture/Compare Selection"]
485 #[inline(always)]
486 pub fn daycc(&self) -> DAYCC_R {
487 DAYCC_R::new(((self.bits >> 17) & 1) != 0)
488 }
489}
490impl W {
491 #[doc = "Bits 0:1 - CC Channel Mode"]
492 #[inline(always)]
493 #[must_use]
494 pub fn mode(&mut self) -> MODE_W<0> {
495 MODE_W::new(self)
496 }
497 #[doc = "Bits 2:3 - Compare Match Output Action"]
498 #[inline(always)]
499 #[must_use]
500 pub fn cmoa(&mut self) -> CMOA_W<2> {
501 CMOA_W::new(self)
502 }
503 #[doc = "Bits 4:5 - Input Capture Edge Select"]
504 #[inline(always)]
505 #[must_use]
506 pub fn icedge(&mut self) -> ICEDGE_W<4> {
507 ICEDGE_W::new(self)
508 }
509 #[doc = "Bits 6:9 - Compare/Capture Channel PRS Input Channel Selection"]
510 #[inline(always)]
511 #[must_use]
512 pub fn prssel(&mut self) -> PRSSEL_W<6> {
513 PRSSEL_W::new(self)
514 }
515 #[doc = "Bit 11 - Capture Compare Channel Comparison Base"]
516 #[inline(always)]
517 #[must_use]
518 pub fn compbase(&mut self) -> COMPBASE_W<11> {
519 COMPBASE_W::new(self)
520 }
521 #[doc = "Bits 12:16 - Capture Compare Channel Comparison Mask"]
522 #[inline(always)]
523 #[must_use]
524 pub fn compmask(&mut self) -> COMPMASK_W<12> {
525 COMPMASK_W::new(self)
526 }
527 #[doc = "Bit 17 - Day Capture/Compare Selection"]
528 #[inline(always)]
529 #[must_use]
530 pub fn daycc(&mut self) -> DAYCC_W<17> {
531 DAYCC_W::new(self)
532 }
533 #[doc = "Writes raw bits to the register."]
534 #[inline(always)]
535 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
536 self.0.bits(bits);
537 self
538 }
539}
540#[doc = "CC Channel 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 [cc2_ctrl](index.html) module"]
541pub struct CC2_CTRL_SPEC;
542impl crate::RegisterSpec for CC2_CTRL_SPEC {
543 type Ux = u32;
544}
545#[doc = "`read()` method returns [cc2_ctrl::R](R) reader structure"]
546impl crate::Readable for CC2_CTRL_SPEC {
547 type Reader = R;
548}
549#[doc = "`write(|w| ..)` method takes [cc2_ctrl::W](W) writer structure"]
550impl crate::Writable for CC2_CTRL_SPEC {
551 type Writer = W;
552 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
553 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
554}
555#[doc = "`reset()` method sets CC2_CTRL to value 0"]
556impl crate::Resettable for CC2_CTRL_SPEC {
557 const RESET_VALUE: Self::Ux = 0;
558}