efm32tg11b_pac/efm32tg11b120/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}
282impl From<PRSSEL_A> for u8 {
283 #[inline(always)]
284 fn from(variant: PRSSEL_A) -> Self {
285 variant as _
286 }
287}
288impl PRSSEL_R {
289 #[doc = "Get enumerated values variant"]
290 #[inline(always)]
291 pub fn variant(&self) -> PRSSEL_A {
292 match self.bits {
293 0 => PRSSEL_A::PRSCH0,
294 1 => PRSSEL_A::PRSCH1,
295 2 => PRSSEL_A::PRSCH2,
296 3 => PRSSEL_A::PRSCH3,
297 4 => PRSSEL_A::PRSCH4,
298 5 => PRSSEL_A::PRSCH5,
299 6 => PRSSEL_A::PRSCH6,
300 7 => PRSSEL_A::PRSCH7,
301 _ => unreachable!(),
302 }
303 }
304 #[doc = "Checks if the value of the field is `PRSCH0`"]
305 #[inline(always)]
306 pub fn is_prsch0(&self) -> bool {
307 *self == PRSSEL_A::PRSCH0
308 }
309 #[doc = "Checks if the value of the field is `PRSCH1`"]
310 #[inline(always)]
311 pub fn is_prsch1(&self) -> bool {
312 *self == PRSSEL_A::PRSCH1
313 }
314 #[doc = "Checks if the value of the field is `PRSCH2`"]
315 #[inline(always)]
316 pub fn is_prsch2(&self) -> bool {
317 *self == PRSSEL_A::PRSCH2
318 }
319 #[doc = "Checks if the value of the field is `PRSCH3`"]
320 #[inline(always)]
321 pub fn is_prsch3(&self) -> bool {
322 *self == PRSSEL_A::PRSCH3
323 }
324 #[doc = "Checks if the value of the field is `PRSCH4`"]
325 #[inline(always)]
326 pub fn is_prsch4(&self) -> bool {
327 *self == PRSSEL_A::PRSCH4
328 }
329 #[doc = "Checks if the value of the field is `PRSCH5`"]
330 #[inline(always)]
331 pub fn is_prsch5(&self) -> bool {
332 *self == PRSSEL_A::PRSCH5
333 }
334 #[doc = "Checks if the value of the field is `PRSCH6`"]
335 #[inline(always)]
336 pub fn is_prsch6(&self) -> bool {
337 *self == PRSSEL_A::PRSCH6
338 }
339 #[doc = "Checks if the value of the field is `PRSCH7`"]
340 #[inline(always)]
341 pub fn is_prsch7(&self) -> bool {
342 *self == PRSSEL_A::PRSCH7
343 }
344}
345#[doc = "Field `PRSSEL` writer - Compare/Capture Channel PRS Input Channel Selection"]
346pub type PRSSEL_W<'a, const O: u8> =
347 crate::FieldWriterSafe<'a, u32, CC2_CTRL_SPEC, u8, PRSSEL_A, 3, O>;
348impl<'a, const O: u8> PRSSEL_W<'a, O> {
349 #[doc = "PRS Channel 0 selected as input"]
350 #[inline(always)]
351 pub fn prsch0(self) -> &'a mut W {
352 self.variant(PRSSEL_A::PRSCH0)
353 }
354 #[doc = "PRS Channel 1 selected as input"]
355 #[inline(always)]
356 pub fn prsch1(self) -> &'a mut W {
357 self.variant(PRSSEL_A::PRSCH1)
358 }
359 #[doc = "PRS Channel 2 selected as input"]
360 #[inline(always)]
361 pub fn prsch2(self) -> &'a mut W {
362 self.variant(PRSSEL_A::PRSCH2)
363 }
364 #[doc = "PRS Channel 3 selected as input"]
365 #[inline(always)]
366 pub fn prsch3(self) -> &'a mut W {
367 self.variant(PRSSEL_A::PRSCH3)
368 }
369 #[doc = "PRS Channel 4 selected as input"]
370 #[inline(always)]
371 pub fn prsch4(self) -> &'a mut W {
372 self.variant(PRSSEL_A::PRSCH4)
373 }
374 #[doc = "PRS Channel 5 selected as input"]
375 #[inline(always)]
376 pub fn prsch5(self) -> &'a mut W {
377 self.variant(PRSSEL_A::PRSCH5)
378 }
379 #[doc = "PRS Channel 6 selected as input"]
380 #[inline(always)]
381 pub fn prsch6(self) -> &'a mut W {
382 self.variant(PRSSEL_A::PRSCH6)
383 }
384 #[doc = "PRS Channel 7 selected as input"]
385 #[inline(always)]
386 pub fn prsch7(self) -> &'a mut W {
387 self.variant(PRSSEL_A::PRSCH7)
388 }
389}
390#[doc = "Field `COMPBASE` reader - Capture Compare Channel Comparison Base"]
391pub type COMPBASE_R = crate::BitReader<bool>;
392#[doc = "Field `COMPBASE` writer - Capture Compare Channel Comparison Base"]
393pub type COMPBASE_W<'a, const O: u8> = crate::BitWriter<'a, u32, CC2_CTRL_SPEC, bool, O>;
394#[doc = "Field `COMPMASK` reader - Capture Compare Channel Comparison Mask"]
395pub type COMPMASK_R = crate::FieldReader<u8, u8>;
396#[doc = "Field `COMPMASK` writer - Capture Compare Channel Comparison Mask"]
397pub type COMPMASK_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CC2_CTRL_SPEC, u8, u8, 5, O>;
398#[doc = "Field `DAYCC` reader - Day Capture/Compare Selection"]
399pub type DAYCC_R = crate::BitReader<bool>;
400#[doc = "Field `DAYCC` writer - Day Capture/Compare Selection"]
401pub type DAYCC_W<'a, const O: u8> = crate::BitWriter<'a, u32, CC2_CTRL_SPEC, bool, O>;
402impl R {
403 #[doc = "Bits 0:1 - CC Channel Mode"]
404 #[inline(always)]
405 pub fn mode(&self) -> MODE_R {
406 MODE_R::new((self.bits & 3) as u8)
407 }
408 #[doc = "Bits 2:3 - Compare Match Output Action"]
409 #[inline(always)]
410 pub fn cmoa(&self) -> CMOA_R {
411 CMOA_R::new(((self.bits >> 2) & 3) as u8)
412 }
413 #[doc = "Bits 4:5 - Input Capture Edge Select"]
414 #[inline(always)]
415 pub fn icedge(&self) -> ICEDGE_R {
416 ICEDGE_R::new(((self.bits >> 4) & 3) as u8)
417 }
418 #[doc = "Bits 6:8 - Compare/Capture Channel PRS Input Channel Selection"]
419 #[inline(always)]
420 pub fn prssel(&self) -> PRSSEL_R {
421 PRSSEL_R::new(((self.bits >> 6) & 7) as u8)
422 }
423 #[doc = "Bit 11 - Capture Compare Channel Comparison Base"]
424 #[inline(always)]
425 pub fn compbase(&self) -> COMPBASE_R {
426 COMPBASE_R::new(((self.bits >> 11) & 1) != 0)
427 }
428 #[doc = "Bits 12:16 - Capture Compare Channel Comparison Mask"]
429 #[inline(always)]
430 pub fn compmask(&self) -> COMPMASK_R {
431 COMPMASK_R::new(((self.bits >> 12) & 0x1f) as u8)
432 }
433 #[doc = "Bit 17 - Day Capture/Compare Selection"]
434 #[inline(always)]
435 pub fn daycc(&self) -> DAYCC_R {
436 DAYCC_R::new(((self.bits >> 17) & 1) != 0)
437 }
438}
439impl W {
440 #[doc = "Bits 0:1 - CC Channel Mode"]
441 #[inline(always)]
442 #[must_use]
443 pub fn mode(&mut self) -> MODE_W<0> {
444 MODE_W::new(self)
445 }
446 #[doc = "Bits 2:3 - Compare Match Output Action"]
447 #[inline(always)]
448 #[must_use]
449 pub fn cmoa(&mut self) -> CMOA_W<2> {
450 CMOA_W::new(self)
451 }
452 #[doc = "Bits 4:5 - Input Capture Edge Select"]
453 #[inline(always)]
454 #[must_use]
455 pub fn icedge(&mut self) -> ICEDGE_W<4> {
456 ICEDGE_W::new(self)
457 }
458 #[doc = "Bits 6:8 - Compare/Capture Channel PRS Input Channel Selection"]
459 #[inline(always)]
460 #[must_use]
461 pub fn prssel(&mut self) -> PRSSEL_W<6> {
462 PRSSEL_W::new(self)
463 }
464 #[doc = "Bit 11 - Capture Compare Channel Comparison Base"]
465 #[inline(always)]
466 #[must_use]
467 pub fn compbase(&mut self) -> COMPBASE_W<11> {
468 COMPBASE_W::new(self)
469 }
470 #[doc = "Bits 12:16 - Capture Compare Channel Comparison Mask"]
471 #[inline(always)]
472 #[must_use]
473 pub fn compmask(&mut self) -> COMPMASK_W<12> {
474 COMPMASK_W::new(self)
475 }
476 #[doc = "Bit 17 - Day Capture/Compare Selection"]
477 #[inline(always)]
478 #[must_use]
479 pub fn daycc(&mut self) -> DAYCC_W<17> {
480 DAYCC_W::new(self)
481 }
482 #[doc = "Writes raw bits to the register."]
483 #[inline(always)]
484 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
485 self.0.bits(bits);
486 self
487 }
488}
489#[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"]
490pub struct CC2_CTRL_SPEC;
491impl crate::RegisterSpec for CC2_CTRL_SPEC {
492 type Ux = u32;
493}
494#[doc = "`read()` method returns [cc2_ctrl::R](R) reader structure"]
495impl crate::Readable for CC2_CTRL_SPEC {
496 type Reader = R;
497}
498#[doc = "`write(|w| ..)` method takes [cc2_ctrl::W](W) writer structure"]
499impl crate::Writable for CC2_CTRL_SPEC {
500 type Writer = W;
501 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
502 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
503}
504#[doc = "`reset()` method sets CC2_CTRL to value 0"]
505impl crate::Resettable for CC2_CTRL_SPEC {
506 const RESET_VALUE: Self::Ux = 0;
507}