stm32l4x2_pac/usb/
lpmcsr.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::LPMCSR {
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 `LPMEN`"]
46#[derive(Clone, Copy, Debug, PartialEq)]
47pub enum LPMENR {
48    #[doc = "enable the LPM support within the USB device"]
49    DISABLED,
50    #[doc = "no LPM transactions are handled"]
51    ENABLED,
52}
53impl LPMENR {
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            LPMENR::DISABLED => false,
69            LPMENR::ENABLED => true,
70        }
71    }
72    #[allow(missing_docs)]
73    #[doc(hidden)]
74    #[inline]
75    pub fn _from(value: bool) -> LPMENR {
76        match value {
77            false => LPMENR::DISABLED,
78            true => LPMENR::ENABLED,
79        }
80    }
81    #[doc = "Checks if the value of the field is `DISABLED`"]
82    #[inline]
83    pub fn is_disabled(&self) -> bool {
84        *self == LPMENR::DISABLED
85    }
86    #[doc = "Checks if the value of the field is `ENABLED`"]
87    #[inline]
88    pub fn is_enabled(&self) -> bool {
89        *self == LPMENR::ENABLED
90    }
91}
92#[doc = "Possible values of the field `LPMACK`"]
93#[derive(Clone, Copy, Debug, PartialEq)]
94pub enum LPMACKR {
95    #[doc = "the valid LPM Token will be NYET"]
96    NYET,
97    #[doc = "the valid LPM Token will be ACK"]
98    ACK,
99}
100impl LPMACKR {
101    #[doc = r" Returns `true` if the bit is clear (0)"]
102    #[inline]
103    pub fn bit_is_clear(&self) -> bool {
104        !self.bit()
105    }
106    #[doc = r" Returns `true` if the bit is set (1)"]
107    #[inline]
108    pub fn bit_is_set(&self) -> bool {
109        self.bit()
110    }
111    #[doc = r" Value of the field as raw bits"]
112    #[inline]
113    pub fn bit(&self) -> bool {
114        match *self {
115            LPMACKR::NYET => false,
116            LPMACKR::ACK => true,
117        }
118    }
119    #[allow(missing_docs)]
120    #[doc(hidden)]
121    #[inline]
122    pub fn _from(value: bool) -> LPMACKR {
123        match value {
124            false => LPMACKR::NYET,
125            true => LPMACKR::ACK,
126        }
127    }
128    #[doc = "Checks if the value of the field is `NYET`"]
129    #[inline]
130    pub fn is_nyet(&self) -> bool {
131        *self == LPMACKR::NYET
132    }
133    #[doc = "Checks if the value of the field is `ACK`"]
134    #[inline]
135    pub fn is_ack(&self) -> bool {
136        *self == LPMACKR::ACK
137    }
138}
139#[doc = r" Value of the field"]
140pub struct REMWAKER {
141    bits: bool,
142}
143impl REMWAKER {
144    #[doc = r" Value of the field as raw bits"]
145    #[inline]
146    pub fn bit(&self) -> bool {
147        self.bits
148    }
149    #[doc = r" Returns `true` if the bit is clear (0)"]
150    #[inline]
151    pub fn bit_is_clear(&self) -> bool {
152        !self.bit()
153    }
154    #[doc = r" Returns `true` if the bit is set (1)"]
155    #[inline]
156    pub fn bit_is_set(&self) -> bool {
157        self.bit()
158    }
159}
160#[doc = r" Value of the field"]
161pub struct BESLR {
162    bits: u8,
163}
164impl BESLR {
165    #[doc = r" Value of the field as raw bits"]
166    #[inline]
167    pub fn bits(&self) -> u8 {
168        self.bits
169    }
170}
171#[doc = "Values that can be written to the field `LPMEN`"]
172pub enum LPMENW {
173    #[doc = "enable the LPM support within the USB device"]
174    DISABLED,
175    #[doc = "no LPM transactions are handled"]
176    ENABLED,
177}
178impl LPMENW {
179    #[allow(missing_docs)]
180    #[doc(hidden)]
181    #[inline]
182    pub fn _bits(&self) -> bool {
183        match *self {
184            LPMENW::DISABLED => false,
185            LPMENW::ENABLED => true,
186        }
187    }
188}
189#[doc = r" Proxy"]
190pub struct _LPMENW<'a> {
191    w: &'a mut W,
192}
193impl<'a> _LPMENW<'a> {
194    #[doc = r" Writes `variant` to the field"]
195    #[inline]
196    pub fn variant(self, variant: LPMENW) -> &'a mut W {
197        {
198            self.bit(variant._bits())
199        }
200    }
201    #[doc = "enable the LPM support within the USB device"]
202    #[inline]
203    pub fn disabled(self) -> &'a mut W {
204        self.variant(LPMENW::DISABLED)
205    }
206    #[doc = "no LPM transactions are handled"]
207    #[inline]
208    pub fn enabled(self) -> &'a mut W {
209        self.variant(LPMENW::ENABLED)
210    }
211    #[doc = r" Sets the field bit"]
212    pub fn set_bit(self) -> &'a mut W {
213        self.bit(true)
214    }
215    #[doc = r" Clears the field bit"]
216    pub fn clear_bit(self) -> &'a mut W {
217        self.bit(false)
218    }
219    #[doc = r" Writes raw bits to the field"]
220    #[inline]
221    pub fn bit(self, value: bool) -> &'a mut W {
222        const MASK: bool = true;
223        const OFFSET: u8 = 0;
224        self.w.bits &= !((MASK as u32) << OFFSET);
225        self.w.bits |= ((value & MASK) as u32) << OFFSET;
226        self.w
227    }
228}
229#[doc = "Values that can be written to the field `LPMACK`"]
230pub enum LPMACKW {
231    #[doc = "the valid LPM Token will be NYET"]
232    NYET,
233    #[doc = "the valid LPM Token will be ACK"]
234    ACK,
235}
236impl LPMACKW {
237    #[allow(missing_docs)]
238    #[doc(hidden)]
239    #[inline]
240    pub fn _bits(&self) -> bool {
241        match *self {
242            LPMACKW::NYET => false,
243            LPMACKW::ACK => true,
244        }
245    }
246}
247#[doc = r" Proxy"]
248pub struct _LPMACKW<'a> {
249    w: &'a mut W,
250}
251impl<'a> _LPMACKW<'a> {
252    #[doc = r" Writes `variant` to the field"]
253    #[inline]
254    pub fn variant(self, variant: LPMACKW) -> &'a mut W {
255        {
256            self.bit(variant._bits())
257        }
258    }
259    #[doc = "the valid LPM Token will be NYET"]
260    #[inline]
261    pub fn nyet(self) -> &'a mut W {
262        self.variant(LPMACKW::NYET)
263    }
264    #[doc = "the valid LPM Token will be ACK"]
265    #[inline]
266    pub fn ack(self) -> &'a mut W {
267        self.variant(LPMACKW::ACK)
268    }
269    #[doc = r" Sets the field bit"]
270    pub fn set_bit(self) -> &'a mut W {
271        self.bit(true)
272    }
273    #[doc = r" Clears the field bit"]
274    pub fn clear_bit(self) -> &'a mut W {
275        self.bit(false)
276    }
277    #[doc = r" Writes raw bits to the field"]
278    #[inline]
279    pub fn bit(self, value: bool) -> &'a mut W {
280        const MASK: bool = true;
281        const OFFSET: u8 = 1;
282        self.w.bits &= !((MASK as u32) << OFFSET);
283        self.w.bits |= ((value & MASK) as u32) << OFFSET;
284        self.w
285    }
286}
287impl R {
288    #[doc = r" Value of the register as raw bits"]
289    #[inline]
290    pub fn bits(&self) -> u32 {
291        self.bits
292    }
293    #[doc = "Bit 0 - LPM support enable"]
294    #[inline]
295    pub fn lpmen(&self) -> LPMENR {
296        LPMENR::_from({
297            const MASK: bool = true;
298            const OFFSET: u8 = 0;
299            ((self.bits >> OFFSET) & MASK as u32) != 0
300        })
301    }
302    #[doc = "Bit 1 - LPM Token acknowledge enable"]
303    #[inline]
304    pub fn lpmack(&self) -> LPMACKR {
305        LPMACKR::_from({
306            const MASK: bool = true;
307            const OFFSET: u8 = 1;
308            ((self.bits >> OFFSET) & MASK as u32) != 0
309        })
310    }
311    #[doc = "Bit 3 - bRemoteWake value"]
312    #[inline]
313    pub fn remwake(&self) -> REMWAKER {
314        let bits = {
315            const MASK: bool = true;
316            const OFFSET: u8 = 3;
317            ((self.bits >> OFFSET) & MASK as u32) != 0
318        };
319        REMWAKER { bits }
320    }
321    #[doc = "Bits 4:7 - BESL value"]
322    #[inline]
323    pub fn besl(&self) -> BESLR {
324        let bits = {
325            const MASK: u8 = 15;
326            const OFFSET: u8 = 4;
327            ((self.bits >> OFFSET) & MASK as u32) as u8
328        };
329        BESLR { bits }
330    }
331}
332impl W {
333    #[doc = r" Reset value of the register"]
334    #[inline]
335    pub fn reset_value() -> W {
336        W { bits: 0 }
337    }
338    #[doc = r" Writes raw bits to the register"]
339    #[inline]
340    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
341        self.bits = bits;
342        self
343    }
344    #[doc = "Bit 0 - LPM support enable"]
345    #[inline]
346    pub fn lpmen(&mut self) -> _LPMENW {
347        _LPMENW { w: self }
348    }
349    #[doc = "Bit 1 - LPM Token acknowledge enable"]
350    #[inline]
351    pub fn lpmack(&mut self) -> _LPMACKW {
352        _LPMACKW { w: self }
353    }
354}