atsamd51g19a/usb/device/
ctrlb.rs1#[doc = "Reader of register CTRLB"]
2pub type R = crate::R<u16, super::CTRLB>;
3#[doc = "Writer for register CTRLB"]
4pub type W = crate::W<u16, super::CTRLB>;
5#[doc = "Register CTRLB `reset()`'s with value 0x01"]
6impl crate::ResetValue for super::CTRLB {
7 type Type = u16;
8 #[inline(always)]
9 fn reset_value() -> Self::Type {
10 0x01
11 }
12}
13#[doc = "Reader of field `DETACH`"]
14pub type DETACH_R = crate::R<bool, bool>;
15#[doc = "Write proxy for field `DETACH`"]
16pub struct DETACH_W<'a> {
17 w: &'a mut W,
18}
19impl<'a> DETACH_W<'a> {
20 #[doc = r"Sets the field bit"]
21 #[inline(always)]
22 pub fn set_bit(self) -> &'a mut W {
23 self.bit(true)
24 }
25 #[doc = r"Clears the field bit"]
26 #[inline(always)]
27 pub fn clear_bit(self) -> &'a mut W {
28 self.bit(false)
29 }
30 #[doc = r"Writes raw bits to the field"]
31 #[inline(always)]
32 pub fn bit(self, value: bool) -> &'a mut W {
33 self.w.bits = (self.w.bits & !0x01) | ((value as u16) & 0x01);
34 self.w
35 }
36}
37#[doc = "Reader of field `UPRSM`"]
38pub type UPRSM_R = crate::R<bool, bool>;
39#[doc = "Write proxy for field `UPRSM`"]
40pub struct UPRSM_W<'a> {
41 w: &'a mut W,
42}
43impl<'a> UPRSM_W<'a> {
44 #[doc = r"Sets the field bit"]
45 #[inline(always)]
46 pub fn set_bit(self) -> &'a mut W {
47 self.bit(true)
48 }
49 #[doc = r"Clears the field bit"]
50 #[inline(always)]
51 pub fn clear_bit(self) -> &'a mut W {
52 self.bit(false)
53 }
54 #[doc = r"Writes raw bits to the field"]
55 #[inline(always)]
56 pub fn bit(self, value: bool) -> &'a mut W {
57 self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u16) & 0x01) << 1);
58 self.w
59 }
60}
61#[doc = "Speed Configuration\n\nValue on reset: 0"]
62#[derive(Clone, Copy, Debug, PartialEq)]
63#[repr(u8)]
64pub enum SPDCONF_A {
65 #[doc = "0: FS : Full Speed"]
66 FS = 0,
67 #[doc = "1: LS : Low Speed"]
68 LS = 1,
69 #[doc = "2: HS : High Speed capable"]
70 HS = 2,
71 #[doc = "3: HSTM: High Speed Test Mode (force high-speed mode for test mode)"]
72 HSTM = 3,
73}
74impl From<SPDCONF_A> for u8 {
75 #[inline(always)]
76 fn from(variant: SPDCONF_A) -> Self {
77 variant as _
78 }
79}
80#[doc = "Reader of field `SPDCONF`"]
81pub type SPDCONF_R = crate::R<u8, SPDCONF_A>;
82impl SPDCONF_R {
83 #[doc = r"Get enumerated values variant"]
84 #[inline(always)]
85 pub fn variant(&self) -> SPDCONF_A {
86 match self.bits {
87 0 => SPDCONF_A::FS,
88 1 => SPDCONF_A::LS,
89 2 => SPDCONF_A::HS,
90 3 => SPDCONF_A::HSTM,
91 _ => unreachable!(),
92 }
93 }
94 #[doc = "Checks if the value of the field is `FS`"]
95 #[inline(always)]
96 pub fn is_fs(&self) -> bool {
97 *self == SPDCONF_A::FS
98 }
99 #[doc = "Checks if the value of the field is `LS`"]
100 #[inline(always)]
101 pub fn is_ls(&self) -> bool {
102 *self == SPDCONF_A::LS
103 }
104 #[doc = "Checks if the value of the field is `HS`"]
105 #[inline(always)]
106 pub fn is_hs(&self) -> bool {
107 *self == SPDCONF_A::HS
108 }
109 #[doc = "Checks if the value of the field is `HSTM`"]
110 #[inline(always)]
111 pub fn is_hstm(&self) -> bool {
112 *self == SPDCONF_A::HSTM
113 }
114}
115#[doc = "Write proxy for field `SPDCONF`"]
116pub struct SPDCONF_W<'a> {
117 w: &'a mut W,
118}
119impl<'a> SPDCONF_W<'a> {
120 #[doc = r"Writes `variant` to the field"]
121 #[inline(always)]
122 pub fn variant(self, variant: SPDCONF_A) -> &'a mut W {
123 {
124 self.bits(variant.into())
125 }
126 }
127 #[doc = "FS : Full Speed"]
128 #[inline(always)]
129 pub fn fs(self) -> &'a mut W {
130 self.variant(SPDCONF_A::FS)
131 }
132 #[doc = "LS : Low Speed"]
133 #[inline(always)]
134 pub fn ls(self) -> &'a mut W {
135 self.variant(SPDCONF_A::LS)
136 }
137 #[doc = "HS : High Speed capable"]
138 #[inline(always)]
139 pub fn hs(self) -> &'a mut W {
140 self.variant(SPDCONF_A::HS)
141 }
142 #[doc = "HSTM: High Speed Test Mode (force high-speed mode for test mode)"]
143 #[inline(always)]
144 pub fn hstm(self) -> &'a mut W {
145 self.variant(SPDCONF_A::HSTM)
146 }
147 #[doc = r"Writes raw bits to the field"]
148 #[inline(always)]
149 pub fn bits(self, value: u8) -> &'a mut W {
150 self.w.bits = (self.w.bits & !(0x03 << 2)) | (((value as u16) & 0x03) << 2);
151 self.w
152 }
153}
154#[doc = "Reader of field `NREPLY`"]
155pub type NREPLY_R = crate::R<bool, bool>;
156#[doc = "Write proxy for field `NREPLY`"]
157pub struct NREPLY_W<'a> {
158 w: &'a mut W,
159}
160impl<'a> NREPLY_W<'a> {
161 #[doc = r"Sets the field bit"]
162 #[inline(always)]
163 pub fn set_bit(self) -> &'a mut W {
164 self.bit(true)
165 }
166 #[doc = r"Clears the field bit"]
167 #[inline(always)]
168 pub fn clear_bit(self) -> &'a mut W {
169 self.bit(false)
170 }
171 #[doc = r"Writes raw bits to the field"]
172 #[inline(always)]
173 pub fn bit(self, value: bool) -> &'a mut W {
174 self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u16) & 0x01) << 4);
175 self.w
176 }
177}
178#[doc = "Reader of field `TSTJ`"]
179pub type TSTJ_R = crate::R<bool, bool>;
180#[doc = "Write proxy for field `TSTJ`"]
181pub struct TSTJ_W<'a> {
182 w: &'a mut W,
183}
184impl<'a> TSTJ_W<'a> {
185 #[doc = r"Sets the field bit"]
186 #[inline(always)]
187 pub fn set_bit(self) -> &'a mut W {
188 self.bit(true)
189 }
190 #[doc = r"Clears the field bit"]
191 #[inline(always)]
192 pub fn clear_bit(self) -> &'a mut W {
193 self.bit(false)
194 }
195 #[doc = r"Writes raw bits to the field"]
196 #[inline(always)]
197 pub fn bit(self, value: bool) -> &'a mut W {
198 self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u16) & 0x01) << 5);
199 self.w
200 }
201}
202#[doc = "Reader of field `TSTK`"]
203pub type TSTK_R = crate::R<bool, bool>;
204#[doc = "Write proxy for field `TSTK`"]
205pub struct TSTK_W<'a> {
206 w: &'a mut W,
207}
208impl<'a> TSTK_W<'a> {
209 #[doc = r"Sets the field bit"]
210 #[inline(always)]
211 pub fn set_bit(self) -> &'a mut W {
212 self.bit(true)
213 }
214 #[doc = r"Clears the field bit"]
215 #[inline(always)]
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(always)]
221 pub fn bit(self, value: bool) -> &'a mut W {
222 self.w.bits = (self.w.bits & !(0x01 << 6)) | (((value as u16) & 0x01) << 6);
223 self.w
224 }
225}
226#[doc = "Reader of field `TSTPCKT`"]
227pub type TSTPCKT_R = crate::R<bool, bool>;
228#[doc = "Write proxy for field `TSTPCKT`"]
229pub struct TSTPCKT_W<'a> {
230 w: &'a mut W,
231}
232impl<'a> TSTPCKT_W<'a> {
233 #[doc = r"Sets the field bit"]
234 #[inline(always)]
235 pub fn set_bit(self) -> &'a mut W {
236 self.bit(true)
237 }
238 #[doc = r"Clears the field bit"]
239 #[inline(always)]
240 pub fn clear_bit(self) -> &'a mut W {
241 self.bit(false)
242 }
243 #[doc = r"Writes raw bits to the field"]
244 #[inline(always)]
245 pub fn bit(self, value: bool) -> &'a mut W {
246 self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u16) & 0x01) << 7);
247 self.w
248 }
249}
250#[doc = "Reader of field `OPMODE2`"]
251pub type OPMODE2_R = crate::R<bool, bool>;
252#[doc = "Write proxy for field `OPMODE2`"]
253pub struct OPMODE2_W<'a> {
254 w: &'a mut W,
255}
256impl<'a> OPMODE2_W<'a> {
257 #[doc = r"Sets the field bit"]
258 #[inline(always)]
259 pub fn set_bit(self) -> &'a mut W {
260 self.bit(true)
261 }
262 #[doc = r"Clears the field bit"]
263 #[inline(always)]
264 pub fn clear_bit(self) -> &'a mut W {
265 self.bit(false)
266 }
267 #[doc = r"Writes raw bits to the field"]
268 #[inline(always)]
269 pub fn bit(self, value: bool) -> &'a mut W {
270 self.w.bits = (self.w.bits & !(0x01 << 8)) | (((value as u16) & 0x01) << 8);
271 self.w
272 }
273}
274#[doc = "Reader of field `GNAK`"]
275pub type GNAK_R = crate::R<bool, bool>;
276#[doc = "Write proxy for field `GNAK`"]
277pub struct GNAK_W<'a> {
278 w: &'a mut W,
279}
280impl<'a> GNAK_W<'a> {
281 #[doc = r"Sets the field bit"]
282 #[inline(always)]
283 pub fn set_bit(self) -> &'a mut W {
284 self.bit(true)
285 }
286 #[doc = r"Clears the field bit"]
287 #[inline(always)]
288 pub fn clear_bit(self) -> &'a mut W {
289 self.bit(false)
290 }
291 #[doc = r"Writes raw bits to the field"]
292 #[inline(always)]
293 pub fn bit(self, value: bool) -> &'a mut W {
294 self.w.bits = (self.w.bits & !(0x01 << 9)) | (((value as u16) & 0x01) << 9);
295 self.w
296 }
297}
298#[doc = "Link Power Management Handshake\n\nValue on reset: 0"]
299#[derive(Clone, Copy, Debug, PartialEq)]
300#[repr(u8)]
301pub enum LPMHDSK_A {
302 #[doc = "0: No handshake. LPM is not supported"]
303 NO = 0,
304 #[doc = "1: ACK"]
305 ACK = 1,
306 #[doc = "2: NYET"]
307 NYET = 2,
308 #[doc = "3: STALL"]
309 STALL = 3,
310}
311impl From<LPMHDSK_A> for u8 {
312 #[inline(always)]
313 fn from(variant: LPMHDSK_A) -> Self {
314 variant as _
315 }
316}
317#[doc = "Reader of field `LPMHDSK`"]
318pub type LPMHDSK_R = crate::R<u8, LPMHDSK_A>;
319impl LPMHDSK_R {
320 #[doc = r"Get enumerated values variant"]
321 #[inline(always)]
322 pub fn variant(&self) -> LPMHDSK_A {
323 match self.bits {
324 0 => LPMHDSK_A::NO,
325 1 => LPMHDSK_A::ACK,
326 2 => LPMHDSK_A::NYET,
327 3 => LPMHDSK_A::STALL,
328 _ => unreachable!(),
329 }
330 }
331 #[doc = "Checks if the value of the field is `NO`"]
332 #[inline(always)]
333 pub fn is_no(&self) -> bool {
334 *self == LPMHDSK_A::NO
335 }
336 #[doc = "Checks if the value of the field is `ACK`"]
337 #[inline(always)]
338 pub fn is_ack(&self) -> bool {
339 *self == LPMHDSK_A::ACK
340 }
341 #[doc = "Checks if the value of the field is `NYET`"]
342 #[inline(always)]
343 pub fn is_nyet(&self) -> bool {
344 *self == LPMHDSK_A::NYET
345 }
346 #[doc = "Checks if the value of the field is `STALL`"]
347 #[inline(always)]
348 pub fn is_stall(&self) -> bool {
349 *self == LPMHDSK_A::STALL
350 }
351}
352#[doc = "Write proxy for field `LPMHDSK`"]
353pub struct LPMHDSK_W<'a> {
354 w: &'a mut W,
355}
356impl<'a> LPMHDSK_W<'a> {
357 #[doc = r"Writes `variant` to the field"]
358 #[inline(always)]
359 pub fn variant(self, variant: LPMHDSK_A) -> &'a mut W {
360 {
361 self.bits(variant.into())
362 }
363 }
364 #[doc = "No handshake. LPM is not supported"]
365 #[inline(always)]
366 pub fn no(self) -> &'a mut W {
367 self.variant(LPMHDSK_A::NO)
368 }
369 #[doc = "ACK"]
370 #[inline(always)]
371 pub fn ack(self) -> &'a mut W {
372 self.variant(LPMHDSK_A::ACK)
373 }
374 #[doc = "NYET"]
375 #[inline(always)]
376 pub fn nyet(self) -> &'a mut W {
377 self.variant(LPMHDSK_A::NYET)
378 }
379 #[doc = "STALL"]
380 #[inline(always)]
381 pub fn stall(self) -> &'a mut W {
382 self.variant(LPMHDSK_A::STALL)
383 }
384 #[doc = r"Writes raw bits to the field"]
385 #[inline(always)]
386 pub fn bits(self, value: u8) -> &'a mut W {
387 self.w.bits = (self.w.bits & !(0x03 << 10)) | (((value as u16) & 0x03) << 10);
388 self.w
389 }
390}
391impl R {
392 #[doc = "Bit 0 - Detach"]
393 #[inline(always)]
394 pub fn detach(&self) -> DETACH_R {
395 DETACH_R::new((self.bits & 0x01) != 0)
396 }
397 #[doc = "Bit 1 - Upstream Resume"]
398 #[inline(always)]
399 pub fn uprsm(&self) -> UPRSM_R {
400 UPRSM_R::new(((self.bits >> 1) & 0x01) != 0)
401 }
402 #[doc = "Bits 2:3 - Speed Configuration"]
403 #[inline(always)]
404 pub fn spdconf(&self) -> SPDCONF_R {
405 SPDCONF_R::new(((self.bits >> 2) & 0x03) as u8)
406 }
407 #[doc = "Bit 4 - No Reply"]
408 #[inline(always)]
409 pub fn nreply(&self) -> NREPLY_R {
410 NREPLY_R::new(((self.bits >> 4) & 0x01) != 0)
411 }
412 #[doc = "Bit 5 - Test mode J"]
413 #[inline(always)]
414 pub fn tstj(&self) -> TSTJ_R {
415 TSTJ_R::new(((self.bits >> 5) & 0x01) != 0)
416 }
417 #[doc = "Bit 6 - Test mode K"]
418 #[inline(always)]
419 pub fn tstk(&self) -> TSTK_R {
420 TSTK_R::new(((self.bits >> 6) & 0x01) != 0)
421 }
422 #[doc = "Bit 7 - Test packet mode"]
423 #[inline(always)]
424 pub fn tstpckt(&self) -> TSTPCKT_R {
425 TSTPCKT_R::new(((self.bits >> 7) & 0x01) != 0)
426 }
427 #[doc = "Bit 8 - Specific Operational Mode"]
428 #[inline(always)]
429 pub fn opmode2(&self) -> OPMODE2_R {
430 OPMODE2_R::new(((self.bits >> 8) & 0x01) != 0)
431 }
432 #[doc = "Bit 9 - Global NAK"]
433 #[inline(always)]
434 pub fn gnak(&self) -> GNAK_R {
435 GNAK_R::new(((self.bits >> 9) & 0x01) != 0)
436 }
437 #[doc = "Bits 10:11 - Link Power Management Handshake"]
438 #[inline(always)]
439 pub fn lpmhdsk(&self) -> LPMHDSK_R {
440 LPMHDSK_R::new(((self.bits >> 10) & 0x03) as u8)
441 }
442}
443impl W {
444 #[doc = "Bit 0 - Detach"]
445 #[inline(always)]
446 pub fn detach(&mut self) -> DETACH_W {
447 DETACH_W { w: self }
448 }
449 #[doc = "Bit 1 - Upstream Resume"]
450 #[inline(always)]
451 pub fn uprsm(&mut self) -> UPRSM_W {
452 UPRSM_W { w: self }
453 }
454 #[doc = "Bits 2:3 - Speed Configuration"]
455 #[inline(always)]
456 pub fn spdconf(&mut self) -> SPDCONF_W {
457 SPDCONF_W { w: self }
458 }
459 #[doc = "Bit 4 - No Reply"]
460 #[inline(always)]
461 pub fn nreply(&mut self) -> NREPLY_W {
462 NREPLY_W { w: self }
463 }
464 #[doc = "Bit 5 - Test mode J"]
465 #[inline(always)]
466 pub fn tstj(&mut self) -> TSTJ_W {
467 TSTJ_W { w: self }
468 }
469 #[doc = "Bit 6 - Test mode K"]
470 #[inline(always)]
471 pub fn tstk(&mut self) -> TSTK_W {
472 TSTK_W { w: self }
473 }
474 #[doc = "Bit 7 - Test packet mode"]
475 #[inline(always)]
476 pub fn tstpckt(&mut self) -> TSTPCKT_W {
477 TSTPCKT_W { w: self }
478 }
479 #[doc = "Bit 8 - Specific Operational Mode"]
480 #[inline(always)]
481 pub fn opmode2(&mut self) -> OPMODE2_W {
482 OPMODE2_W { w: self }
483 }
484 #[doc = "Bit 9 - Global NAK"]
485 #[inline(always)]
486 pub fn gnak(&mut self) -> GNAK_W {
487 GNAK_W { w: self }
488 }
489 #[doc = "Bits 10:11 - Link Power Management Handshake"]
490 #[inline(always)]
491 pub fn lpmhdsk(&mut self) -> LPMHDSK_W {
492 LPMHDSK_W { w: self }
493 }
494}