stm32l4x2_pac/usb/
fnr.rs

1#[doc = r" Value read from the register"]
2pub struct R {
3    bits: u32,
4}
5impl super::FNR {
6    #[doc = r" Reads the contents of the register"]
7    #[inline]
8    pub fn read(&self) -> R {
9        R {
10            bits: self.register.get(),
11        }
12    }
13}
14#[doc = r" Value of the field"]
15pub struct FNR {
16    bits: u16,
17}
18impl FNR {
19    #[doc = r" Value of the field as raw bits"]
20    #[inline]
21    pub fn bits(&self) -> u16 {
22        self.bits
23    }
24}
25#[doc = r" Value of the field"]
26pub struct LSOFR {
27    bits: u8,
28}
29impl LSOFR {
30    #[doc = r" Value of the field as raw bits"]
31    #[inline]
32    pub fn bits(&self) -> u8 {
33        self.bits
34    }
35}
36#[doc = "Possible values of the field `LCK`"]
37#[derive(Clone, Copy, Debug, PartialEq)]
38pub enum LCKR {
39    #[doc = "the frame timer remains in this state until an USB reset or USB suspend event occurs"]
40    LOCKED,
41    #[doc = r" Reserved"]
42    _Reserved(bool),
43}
44impl LCKR {
45    #[doc = r" Returns `true` if the bit is clear (0)"]
46    #[inline]
47    pub fn bit_is_clear(&self) -> bool {
48        !self.bit()
49    }
50    #[doc = r" Returns `true` if the bit is set (1)"]
51    #[inline]
52    pub fn bit_is_set(&self) -> bool {
53        self.bit()
54    }
55    #[doc = r" Value of the field as raw bits"]
56    #[inline]
57    pub fn bit(&self) -> bool {
58        match *self {
59            LCKR::LOCKED => true,
60            LCKR::_Reserved(bits) => bits,
61        }
62    }
63    #[allow(missing_docs)]
64    #[doc(hidden)]
65    #[inline]
66    pub fn _from(value: bool) -> LCKR {
67        match value {
68            true => LCKR::LOCKED,
69            i => LCKR::_Reserved(i),
70        }
71    }
72    #[doc = "Checks if the value of the field is `LOCKED`"]
73    #[inline]
74    pub fn is_locked(&self) -> bool {
75        *self == LCKR::LOCKED
76    }
77}
78#[doc = "Possible values of the field `RXDM`"]
79#[derive(Clone, Copy, Debug, PartialEq)]
80pub enum RXDMR {
81    #[doc = "received data minus upstream port data line"]
82    RECEIVED,
83    #[doc = r" Reserved"]
84    _Reserved(bool),
85}
86impl RXDMR {
87    #[doc = r" Returns `true` if the bit is clear (0)"]
88    #[inline]
89    pub fn bit_is_clear(&self) -> bool {
90        !self.bit()
91    }
92    #[doc = r" Returns `true` if the bit is set (1)"]
93    #[inline]
94    pub fn bit_is_set(&self) -> bool {
95        self.bit()
96    }
97    #[doc = r" Value of the field as raw bits"]
98    #[inline]
99    pub fn bit(&self) -> bool {
100        match *self {
101            RXDMR::RECEIVED => true,
102            RXDMR::_Reserved(bits) => bits,
103        }
104    }
105    #[allow(missing_docs)]
106    #[doc(hidden)]
107    #[inline]
108    pub fn _from(value: bool) -> RXDMR {
109        match value {
110            true => RXDMR::RECEIVED,
111            i => RXDMR::_Reserved(i),
112        }
113    }
114    #[doc = "Checks if the value of the field is `RECEIVED`"]
115    #[inline]
116    pub fn is_received(&self) -> bool {
117        *self == RXDMR::RECEIVED
118    }
119}
120#[doc = "Possible values of the field `RXDP`"]
121#[derive(Clone, Copy, Debug, PartialEq)]
122pub enum RXDPR {
123    #[doc = "received data plus upstream port data line"]
124    RECEIVED,
125    #[doc = r" Reserved"]
126    _Reserved(bool),
127}
128impl RXDPR {
129    #[doc = r" Returns `true` if the bit is clear (0)"]
130    #[inline]
131    pub fn bit_is_clear(&self) -> bool {
132        !self.bit()
133    }
134    #[doc = r" Returns `true` if the bit is set (1)"]
135    #[inline]
136    pub fn bit_is_set(&self) -> bool {
137        self.bit()
138    }
139    #[doc = r" Value of the field as raw bits"]
140    #[inline]
141    pub fn bit(&self) -> bool {
142        match *self {
143            RXDPR::RECEIVED => true,
144            RXDPR::_Reserved(bits) => bits,
145        }
146    }
147    #[allow(missing_docs)]
148    #[doc(hidden)]
149    #[inline]
150    pub fn _from(value: bool) -> RXDPR {
151        match value {
152            true => RXDPR::RECEIVED,
153            i => RXDPR::_Reserved(i),
154        }
155    }
156    #[doc = "Checks if the value of the field is `RECEIVED`"]
157    #[inline]
158    pub fn is_received(&self) -> bool {
159        *self == RXDPR::RECEIVED
160    }
161}
162impl R {
163    #[doc = r" Value of the register as raw bits"]
164    #[inline]
165    pub fn bits(&self) -> u32 {
166        self.bits
167    }
168    #[doc = "Bits 0:10 - Frame number"]
169    #[inline]
170    pub fn fn_(&self) -> FNR {
171        let bits = {
172            const MASK: u16 = 2047;
173            const OFFSET: u8 = 0;
174            ((self.bits >> OFFSET) & MASK as u32) as u16
175        };
176        FNR { bits }
177    }
178    #[doc = "Bits 11:12 - Lost SOF"]
179    #[inline]
180    pub fn lsof(&self) -> LSOFR {
181        let bits = {
182            const MASK: u8 = 3;
183            const OFFSET: u8 = 11;
184            ((self.bits >> OFFSET) & MASK as u32) as u8
185        };
186        LSOFR { bits }
187    }
188    #[doc = "Bit 13 - Locked"]
189    #[inline]
190    pub fn lck(&self) -> LCKR {
191        LCKR::_from({
192            const MASK: bool = true;
193            const OFFSET: u8 = 13;
194            ((self.bits >> OFFSET) & MASK as u32) != 0
195        })
196    }
197    #[doc = "Bit 14 - Receive data - line status"]
198    #[inline]
199    pub fn rxdm(&self) -> RXDMR {
200        RXDMR::_from({
201            const MASK: bool = true;
202            const OFFSET: u8 = 14;
203            ((self.bits >> OFFSET) & MASK as u32) != 0
204        })
205    }
206    #[doc = "Bit 15 - Receive data + line status"]
207    #[inline]
208    pub fn rxdp(&self) -> RXDPR {
209        RXDPR::_from({
210            const MASK: bool = true;
211            const OFFSET: u8 = 15;
212            ((self.bits >> OFFSET) & MASK as u32) != 0
213        })
214    }
215}