s32k144/flexio/
shiftctl2.rs

1#[doc = r" Value read from the register"]
2pub struct R {
3    bits: u32,
4}
5#[doc = r" Value to write to the register"]
6pub struct W {
7    bits: u32,
8}
9impl super::SHIFTCTL2 {
10    #[doc = r" Modifies the contents of the register"]
11    #[inline]
12    pub fn modify<F>(&self, f: F)
13    where
14        for<'w> F: FnOnce(&R, &'w mut W) -> &'w mut W,
15    {
16        let bits = self.register.get();
17        let r = R { bits: bits };
18        let mut w = W { bits: bits };
19        f(&r, &mut w);
20        self.register.set(w.bits);
21    }
22    #[doc = r" Reads the contents of the register"]
23    #[inline]
24    pub fn read(&self) -> R {
25        R { bits: self.register.get() }
26    }
27    #[doc = r" Writes to the register"]
28    #[inline]
29    pub fn write<F>(&self, f: F)
30    where
31        F: FnOnce(&mut W) -> &mut W,
32    {
33        let mut w = W::reset_value();
34        f(&mut w);
35        self.register.set(w.bits);
36    }
37    #[doc = r" Writes the reset value to the register"]
38    #[inline]
39    pub fn reset(&self) {
40        self.write(|w| w)
41    }
42}
43#[doc = "Possible values of the field `SMOD`"]
44#[derive(Clone, Copy, Debug, PartialEq)]
45pub enum SMODR {
46    #[doc = "Disabled."]
47    _0,
48    #[doc = "Receive mode. Captures the current Shifter content into the SHIFTBUF on expiration of the Timer."]
49    _1,
50    #[doc = "Transmit mode. Load SHIFTBUF contents into the Shifter on expiration of the Timer."]
51    _10,
52    #[doc = "Match Store mode. Shifter data is compared to SHIFTBUF content on expiration of the Timer."]
53    _100,
54    #[doc = "Match Continuous mode. Shifter data is continuously compared to SHIFTBUF contents."]
55    _101,
56    #[doc = r" Reserved"]
57    _Reserved(u8),
58}
59impl SMODR {
60    #[doc = r" Value of the field as raw bits"]
61    #[inline]
62    pub fn bits(&self) -> u8 {
63        match *self {
64            SMODR::_0 => 0,
65            SMODR::_1 => 1,
66            SMODR::_10 => 2,
67            SMODR::_100 => 4,
68            SMODR::_101 => 5,
69            SMODR::_Reserved(bits) => bits,
70        }
71    }
72    #[allow(missing_docs)]
73    #[doc(hidden)]
74    #[inline]
75    pub fn _from(value: u8) -> SMODR {
76        match value {
77            0 => SMODR::_0,
78            1 => SMODR::_1,
79            2 => SMODR::_10,
80            4 => SMODR::_100,
81            5 => SMODR::_101,
82            i => SMODR::_Reserved(i),
83        }
84    }
85    #[doc = "Checks if the value of the field is `_0`"]
86    #[inline]
87    pub fn is_0(&self) -> bool {
88        *self == SMODR::_0
89    }
90    #[doc = "Checks if the value of the field is `_1`"]
91    #[inline]
92    pub fn is_1(&self) -> bool {
93        *self == SMODR::_1
94    }
95    #[doc = "Checks if the value of the field is `_10`"]
96    #[inline]
97    pub fn is_10(&self) -> bool {
98        *self == SMODR::_10
99    }
100    #[doc = "Checks if the value of the field is `_100`"]
101    #[inline]
102    pub fn is_100(&self) -> bool {
103        *self == SMODR::_100
104    }
105    #[doc = "Checks if the value of the field is `_101`"]
106    #[inline]
107    pub fn is_101(&self) -> bool {
108        *self == SMODR::_101
109    }
110}
111#[doc = "Possible values of the field `PINPOL`"]
112#[derive(Clone, Copy, Debug, PartialEq)]
113pub enum PINPOLR {
114    #[doc = "Pin is active high"]
115    _0,
116    #[doc = "Pin is active low"]
117    _1,
118}
119impl PINPOLR {
120    #[doc = r" Returns `true` if the bit is clear (0)"]
121    #[inline]
122    pub fn bit_is_clear(&self) -> bool {
123        !self.bit()
124    }
125    #[doc = r" Returns `true` if the bit is set (1)"]
126    #[inline]
127    pub fn bit_is_set(&self) -> bool {
128        self.bit()
129    }
130    #[doc = r" Value of the field as raw bits"]
131    #[inline]
132    pub fn bit(&self) -> bool {
133        match *self {
134            PINPOLR::_0 => false,
135            PINPOLR::_1 => true,
136        }
137    }
138    #[allow(missing_docs)]
139    #[doc(hidden)]
140    #[inline]
141    pub fn _from(value: bool) -> PINPOLR {
142        match value {
143            false => PINPOLR::_0,
144            true => PINPOLR::_1,
145        }
146    }
147    #[doc = "Checks if the value of the field is `_0`"]
148    #[inline]
149    pub fn is_0(&self) -> bool {
150        *self == PINPOLR::_0
151    }
152    #[doc = "Checks if the value of the field is `_1`"]
153    #[inline]
154    pub fn is_1(&self) -> bool {
155        *self == PINPOLR::_1
156    }
157}
158#[doc = r" Value of the field"]
159pub struct PINSELR {
160    bits: u8,
161}
162impl PINSELR {
163    #[doc = r" Value of the field as raw bits"]
164    #[inline]
165    pub fn bits(&self) -> u8 {
166        self.bits
167    }
168}
169#[doc = "Possible values of the field `PINCFG`"]
170#[derive(Clone, Copy, Debug, PartialEq)]
171pub enum PINCFGR {
172    #[doc = "Shifter pin output disabled"]
173    _0,
174    #[doc = "Shifter pin open drain or bidirectional output enable"]
175    _1,
176    #[doc = "Shifter pin bidirectional output data"]
177    _10,
178    #[doc = "Shifter pin output"]
179    _11,
180}
181impl PINCFGR {
182    #[doc = r" Value of the field as raw bits"]
183    #[inline]
184    pub fn bits(&self) -> u8 {
185        match *self {
186            PINCFGR::_0 => 0,
187            PINCFGR::_1 => 1,
188            PINCFGR::_10 => 2,
189            PINCFGR::_11 => 3,
190        }
191    }
192    #[allow(missing_docs)]
193    #[doc(hidden)]
194    #[inline]
195    pub fn _from(value: u8) -> PINCFGR {
196        match value {
197            0 => PINCFGR::_0,
198            1 => PINCFGR::_1,
199            2 => PINCFGR::_10,
200            3 => PINCFGR::_11,
201            _ => unreachable!(),
202        }
203    }
204    #[doc = "Checks if the value of the field is `_0`"]
205    #[inline]
206    pub fn is_0(&self) -> bool {
207        *self == PINCFGR::_0
208    }
209    #[doc = "Checks if the value of the field is `_1`"]
210    #[inline]
211    pub fn is_1(&self) -> bool {
212        *self == PINCFGR::_1
213    }
214    #[doc = "Checks if the value of the field is `_10`"]
215    #[inline]
216    pub fn is_10(&self) -> bool {
217        *self == PINCFGR::_10
218    }
219    #[doc = "Checks if the value of the field is `_11`"]
220    #[inline]
221    pub fn is_11(&self) -> bool {
222        *self == PINCFGR::_11
223    }
224}
225#[doc = "Possible values of the field `TIMPOL`"]
226#[derive(Clone, Copy, Debug, PartialEq)]
227pub enum TIMPOLR {
228    #[doc = "Shift on posedge of Shift clock"]
229    _0,
230    #[doc = "Shift on negedge of Shift clock"]
231    _1,
232}
233impl TIMPOLR {
234    #[doc = r" Returns `true` if the bit is clear (0)"]
235    #[inline]
236    pub fn bit_is_clear(&self) -> bool {
237        !self.bit()
238    }
239    #[doc = r" Returns `true` if the bit is set (1)"]
240    #[inline]
241    pub fn bit_is_set(&self) -> bool {
242        self.bit()
243    }
244    #[doc = r" Value of the field as raw bits"]
245    #[inline]
246    pub fn bit(&self) -> bool {
247        match *self {
248            TIMPOLR::_0 => false,
249            TIMPOLR::_1 => true,
250        }
251    }
252    #[allow(missing_docs)]
253    #[doc(hidden)]
254    #[inline]
255    pub fn _from(value: bool) -> TIMPOLR {
256        match value {
257            false => TIMPOLR::_0,
258            true => TIMPOLR::_1,
259        }
260    }
261    #[doc = "Checks if the value of the field is `_0`"]
262    #[inline]
263    pub fn is_0(&self) -> bool {
264        *self == TIMPOLR::_0
265    }
266    #[doc = "Checks if the value of the field is `_1`"]
267    #[inline]
268    pub fn is_1(&self) -> bool {
269        *self == TIMPOLR::_1
270    }
271}
272#[doc = r" Value of the field"]
273pub struct TIMSELR {
274    bits: u8,
275}
276impl TIMSELR {
277    #[doc = r" Value of the field as raw bits"]
278    #[inline]
279    pub fn bits(&self) -> u8 {
280        self.bits
281    }
282}
283#[doc = "Values that can be written to the field `SMOD`"]
284pub enum SMODW {
285    #[doc = "Disabled."]
286    _0,
287    #[doc = "Receive mode. Captures the current Shifter content into the SHIFTBUF on expiration of the Timer."]
288    _1,
289    #[doc = "Transmit mode. Load SHIFTBUF contents into the Shifter on expiration of the Timer."]
290    _10,
291    #[doc = "Match Store mode. Shifter data is compared to SHIFTBUF content on expiration of the Timer."]
292    _100,
293    #[doc = "Match Continuous mode. Shifter data is continuously compared to SHIFTBUF contents."]
294    _101,
295}
296impl SMODW {
297    #[allow(missing_docs)]
298    #[doc(hidden)]
299    #[inline]
300    pub fn _bits(&self) -> u8 {
301        match *self {
302            SMODW::_0 => 0,
303            SMODW::_1 => 1,
304            SMODW::_10 => 2,
305            SMODW::_100 => 4,
306            SMODW::_101 => 5,
307        }
308    }
309}
310#[doc = r" Proxy"]
311pub struct _SMODW<'a> {
312    w: &'a mut W,
313}
314impl<'a> _SMODW<'a> {
315    #[doc = r" Writes `variant` to the field"]
316    #[inline]
317    pub fn variant(self, variant: SMODW) -> &'a mut W {
318        unsafe { self.bits(variant._bits()) }
319    }
320    #[doc = "Disabled."]
321    #[inline]
322    pub fn _0(self) -> &'a mut W {
323        self.variant(SMODW::_0)
324    }
325    #[doc = "Receive mode. Captures the current Shifter content into the SHIFTBUF on expiration of the Timer."]
326    #[inline]
327    pub fn _1(self) -> &'a mut W {
328        self.variant(SMODW::_1)
329    }
330    #[doc = "Transmit mode. Load SHIFTBUF contents into the Shifter on expiration of the Timer."]
331    #[inline]
332    pub fn _10(self) -> &'a mut W {
333        self.variant(SMODW::_10)
334    }
335    #[doc = "Match Store mode. Shifter data is compared to SHIFTBUF content on expiration of the Timer."]
336    #[inline]
337    pub fn _100(self) -> &'a mut W {
338        self.variant(SMODW::_100)
339    }
340    #[doc = "Match Continuous mode. Shifter data is continuously compared to SHIFTBUF contents."]
341    #[inline]
342    pub fn _101(self) -> &'a mut W {
343        self.variant(SMODW::_101)
344    }
345    #[doc = r" Writes raw bits to the field"]
346    #[inline]
347    pub unsafe fn bits(self, value: u8) -> &'a mut W {
348        const MASK: u8 = 7;
349        const OFFSET: u8 = 0;
350        self.w.bits &= !((MASK as u32) << OFFSET);
351        self.w.bits |= ((value & MASK) as u32) << OFFSET;
352        self.w
353    }
354}
355#[doc = "Values that can be written to the field `PINPOL`"]
356pub enum PINPOLW {
357    #[doc = "Pin is active high"]
358    _0,
359    #[doc = "Pin is active low"]
360    _1,
361}
362impl PINPOLW {
363    #[allow(missing_docs)]
364    #[doc(hidden)]
365    #[inline]
366    pub fn _bits(&self) -> bool {
367        match *self {
368            PINPOLW::_0 => false,
369            PINPOLW::_1 => true,
370        }
371    }
372}
373#[doc = r" Proxy"]
374pub struct _PINPOLW<'a> {
375    w: &'a mut W,
376}
377impl<'a> _PINPOLW<'a> {
378    #[doc = r" Writes `variant` to the field"]
379    #[inline]
380    pub fn variant(self, variant: PINPOLW) -> &'a mut W {
381        {
382            self.bit(variant._bits())
383        }
384    }
385    #[doc = "Pin is active high"]
386    #[inline]
387    pub fn _0(self) -> &'a mut W {
388        self.variant(PINPOLW::_0)
389    }
390    #[doc = "Pin is active low"]
391    #[inline]
392    pub fn _1(self) -> &'a mut W {
393        self.variant(PINPOLW::_1)
394    }
395    #[doc = r" Sets the field bit"]
396    pub fn set_bit(self) -> &'a mut W {
397        self.bit(true)
398    }
399    #[doc = r" Clears the field bit"]
400    pub fn clear_bit(self) -> &'a mut W {
401        self.bit(false)
402    }
403    #[doc = r" Writes raw bits to the field"]
404    #[inline]
405    pub fn bit(self, value: bool) -> &'a mut W {
406        const MASK: bool = true;
407        const OFFSET: u8 = 7;
408        self.w.bits &= !((MASK as u32) << OFFSET);
409        self.w.bits |= ((value & MASK) as u32) << OFFSET;
410        self.w
411    }
412}
413#[doc = r" Proxy"]
414pub struct _PINSELW<'a> {
415    w: &'a mut W,
416}
417impl<'a> _PINSELW<'a> {
418    #[doc = r" Writes raw bits to the field"]
419    #[inline]
420    pub unsafe fn bits(self, value: u8) -> &'a mut W {
421        const MASK: u8 = 7;
422        const OFFSET: u8 = 8;
423        self.w.bits &= !((MASK as u32) << OFFSET);
424        self.w.bits |= ((value & MASK) as u32) << OFFSET;
425        self.w
426    }
427}
428#[doc = "Values that can be written to the field `PINCFG`"]
429pub enum PINCFGW {
430    #[doc = "Shifter pin output disabled"]
431    _0,
432    #[doc = "Shifter pin open drain or bidirectional output enable"]
433    _1,
434    #[doc = "Shifter pin bidirectional output data"]
435    _10,
436    #[doc = "Shifter pin output"]
437    _11,
438}
439impl PINCFGW {
440    #[allow(missing_docs)]
441    #[doc(hidden)]
442    #[inline]
443    pub fn _bits(&self) -> u8 {
444        match *self {
445            PINCFGW::_0 => 0,
446            PINCFGW::_1 => 1,
447            PINCFGW::_10 => 2,
448            PINCFGW::_11 => 3,
449        }
450    }
451}
452#[doc = r" Proxy"]
453pub struct _PINCFGW<'a> {
454    w: &'a mut W,
455}
456impl<'a> _PINCFGW<'a> {
457    #[doc = r" Writes `variant` to the field"]
458    #[inline]
459    pub fn variant(self, variant: PINCFGW) -> &'a mut W {
460        {
461            self.bits(variant._bits())
462        }
463    }
464    #[doc = "Shifter pin output disabled"]
465    #[inline]
466    pub fn _0(self) -> &'a mut W {
467        self.variant(PINCFGW::_0)
468    }
469    #[doc = "Shifter pin open drain or bidirectional output enable"]
470    #[inline]
471    pub fn _1(self) -> &'a mut W {
472        self.variant(PINCFGW::_1)
473    }
474    #[doc = "Shifter pin bidirectional output data"]
475    #[inline]
476    pub fn _10(self) -> &'a mut W {
477        self.variant(PINCFGW::_10)
478    }
479    #[doc = "Shifter pin output"]
480    #[inline]
481    pub fn _11(self) -> &'a mut W {
482        self.variant(PINCFGW::_11)
483    }
484    #[doc = r" Writes raw bits to the field"]
485    #[inline]
486    pub fn bits(self, value: u8) -> &'a mut W {
487        const MASK: u8 = 3;
488        const OFFSET: u8 = 16;
489        self.w.bits &= !((MASK as u32) << OFFSET);
490        self.w.bits |= ((value & MASK) as u32) << OFFSET;
491        self.w
492    }
493}
494#[doc = "Values that can be written to the field `TIMPOL`"]
495pub enum TIMPOLW {
496    #[doc = "Shift on posedge of Shift clock"]
497    _0,
498    #[doc = "Shift on negedge of Shift clock"]
499    _1,
500}
501impl TIMPOLW {
502    #[allow(missing_docs)]
503    #[doc(hidden)]
504    #[inline]
505    pub fn _bits(&self) -> bool {
506        match *self {
507            TIMPOLW::_0 => false,
508            TIMPOLW::_1 => true,
509        }
510    }
511}
512#[doc = r" Proxy"]
513pub struct _TIMPOLW<'a> {
514    w: &'a mut W,
515}
516impl<'a> _TIMPOLW<'a> {
517    #[doc = r" Writes `variant` to the field"]
518    #[inline]
519    pub fn variant(self, variant: TIMPOLW) -> &'a mut W {
520        {
521            self.bit(variant._bits())
522        }
523    }
524    #[doc = "Shift on posedge of Shift clock"]
525    #[inline]
526    pub fn _0(self) -> &'a mut W {
527        self.variant(TIMPOLW::_0)
528    }
529    #[doc = "Shift on negedge of Shift clock"]
530    #[inline]
531    pub fn _1(self) -> &'a mut W {
532        self.variant(TIMPOLW::_1)
533    }
534    #[doc = r" Sets the field bit"]
535    pub fn set_bit(self) -> &'a mut W {
536        self.bit(true)
537    }
538    #[doc = r" Clears the field bit"]
539    pub fn clear_bit(self) -> &'a mut W {
540        self.bit(false)
541    }
542    #[doc = r" Writes raw bits to the field"]
543    #[inline]
544    pub fn bit(self, value: bool) -> &'a mut W {
545        const MASK: bool = true;
546        const OFFSET: u8 = 23;
547        self.w.bits &= !((MASK as u32) << OFFSET);
548        self.w.bits |= ((value & MASK) as u32) << OFFSET;
549        self.w
550    }
551}
552#[doc = r" Proxy"]
553pub struct _TIMSELW<'a> {
554    w: &'a mut W,
555}
556impl<'a> _TIMSELW<'a> {
557    #[doc = r" Writes raw bits to the field"]
558    #[inline]
559    pub unsafe fn bits(self, value: u8) -> &'a mut W {
560        const MASK: u8 = 3;
561        const OFFSET: u8 = 24;
562        self.w.bits &= !((MASK as u32) << OFFSET);
563        self.w.bits |= ((value & MASK) as u32) << OFFSET;
564        self.w
565    }
566}
567impl R {
568    #[doc = r" Value of the register as raw bits"]
569    #[inline]
570    pub fn bits(&self) -> u32 {
571        self.bits
572    }
573    #[doc = "Bits 0:2 - Shifter Mode"]
574    #[inline]
575    pub fn smod(&self) -> SMODR {
576        SMODR::_from({
577            const MASK: u8 = 7;
578            const OFFSET: u8 = 0;
579            ((self.bits >> OFFSET) & MASK as u32) as u8
580        })
581    }
582    #[doc = "Bit 7 - Shifter Pin Polarity"]
583    #[inline]
584    pub fn pinpol(&self) -> PINPOLR {
585        PINPOLR::_from({
586            const MASK: bool = true;
587            const OFFSET: u8 = 7;
588            ((self.bits >> OFFSET) & MASK as u32) != 0
589        })
590    }
591    #[doc = "Bits 8:10 - Shifter Pin Select"]
592    #[inline]
593    pub fn pinsel(&self) -> PINSELR {
594        let bits = {
595            const MASK: u8 = 7;
596            const OFFSET: u8 = 8;
597            ((self.bits >> OFFSET) & MASK as u32) as u8
598        };
599        PINSELR { bits }
600    }
601    #[doc = "Bits 16:17 - Shifter Pin Configuration"]
602    #[inline]
603    pub fn pincfg(&self) -> PINCFGR {
604        PINCFGR::_from({
605            const MASK: u8 = 3;
606            const OFFSET: u8 = 16;
607            ((self.bits >> OFFSET) & MASK as u32) as u8
608        })
609    }
610    #[doc = "Bit 23 - Timer Polarity"]
611    #[inline]
612    pub fn timpol(&self) -> TIMPOLR {
613        TIMPOLR::_from({
614            const MASK: bool = true;
615            const OFFSET: u8 = 23;
616            ((self.bits >> OFFSET) & MASK as u32) != 0
617        })
618    }
619    #[doc = "Bits 24:25 - Timer Select"]
620    #[inline]
621    pub fn timsel(&self) -> TIMSELR {
622        let bits = {
623            const MASK: u8 = 3;
624            const OFFSET: u8 = 24;
625            ((self.bits >> OFFSET) & MASK as u32) as u8
626        };
627        TIMSELR { bits }
628    }
629}
630impl W {
631    #[doc = r" Reset value of the register"]
632    #[inline]
633    pub fn reset_value() -> W {
634        W { bits: 0 }
635    }
636    #[doc = r" Writes raw bits to the register"]
637    #[inline]
638    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
639        self.bits = bits;
640        self
641    }
642    #[doc = "Bits 0:2 - Shifter Mode"]
643    #[inline]
644    pub fn smod(&mut self) -> _SMODW {
645        _SMODW { w: self }
646    }
647    #[doc = "Bit 7 - Shifter Pin Polarity"]
648    #[inline]
649    pub fn pinpol(&mut self) -> _PINPOLW {
650        _PINPOLW { w: self }
651    }
652    #[doc = "Bits 8:10 - Shifter Pin Select"]
653    #[inline]
654    pub fn pinsel(&mut self) -> _PINSELW {
655        _PINSELW { w: self }
656    }
657    #[doc = "Bits 16:17 - Shifter Pin Configuration"]
658    #[inline]
659    pub fn pincfg(&mut self) -> _PINCFGW {
660        _PINCFGW { w: self }
661    }
662    #[doc = "Bit 23 - Timer Polarity"]
663    #[inline]
664    pub fn timpol(&mut self) -> _TIMPOLW {
665        _TIMPOLW { w: self }
666    }
667    #[doc = "Bits 24:25 - Timer Select"]
668    #[inline]
669    pub fn timsel(&mut self) -> _TIMSELW {
670        _TIMSELW { w: self }
671    }
672}