s32k118_pac/flexio/
timctl1.rs1#[doc = "Register `TIMCTL1` reader"]
2pub struct R(crate::R<TIMCTL1_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<TIMCTL1_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<TIMCTL1_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<TIMCTL1_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `TIMCTL1` writer"]
17pub struct W(crate::W<TIMCTL1_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<TIMCTL1_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<TIMCTL1_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<TIMCTL1_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Timer Mode\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum TIMOD_A {
41 #[doc = "0: Timer Disabled."]
42 _0 = 0,
43 #[doc = "1: Dual 8-bit counters baud/bit mode."]
44 _1 = 1,
45 #[doc = "2: Dual 8-bit counters PWM mode."]
46 _10 = 2,
47 #[doc = "3: Single 16-bit counter mode."]
48 _11 = 3,
49}
50impl From<TIMOD_A> for u8 {
51 #[inline(always)]
52 fn from(variant: TIMOD_A) -> Self {
53 variant as _
54 }
55}
56#[doc = "Field `TIMOD` reader - Timer Mode"]
57pub struct TIMOD_R(crate::FieldReader<u8, TIMOD_A>);
58impl TIMOD_R {
59 #[inline(always)]
60 pub(crate) fn new(bits: u8) -> Self {
61 TIMOD_R(crate::FieldReader::new(bits))
62 }
63 #[doc = r"Get enumerated values variant"]
64 #[inline(always)]
65 pub fn variant(&self) -> TIMOD_A {
66 match self.bits {
67 0 => TIMOD_A::_0,
68 1 => TIMOD_A::_1,
69 2 => TIMOD_A::_10,
70 3 => TIMOD_A::_11,
71 _ => unreachable!(),
72 }
73 }
74 #[doc = "Checks if the value of the field is `_0`"]
75 #[inline(always)]
76 pub fn is_0(&self) -> bool {
77 **self == TIMOD_A::_0
78 }
79 #[doc = "Checks if the value of the field is `_1`"]
80 #[inline(always)]
81 pub fn is_1(&self) -> bool {
82 **self == TIMOD_A::_1
83 }
84 #[doc = "Checks if the value of the field is `_10`"]
85 #[inline(always)]
86 pub fn is_10(&self) -> bool {
87 **self == TIMOD_A::_10
88 }
89 #[doc = "Checks if the value of the field is `_11`"]
90 #[inline(always)]
91 pub fn is_11(&self) -> bool {
92 **self == TIMOD_A::_11
93 }
94}
95impl core::ops::Deref for TIMOD_R {
96 type Target = crate::FieldReader<u8, TIMOD_A>;
97 #[inline(always)]
98 fn deref(&self) -> &Self::Target {
99 &self.0
100 }
101}
102#[doc = "Field `TIMOD` writer - Timer Mode"]
103pub struct TIMOD_W<'a> {
104 w: &'a mut W,
105}
106impl<'a> TIMOD_W<'a> {
107 #[doc = r"Writes `variant` to the field"]
108 #[inline(always)]
109 pub fn variant(self, variant: TIMOD_A) -> &'a mut W {
110 self.bits(variant.into())
111 }
112 #[doc = "Timer Disabled."]
113 #[inline(always)]
114 pub fn _0(self) -> &'a mut W {
115 self.variant(TIMOD_A::_0)
116 }
117 #[doc = "Dual 8-bit counters baud/bit mode."]
118 #[inline(always)]
119 pub fn _1(self) -> &'a mut W {
120 self.variant(TIMOD_A::_1)
121 }
122 #[doc = "Dual 8-bit counters PWM mode."]
123 #[inline(always)]
124 pub fn _10(self) -> &'a mut W {
125 self.variant(TIMOD_A::_10)
126 }
127 #[doc = "Single 16-bit counter mode."]
128 #[inline(always)]
129 pub fn _11(self) -> &'a mut W {
130 self.variant(TIMOD_A::_11)
131 }
132 #[doc = r"Writes raw bits to the field"]
133 #[inline(always)]
134 pub fn bits(self, value: u8) -> &'a mut W {
135 self.w.bits = (self.w.bits & !0x03) | (value as u32 & 0x03);
136 self.w
137 }
138}
139#[doc = "Timer Pin Polarity\n\nValue on reset: 0"]
140#[derive(Clone, Copy, Debug, PartialEq)]
141pub enum PINPOL_A {
142 #[doc = "0: Pin is active high"]
143 _0 = 0,
144 #[doc = "1: Pin is active low"]
145 _1 = 1,
146}
147impl From<PINPOL_A> for bool {
148 #[inline(always)]
149 fn from(variant: PINPOL_A) -> Self {
150 variant as u8 != 0
151 }
152}
153#[doc = "Field `PINPOL` reader - Timer Pin Polarity"]
154pub struct PINPOL_R(crate::FieldReader<bool, PINPOL_A>);
155impl PINPOL_R {
156 #[inline(always)]
157 pub(crate) fn new(bits: bool) -> Self {
158 PINPOL_R(crate::FieldReader::new(bits))
159 }
160 #[doc = r"Get enumerated values variant"]
161 #[inline(always)]
162 pub fn variant(&self) -> PINPOL_A {
163 match self.bits {
164 false => PINPOL_A::_0,
165 true => PINPOL_A::_1,
166 }
167 }
168 #[doc = "Checks if the value of the field is `_0`"]
169 #[inline(always)]
170 pub fn is_0(&self) -> bool {
171 **self == PINPOL_A::_0
172 }
173 #[doc = "Checks if the value of the field is `_1`"]
174 #[inline(always)]
175 pub fn is_1(&self) -> bool {
176 **self == PINPOL_A::_1
177 }
178}
179impl core::ops::Deref for PINPOL_R {
180 type Target = crate::FieldReader<bool, PINPOL_A>;
181 #[inline(always)]
182 fn deref(&self) -> &Self::Target {
183 &self.0
184 }
185}
186#[doc = "Field `PINPOL` writer - Timer Pin Polarity"]
187pub struct PINPOL_W<'a> {
188 w: &'a mut W,
189}
190impl<'a> PINPOL_W<'a> {
191 #[doc = r"Writes `variant` to the field"]
192 #[inline(always)]
193 pub fn variant(self, variant: PINPOL_A) -> &'a mut W {
194 self.bit(variant.into())
195 }
196 #[doc = "Pin is active high"]
197 #[inline(always)]
198 pub fn _0(self) -> &'a mut W {
199 self.variant(PINPOL_A::_0)
200 }
201 #[doc = "Pin is active low"]
202 #[inline(always)]
203 pub fn _1(self) -> &'a mut W {
204 self.variant(PINPOL_A::_1)
205 }
206 #[doc = r"Sets the field bit"]
207 #[inline(always)]
208 pub fn set_bit(self) -> &'a mut W {
209 self.bit(true)
210 }
211 #[doc = r"Clears the field bit"]
212 #[inline(always)]
213 pub fn clear_bit(self) -> &'a mut W {
214 self.bit(false)
215 }
216 #[doc = r"Writes raw bits to the field"]
217 #[inline(always)]
218 pub fn bit(self, value: bool) -> &'a mut W {
219 self.w.bits = (self.w.bits & !(0x01 << 7)) | ((value as u32 & 0x01) << 7);
220 self.w
221 }
222}
223#[doc = "Field `PINSEL` reader - Timer Pin Select"]
224pub struct PINSEL_R(crate::FieldReader<u8, u8>);
225impl PINSEL_R {
226 #[inline(always)]
227 pub(crate) fn new(bits: u8) -> Self {
228 PINSEL_R(crate::FieldReader::new(bits))
229 }
230}
231impl core::ops::Deref for PINSEL_R {
232 type Target = crate::FieldReader<u8, u8>;
233 #[inline(always)]
234 fn deref(&self) -> &Self::Target {
235 &self.0
236 }
237}
238#[doc = "Field `PINSEL` writer - Timer Pin Select"]
239pub struct PINSEL_W<'a> {
240 w: &'a mut W,
241}
242impl<'a> PINSEL_W<'a> {
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 & !(0x07 << 8)) | ((value as u32 & 0x07) << 8);
247 self.w
248 }
249}
250#[doc = "Timer Pin Configuration\n\nValue on reset: 0"]
251#[derive(Clone, Copy, Debug, PartialEq)]
252#[repr(u8)]
253pub enum PINCFG_A {
254 #[doc = "0: Timer pin output disabled"]
255 _0 = 0,
256 #[doc = "1: Timer pin open drain or bidirectional output enable"]
257 _1 = 1,
258 #[doc = "2: Timer pin bidirectional output data"]
259 _10 = 2,
260 #[doc = "3: Timer pin output"]
261 _11 = 3,
262}
263impl From<PINCFG_A> for u8 {
264 #[inline(always)]
265 fn from(variant: PINCFG_A) -> Self {
266 variant as _
267 }
268}
269#[doc = "Field `PINCFG` reader - Timer Pin Configuration"]
270pub struct PINCFG_R(crate::FieldReader<u8, PINCFG_A>);
271impl PINCFG_R {
272 #[inline(always)]
273 pub(crate) fn new(bits: u8) -> Self {
274 PINCFG_R(crate::FieldReader::new(bits))
275 }
276 #[doc = r"Get enumerated values variant"]
277 #[inline(always)]
278 pub fn variant(&self) -> PINCFG_A {
279 match self.bits {
280 0 => PINCFG_A::_0,
281 1 => PINCFG_A::_1,
282 2 => PINCFG_A::_10,
283 3 => PINCFG_A::_11,
284 _ => unreachable!(),
285 }
286 }
287 #[doc = "Checks if the value of the field is `_0`"]
288 #[inline(always)]
289 pub fn is_0(&self) -> bool {
290 **self == PINCFG_A::_0
291 }
292 #[doc = "Checks if the value of the field is `_1`"]
293 #[inline(always)]
294 pub fn is_1(&self) -> bool {
295 **self == PINCFG_A::_1
296 }
297 #[doc = "Checks if the value of the field is `_10`"]
298 #[inline(always)]
299 pub fn is_10(&self) -> bool {
300 **self == PINCFG_A::_10
301 }
302 #[doc = "Checks if the value of the field is `_11`"]
303 #[inline(always)]
304 pub fn is_11(&self) -> bool {
305 **self == PINCFG_A::_11
306 }
307}
308impl core::ops::Deref for PINCFG_R {
309 type Target = crate::FieldReader<u8, PINCFG_A>;
310 #[inline(always)]
311 fn deref(&self) -> &Self::Target {
312 &self.0
313 }
314}
315#[doc = "Field `PINCFG` writer - Timer Pin Configuration"]
316pub struct PINCFG_W<'a> {
317 w: &'a mut W,
318}
319impl<'a> PINCFG_W<'a> {
320 #[doc = r"Writes `variant` to the field"]
321 #[inline(always)]
322 pub fn variant(self, variant: PINCFG_A) -> &'a mut W {
323 self.bits(variant.into())
324 }
325 #[doc = "Timer pin output disabled"]
326 #[inline(always)]
327 pub fn _0(self) -> &'a mut W {
328 self.variant(PINCFG_A::_0)
329 }
330 #[doc = "Timer pin open drain or bidirectional output enable"]
331 #[inline(always)]
332 pub fn _1(self) -> &'a mut W {
333 self.variant(PINCFG_A::_1)
334 }
335 #[doc = "Timer pin bidirectional output data"]
336 #[inline(always)]
337 pub fn _10(self) -> &'a mut W {
338 self.variant(PINCFG_A::_10)
339 }
340 #[doc = "Timer pin output"]
341 #[inline(always)]
342 pub fn _11(self) -> &'a mut W {
343 self.variant(PINCFG_A::_11)
344 }
345 #[doc = r"Writes raw bits to the field"]
346 #[inline(always)]
347 pub fn bits(self, value: u8) -> &'a mut W {
348 self.w.bits = (self.w.bits & !(0x03 << 16)) | ((value as u32 & 0x03) << 16);
349 self.w
350 }
351}
352#[doc = "Trigger Source\n\nValue on reset: 0"]
353#[derive(Clone, Copy, Debug, PartialEq)]
354pub enum TRGSRC_A {
355 #[doc = "0: External trigger selected"]
356 _0 = 0,
357 #[doc = "1: Internal trigger selected"]
358 _1 = 1,
359}
360impl From<TRGSRC_A> for bool {
361 #[inline(always)]
362 fn from(variant: TRGSRC_A) -> Self {
363 variant as u8 != 0
364 }
365}
366#[doc = "Field `TRGSRC` reader - Trigger Source"]
367pub struct TRGSRC_R(crate::FieldReader<bool, TRGSRC_A>);
368impl TRGSRC_R {
369 #[inline(always)]
370 pub(crate) fn new(bits: bool) -> Self {
371 TRGSRC_R(crate::FieldReader::new(bits))
372 }
373 #[doc = r"Get enumerated values variant"]
374 #[inline(always)]
375 pub fn variant(&self) -> TRGSRC_A {
376 match self.bits {
377 false => TRGSRC_A::_0,
378 true => TRGSRC_A::_1,
379 }
380 }
381 #[doc = "Checks if the value of the field is `_0`"]
382 #[inline(always)]
383 pub fn is_0(&self) -> bool {
384 **self == TRGSRC_A::_0
385 }
386 #[doc = "Checks if the value of the field is `_1`"]
387 #[inline(always)]
388 pub fn is_1(&self) -> bool {
389 **self == TRGSRC_A::_1
390 }
391}
392impl core::ops::Deref for TRGSRC_R {
393 type Target = crate::FieldReader<bool, TRGSRC_A>;
394 #[inline(always)]
395 fn deref(&self) -> &Self::Target {
396 &self.0
397 }
398}
399#[doc = "Field `TRGSRC` writer - Trigger Source"]
400pub struct TRGSRC_W<'a> {
401 w: &'a mut W,
402}
403impl<'a> TRGSRC_W<'a> {
404 #[doc = r"Writes `variant` to the field"]
405 #[inline(always)]
406 pub fn variant(self, variant: TRGSRC_A) -> &'a mut W {
407 self.bit(variant.into())
408 }
409 #[doc = "External trigger selected"]
410 #[inline(always)]
411 pub fn _0(self) -> &'a mut W {
412 self.variant(TRGSRC_A::_0)
413 }
414 #[doc = "Internal trigger selected"]
415 #[inline(always)]
416 pub fn _1(self) -> &'a mut W {
417 self.variant(TRGSRC_A::_1)
418 }
419 #[doc = r"Sets the field bit"]
420 #[inline(always)]
421 pub fn set_bit(self) -> &'a mut W {
422 self.bit(true)
423 }
424 #[doc = r"Clears the field bit"]
425 #[inline(always)]
426 pub fn clear_bit(self) -> &'a mut W {
427 self.bit(false)
428 }
429 #[doc = r"Writes raw bits to the field"]
430 #[inline(always)]
431 pub fn bit(self, value: bool) -> &'a mut W {
432 self.w.bits = (self.w.bits & !(0x01 << 22)) | ((value as u32 & 0x01) << 22);
433 self.w
434 }
435}
436#[doc = "Trigger Polarity\n\nValue on reset: 0"]
437#[derive(Clone, Copy, Debug, PartialEq)]
438pub enum TRGPOL_A {
439 #[doc = "0: Trigger active high"]
440 _0 = 0,
441 #[doc = "1: Trigger active low"]
442 _1 = 1,
443}
444impl From<TRGPOL_A> for bool {
445 #[inline(always)]
446 fn from(variant: TRGPOL_A) -> Self {
447 variant as u8 != 0
448 }
449}
450#[doc = "Field `TRGPOL` reader - Trigger Polarity"]
451pub struct TRGPOL_R(crate::FieldReader<bool, TRGPOL_A>);
452impl TRGPOL_R {
453 #[inline(always)]
454 pub(crate) fn new(bits: bool) -> Self {
455 TRGPOL_R(crate::FieldReader::new(bits))
456 }
457 #[doc = r"Get enumerated values variant"]
458 #[inline(always)]
459 pub fn variant(&self) -> TRGPOL_A {
460 match self.bits {
461 false => TRGPOL_A::_0,
462 true => TRGPOL_A::_1,
463 }
464 }
465 #[doc = "Checks if the value of the field is `_0`"]
466 #[inline(always)]
467 pub fn is_0(&self) -> bool {
468 **self == TRGPOL_A::_0
469 }
470 #[doc = "Checks if the value of the field is `_1`"]
471 #[inline(always)]
472 pub fn is_1(&self) -> bool {
473 **self == TRGPOL_A::_1
474 }
475}
476impl core::ops::Deref for TRGPOL_R {
477 type Target = crate::FieldReader<bool, TRGPOL_A>;
478 #[inline(always)]
479 fn deref(&self) -> &Self::Target {
480 &self.0
481 }
482}
483#[doc = "Field `TRGPOL` writer - Trigger Polarity"]
484pub struct TRGPOL_W<'a> {
485 w: &'a mut W,
486}
487impl<'a> TRGPOL_W<'a> {
488 #[doc = r"Writes `variant` to the field"]
489 #[inline(always)]
490 pub fn variant(self, variant: TRGPOL_A) -> &'a mut W {
491 self.bit(variant.into())
492 }
493 #[doc = "Trigger active high"]
494 #[inline(always)]
495 pub fn _0(self) -> &'a mut W {
496 self.variant(TRGPOL_A::_0)
497 }
498 #[doc = "Trigger active low"]
499 #[inline(always)]
500 pub fn _1(self) -> &'a mut W {
501 self.variant(TRGPOL_A::_1)
502 }
503 #[doc = r"Sets the field bit"]
504 #[inline(always)]
505 pub fn set_bit(self) -> &'a mut W {
506 self.bit(true)
507 }
508 #[doc = r"Clears the field bit"]
509 #[inline(always)]
510 pub fn clear_bit(self) -> &'a mut W {
511 self.bit(false)
512 }
513 #[doc = r"Writes raw bits to the field"]
514 #[inline(always)]
515 pub fn bit(self, value: bool) -> &'a mut W {
516 self.w.bits = (self.w.bits & !(0x01 << 23)) | ((value as u32 & 0x01) << 23);
517 self.w
518 }
519}
520#[doc = "Field `TRGSEL` reader - Trigger Select"]
521pub struct TRGSEL_R(crate::FieldReader<u8, u8>);
522impl TRGSEL_R {
523 #[inline(always)]
524 pub(crate) fn new(bits: u8) -> Self {
525 TRGSEL_R(crate::FieldReader::new(bits))
526 }
527}
528impl core::ops::Deref for TRGSEL_R {
529 type Target = crate::FieldReader<u8, u8>;
530 #[inline(always)]
531 fn deref(&self) -> &Self::Target {
532 &self.0
533 }
534}
535#[doc = "Field `TRGSEL` writer - Trigger Select"]
536pub struct TRGSEL_W<'a> {
537 w: &'a mut W,
538}
539impl<'a> TRGSEL_W<'a> {
540 #[doc = r"Writes raw bits to the field"]
541 #[inline(always)]
542 pub unsafe fn bits(self, value: u8) -> &'a mut W {
543 self.w.bits = (self.w.bits & !(0x0f << 24)) | ((value as u32 & 0x0f) << 24);
544 self.w
545 }
546}
547impl R {
548 #[doc = "Bits 0:1 - Timer Mode"]
549 #[inline(always)]
550 pub fn timod(&self) -> TIMOD_R {
551 TIMOD_R::new((self.bits & 0x03) as u8)
552 }
553 #[doc = "Bit 7 - Timer Pin Polarity"]
554 #[inline(always)]
555 pub fn pinpol(&self) -> PINPOL_R {
556 PINPOL_R::new(((self.bits >> 7) & 0x01) != 0)
557 }
558 #[doc = "Bits 8:10 - Timer Pin Select"]
559 #[inline(always)]
560 pub fn pinsel(&self) -> PINSEL_R {
561 PINSEL_R::new(((self.bits >> 8) & 0x07) as u8)
562 }
563 #[doc = "Bits 16:17 - Timer Pin Configuration"]
564 #[inline(always)]
565 pub fn pincfg(&self) -> PINCFG_R {
566 PINCFG_R::new(((self.bits >> 16) & 0x03) as u8)
567 }
568 #[doc = "Bit 22 - Trigger Source"]
569 #[inline(always)]
570 pub fn trgsrc(&self) -> TRGSRC_R {
571 TRGSRC_R::new(((self.bits >> 22) & 0x01) != 0)
572 }
573 #[doc = "Bit 23 - Trigger Polarity"]
574 #[inline(always)]
575 pub fn trgpol(&self) -> TRGPOL_R {
576 TRGPOL_R::new(((self.bits >> 23) & 0x01) != 0)
577 }
578 #[doc = "Bits 24:27 - Trigger Select"]
579 #[inline(always)]
580 pub fn trgsel(&self) -> TRGSEL_R {
581 TRGSEL_R::new(((self.bits >> 24) & 0x0f) as u8)
582 }
583}
584impl W {
585 #[doc = "Bits 0:1 - Timer Mode"]
586 #[inline(always)]
587 pub fn timod(&mut self) -> TIMOD_W {
588 TIMOD_W { w: self }
589 }
590 #[doc = "Bit 7 - Timer Pin Polarity"]
591 #[inline(always)]
592 pub fn pinpol(&mut self) -> PINPOL_W {
593 PINPOL_W { w: self }
594 }
595 #[doc = "Bits 8:10 - Timer Pin Select"]
596 #[inline(always)]
597 pub fn pinsel(&mut self) -> PINSEL_W {
598 PINSEL_W { w: self }
599 }
600 #[doc = "Bits 16:17 - Timer Pin Configuration"]
601 #[inline(always)]
602 pub fn pincfg(&mut self) -> PINCFG_W {
603 PINCFG_W { w: self }
604 }
605 #[doc = "Bit 22 - Trigger Source"]
606 #[inline(always)]
607 pub fn trgsrc(&mut self) -> TRGSRC_W {
608 TRGSRC_W { w: self }
609 }
610 #[doc = "Bit 23 - Trigger Polarity"]
611 #[inline(always)]
612 pub fn trgpol(&mut self) -> TRGPOL_W {
613 TRGPOL_W { w: self }
614 }
615 #[doc = "Bits 24:27 - Trigger Select"]
616 #[inline(always)]
617 pub fn trgsel(&mut self) -> TRGSEL_W {
618 TRGSEL_W { w: self }
619 }
620 #[doc = "Writes raw bits to the register."]
621 #[inline(always)]
622 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
623 self.0.bits(bits);
624 self
625 }
626}
627#[doc = "Timer Control N 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 [timctl1](index.html) module"]
628pub struct TIMCTL1_SPEC;
629impl crate::RegisterSpec for TIMCTL1_SPEC {
630 type Ux = u32;
631}
632#[doc = "`read()` method returns [timctl1::R](R) reader structure"]
633impl crate::Readable for TIMCTL1_SPEC {
634 type Reader = R;
635}
636#[doc = "`write(|w| ..)` method takes [timctl1::W](W) writer structure"]
637impl crate::Writable for TIMCTL1_SPEC {
638 type Writer = W;
639}
640#[doc = "`reset()` method sets TIMCTL1 to value 0"]
641impl crate::Resettable for TIMCTL1_SPEC {
642 #[inline(always)]
643 fn reset_value() -> Self::Ux {
644 0
645 }
646}