mk20d7/ftm0/csc/
mod.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::CSC {
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 {
26            bits: self.register.get(),
27        }
28    }
29    #[doc = r" Writes to the register"]
30    #[inline]
31    pub fn write<F>(&self, f: F)
32    where
33        F: FnOnce(&mut W) -> &mut W,
34    {
35        let mut w = W::reset_value();
36        f(&mut w);
37        self.register.set(w.bits);
38    }
39    #[doc = r" Writes the reset value to the register"]
40    #[inline]
41    pub fn reset(&self) {
42        self.write(|w| w)
43    }
44}
45#[doc = "Possible values of the field `DMA`"]
46#[derive(Clone, Copy, Debug, PartialEq)]
47pub enum DMAR {
48    #[doc = "Disable DMA transfers."]
49    _0,
50    #[doc = "Enable DMA transfers."]
51    _1,
52}
53impl DMAR {
54    #[doc = r" Returns `true` if the bit is clear (0)"]
55    #[inline]
56    pub fn bit_is_clear(&self) -> bool {
57        !self.bit()
58    }
59    #[doc = r" Returns `true` if the bit is set (1)"]
60    #[inline]
61    pub fn bit_is_set(&self) -> bool {
62        self.bit()
63    }
64    #[doc = r" Value of the field as raw bits"]
65    #[inline]
66    pub fn bit(&self) -> bool {
67        match *self {
68            DMAR::_0 => false,
69            DMAR::_1 => true,
70        }
71    }
72    #[allow(missing_docs)]
73    #[doc(hidden)]
74    #[inline]
75    pub fn _from(value: bool) -> DMAR {
76        match value {
77            false => DMAR::_0,
78            true => DMAR::_1,
79        }
80    }
81    #[doc = "Checks if the value of the field is `_0`"]
82    #[inline]
83    pub fn is_0(&self) -> bool {
84        *self == DMAR::_0
85    }
86    #[doc = "Checks if the value of the field is `_1`"]
87    #[inline]
88    pub fn is_1(&self) -> bool {
89        *self == DMAR::_1
90    }
91}
92#[doc = r" Value of the field"]
93pub struct ELSAR {
94    bits: bool,
95}
96impl ELSAR {
97    #[doc = r" Value of the field as raw bits"]
98    #[inline]
99    pub fn bit(&self) -> bool {
100        self.bits
101    }
102    #[doc = r" Returns `true` if the bit is clear (0)"]
103    #[inline]
104    pub fn bit_is_clear(&self) -> bool {
105        !self.bit()
106    }
107    #[doc = r" Returns `true` if the bit is set (1)"]
108    #[inline]
109    pub fn bit_is_set(&self) -> bool {
110        self.bit()
111    }
112}
113#[doc = r" Value of the field"]
114pub struct ELSBR {
115    bits: bool,
116}
117impl ELSBR {
118    #[doc = r" Value of the field as raw bits"]
119    #[inline]
120    pub fn bit(&self) -> bool {
121        self.bits
122    }
123    #[doc = r" Returns `true` if the bit is clear (0)"]
124    #[inline]
125    pub fn bit_is_clear(&self) -> bool {
126        !self.bit()
127    }
128    #[doc = r" Returns `true` if the bit is set (1)"]
129    #[inline]
130    pub fn bit_is_set(&self) -> bool {
131        self.bit()
132    }
133}
134#[doc = r" Value of the field"]
135pub struct MSAR {
136    bits: bool,
137}
138impl MSAR {
139    #[doc = r" Value of the field as raw bits"]
140    #[inline]
141    pub fn bit(&self) -> bool {
142        self.bits
143    }
144    #[doc = r" Returns `true` if the bit is clear (0)"]
145    #[inline]
146    pub fn bit_is_clear(&self) -> bool {
147        !self.bit()
148    }
149    #[doc = r" Returns `true` if the bit is set (1)"]
150    #[inline]
151    pub fn bit_is_set(&self) -> bool {
152        self.bit()
153    }
154}
155#[doc = r" Value of the field"]
156pub struct MSBR {
157    bits: bool,
158}
159impl MSBR {
160    #[doc = r" Value of the field as raw bits"]
161    #[inline]
162    pub fn bit(&self) -> bool {
163        self.bits
164    }
165    #[doc = r" Returns `true` if the bit is clear (0)"]
166    #[inline]
167    pub fn bit_is_clear(&self) -> bool {
168        !self.bit()
169    }
170    #[doc = r" Returns `true` if the bit is set (1)"]
171    #[inline]
172    pub fn bit_is_set(&self) -> bool {
173        self.bit()
174    }
175}
176#[doc = "Possible values of the field `CHIE`"]
177#[derive(Clone, Copy, Debug, PartialEq)]
178pub enum CHIER {
179    #[doc = "Disable channel interrupts. Use software polling."]
180    _0,
181    #[doc = "Enable channel interrupts."]
182    _1,
183}
184impl CHIER {
185    #[doc = r" Returns `true` if the bit is clear (0)"]
186    #[inline]
187    pub fn bit_is_clear(&self) -> bool {
188        !self.bit()
189    }
190    #[doc = r" Returns `true` if the bit is set (1)"]
191    #[inline]
192    pub fn bit_is_set(&self) -> bool {
193        self.bit()
194    }
195    #[doc = r" Value of the field as raw bits"]
196    #[inline]
197    pub fn bit(&self) -> bool {
198        match *self {
199            CHIER::_0 => false,
200            CHIER::_1 => true,
201        }
202    }
203    #[allow(missing_docs)]
204    #[doc(hidden)]
205    #[inline]
206    pub fn _from(value: bool) -> CHIER {
207        match value {
208            false => CHIER::_0,
209            true => CHIER::_1,
210        }
211    }
212    #[doc = "Checks if the value of the field is `_0`"]
213    #[inline]
214    pub fn is_0(&self) -> bool {
215        *self == CHIER::_0
216    }
217    #[doc = "Checks if the value of the field is `_1`"]
218    #[inline]
219    pub fn is_1(&self) -> bool {
220        *self == CHIER::_1
221    }
222}
223#[doc = "Possible values of the field `CHF`"]
224#[derive(Clone, Copy, Debug, PartialEq)]
225pub enum CHFR {
226    #[doc = "No channel event has occurred."]
227    _0,
228    #[doc = "A channel event has occurred."]
229    _1,
230}
231impl CHFR {
232    #[doc = r" Returns `true` if the bit is clear (0)"]
233    #[inline]
234    pub fn bit_is_clear(&self) -> bool {
235        !self.bit()
236    }
237    #[doc = r" Returns `true` if the bit is set (1)"]
238    #[inline]
239    pub fn bit_is_set(&self) -> bool {
240        self.bit()
241    }
242    #[doc = r" Value of the field as raw bits"]
243    #[inline]
244    pub fn bit(&self) -> bool {
245        match *self {
246            CHFR::_0 => false,
247            CHFR::_1 => true,
248        }
249    }
250    #[allow(missing_docs)]
251    #[doc(hidden)]
252    #[inline]
253    pub fn _from(value: bool) -> CHFR {
254        match value {
255            false => CHFR::_0,
256            true => CHFR::_1,
257        }
258    }
259    #[doc = "Checks if the value of the field is `_0`"]
260    #[inline]
261    pub fn is_0(&self) -> bool {
262        *self == CHFR::_0
263    }
264    #[doc = "Checks if the value of the field is `_1`"]
265    #[inline]
266    pub fn is_1(&self) -> bool {
267        *self == CHFR::_1
268    }
269}
270#[doc = "Values that can be written to the field `DMA`"]
271pub enum DMAW {
272    #[doc = "Disable DMA transfers."]
273    _0,
274    #[doc = "Enable DMA transfers."]
275    _1,
276}
277impl DMAW {
278    #[allow(missing_docs)]
279    #[doc(hidden)]
280    #[inline]
281    pub fn _bits(&self) -> bool {
282        match *self {
283            DMAW::_0 => false,
284            DMAW::_1 => true,
285        }
286    }
287}
288#[doc = r" Proxy"]
289pub struct _DMAW<'a> {
290    w: &'a mut W,
291}
292impl<'a> _DMAW<'a> {
293    #[doc = r" Writes `variant` to the field"]
294    #[inline]
295    pub fn variant(self, variant: DMAW) -> &'a mut W {
296        {
297            self.bit(variant._bits())
298        }
299    }
300    #[doc = "Disable DMA transfers."]
301    #[inline]
302    pub fn _0(self) -> &'a mut W {
303        self.variant(DMAW::_0)
304    }
305    #[doc = "Enable DMA transfers."]
306    #[inline]
307    pub fn _1(self) -> &'a mut W {
308        self.variant(DMAW::_1)
309    }
310    #[doc = r" Sets the field bit"]
311    pub fn set_bit(self) -> &'a mut W {
312        self.bit(true)
313    }
314    #[doc = r" Clears the field bit"]
315    pub fn clear_bit(self) -> &'a mut W {
316        self.bit(false)
317    }
318    #[doc = r" Writes raw bits to the field"]
319    #[inline]
320    pub fn bit(self, value: bool) -> &'a mut W {
321        const MASK: bool = true;
322        const OFFSET: u8 = 0;
323        self.w.bits &= !((MASK as u32) << OFFSET);
324        self.w.bits |= ((value & MASK) as u32) << OFFSET;
325        self.w
326    }
327}
328#[doc = r" Proxy"]
329pub struct _ELSAW<'a> {
330    w: &'a mut W,
331}
332impl<'a> _ELSAW<'a> {
333    #[doc = r" Sets the field bit"]
334    pub fn set_bit(self) -> &'a mut W {
335        self.bit(true)
336    }
337    #[doc = r" Clears the field bit"]
338    pub fn clear_bit(self) -> &'a mut W {
339        self.bit(false)
340    }
341    #[doc = r" Writes raw bits to the field"]
342    #[inline]
343    pub fn bit(self, value: bool) -> &'a mut W {
344        const MASK: bool = true;
345        const OFFSET: u8 = 2;
346        self.w.bits &= !((MASK as u32) << OFFSET);
347        self.w.bits |= ((value & MASK) as u32) << OFFSET;
348        self.w
349    }
350}
351#[doc = r" Proxy"]
352pub struct _ELSBW<'a> {
353    w: &'a mut W,
354}
355impl<'a> _ELSBW<'a> {
356    #[doc = r" Sets the field bit"]
357    pub fn set_bit(self) -> &'a mut W {
358        self.bit(true)
359    }
360    #[doc = r" Clears the field bit"]
361    pub fn clear_bit(self) -> &'a mut W {
362        self.bit(false)
363    }
364    #[doc = r" Writes raw bits to the field"]
365    #[inline]
366    pub fn bit(self, value: bool) -> &'a mut W {
367        const MASK: bool = true;
368        const OFFSET: u8 = 3;
369        self.w.bits &= !((MASK as u32) << OFFSET);
370        self.w.bits |= ((value & MASK) as u32) << OFFSET;
371        self.w
372    }
373}
374#[doc = r" Proxy"]
375pub struct _MSAW<'a> {
376    w: &'a mut W,
377}
378impl<'a> _MSAW<'a> {
379    #[doc = r" Sets the field bit"]
380    pub fn set_bit(self) -> &'a mut W {
381        self.bit(true)
382    }
383    #[doc = r" Clears the field bit"]
384    pub fn clear_bit(self) -> &'a mut W {
385        self.bit(false)
386    }
387    #[doc = r" Writes raw bits to the field"]
388    #[inline]
389    pub fn bit(self, value: bool) -> &'a mut W {
390        const MASK: bool = true;
391        const OFFSET: u8 = 4;
392        self.w.bits &= !((MASK as u32) << OFFSET);
393        self.w.bits |= ((value & MASK) as u32) << OFFSET;
394        self.w
395    }
396}
397#[doc = r" Proxy"]
398pub struct _MSBW<'a> {
399    w: &'a mut W,
400}
401impl<'a> _MSBW<'a> {
402    #[doc = r" Sets the field bit"]
403    pub fn set_bit(self) -> &'a mut W {
404        self.bit(true)
405    }
406    #[doc = r" Clears the field bit"]
407    pub fn clear_bit(self) -> &'a mut W {
408        self.bit(false)
409    }
410    #[doc = r" Writes raw bits to the field"]
411    #[inline]
412    pub fn bit(self, value: bool) -> &'a mut W {
413        const MASK: bool = true;
414        const OFFSET: u8 = 5;
415        self.w.bits &= !((MASK as u32) << OFFSET);
416        self.w.bits |= ((value & MASK) as u32) << OFFSET;
417        self.w
418    }
419}
420#[doc = "Values that can be written to the field `CHIE`"]
421pub enum CHIEW {
422    #[doc = "Disable channel interrupts. Use software polling."]
423    _0,
424    #[doc = "Enable channel interrupts."]
425    _1,
426}
427impl CHIEW {
428    #[allow(missing_docs)]
429    #[doc(hidden)]
430    #[inline]
431    pub fn _bits(&self) -> bool {
432        match *self {
433            CHIEW::_0 => false,
434            CHIEW::_1 => true,
435        }
436    }
437}
438#[doc = r" Proxy"]
439pub struct _CHIEW<'a> {
440    w: &'a mut W,
441}
442impl<'a> _CHIEW<'a> {
443    #[doc = r" Writes `variant` to the field"]
444    #[inline]
445    pub fn variant(self, variant: CHIEW) -> &'a mut W {
446        {
447            self.bit(variant._bits())
448        }
449    }
450    #[doc = "Disable channel interrupts. Use software polling."]
451    #[inline]
452    pub fn _0(self) -> &'a mut W {
453        self.variant(CHIEW::_0)
454    }
455    #[doc = "Enable channel interrupts."]
456    #[inline]
457    pub fn _1(self) -> &'a mut W {
458        self.variant(CHIEW::_1)
459    }
460    #[doc = r" Sets the field bit"]
461    pub fn set_bit(self) -> &'a mut W {
462        self.bit(true)
463    }
464    #[doc = r" Clears the field bit"]
465    pub fn clear_bit(self) -> &'a mut W {
466        self.bit(false)
467    }
468    #[doc = r" Writes raw bits to the field"]
469    #[inline]
470    pub fn bit(self, value: bool) -> &'a mut W {
471        const MASK: bool = true;
472        const OFFSET: u8 = 6;
473        self.w.bits &= !((MASK as u32) << OFFSET);
474        self.w.bits |= ((value & MASK) as u32) << OFFSET;
475        self.w
476    }
477}
478impl R {
479    #[doc = r" Value of the register as raw bits"]
480    #[inline]
481    pub fn bits(&self) -> u32 {
482        self.bits
483    }
484    #[doc = "Bit 0 - DMA Enable"]
485    #[inline]
486    pub fn dma(&self) -> DMAR {
487        DMAR::_from({
488            const MASK: bool = true;
489            const OFFSET: u8 = 0;
490            ((self.bits >> OFFSET) & MASK as u32) != 0
491        })
492    }
493    #[doc = "Bit 2 - Edge or Level Select"]
494    #[inline]
495    pub fn elsa(&self) -> ELSAR {
496        let bits = {
497            const MASK: bool = true;
498            const OFFSET: u8 = 2;
499            ((self.bits >> OFFSET) & MASK as u32) != 0
500        };
501        ELSAR { bits }
502    }
503    #[doc = "Bit 3 - Edge or Level Select"]
504    #[inline]
505    pub fn elsb(&self) -> ELSBR {
506        let bits = {
507            const MASK: bool = true;
508            const OFFSET: u8 = 3;
509            ((self.bits >> OFFSET) & MASK as u32) != 0
510        };
511        ELSBR { bits }
512    }
513    #[doc = "Bit 4 - Channel Mode Select"]
514    #[inline]
515    pub fn msa(&self) -> MSAR {
516        let bits = {
517            const MASK: bool = true;
518            const OFFSET: u8 = 4;
519            ((self.bits >> OFFSET) & MASK as u32) != 0
520        };
521        MSAR { bits }
522    }
523    #[doc = "Bit 5 - Channel Mode Select"]
524    #[inline]
525    pub fn msb(&self) -> MSBR {
526        let bits = {
527            const MASK: bool = true;
528            const OFFSET: u8 = 5;
529            ((self.bits >> OFFSET) & MASK as u32) != 0
530        };
531        MSBR { bits }
532    }
533    #[doc = "Bit 6 - Channel Interrupt Enable"]
534    #[inline]
535    pub fn chie(&self) -> CHIER {
536        CHIER::_from({
537            const MASK: bool = true;
538            const OFFSET: u8 = 6;
539            ((self.bits >> OFFSET) & MASK as u32) != 0
540        })
541    }
542    #[doc = "Bit 7 - Channel Flag"]
543    #[inline]
544    pub fn chf(&self) -> CHFR {
545        CHFR::_from({
546            const MASK: bool = true;
547            const OFFSET: u8 = 7;
548            ((self.bits >> OFFSET) & MASK as u32) != 0
549        })
550    }
551}
552impl W {
553    #[doc = r" Reset value of the register"]
554    #[inline]
555    pub fn reset_value() -> W {
556        W { bits: 0 }
557    }
558    #[doc = r" Writes raw bits to the register"]
559    #[inline]
560    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
561        self.bits = bits;
562        self
563    }
564    #[doc = "Bit 0 - DMA Enable"]
565    #[inline]
566    pub fn dma(&mut self) -> _DMAW {
567        _DMAW { w: self }
568    }
569    #[doc = "Bit 2 - Edge or Level Select"]
570    #[inline]
571    pub fn elsa(&mut self) -> _ELSAW {
572        _ELSAW { w: self }
573    }
574    #[doc = "Bit 3 - Edge or Level Select"]
575    #[inline]
576    pub fn elsb(&mut self) -> _ELSBW {
577        _ELSBW { w: self }
578    }
579    #[doc = "Bit 4 - Channel Mode Select"]
580    #[inline]
581    pub fn msa(&mut self) -> _MSAW {
582        _MSAW { w: self }
583    }
584    #[doc = "Bit 5 - Channel Mode Select"]
585    #[inline]
586    pub fn msb(&mut self) -> _MSBW {
587        _MSBW { w: self }
588    }
589    #[doc = "Bit 6 - Channel Interrupt Enable"]
590    #[inline]
591    pub fn chie(&mut self) -> _CHIEW {
592        _CHIEW { w: self }
593    }
594}