1#[doc = "Reader of register SC"]
2pub type R = crate::R<u32, super::SC>;
3#[doc = "Writer for register SC"]
4pub type W = crate::W<u32, super::SC>;
5#[doc = "Register SC `reset()`'s with value 0"]
6impl crate::ResetValue for super::SC {
7 type Type = u32;
8 #[inline(always)]
9 fn reset_value() -> Self::Type {
10 0
11 }
12}
13#[doc = "Possible values of the field `PS`"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15pub enum PS_A {
16 #[doc = "Divide by 1"]
17 _000,
18 #[doc = "Divide by 2"]
19 _001,
20 #[doc = "Divide by 4"]
21 _010,
22 #[doc = "Divide by 8"]
23 _011,
24 #[doc = "Divide by 16"]
25 _100,
26 #[doc = "Divide by 32"]
27 _101,
28 #[doc = "Divide by 64"]
29 _110,
30 #[doc = "Divide by 128"]
31 _111,
32}
33impl crate::ToBits<u8> for PS_A {
34 #[inline(always)]
35 fn _bits(&self) -> u8 {
36 match *self {
37 PS_A::_000 => 0,
38 PS_A::_001 => 1,
39 PS_A::_010 => 2,
40 PS_A::_011 => 3,
41 PS_A::_100 => 4,
42 PS_A::_101 => 5,
43 PS_A::_110 => 6,
44 PS_A::_111 => 7,
45 }
46 }
47}
48#[doc = "Reader of field `PS`"]
49pub type PS_R = crate::R<u8, PS_A>;
50impl PS_R {
51 #[doc = r"Get enumerated values variant"]
52 #[inline(always)]
53 pub fn variant(&self) -> PS_A {
54 match self.bits {
55 0 => PS_A::_000,
56 1 => PS_A::_001,
57 2 => PS_A::_010,
58 3 => PS_A::_011,
59 4 => PS_A::_100,
60 5 => PS_A::_101,
61 6 => PS_A::_110,
62 7 => PS_A::_111,
63 _ => unreachable!(),
64 }
65 }
66 #[doc = "Checks if the value of the field is `_000`"]
67 #[inline(always)]
68 pub fn is_000(&self) -> bool {
69 *self == PS_A::_000
70 }
71 #[doc = "Checks if the value of the field is `_001`"]
72 #[inline(always)]
73 pub fn is_001(&self) -> bool {
74 *self == PS_A::_001
75 }
76 #[doc = "Checks if the value of the field is `_010`"]
77 #[inline(always)]
78 pub fn is_010(&self) -> bool {
79 *self == PS_A::_010
80 }
81 #[doc = "Checks if the value of the field is `_011`"]
82 #[inline(always)]
83 pub fn is_011(&self) -> bool {
84 *self == PS_A::_011
85 }
86 #[doc = "Checks if the value of the field is `_100`"]
87 #[inline(always)]
88 pub fn is_100(&self) -> bool {
89 *self == PS_A::_100
90 }
91 #[doc = "Checks if the value of the field is `_101`"]
92 #[inline(always)]
93 pub fn is_101(&self) -> bool {
94 *self == PS_A::_101
95 }
96 #[doc = "Checks if the value of the field is `_110`"]
97 #[inline(always)]
98 pub fn is_110(&self) -> bool {
99 *self == PS_A::_110
100 }
101 #[doc = "Checks if the value of the field is `_111`"]
102 #[inline(always)]
103 pub fn is_111(&self) -> bool {
104 *self == PS_A::_111
105 }
106}
107#[doc = "Write proxy for field `PS`"]
108pub struct PS_W<'a> {
109 w: &'a mut W,
110}
111impl<'a> PS_W<'a> {
112 #[doc = r"Writes `variant` to the field"]
113 #[inline(always)]
114 pub fn variant(self, variant: PS_A) -> &'a mut W {
115 use crate::ToBits;
116 {
117 self.bits(variant._bits())
118 }
119 }
120 #[doc = "Divide by 1"]
121 #[inline(always)]
122 pub fn _000(self) -> &'a mut W {
123 self.variant(PS_A::_000)
124 }
125 #[doc = "Divide by 2"]
126 #[inline(always)]
127 pub fn _001(self) -> &'a mut W {
128 self.variant(PS_A::_001)
129 }
130 #[doc = "Divide by 4"]
131 #[inline(always)]
132 pub fn _010(self) -> &'a mut W {
133 self.variant(PS_A::_010)
134 }
135 #[doc = "Divide by 8"]
136 #[inline(always)]
137 pub fn _011(self) -> &'a mut W {
138 self.variant(PS_A::_011)
139 }
140 #[doc = "Divide by 16"]
141 #[inline(always)]
142 pub fn _100(self) -> &'a mut W {
143 self.variant(PS_A::_100)
144 }
145 #[doc = "Divide by 32"]
146 #[inline(always)]
147 pub fn _101(self) -> &'a mut W {
148 self.variant(PS_A::_101)
149 }
150 #[doc = "Divide by 64"]
151 #[inline(always)]
152 pub fn _110(self) -> &'a mut W {
153 self.variant(PS_A::_110)
154 }
155 #[doc = "Divide by 128"]
156 #[inline(always)]
157 pub fn _111(self) -> &'a mut W {
158 self.variant(PS_A::_111)
159 }
160 #[doc = r"Writes raw bits to the field"]
161 #[inline(always)]
162 pub fn bits(self, value: u8) -> &'a mut W {
163 self.w.bits = (self.w.bits & !0x07) | ((value as u32) & 0x07);
164 self.w
165 }
166}
167#[doc = "Possible values of the field `CMOD`"]
168#[derive(Clone, Copy, Debug, PartialEq)]
169pub enum CMOD_A {
170 #[doc = "TPM counter is disabled"]
171 _00,
172 #[doc = "TPM counter increments on every TPM counter clock"]
173 _01,
174 #[doc = "TPM counter increments on rising edge of TPM_EXTCLK synchronized to the TPM counter clock"]
175 _10,
176}
177impl crate::ToBits<u8> for CMOD_A {
178 #[inline(always)]
179 fn _bits(&self) -> u8 {
180 match *self {
181 CMOD_A::_00 => 0,
182 CMOD_A::_01 => 1,
183 CMOD_A::_10 => 2,
184 }
185 }
186}
187#[doc = "Reader of field `CMOD`"]
188pub type CMOD_R = crate::R<u8, CMOD_A>;
189impl CMOD_R {
190 #[doc = r"Get enumerated values variant"]
191 #[inline(always)]
192 pub fn variant(&self) -> crate::Variant<u8, CMOD_A> {
193 use crate::Variant::*;
194 match self.bits {
195 0 => Val(CMOD_A::_00),
196 1 => Val(CMOD_A::_01),
197 2 => Val(CMOD_A::_10),
198 i => Res(i),
199 }
200 }
201 #[doc = "Checks if the value of the field is `_00`"]
202 #[inline(always)]
203 pub fn is_00(&self) -> bool {
204 *self == CMOD_A::_00
205 }
206 #[doc = "Checks if the value of the field is `_01`"]
207 #[inline(always)]
208 pub fn is_01(&self) -> bool {
209 *self == CMOD_A::_01
210 }
211 #[doc = "Checks if the value of the field is `_10`"]
212 #[inline(always)]
213 pub fn is_10(&self) -> bool {
214 *self == CMOD_A::_10
215 }
216}
217#[doc = "Write proxy for field `CMOD`"]
218pub struct CMOD_W<'a> {
219 w: &'a mut W,
220}
221impl<'a> CMOD_W<'a> {
222 #[doc = r"Writes `variant` to the field"]
223 #[inline(always)]
224 pub fn variant(self, variant: CMOD_A) -> &'a mut W {
225 use crate::ToBits;
226 unsafe { self.bits(variant._bits()) }
227 }
228 #[doc = "TPM counter is disabled"]
229 #[inline(always)]
230 pub fn _00(self) -> &'a mut W {
231 self.variant(CMOD_A::_00)
232 }
233 #[doc = "TPM counter increments on every TPM counter clock"]
234 #[inline(always)]
235 pub fn _01(self) -> &'a mut W {
236 self.variant(CMOD_A::_01)
237 }
238 #[doc = "TPM counter increments on rising edge of TPM_EXTCLK synchronized to the TPM counter clock"]
239 #[inline(always)]
240 pub fn _10(self) -> &'a mut W {
241 self.variant(CMOD_A::_10)
242 }
243 #[doc = r"Writes raw bits to the field"]
244 #[inline(always)]
245 pub unsafe fn bits(self, value: u8) -> &'a mut W {
246 self.w.bits = (self.w.bits & !(0x03 << 3)) | (((value as u32) & 0x03) << 3);
247 self.w
248 }
249}
250#[doc = "Possible values of the field `CPWMS`"]
251#[derive(Clone, Copy, Debug, PartialEq)]
252pub enum CPWMS_A {
253 #[doc = "TPM counter operates in up counting mode."]
254 _0,
255 #[doc = "TPM counter operates in up-down counting mode."]
256 _1,
257}
258impl crate::ToBits<bool> for CPWMS_A {
259 #[inline(always)]
260 fn _bits(&self) -> bool {
261 match *self {
262 CPWMS_A::_0 => false,
263 CPWMS_A::_1 => true,
264 }
265 }
266}
267#[doc = "Reader of field `CPWMS`"]
268pub type CPWMS_R = crate::R<bool, CPWMS_A>;
269impl CPWMS_R {
270 #[doc = r"Get enumerated values variant"]
271 #[inline(always)]
272 pub fn variant(&self) -> CPWMS_A {
273 match self.bits {
274 false => CPWMS_A::_0,
275 true => CPWMS_A::_1,
276 }
277 }
278 #[doc = "Checks if the value of the field is `_0`"]
279 #[inline(always)]
280 pub fn is_0(&self) -> bool {
281 *self == CPWMS_A::_0
282 }
283 #[doc = "Checks if the value of the field is `_1`"]
284 #[inline(always)]
285 pub fn is_1(&self) -> bool {
286 *self == CPWMS_A::_1
287 }
288}
289#[doc = "Write proxy for field `CPWMS`"]
290pub struct CPWMS_W<'a> {
291 w: &'a mut W,
292}
293impl<'a> CPWMS_W<'a> {
294 #[doc = r"Writes `variant` to the field"]
295 #[inline(always)]
296 pub fn variant(self, variant: CPWMS_A) -> &'a mut W {
297 use crate::ToBits;
298 {
299 self.bit(variant._bits())
300 }
301 }
302 #[doc = "TPM counter operates in up counting mode."]
303 #[inline(always)]
304 pub fn _0(self) -> &'a mut W {
305 self.variant(CPWMS_A::_0)
306 }
307 #[doc = "TPM counter operates in up-down counting mode."]
308 #[inline(always)]
309 pub fn _1(self) -> &'a mut W {
310 self.variant(CPWMS_A::_1)
311 }
312 #[doc = r"Sets the field bit"]
313 #[inline(always)]
314 pub fn set_bit(self) -> &'a mut W {
315 self.bit(true)
316 }
317 #[doc = r"Clears the field bit"]
318 #[inline(always)]
319 pub fn clear_bit(self) -> &'a mut W {
320 self.bit(false)
321 }
322 #[doc = r"Writes raw bits to the field"]
323 #[inline(always)]
324 pub fn bit(self, value: bool) -> &'a mut W {
325 self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u32) & 0x01) << 5);
326 self.w
327 }
328}
329#[doc = "Possible values of the field `TOIE`"]
330#[derive(Clone, Copy, Debug, PartialEq)]
331pub enum TOIE_A {
332 #[doc = "Disable TOF interrupts. Use software polling or DMA request."]
333 _0,
334 #[doc = "Enable TOF interrupts. An interrupt is generated when TOF equals one."]
335 _1,
336}
337impl crate::ToBits<bool> for TOIE_A {
338 #[inline(always)]
339 fn _bits(&self) -> bool {
340 match *self {
341 TOIE_A::_0 => false,
342 TOIE_A::_1 => true,
343 }
344 }
345}
346#[doc = "Reader of field `TOIE`"]
347pub type TOIE_R = crate::R<bool, TOIE_A>;
348impl TOIE_R {
349 #[doc = r"Get enumerated values variant"]
350 #[inline(always)]
351 pub fn variant(&self) -> TOIE_A {
352 match self.bits {
353 false => TOIE_A::_0,
354 true => TOIE_A::_1,
355 }
356 }
357 #[doc = "Checks if the value of the field is `_0`"]
358 #[inline(always)]
359 pub fn is_0(&self) -> bool {
360 *self == TOIE_A::_0
361 }
362 #[doc = "Checks if the value of the field is `_1`"]
363 #[inline(always)]
364 pub fn is_1(&self) -> bool {
365 *self == TOIE_A::_1
366 }
367}
368#[doc = "Write proxy for field `TOIE`"]
369pub struct TOIE_W<'a> {
370 w: &'a mut W,
371}
372impl<'a> TOIE_W<'a> {
373 #[doc = r"Writes `variant` to the field"]
374 #[inline(always)]
375 pub fn variant(self, variant: TOIE_A) -> &'a mut W {
376 use crate::ToBits;
377 {
378 self.bit(variant._bits())
379 }
380 }
381 #[doc = "Disable TOF interrupts. Use software polling or DMA request."]
382 #[inline(always)]
383 pub fn _0(self) -> &'a mut W {
384 self.variant(TOIE_A::_0)
385 }
386 #[doc = "Enable TOF interrupts. An interrupt is generated when TOF equals one."]
387 #[inline(always)]
388 pub fn _1(self) -> &'a mut W {
389 self.variant(TOIE_A::_1)
390 }
391 #[doc = r"Sets the field bit"]
392 #[inline(always)]
393 pub fn set_bit(self) -> &'a mut W {
394 self.bit(true)
395 }
396 #[doc = r"Clears the field bit"]
397 #[inline(always)]
398 pub fn clear_bit(self) -> &'a mut W {
399 self.bit(false)
400 }
401 #[doc = r"Writes raw bits to the field"]
402 #[inline(always)]
403 pub fn bit(self, value: bool) -> &'a mut W {
404 self.w.bits = (self.w.bits & !(0x01 << 6)) | (((value as u32) & 0x01) << 6);
405 self.w
406 }
407}
408#[doc = "Possible values of the field `TOF`"]
409#[derive(Clone, Copy, Debug, PartialEq)]
410pub enum TOF_A {
411 #[doc = "TPM counter has not overflowed."]
412 _0,
413 #[doc = "TPM counter has overflowed."]
414 _1,
415}
416impl crate::ToBits<bool> for TOF_A {
417 #[inline(always)]
418 fn _bits(&self) -> bool {
419 match *self {
420 TOF_A::_0 => false,
421 TOF_A::_1 => true,
422 }
423 }
424}
425#[doc = "Reader of field `TOF`"]
426pub type TOF_R = crate::R<bool, TOF_A>;
427impl TOF_R {
428 #[doc = r"Get enumerated values variant"]
429 #[inline(always)]
430 pub fn variant(&self) -> TOF_A {
431 match self.bits {
432 false => TOF_A::_0,
433 true => TOF_A::_1,
434 }
435 }
436 #[doc = "Checks if the value of the field is `_0`"]
437 #[inline(always)]
438 pub fn is_0(&self) -> bool {
439 *self == TOF_A::_0
440 }
441 #[doc = "Checks if the value of the field is `_1`"]
442 #[inline(always)]
443 pub fn is_1(&self) -> bool {
444 *self == TOF_A::_1
445 }
446}
447#[doc = "Write proxy for field `TOF`"]
448pub struct TOF_W<'a> {
449 w: &'a mut W,
450}
451impl<'a> TOF_W<'a> {
452 #[doc = r"Writes `variant` to the field"]
453 #[inline(always)]
454 pub fn variant(self, variant: TOF_A) -> &'a mut W {
455 use crate::ToBits;
456 {
457 self.bit(variant._bits())
458 }
459 }
460 #[doc = "TPM counter has not overflowed."]
461 #[inline(always)]
462 pub fn _0(self) -> &'a mut W {
463 self.variant(TOF_A::_0)
464 }
465 #[doc = "TPM counter has overflowed."]
466 #[inline(always)]
467 pub fn _1(self) -> &'a mut W {
468 self.variant(TOF_A::_1)
469 }
470 #[doc = r"Sets the field bit"]
471 #[inline(always)]
472 pub fn set_bit(self) -> &'a mut W {
473 self.bit(true)
474 }
475 #[doc = r"Clears the field bit"]
476 #[inline(always)]
477 pub fn clear_bit(self) -> &'a mut W {
478 self.bit(false)
479 }
480 #[doc = r"Writes raw bits to the field"]
481 #[inline(always)]
482 pub fn bit(self, value: bool) -> &'a mut W {
483 self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u32) & 0x01) << 7);
484 self.w
485 }
486}
487#[doc = "Possible values of the field `DMA`"]
488#[derive(Clone, Copy, Debug, PartialEq)]
489pub enum DMA_A {
490 #[doc = "Disables DMA transfers."]
491 _0,
492 #[doc = "Enables DMA transfers."]
493 _1,
494}
495impl crate::ToBits<bool> for DMA_A {
496 #[inline(always)]
497 fn _bits(&self) -> bool {
498 match *self {
499 DMA_A::_0 => false,
500 DMA_A::_1 => true,
501 }
502 }
503}
504#[doc = "Reader of field `DMA`"]
505pub type DMA_R = crate::R<bool, DMA_A>;
506impl DMA_R {
507 #[doc = r"Get enumerated values variant"]
508 #[inline(always)]
509 pub fn variant(&self) -> DMA_A {
510 match self.bits {
511 false => DMA_A::_0,
512 true => DMA_A::_1,
513 }
514 }
515 #[doc = "Checks if the value of the field is `_0`"]
516 #[inline(always)]
517 pub fn is_0(&self) -> bool {
518 *self == DMA_A::_0
519 }
520 #[doc = "Checks if the value of the field is `_1`"]
521 #[inline(always)]
522 pub fn is_1(&self) -> bool {
523 *self == DMA_A::_1
524 }
525}
526#[doc = "Write proxy for field `DMA`"]
527pub struct DMA_W<'a> {
528 w: &'a mut W,
529}
530impl<'a> DMA_W<'a> {
531 #[doc = r"Writes `variant` to the field"]
532 #[inline(always)]
533 pub fn variant(self, variant: DMA_A) -> &'a mut W {
534 use crate::ToBits;
535 {
536 self.bit(variant._bits())
537 }
538 }
539 #[doc = "Disables DMA transfers."]
540 #[inline(always)]
541 pub fn _0(self) -> &'a mut W {
542 self.variant(DMA_A::_0)
543 }
544 #[doc = "Enables DMA transfers."]
545 #[inline(always)]
546 pub fn _1(self) -> &'a mut W {
547 self.variant(DMA_A::_1)
548 }
549 #[doc = r"Sets the field bit"]
550 #[inline(always)]
551 pub fn set_bit(self) -> &'a mut W {
552 self.bit(true)
553 }
554 #[doc = r"Clears the field bit"]
555 #[inline(always)]
556 pub fn clear_bit(self) -> &'a mut W {
557 self.bit(false)
558 }
559 #[doc = r"Writes raw bits to the field"]
560 #[inline(always)]
561 pub fn bit(self, value: bool) -> &'a mut W {
562 self.w.bits = (self.w.bits & !(0x01 << 8)) | (((value as u32) & 0x01) << 8);
563 self.w
564 }
565}
566impl R {
567 #[doc = "Bits 0:2 - Prescale Factor Selection"]
568 #[inline(always)]
569 pub fn ps(&self) -> PS_R {
570 PS_R::new((self.bits & 0x07) as u8)
571 }
572 #[doc = "Bits 3:4 - Clock Mode Selection"]
573 #[inline(always)]
574 pub fn cmod(&self) -> CMOD_R {
575 CMOD_R::new(((self.bits >> 3) & 0x03) as u8)
576 }
577 #[doc = "Bit 5 - Center-Aligned PWM Select"]
578 #[inline(always)]
579 pub fn cpwms(&self) -> CPWMS_R {
580 CPWMS_R::new(((self.bits >> 5) & 0x01) != 0)
581 }
582 #[doc = "Bit 6 - Timer Overflow Interrupt Enable"]
583 #[inline(always)]
584 pub fn toie(&self) -> TOIE_R {
585 TOIE_R::new(((self.bits >> 6) & 0x01) != 0)
586 }
587 #[doc = "Bit 7 - Timer Overflow Flag"]
588 #[inline(always)]
589 pub fn tof(&self) -> TOF_R {
590 TOF_R::new(((self.bits >> 7) & 0x01) != 0)
591 }
592 #[doc = "Bit 8 - DMA Enable"]
593 #[inline(always)]
594 pub fn dma(&self) -> DMA_R {
595 DMA_R::new(((self.bits >> 8) & 0x01) != 0)
596 }
597}
598impl W {
599 #[doc = "Bits 0:2 - Prescale Factor Selection"]
600 #[inline(always)]
601 pub fn ps(&mut self) -> PS_W {
602 PS_W { w: self }
603 }
604 #[doc = "Bits 3:4 - Clock Mode Selection"]
605 #[inline(always)]
606 pub fn cmod(&mut self) -> CMOD_W {
607 CMOD_W { w: self }
608 }
609 #[doc = "Bit 5 - Center-Aligned PWM Select"]
610 #[inline(always)]
611 pub fn cpwms(&mut self) -> CPWMS_W {
612 CPWMS_W { w: self }
613 }
614 #[doc = "Bit 6 - Timer Overflow Interrupt Enable"]
615 #[inline(always)]
616 pub fn toie(&mut self) -> TOIE_W {
617 TOIE_W { w: self }
618 }
619 #[doc = "Bit 7 - Timer Overflow Flag"]
620 #[inline(always)]
621 pub fn tof(&mut self) -> TOF_W {
622 TOF_W { w: self }
623 }
624 #[doc = "Bit 8 - DMA Enable"]
625 #[inline(always)]
626 pub fn dma(&mut self) -> DMA_W {
627 DMA_W { w: self }
628 }
629}