mk20d7/usb0/token/
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::TOKEN {
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 = r" Value of the field"]
46pub struct TOKENENDPTR {
47    bits: u8,
48}
49impl TOKENENDPTR {
50    #[doc = r" Value of the field as raw bits"]
51    #[inline]
52    pub fn bits(&self) -> u8 {
53        self.bits
54    }
55}
56#[doc = "Possible values of the field `TOKENPID`"]
57#[derive(Clone, Copy, Debug, PartialEq)]
58pub enum TOKENPIDR {
59    #[doc = "OUT Token. USB Module performs an OUT (TX) transaction."]
60    _0001,
61    #[doc = "IN Token. USB Module performs an In (RX) transaction."]
62    _1001,
63    #[doc = "SETUP Token. USB Module performs a SETUP (TX) transaction"]
64    _1101,
65    #[doc = r" Reserved"]
66    _Reserved(u8),
67}
68impl TOKENPIDR {
69    #[doc = r" Value of the field as raw bits"]
70    #[inline]
71    pub fn bits(&self) -> u8 {
72        match *self {
73            TOKENPIDR::_0001 => 1,
74            TOKENPIDR::_1001 => 9,
75            TOKENPIDR::_1101 => 13,
76            TOKENPIDR::_Reserved(bits) => bits,
77        }
78    }
79    #[allow(missing_docs)]
80    #[doc(hidden)]
81    #[inline]
82    pub fn _from(value: u8) -> TOKENPIDR {
83        match value {
84            1 => TOKENPIDR::_0001,
85            9 => TOKENPIDR::_1001,
86            13 => TOKENPIDR::_1101,
87            i => TOKENPIDR::_Reserved(i),
88        }
89    }
90    #[doc = "Checks if the value of the field is `_0001`"]
91    #[inline]
92    pub fn is_0001(&self) -> bool {
93        *self == TOKENPIDR::_0001
94    }
95    #[doc = "Checks if the value of the field is `_1001`"]
96    #[inline]
97    pub fn is_1001(&self) -> bool {
98        *self == TOKENPIDR::_1001
99    }
100    #[doc = "Checks if the value of the field is `_1101`"]
101    #[inline]
102    pub fn is_1101(&self) -> bool {
103        *self == TOKENPIDR::_1101
104    }
105}
106#[doc = r" Proxy"]
107pub struct _TOKENENDPTW<'a> {
108    w: &'a mut W,
109}
110impl<'a> _TOKENENDPTW<'a> {
111    #[doc = r" Writes raw bits to the field"]
112    #[inline]
113    pub unsafe fn bits(self, value: u8) -> &'a mut W {
114        const MASK: u8 = 15;
115        const OFFSET: u8 = 0;
116        self.w.bits &= !((MASK as u8) << OFFSET);
117        self.w.bits |= ((value & MASK) as u8) << OFFSET;
118        self.w
119    }
120}
121#[doc = "Values that can be written to the field `TOKENPID`"]
122pub enum TOKENPIDW {
123    #[doc = "OUT Token. USB Module performs an OUT (TX) transaction."]
124    _0001,
125    #[doc = "IN Token. USB Module performs an In (RX) transaction."]
126    _1001,
127    #[doc = "SETUP Token. USB Module performs a SETUP (TX) transaction"]
128    _1101,
129}
130impl TOKENPIDW {
131    #[allow(missing_docs)]
132    #[doc(hidden)]
133    #[inline]
134    pub fn _bits(&self) -> u8 {
135        match *self {
136            TOKENPIDW::_0001 => 1,
137            TOKENPIDW::_1001 => 9,
138            TOKENPIDW::_1101 => 13,
139        }
140    }
141}
142#[doc = r" Proxy"]
143pub struct _TOKENPIDW<'a> {
144    w: &'a mut W,
145}
146impl<'a> _TOKENPIDW<'a> {
147    #[doc = r" Writes `variant` to the field"]
148    #[inline]
149    pub fn variant(self, variant: TOKENPIDW) -> &'a mut W {
150        unsafe { self.bits(variant._bits()) }
151    }
152    #[doc = "OUT Token. USB Module performs an OUT (TX) transaction."]
153    #[inline]
154    pub fn _0001(self) -> &'a mut W {
155        self.variant(TOKENPIDW::_0001)
156    }
157    #[doc = "IN Token. USB Module performs an In (RX) transaction."]
158    #[inline]
159    pub fn _1001(self) -> &'a mut W {
160        self.variant(TOKENPIDW::_1001)
161    }
162    #[doc = "SETUP Token. USB Module performs a SETUP (TX) transaction"]
163    #[inline]
164    pub fn _1101(self) -> &'a mut W {
165        self.variant(TOKENPIDW::_1101)
166    }
167    #[doc = r" Writes raw bits to the field"]
168    #[inline]
169    pub unsafe fn bits(self, value: u8) -> &'a mut W {
170        const MASK: u8 = 15;
171        const OFFSET: u8 = 4;
172        self.w.bits &= !((MASK as u8) << OFFSET);
173        self.w.bits |= ((value & MASK) as u8) << OFFSET;
174        self.w
175    }
176}
177impl R {
178    #[doc = r" Value of the register as raw bits"]
179    #[inline]
180    pub fn bits(&self) -> u8 {
181        self.bits
182    }
183    #[doc = "Bits 0:3 - no description available"]
184    #[inline]
185    pub fn tokenendpt(&self) -> TOKENENDPTR {
186        let bits = {
187            const MASK: u8 = 15;
188            const OFFSET: u8 = 0;
189            ((self.bits >> OFFSET) & MASK as u8) as u8
190        };
191        TOKENENDPTR { bits }
192    }
193    #[doc = "Bits 4:7 - no description available"]
194    #[inline]
195    pub fn tokenpid(&self) -> TOKENPIDR {
196        TOKENPIDR::_from({
197            const MASK: u8 = 15;
198            const OFFSET: u8 = 4;
199            ((self.bits >> OFFSET) & MASK as u8) as u8
200        })
201    }
202}
203impl W {
204    #[doc = r" Reset value of the register"]
205    #[inline]
206    pub fn reset_value() -> W {
207        W { bits: 0 }
208    }
209    #[doc = r" Writes raw bits to the register"]
210    #[inline]
211    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
212        self.bits = bits;
213        self
214    }
215    #[doc = "Bits 0:3 - no description available"]
216    #[inline]
217    pub fn tokenendpt(&mut self) -> _TOKENENDPTW {
218        _TOKENENDPTW { w: self }
219    }
220    #[doc = "Bits 4:7 - no description available"]
221    #[inline]
222    pub fn tokenpid(&mut self) -> _TOKENPIDW {
223        _TOKENPIDW { w: self }
224    }
225}