efm32gg12b810_pac/usb/
dcfg.rs1#[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 `ENDEVOUTNAK` reader - Enable Device OUT NAK"]
180pub type ENDEVOUTNAK_R = crate::BitReader<bool>;
181#[doc = "Field `ENDEVOUTNAK` writer - Enable Device OUT NAK"]
182pub type ENDEVOUTNAK_W<'a> = crate::BitWriter<'a, u32, DCFG_SPEC, bool, 13>;
183#[doc = "Field `XCVRDLY` reader - "]
184pub type XCVRDLY_R = crate::BitReader<bool>;
185#[doc = "Field `XCVRDLY` writer - "]
186pub type XCVRDLY_W<'a> = crate::BitWriter<'a, u32, DCFG_SPEC, bool, 14>;
187#[doc = "Field `ERRATICINTMSK` reader - "]
188pub type ERRATICINTMSK_R = crate::BitReader<bool>;
189#[doc = "Field `ERRATICINTMSK` writer - "]
190pub type ERRATICINTMSK_W<'a> = crate::BitWriter<'a, u32, DCFG_SPEC, bool, 15>;
191#[doc = "Field `RESVALID` reader - Resume Validation Period"]
192pub type RESVALID_R = crate::FieldReader<u8, u8>;
193#[doc = "Field `RESVALID` writer - Resume Validation Period"]
194pub type RESVALID_W<'a> = crate::FieldWriter<'a, u32, DCFG_SPEC, u8, u8, 6, 26>;
195impl R {
196 #[doc = "Bits 0:1 - Device Speed"]
197 #[inline(always)]
198 pub fn devspd(&self) -> DEVSPD_R {
199 DEVSPD_R::new((self.bits & 3) as u8)
200 }
201 #[doc = "Bit 2 - Non-Zero-Length Status OUT Handshake"]
202 #[inline(always)]
203 pub fn nzstsouthshk(&self) -> NZSTSOUTHSHK_R {
204 NZSTSOUTHSHK_R::new(((self.bits >> 2) & 1) != 0)
205 }
206 #[doc = "Bit 3 - Enable 32 kHz Suspend Mode"]
207 #[inline(always)]
208 pub fn ena32khzsusp(&self) -> ENA32KHZSUSP_R {
209 ENA32KHZSUSP_R::new(((self.bits >> 3) & 1) != 0)
210 }
211 #[doc = "Bits 4:10 - Device Address"]
212 #[inline(always)]
213 pub fn devaddr(&self) -> DEVADDR_R {
214 DEVADDR_R::new(((self.bits >> 4) & 0x7f) as u8)
215 }
216 #[doc = "Bits 11:12 - Periodic Frame Interval"]
217 #[inline(always)]
218 pub fn perfrint(&self) -> PERFRINT_R {
219 PERFRINT_R::new(((self.bits >> 11) & 3) as u8)
220 }
221 #[doc = "Bit 13 - Enable Device OUT NAK"]
222 #[inline(always)]
223 pub fn endevoutnak(&self) -> ENDEVOUTNAK_R {
224 ENDEVOUTNAK_R::new(((self.bits >> 13) & 1) != 0)
225 }
226 #[doc = "Bit 14"]
227 #[inline(always)]
228 pub fn xcvrdly(&self) -> XCVRDLY_R {
229 XCVRDLY_R::new(((self.bits >> 14) & 1) != 0)
230 }
231 #[doc = "Bit 15"]
232 #[inline(always)]
233 pub fn erraticintmsk(&self) -> ERRATICINTMSK_R {
234 ERRATICINTMSK_R::new(((self.bits >> 15) & 1) != 0)
235 }
236 #[doc = "Bits 26:31 - Resume Validation Period"]
237 #[inline(always)]
238 pub fn resvalid(&self) -> RESVALID_R {
239 RESVALID_R::new(((self.bits >> 26) & 0x3f) as u8)
240 }
241}
242impl W {
243 #[doc = "Bits 0:1 - Device Speed"]
244 #[inline(always)]
245 pub fn devspd(&mut self) -> DEVSPD_W {
246 DEVSPD_W::new(self)
247 }
248 #[doc = "Bit 2 - Non-Zero-Length Status OUT Handshake"]
249 #[inline(always)]
250 pub fn nzstsouthshk(&mut self) -> NZSTSOUTHSHK_W {
251 NZSTSOUTHSHK_W::new(self)
252 }
253 #[doc = "Bit 3 - Enable 32 kHz Suspend Mode"]
254 #[inline(always)]
255 pub fn ena32khzsusp(&mut self) -> ENA32KHZSUSP_W {
256 ENA32KHZSUSP_W::new(self)
257 }
258 #[doc = "Bits 4:10 - Device Address"]
259 #[inline(always)]
260 pub fn devaddr(&mut self) -> DEVADDR_W {
261 DEVADDR_W::new(self)
262 }
263 #[doc = "Bits 11:12 - Periodic Frame Interval"]
264 #[inline(always)]
265 pub fn perfrint(&mut self) -> PERFRINT_W {
266 PERFRINT_W::new(self)
267 }
268 #[doc = "Bit 13 - Enable Device OUT NAK"]
269 #[inline(always)]
270 pub fn endevoutnak(&mut self) -> ENDEVOUTNAK_W {
271 ENDEVOUTNAK_W::new(self)
272 }
273 #[doc = "Bit 14"]
274 #[inline(always)]
275 pub fn xcvrdly(&mut self) -> XCVRDLY_W {
276 XCVRDLY_W::new(self)
277 }
278 #[doc = "Bit 15"]
279 #[inline(always)]
280 pub fn erraticintmsk(&mut self) -> ERRATICINTMSK_W {
281 ERRATICINTMSK_W::new(self)
282 }
283 #[doc = "Bits 26:31 - Resume Validation Period"]
284 #[inline(always)]
285 pub fn resvalid(&mut self) -> RESVALID_W {
286 RESVALID_W::new(self)
287 }
288 #[doc = "Writes raw bits to the register."]
289 #[inline(always)]
290 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
291 self.0.bits(bits);
292 self
293 }
294}
295#[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"]
296pub struct DCFG_SPEC;
297impl crate::RegisterSpec for DCFG_SPEC {
298 type Ux = u32;
299}
300#[doc = "`read()` method returns [dcfg::R](R) reader structure"]
301impl crate::Readable for DCFG_SPEC {
302 type Reader = R;
303}
304#[doc = "`write(|w| ..)` method takes [dcfg::W](W) writer structure"]
305impl crate::Writable for DCFG_SPEC {
306 type Writer = W;
307}
308#[doc = "`reset()` method sets DCFG to value 0x0800_0000"]
309impl crate::Resettable for DCFG_SPEC {
310 #[inline(always)]
311 fn reset_value() -> Self::Ux {
312 0x0800_0000
313 }
314}