1#[doc = "Reader of register DCFG"]
2pub type R = crate::R<u32, super::DCFG>;
3#[doc = "Writer for register DCFG"]
4pub type W = crate::W<u32, super::DCFG>;
5#[doc = "Register DCFG `reset()`'s with value 0x0800_0000"]
6impl crate::ResetValue for super::DCFG {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type { 0x0800_0000 }
10}
11#[doc = "Device Speed\n\nValue on reset: 0"]
12#[derive(Clone, Copy, Debug, PartialEq)]
13#[repr(u8)]
14pub enum DEVSPD_A {
15    #[doc = "2: Low speed (PHY clock is 6 MHz). If you select 6 MHz LS mode, you must do a soft reset."]
16    LS = 2,
17    #[doc = "3: Full speed (PHY clock is 48 MHz)."]
18    FS = 3,
19}
20impl From<DEVSPD_A> for u8 {
21    #[inline(always)]
22    fn from(variant: DEVSPD_A) -> Self { variant as _ }
23}
24#[doc = "Reader of field `DEVSPD`"]
25pub type DEVSPD_R = crate::R<u8, DEVSPD_A>;
26impl DEVSPD_R {
27    #[doc = r"Get enumerated values variant"]
28    #[inline(always)]
29    pub fn variant(&self) -> crate::Variant<u8, DEVSPD_A> {
30        use crate::Variant::*;
31        match self.bits {
32            2 => Val(DEVSPD_A::LS),
33            3 => Val(DEVSPD_A::FS),
34            i => Res(i),
35        }
36    }
37    #[doc = "Checks if the value of the field is `LS`"]
38    #[inline(always)]
39    pub fn is_ls(&self) -> bool { *self == DEVSPD_A::LS }
40    #[doc = "Checks if the value of the field is `FS`"]
41    #[inline(always)]
42    pub fn is_fs(&self) -> bool { *self == DEVSPD_A::FS }
43}
44#[doc = "Write proxy for field `DEVSPD`"]
45pub struct DEVSPD_W<'a> {
46    w: &'a mut W,
47}
48impl<'a> DEVSPD_W<'a> {
49    #[doc = r"Writes `variant` to the field"]
50    #[inline(always)]
51    pub fn variant(self, variant: DEVSPD_A) -> &'a mut W { unsafe { self.bits(variant.into()) } }
52    #[doc = "Low speed (PHY clock is 6 MHz). If you select 6 MHz LS mode, you must do a soft reset."]
53    #[inline(always)]
54    pub fn ls(self) -> &'a mut W { self.variant(DEVSPD_A::LS) }
55    #[doc = "Full speed (PHY clock is 48 MHz)."]
56    #[inline(always)]
57    pub fn fs(self) -> &'a mut W { self.variant(DEVSPD_A::FS) }
58    #[doc = r"Writes raw bits to the field"]
59    #[inline(always)]
60    pub unsafe fn bits(self, value: u8) -> &'a mut W {
61        self.w.bits = (self.w.bits & !0x03) | ((value as u32) & 0x03);
62        self.w
63    }
64}
65#[doc = "Reader of field `NZSTSOUTHSHK`"]
66pub type NZSTSOUTHSHK_R = crate::R<bool, bool>;
67#[doc = "Write proxy for field `NZSTSOUTHSHK`"]
68pub struct NZSTSOUTHSHK_W<'a> {
69    w: &'a mut W,
70}
71impl<'a> NZSTSOUTHSHK_W<'a> {
72    #[doc = r"Sets the field bit"]
73    #[inline(always)]
74    pub fn set_bit(self) -> &'a mut W { self.bit(true) }
75    #[doc = r"Clears the field bit"]
76    #[inline(always)]
77    pub fn clear_bit(self) -> &'a mut W { self.bit(false) }
78    #[doc = r"Writes raw bits to the field"]
79    #[inline(always)]
80    pub fn bit(self, value: bool) -> &'a mut W {
81        self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2);
82        self.w
83    }
84}
85#[doc = "Reader of field `ENA32KHZSUSP`"]
86pub type ENA32KHZSUSP_R = crate::R<bool, bool>;
87#[doc = "Write proxy for field `ENA32KHZSUSP`"]
88pub struct ENA32KHZSUSP_W<'a> {
89    w: &'a mut W,
90}
91impl<'a> ENA32KHZSUSP_W<'a> {
92    #[doc = r"Sets the field bit"]
93    #[inline(always)]
94    pub fn set_bit(self) -> &'a mut W { self.bit(true) }
95    #[doc = r"Clears the field bit"]
96    #[inline(always)]
97    pub fn clear_bit(self) -> &'a mut W { self.bit(false) }
98    #[doc = r"Writes raw bits to the field"]
99    #[inline(always)]
100    pub fn bit(self, value: bool) -> &'a mut W {
101        self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3);
102        self.w
103    }
104}
105#[doc = "Reader of field `DEVADDR`"]
106pub type DEVADDR_R = crate::R<u8, u8>;
107#[doc = "Write proxy for field `DEVADDR`"]
108pub struct DEVADDR_W<'a> {
109    w: &'a mut W,
110}
111impl<'a> DEVADDR_W<'a> {
112    #[doc = r"Writes raw bits to the field"]
113    #[inline(always)]
114    pub unsafe fn bits(self, value: u8) -> &'a mut W {
115        self.w.bits = (self.w.bits & !(0x7f << 4)) | (((value as u32) & 0x7f) << 4);
116        self.w
117    }
118}
119#[doc = "Periodic Frame Interval\n\nValue on reset: 0"]
120#[derive(Clone, Copy, Debug, PartialEq)]
121#[repr(u8)]
122pub enum PERFRINT_A {
123    #[doc = "0: 80% of the frame interval."]
124    _80PCNT = 0,
125    #[doc = "1: 85% of the frame interval."]
126    _85PCNT = 1,
127    #[doc = "2: 90% of the frame interval."]
128    _90PCNT = 2,
129    #[doc = "3: 95% of the frame interval."]
130    _95PCNT = 3,
131}
132impl From<PERFRINT_A> for u8 {
133    #[inline(always)]
134    fn from(variant: PERFRINT_A) -> Self { variant as _ }
135}
136#[doc = "Reader of field `PERFRINT`"]
137pub type PERFRINT_R = crate::R<u8, PERFRINT_A>;
138impl PERFRINT_R {
139    #[doc = r"Get enumerated values variant"]
140    #[inline(always)]
141    pub fn variant(&self) -> PERFRINT_A {
142        match self.bits {
143            0 => PERFRINT_A::_80PCNT,
144            1 => PERFRINT_A::_85PCNT,
145            2 => PERFRINT_A::_90PCNT,
146            3 => PERFRINT_A::_95PCNT,
147            _ => unreachable!(),
148        }
149    }
150    #[doc = "Checks if the value of the field is `_80PCNT`"]
151    #[inline(always)]
152    pub fn is_80pcnt(&self) -> bool { *self == PERFRINT_A::_80PCNT }
153    #[doc = "Checks if the value of the field is `_85PCNT`"]
154    #[inline(always)]
155    pub fn is_85pcnt(&self) -> bool { *self == PERFRINT_A::_85PCNT }
156    #[doc = "Checks if the value of the field is `_90PCNT`"]
157    #[inline(always)]
158    pub fn is_90pcnt(&self) -> bool { *self == PERFRINT_A::_90PCNT }
159    #[doc = "Checks if the value of the field is `_95PCNT`"]
160    #[inline(always)]
161    pub fn is_95pcnt(&self) -> bool { *self == PERFRINT_A::_95PCNT }
162}
163#[doc = "Write proxy for field `PERFRINT`"]
164pub struct PERFRINT_W<'a> {
165    w: &'a mut W,
166}
167impl<'a> PERFRINT_W<'a> {
168    #[doc = r"Writes `variant` to the field"]
169    #[inline(always)]
170    pub fn variant(self, variant: PERFRINT_A) -> &'a mut W {
171        {
172            self.bits(variant.into())
173        }
174    }
175    #[doc = "80% of the frame interval."]
176    #[inline(always)]
177    pub fn _80pcnt(self) -> &'a mut W { self.variant(PERFRINT_A::_80PCNT) }
178    #[doc = "85% of the frame interval."]
179    #[inline(always)]
180    pub fn _85pcnt(self) -> &'a mut W { self.variant(PERFRINT_A::_85PCNT) }
181    #[doc = "90% of the frame interval."]
182    #[inline(always)]
183    pub fn _90pcnt(self) -> &'a mut W { self.variant(PERFRINT_A::_90PCNT) }
184    #[doc = "95% of the frame interval."]
185    #[inline(always)]
186    pub fn _95pcnt(self) -> &'a mut W { self.variant(PERFRINT_A::_95PCNT) }
187    #[doc = r"Writes raw bits to the field"]
188    #[inline(always)]
189    pub fn bits(self, value: u8) -> &'a mut W {
190        self.w.bits = (self.w.bits & !(0x03 << 11)) | (((value as u32) & 0x03) << 11);
191        self.w
192    }
193}
194#[doc = "Reader of field `ENDEVOUTNAK`"]
195pub type ENDEVOUTNAK_R = crate::R<bool, bool>;
196#[doc = "Write proxy for field `ENDEVOUTNAK`"]
197pub struct ENDEVOUTNAK_W<'a> {
198    w: &'a mut W,
199}
200impl<'a> ENDEVOUTNAK_W<'a> {
201    #[doc = r"Sets the field bit"]
202    #[inline(always)]
203    pub fn set_bit(self) -> &'a mut W { self.bit(true) }
204    #[doc = r"Clears the field bit"]
205    #[inline(always)]
206    pub fn clear_bit(self) -> &'a mut W { self.bit(false) }
207    #[doc = r"Writes raw bits to the field"]
208    #[inline(always)]
209    pub fn bit(self, value: bool) -> &'a mut W {
210        self.w.bits = (self.w.bits & !(0x01 << 13)) | (((value as u32) & 0x01) << 13);
211        self.w
212    }
213}
214#[doc = "Reader of field `XCVRDLY`"]
215pub type XCVRDLY_R = crate::R<bool, bool>;
216#[doc = "Write proxy for field `XCVRDLY`"]
217pub struct XCVRDLY_W<'a> {
218    w: &'a mut W,
219}
220impl<'a> XCVRDLY_W<'a> {
221    #[doc = r"Sets the field bit"]
222    #[inline(always)]
223    pub fn set_bit(self) -> &'a mut W { self.bit(true) }
224    #[doc = r"Clears the field bit"]
225    #[inline(always)]
226    pub fn clear_bit(self) -> &'a mut W { self.bit(false) }
227    #[doc = r"Writes raw bits to the field"]
228    #[inline(always)]
229    pub fn bit(self, value: bool) -> &'a mut W {
230        self.w.bits = (self.w.bits & !(0x01 << 14)) | (((value as u32) & 0x01) << 14);
231        self.w
232    }
233}
234#[doc = "Reader of field `ERRATICINTMSK`"]
235pub type ERRATICINTMSK_R = crate::R<bool, bool>;
236#[doc = "Write proxy for field `ERRATICINTMSK`"]
237pub struct ERRATICINTMSK_W<'a> {
238    w: &'a mut W,
239}
240impl<'a> ERRATICINTMSK_W<'a> {
241    #[doc = r"Sets the field bit"]
242    #[inline(always)]
243    pub fn set_bit(self) -> &'a mut W { self.bit(true) }
244    #[doc = r"Clears the field bit"]
245    #[inline(always)]
246    pub fn clear_bit(self) -> &'a mut W { self.bit(false) }
247    #[doc = r"Writes raw bits to the field"]
248    #[inline(always)]
249    pub fn bit(self, value: bool) -> &'a mut W {
250        self.w.bits = (self.w.bits & !(0x01 << 15)) | (((value as u32) & 0x01) << 15);
251        self.w
252    }
253}
254#[doc = "Reader of field `RESVALID`"]
255pub type RESVALID_R = crate::R<u8, u8>;
256#[doc = "Write proxy for field `RESVALID`"]
257pub struct RESVALID_W<'a> {
258    w: &'a mut W,
259}
260impl<'a> RESVALID_W<'a> {
261    #[doc = r"Writes raw bits to the field"]
262    #[inline(always)]
263    pub unsafe fn bits(self, value: u8) -> &'a mut W {
264        self.w.bits = (self.w.bits & !(0x3f << 26)) | (((value as u32) & 0x3f) << 26);
265        self.w
266    }
267}
268impl R {
269    #[doc = "Bits 0:1 - Device Speed"]
270    #[inline(always)]
271    pub fn devspd(&self) -> DEVSPD_R { DEVSPD_R::new((self.bits & 0x03) as u8) }
272    #[doc = "Bit 2 - Non-Zero-Length Status OUT Handshake"]
273    #[inline(always)]
274    pub fn nzstsouthshk(&self) -> NZSTSOUTHSHK_R {
275        NZSTSOUTHSHK_R::new(((self.bits >> 2) & 0x01) != 0)
276    }
277    #[doc = "Bit 3 - Enable 32 kHz Suspend Mode"]
278    #[inline(always)]
279    pub fn ena32khzsusp(&self) -> ENA32KHZSUSP_R {
280        ENA32KHZSUSP_R::new(((self.bits >> 3) & 0x01) != 0)
281    }
282    #[doc = "Bits 4:10 - Device Address"]
283    #[inline(always)]
284    pub fn devaddr(&self) -> DEVADDR_R { DEVADDR_R::new(((self.bits >> 4) & 0x7f) as u8) }
285    #[doc = "Bits 11:12 - Periodic Frame Interval"]
286    #[inline(always)]
287    pub fn perfrint(&self) -> PERFRINT_R { PERFRINT_R::new(((self.bits >> 11) & 0x03) as u8) }
288    #[doc = "Bit 13 - Enable Device OUT NAK"]
289    #[inline(always)]
290    pub fn endevoutnak(&self) -> ENDEVOUTNAK_R {
291        ENDEVOUTNAK_R::new(((self.bits >> 13) & 0x01) != 0)
292    }
293    #[doc = "Bit 14"]
294    #[inline(always)]
295    pub fn xcvrdly(&self) -> XCVRDLY_R { XCVRDLY_R::new(((self.bits >> 14) & 0x01) != 0) }
296    #[doc = "Bit 15"]
297    #[inline(always)]
298    pub fn erraticintmsk(&self) -> ERRATICINTMSK_R {
299        ERRATICINTMSK_R::new(((self.bits >> 15) & 0x01) != 0)
300    }
301    #[doc = "Bits 26:31 - Resume Validation Period"]
302    #[inline(always)]
303    pub fn resvalid(&self) -> RESVALID_R { RESVALID_R::new(((self.bits >> 26) & 0x3f) as u8) }
304}
305impl W {
306    #[doc = "Bits 0:1 - Device Speed"]
307    #[inline(always)]
308    pub fn devspd(&mut self) -> DEVSPD_W { DEVSPD_W { w: self } }
309    #[doc = "Bit 2 - Non-Zero-Length Status OUT Handshake"]
310    #[inline(always)]
311    pub fn nzstsouthshk(&mut self) -> NZSTSOUTHSHK_W { NZSTSOUTHSHK_W { w: self } }
312    #[doc = "Bit 3 - Enable 32 kHz Suspend Mode"]
313    #[inline(always)]
314    pub fn ena32khzsusp(&mut self) -> ENA32KHZSUSP_W { ENA32KHZSUSP_W { w: self } }
315    #[doc = "Bits 4:10 - Device Address"]
316    #[inline(always)]
317    pub fn devaddr(&mut self) -> DEVADDR_W { DEVADDR_W { w: self } }
318    #[doc = "Bits 11:12 - Periodic Frame Interval"]
319    #[inline(always)]
320    pub fn perfrint(&mut self) -> PERFRINT_W { PERFRINT_W { w: self } }
321    #[doc = "Bit 13 - Enable Device OUT NAK"]
322    #[inline(always)]
323    pub fn endevoutnak(&mut self) -> ENDEVOUTNAK_W { ENDEVOUTNAK_W { w: self } }
324    #[doc = "Bit 14"]
325    #[inline(always)]
326    pub fn xcvrdly(&mut self) -> XCVRDLY_W { XCVRDLY_W { w: self } }
327    #[doc = "Bit 15"]
328    #[inline(always)]
329    pub fn erraticintmsk(&mut self) -> ERRATICINTMSK_W { ERRATICINTMSK_W { w: self } }
330    #[doc = "Bits 26:31 - Resume Validation Period"]
331    #[inline(always)]
332    pub fn resvalid(&mut self) -> RESVALID_W { RESVALID_W { w: self } }
333}