efm32hg310_pac/usb/
dcfg.rs

1#[doc = "Register `DCFG` reader"]
2pub struct R(crate::R<DCFG_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<DCFG_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<DCFG_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<DCFG_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `DCFG` writer"]
17pub struct W(crate::W<DCFG_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<DCFG_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<DCFG_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<DCFG_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Device Speed\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum DEVSPD_A {
41    #[doc = "2: Low speed (PHY clock is 6 MHz). If you select 6 MHz LS mode, you must do a soft reset."]
42    LS = 2,
43    #[doc = "3: Full speed (PHY clock is 48 MHz)."]
44    FS = 3,
45}
46impl From<DEVSPD_A> for u8 {
47    #[inline(always)]
48    fn from(variant: DEVSPD_A) -> Self {
49        variant as _
50    }
51}
52#[doc = "Field `DEVSPD` reader - Device Speed"]
53pub type DEVSPD_R = crate::FieldReader<u8, DEVSPD_A>;
54impl DEVSPD_R {
55    #[doc = "Get enumerated values variant"]
56    #[inline(always)]
57    pub fn variant(&self) -> Option<DEVSPD_A> {
58        match self.bits {
59            2 => Some(DEVSPD_A::LS),
60            3 => Some(DEVSPD_A::FS),
61            _ => None,
62        }
63    }
64    #[doc = "Checks if the value of the field is `LS`"]
65    #[inline(always)]
66    pub fn is_ls(&self) -> bool {
67        *self == DEVSPD_A::LS
68    }
69    #[doc = "Checks if the value of the field is `FS`"]
70    #[inline(always)]
71    pub fn is_fs(&self) -> bool {
72        *self == DEVSPD_A::FS
73    }
74}
75#[doc = "Field `DEVSPD` writer - Device Speed"]
76pub type DEVSPD_W<'a> = crate::FieldWriter<'a, u32, DCFG_SPEC, u8, DEVSPD_A, 2, 0>;
77impl<'a> DEVSPD_W<'a> {
78    #[doc = "Low speed (PHY clock is 6 MHz). If you select 6 MHz LS mode, you must do a soft reset."]
79    #[inline(always)]
80    pub fn ls(self) -> &'a mut W {
81        self.variant(DEVSPD_A::LS)
82    }
83    #[doc = "Full speed (PHY clock is 48 MHz)."]
84    #[inline(always)]
85    pub fn fs(self) -> &'a mut W {
86        self.variant(DEVSPD_A::FS)
87    }
88}
89#[doc = "Field `NZSTSOUTHSHK` reader - Non-Zero-Length Status OUT Handshake"]
90pub type NZSTSOUTHSHK_R = crate::BitReader<bool>;
91#[doc = "Field `NZSTSOUTHSHK` writer - Non-Zero-Length Status OUT Handshake"]
92pub type NZSTSOUTHSHK_W<'a> = crate::BitWriter<'a, u32, DCFG_SPEC, bool, 2>;
93#[doc = "Field `ENA32KHZSUSP` reader - Enable 32 KHz Suspend mode"]
94pub type ENA32KHZSUSP_R = crate::BitReader<bool>;
95#[doc = "Field `ENA32KHZSUSP` writer - Enable 32 KHz Suspend mode"]
96pub type ENA32KHZSUSP_W<'a> = crate::BitWriter<'a, u32, DCFG_SPEC, bool, 3>;
97#[doc = "Field `DEVADDR` reader - Device Address"]
98pub type DEVADDR_R = crate::FieldReader<u8, u8>;
99#[doc = "Field `DEVADDR` writer - Device Address"]
100pub type DEVADDR_W<'a> = crate::FieldWriter<'a, u32, DCFG_SPEC, u8, u8, 7, 4>;
101#[doc = "Periodic Frame Interval\n\nValue on reset: 0"]
102#[derive(Clone, Copy, Debug, PartialEq)]
103#[repr(u8)]
104pub enum PERFRINT_A {
105    #[doc = "0: 80% of the frame interval."]
106    _80PCNT = 0,
107    #[doc = "1: 85% of the frame interval."]
108    _85PCNT = 1,
109    #[doc = "2: 90% of the frame interval."]
110    _90PCNT = 2,
111    #[doc = "3: 95% of the frame interval."]
112    _95PCNT = 3,
113}
114impl From<PERFRINT_A> for u8 {
115    #[inline(always)]
116    fn from(variant: PERFRINT_A) -> Self {
117        variant as _
118    }
119}
120#[doc = "Field `PERFRINT` reader - Periodic Frame Interval"]
121pub type PERFRINT_R = crate::FieldReader<u8, PERFRINT_A>;
122impl PERFRINT_R {
123    #[doc = "Get enumerated values variant"]
124    #[inline(always)]
125    pub fn variant(&self) -> PERFRINT_A {
126        match self.bits {
127            0 => PERFRINT_A::_80PCNT,
128            1 => PERFRINT_A::_85PCNT,
129            2 => PERFRINT_A::_90PCNT,
130            3 => PERFRINT_A::_95PCNT,
131            _ => unreachable!(),
132        }
133    }
134    #[doc = "Checks if the value of the field is `_80PCNT`"]
135    #[inline(always)]
136    pub fn is_80pcnt(&self) -> bool {
137        *self == PERFRINT_A::_80PCNT
138    }
139    #[doc = "Checks if the value of the field is `_85PCNT`"]
140    #[inline(always)]
141    pub fn is_85pcnt(&self) -> bool {
142        *self == PERFRINT_A::_85PCNT
143    }
144    #[doc = "Checks if the value of the field is `_90PCNT`"]
145    #[inline(always)]
146    pub fn is_90pcnt(&self) -> bool {
147        *self == PERFRINT_A::_90PCNT
148    }
149    #[doc = "Checks if the value of the field is `_95PCNT`"]
150    #[inline(always)]
151    pub fn is_95pcnt(&self) -> bool {
152        *self == PERFRINT_A::_95PCNT
153    }
154}
155#[doc = "Field `PERFRINT` writer - Periodic Frame Interval"]
156pub type PERFRINT_W<'a> = crate::FieldWriterSafe<'a, u32, DCFG_SPEC, u8, PERFRINT_A, 2, 11>;
157impl<'a> PERFRINT_W<'a> {
158    #[doc = "80% of the frame interval."]
159    #[inline(always)]
160    pub fn _80pcnt(self) -> &'a mut W {
161        self.variant(PERFRINT_A::_80PCNT)
162    }
163    #[doc = "85% of the frame interval."]
164    #[inline(always)]
165    pub fn _85pcnt(self) -> &'a mut W {
166        self.variant(PERFRINT_A::_85PCNT)
167    }
168    #[doc = "90% of the frame interval."]
169    #[inline(always)]
170    pub fn _90pcnt(self) -> &'a mut W {
171        self.variant(PERFRINT_A::_90PCNT)
172    }
173    #[doc = "95% of the frame interval."]
174    #[inline(always)]
175    pub fn _95pcnt(self) -> &'a mut W {
176        self.variant(PERFRINT_A::_95PCNT)
177    }
178}
179#[doc = "Field `ERRATICINTMSK` reader - "]
180pub type ERRATICINTMSK_R = crate::BitReader<bool>;
181#[doc = "Field `ERRATICINTMSK` writer - "]
182pub type ERRATICINTMSK_W<'a> = crate::BitWriter<'a, u32, DCFG_SPEC, bool, 15>;
183#[doc = "Field `RESVALID` reader - Resume Validation Period"]
184pub type RESVALID_R = crate::FieldReader<u8, u8>;
185#[doc = "Field `RESVALID` writer - Resume Validation Period"]
186pub type RESVALID_W<'a> = crate::FieldWriter<'a, u32, DCFG_SPEC, u8, u8, 6, 26>;
187impl R {
188    #[doc = "Bits 0:1 - Device Speed"]
189    #[inline(always)]
190    pub fn devspd(&self) -> DEVSPD_R {
191        DEVSPD_R::new((self.bits & 3) as u8)
192    }
193    #[doc = "Bit 2 - Non-Zero-Length Status OUT Handshake"]
194    #[inline(always)]
195    pub fn nzstsouthshk(&self) -> NZSTSOUTHSHK_R {
196        NZSTSOUTHSHK_R::new(((self.bits >> 2) & 1) != 0)
197    }
198    #[doc = "Bit 3 - Enable 32 KHz Suspend mode"]
199    #[inline(always)]
200    pub fn ena32khzsusp(&self) -> ENA32KHZSUSP_R {
201        ENA32KHZSUSP_R::new(((self.bits >> 3) & 1) != 0)
202    }
203    #[doc = "Bits 4:10 - Device Address"]
204    #[inline(always)]
205    pub fn devaddr(&self) -> DEVADDR_R {
206        DEVADDR_R::new(((self.bits >> 4) & 0x7f) as u8)
207    }
208    #[doc = "Bits 11:12 - Periodic Frame Interval"]
209    #[inline(always)]
210    pub fn perfrint(&self) -> PERFRINT_R {
211        PERFRINT_R::new(((self.bits >> 11) & 3) as u8)
212    }
213    #[doc = "Bit 15"]
214    #[inline(always)]
215    pub fn erraticintmsk(&self) -> ERRATICINTMSK_R {
216        ERRATICINTMSK_R::new(((self.bits >> 15) & 1) != 0)
217    }
218    #[doc = "Bits 26:31 - Resume Validation Period"]
219    #[inline(always)]
220    pub fn resvalid(&self) -> RESVALID_R {
221        RESVALID_R::new(((self.bits >> 26) & 0x3f) as u8)
222    }
223}
224impl W {
225    #[doc = "Bits 0:1 - Device Speed"]
226    #[inline(always)]
227    pub fn devspd(&mut self) -> DEVSPD_W {
228        DEVSPD_W::new(self)
229    }
230    #[doc = "Bit 2 - Non-Zero-Length Status OUT Handshake"]
231    #[inline(always)]
232    pub fn nzstsouthshk(&mut self) -> NZSTSOUTHSHK_W {
233        NZSTSOUTHSHK_W::new(self)
234    }
235    #[doc = "Bit 3 - Enable 32 KHz Suspend mode"]
236    #[inline(always)]
237    pub fn ena32khzsusp(&mut self) -> ENA32KHZSUSP_W {
238        ENA32KHZSUSP_W::new(self)
239    }
240    #[doc = "Bits 4:10 - Device Address"]
241    #[inline(always)]
242    pub fn devaddr(&mut self) -> DEVADDR_W {
243        DEVADDR_W::new(self)
244    }
245    #[doc = "Bits 11:12 - Periodic Frame Interval"]
246    #[inline(always)]
247    pub fn perfrint(&mut self) -> PERFRINT_W {
248        PERFRINT_W::new(self)
249    }
250    #[doc = "Bit 15"]
251    #[inline(always)]
252    pub fn erraticintmsk(&mut self) -> ERRATICINTMSK_W {
253        ERRATICINTMSK_W::new(self)
254    }
255    #[doc = "Bits 26:31 - Resume Validation Period"]
256    #[inline(always)]
257    pub fn resvalid(&mut self) -> RESVALID_W {
258        RESVALID_W::new(self)
259    }
260    #[doc = "Writes raw bits to the register."]
261    #[inline(always)]
262    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
263        self.0.bits(bits);
264        self
265    }
266}
267#[doc = "Device Configuration Register\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dcfg](index.html) module"]
268pub struct DCFG_SPEC;
269impl crate::RegisterSpec for DCFG_SPEC {
270    type Ux = u32;
271}
272#[doc = "`read()` method returns [dcfg::R](R) reader structure"]
273impl crate::Readable for DCFG_SPEC {
274    type Reader = R;
275}
276#[doc = "`write(|w| ..)` method takes [dcfg::W](W) writer structure"]
277impl crate::Writable for DCFG_SPEC {
278    type Writer = W;
279}
280#[doc = "`reset()` method sets DCFG to value 0x0800_0000"]
281impl crate::Resettable for DCFG_SPEC {
282    #[inline(always)]
283    fn reset_value() -> Self::Ux {
284        0x0800_0000
285    }
286}