mk20d7/usb0/ctl/
mod.rs

1#[doc = r" Value read from the register"]
2pub struct R {
3    bits: u8,
4}
5#[doc = r" Value to write to the register"]
6pub struct W {
7    bits: u8,
8}
9impl super::CTL {
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 `USBENSOFEN`"]
46#[derive(Clone, Copy, Debug, PartialEq)]
47pub enum USBENSOFENR {
48    #[doc = "The USB Module is disabled."]
49    _0,
50    #[doc = "The USB Module is enabled."]
51    _1,
52}
53impl USBENSOFENR {
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            USBENSOFENR::_0 => false,
69            USBENSOFENR::_1 => true,
70        }
71    }
72    #[allow(missing_docs)]
73    #[doc(hidden)]
74    #[inline]
75    pub fn _from(value: bool) -> USBENSOFENR {
76        match value {
77            false => USBENSOFENR::_0,
78            true => USBENSOFENR::_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 == USBENSOFENR::_0
85    }
86    #[doc = "Checks if the value of the field is `_1`"]
87    #[inline]
88    pub fn is_1(&self) -> bool {
89        *self == USBENSOFENR::_1
90    }
91}
92#[doc = r" Value of the field"]
93pub struct ODDRSTR {
94    bits: bool,
95}
96impl ODDRSTR {
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 RESUMER {
115    bits: bool,
116}
117impl RESUMER {
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 HOSTMODEENR {
136    bits: bool,
137}
138impl HOSTMODEENR {
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 RESETR {
157    bits: bool,
158}
159impl RESETR {
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 = r" Value of the field"]
177pub struct TXSUSPENDTOKENBUSYR {
178    bits: bool,
179}
180impl TXSUSPENDTOKENBUSYR {
181    #[doc = r" Value of the field as raw bits"]
182    #[inline]
183    pub fn bit(&self) -> bool {
184        self.bits
185    }
186    #[doc = r" Returns `true` if the bit is clear (0)"]
187    #[inline]
188    pub fn bit_is_clear(&self) -> bool {
189        !self.bit()
190    }
191    #[doc = r" Returns `true` if the bit is set (1)"]
192    #[inline]
193    pub fn bit_is_set(&self) -> bool {
194        self.bit()
195    }
196}
197#[doc = r" Value of the field"]
198pub struct SE0R {
199    bits: bool,
200}
201impl SE0R {
202    #[doc = r" Value of the field as raw bits"]
203    #[inline]
204    pub fn bit(&self) -> bool {
205        self.bits
206    }
207    #[doc = r" Returns `true` if the bit is clear (0)"]
208    #[inline]
209    pub fn bit_is_clear(&self) -> bool {
210        !self.bit()
211    }
212    #[doc = r" Returns `true` if the bit is set (1)"]
213    #[inline]
214    pub fn bit_is_set(&self) -> bool {
215        self.bit()
216    }
217}
218#[doc = r" Value of the field"]
219pub struct JSTATER {
220    bits: bool,
221}
222impl JSTATER {
223    #[doc = r" Value of the field as raw bits"]
224    #[inline]
225    pub fn bit(&self) -> bool {
226        self.bits
227    }
228    #[doc = r" Returns `true` if the bit is clear (0)"]
229    #[inline]
230    pub fn bit_is_clear(&self) -> bool {
231        !self.bit()
232    }
233    #[doc = r" Returns `true` if the bit is set (1)"]
234    #[inline]
235    pub fn bit_is_set(&self) -> bool {
236        self.bit()
237    }
238}
239#[doc = "Values that can be written to the field `USBENSOFEN`"]
240pub enum USBENSOFENW {
241    #[doc = "The USB Module is disabled."]
242    _0,
243    #[doc = "The USB Module is enabled."]
244    _1,
245}
246impl USBENSOFENW {
247    #[allow(missing_docs)]
248    #[doc(hidden)]
249    #[inline]
250    pub fn _bits(&self) -> bool {
251        match *self {
252            USBENSOFENW::_0 => false,
253            USBENSOFENW::_1 => true,
254        }
255    }
256}
257#[doc = r" Proxy"]
258pub struct _USBENSOFENW<'a> {
259    w: &'a mut W,
260}
261impl<'a> _USBENSOFENW<'a> {
262    #[doc = r" Writes `variant` to the field"]
263    #[inline]
264    pub fn variant(self, variant: USBENSOFENW) -> &'a mut W {
265        {
266            self.bit(variant._bits())
267        }
268    }
269    #[doc = "The USB Module is disabled."]
270    #[inline]
271    pub fn _0(self) -> &'a mut W {
272        self.variant(USBENSOFENW::_0)
273    }
274    #[doc = "The USB Module is enabled."]
275    #[inline]
276    pub fn _1(self) -> &'a mut W {
277        self.variant(USBENSOFENW::_1)
278    }
279    #[doc = r" Sets the field bit"]
280    pub fn set_bit(self) -> &'a mut W {
281        self.bit(true)
282    }
283    #[doc = r" Clears the field bit"]
284    pub fn clear_bit(self) -> &'a mut W {
285        self.bit(false)
286    }
287    #[doc = r" Writes raw bits to the field"]
288    #[inline]
289    pub fn bit(self, value: bool) -> &'a mut W {
290        const MASK: bool = true;
291        const OFFSET: u8 = 0;
292        self.w.bits &= !((MASK as u8) << OFFSET);
293        self.w.bits |= ((value & MASK) as u8) << OFFSET;
294        self.w
295    }
296}
297#[doc = r" Proxy"]
298pub struct _ODDRSTW<'a> {
299    w: &'a mut W,
300}
301impl<'a> _ODDRSTW<'a> {
302    #[doc = r" Sets the field bit"]
303    pub fn set_bit(self) -> &'a mut W {
304        self.bit(true)
305    }
306    #[doc = r" Clears the field bit"]
307    pub fn clear_bit(self) -> &'a mut W {
308        self.bit(false)
309    }
310    #[doc = r" Writes raw bits to the field"]
311    #[inline]
312    pub fn bit(self, value: bool) -> &'a mut W {
313        const MASK: bool = true;
314        const OFFSET: u8 = 1;
315        self.w.bits &= !((MASK as u8) << OFFSET);
316        self.w.bits |= ((value & MASK) as u8) << OFFSET;
317        self.w
318    }
319}
320#[doc = r" Proxy"]
321pub struct _RESUMEW<'a> {
322    w: &'a mut W,
323}
324impl<'a> _RESUMEW<'a> {
325    #[doc = r" Sets the field bit"]
326    pub fn set_bit(self) -> &'a mut W {
327        self.bit(true)
328    }
329    #[doc = r" Clears the field bit"]
330    pub fn clear_bit(self) -> &'a mut W {
331        self.bit(false)
332    }
333    #[doc = r" Writes raw bits to the field"]
334    #[inline]
335    pub fn bit(self, value: bool) -> &'a mut W {
336        const MASK: bool = true;
337        const OFFSET: u8 = 2;
338        self.w.bits &= !((MASK as u8) << OFFSET);
339        self.w.bits |= ((value & MASK) as u8) << OFFSET;
340        self.w
341    }
342}
343#[doc = r" Proxy"]
344pub struct _HOSTMODEENW<'a> {
345    w: &'a mut W,
346}
347impl<'a> _HOSTMODEENW<'a> {
348    #[doc = r" Sets the field bit"]
349    pub fn set_bit(self) -> &'a mut W {
350        self.bit(true)
351    }
352    #[doc = r" Clears the field bit"]
353    pub fn clear_bit(self) -> &'a mut W {
354        self.bit(false)
355    }
356    #[doc = r" Writes raw bits to the field"]
357    #[inline]
358    pub fn bit(self, value: bool) -> &'a mut W {
359        const MASK: bool = true;
360        const OFFSET: u8 = 3;
361        self.w.bits &= !((MASK as u8) << OFFSET);
362        self.w.bits |= ((value & MASK) as u8) << OFFSET;
363        self.w
364    }
365}
366#[doc = r" Proxy"]
367pub struct _RESETW<'a> {
368    w: &'a mut W,
369}
370impl<'a> _RESETW<'a> {
371    #[doc = r" Sets the field bit"]
372    pub fn set_bit(self) -> &'a mut W {
373        self.bit(true)
374    }
375    #[doc = r" Clears the field bit"]
376    pub fn clear_bit(self) -> &'a mut W {
377        self.bit(false)
378    }
379    #[doc = r" Writes raw bits to the field"]
380    #[inline]
381    pub fn bit(self, value: bool) -> &'a mut W {
382        const MASK: bool = true;
383        const OFFSET: u8 = 4;
384        self.w.bits &= !((MASK as u8) << OFFSET);
385        self.w.bits |= ((value & MASK) as u8) << OFFSET;
386        self.w
387    }
388}
389#[doc = r" Proxy"]
390pub struct _TXSUSPENDTOKENBUSYW<'a> {
391    w: &'a mut W,
392}
393impl<'a> _TXSUSPENDTOKENBUSYW<'a> {
394    #[doc = r" Sets the field bit"]
395    pub fn set_bit(self) -> &'a mut W {
396        self.bit(true)
397    }
398    #[doc = r" Clears the field bit"]
399    pub fn clear_bit(self) -> &'a mut W {
400        self.bit(false)
401    }
402    #[doc = r" Writes raw bits to the field"]
403    #[inline]
404    pub fn bit(self, value: bool) -> &'a mut W {
405        const MASK: bool = true;
406        const OFFSET: u8 = 5;
407        self.w.bits &= !((MASK as u8) << OFFSET);
408        self.w.bits |= ((value & MASK) as u8) << OFFSET;
409        self.w
410    }
411}
412#[doc = r" Proxy"]
413pub struct _SE0W<'a> {
414    w: &'a mut W,
415}
416impl<'a> _SE0W<'a> {
417    #[doc = r" Sets the field bit"]
418    pub fn set_bit(self) -> &'a mut W {
419        self.bit(true)
420    }
421    #[doc = r" Clears the field bit"]
422    pub fn clear_bit(self) -> &'a mut W {
423        self.bit(false)
424    }
425    #[doc = r" Writes raw bits to the field"]
426    #[inline]
427    pub fn bit(self, value: bool) -> &'a mut W {
428        const MASK: bool = true;
429        const OFFSET: u8 = 6;
430        self.w.bits &= !((MASK as u8) << OFFSET);
431        self.w.bits |= ((value & MASK) as u8) << OFFSET;
432        self.w
433    }
434}
435#[doc = r" Proxy"]
436pub struct _JSTATEW<'a> {
437    w: &'a mut W,
438}
439impl<'a> _JSTATEW<'a> {
440    #[doc = r" Sets the field bit"]
441    pub fn set_bit(self) -> &'a mut W {
442        self.bit(true)
443    }
444    #[doc = r" Clears the field bit"]
445    pub fn clear_bit(self) -> &'a mut W {
446        self.bit(false)
447    }
448    #[doc = r" Writes raw bits to the field"]
449    #[inline]
450    pub fn bit(self, value: bool) -> &'a mut W {
451        const MASK: bool = true;
452        const OFFSET: u8 = 7;
453        self.w.bits &= !((MASK as u8) << OFFSET);
454        self.w.bits |= ((value & MASK) as u8) << OFFSET;
455        self.w
456    }
457}
458impl R {
459    #[doc = r" Value of the register as raw bits"]
460    #[inline]
461    pub fn bits(&self) -> u8 {
462        self.bits
463    }
464    #[doc = "Bit 0 - USB Enable"]
465    #[inline]
466    pub fn usbensofen(&self) -> USBENSOFENR {
467        USBENSOFENR::_from({
468            const MASK: bool = true;
469            const OFFSET: u8 = 0;
470            ((self.bits >> OFFSET) & MASK as u8) != 0
471        })
472    }
473    #[doc = "Bit 1 - no description available"]
474    #[inline]
475    pub fn oddrst(&self) -> ODDRSTR {
476        let bits = {
477            const MASK: bool = true;
478            const OFFSET: u8 = 1;
479            ((self.bits >> OFFSET) & MASK as u8) != 0
480        };
481        ODDRSTR { bits }
482    }
483    #[doc = "Bit 2 - no description available"]
484    #[inline]
485    pub fn resume(&self) -> RESUMER {
486        let bits = {
487            const MASK: bool = true;
488            const OFFSET: u8 = 2;
489            ((self.bits >> OFFSET) & MASK as u8) != 0
490        };
491        RESUMER { bits }
492    }
493    #[doc = "Bit 3 - no description available"]
494    #[inline]
495    pub fn hostmodeen(&self) -> HOSTMODEENR {
496        let bits = {
497            const MASK: bool = true;
498            const OFFSET: u8 = 3;
499            ((self.bits >> OFFSET) & MASK as u8) != 0
500        };
501        HOSTMODEENR { bits }
502    }
503    #[doc = "Bit 4 - no description available"]
504    #[inline]
505    pub fn reset(&self) -> RESETR {
506        let bits = {
507            const MASK: bool = true;
508            const OFFSET: u8 = 4;
509            ((self.bits >> OFFSET) & MASK as u8) != 0
510        };
511        RESETR { bits }
512    }
513    #[doc = "Bit 5 - no description available"]
514    #[inline]
515    pub fn txsuspendtokenbusy(&self) -> TXSUSPENDTOKENBUSYR {
516        let bits = {
517            const MASK: bool = true;
518            const OFFSET: u8 = 5;
519            ((self.bits >> OFFSET) & MASK as u8) != 0
520        };
521        TXSUSPENDTOKENBUSYR { bits }
522    }
523    #[doc = "Bit 6 - Live USB Single Ended Zero signal"]
524    #[inline]
525    pub fn se0(&self) -> SE0R {
526        let bits = {
527            const MASK: bool = true;
528            const OFFSET: u8 = 6;
529            ((self.bits >> OFFSET) & MASK as u8) != 0
530        };
531        SE0R { bits }
532    }
533    #[doc = "Bit 7 - Live USB differential receiver JSTATE signal"]
534    #[inline]
535    pub fn jstate(&self) -> JSTATER {
536        let bits = {
537            const MASK: bool = true;
538            const OFFSET: u8 = 7;
539            ((self.bits >> OFFSET) & MASK as u8) != 0
540        };
541        JSTATER { bits }
542    }
543}
544impl W {
545    #[doc = r" Reset value of the register"]
546    #[inline]
547    pub fn reset_value() -> W {
548        W { bits: 0 }
549    }
550    #[doc = r" Writes raw bits to the register"]
551    #[inline]
552    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
553        self.bits = bits;
554        self
555    }
556    #[doc = "Bit 0 - USB Enable"]
557    #[inline]
558    pub fn usbensofen(&mut self) -> _USBENSOFENW {
559        _USBENSOFENW { w: self }
560    }
561    #[doc = "Bit 1 - no description available"]
562    #[inline]
563    pub fn oddrst(&mut self) -> _ODDRSTW {
564        _ODDRSTW { w: self }
565    }
566    #[doc = "Bit 2 - no description available"]
567    #[inline]
568    pub fn resume(&mut self) -> _RESUMEW {
569        _RESUMEW { w: self }
570    }
571    #[doc = "Bit 3 - no description available"]
572    #[inline]
573    pub fn hostmodeen(&mut self) -> _HOSTMODEENW {
574        _HOSTMODEENW { w: self }
575    }
576    #[doc = "Bit 4 - no description available"]
577    #[inline]
578    pub fn reset(&mut self) -> _RESETW {
579        _RESETW { w: self }
580    }
581    #[doc = "Bit 5 - no description available"]
582    #[inline]
583    pub fn txsuspendtokenbusy(&mut self) -> _TXSUSPENDTOKENBUSYW {
584        _TXSUSPENDTOKENBUSYW { w: self }
585    }
586    #[doc = "Bit 6 - Live USB Single Ended Zero signal"]
587    #[inline]
588    pub fn se0(&mut self) -> _SE0W {
589        _SE0W { w: self }
590    }
591    #[doc = "Bit 7 - Live USB differential receiver JSTATE signal"]
592    #[inline]
593    pub fn jstate(&mut self) -> _JSTATEW {
594        _JSTATEW { w: self }
595    }
596}