atsams70j21/usbhs/
usbhs_devctrl.rs1#[doc = "Register `USBHS_DEVCTRL` reader"]
2pub struct R(crate::R<USBHS_DEVCTRL_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<USBHS_DEVCTRL_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<USBHS_DEVCTRL_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<USBHS_DEVCTRL_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `USBHS_DEVCTRL` writer"]
17pub struct W(crate::W<USBHS_DEVCTRL_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<USBHS_DEVCTRL_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<USBHS_DEVCTRL_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<USBHS_DEVCTRL_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `UADD` reader - USB Address"]
38pub struct UADD_R(crate::FieldReader<u8, u8>);
39impl UADD_R {
40 #[inline(always)]
41 pub(crate) fn new(bits: u8) -> Self {
42 UADD_R(crate::FieldReader::new(bits))
43 }
44}
45impl core::ops::Deref for UADD_R {
46 type Target = crate::FieldReader<u8, u8>;
47 #[inline(always)]
48 fn deref(&self) -> &Self::Target {
49 &self.0
50 }
51}
52#[doc = "Field `UADD` writer - USB Address"]
53pub struct UADD_W<'a> {
54 w: &'a mut W,
55}
56impl<'a> UADD_W<'a> {
57 #[doc = r"Writes raw bits to the field"]
58 #[inline(always)]
59 pub unsafe fn bits(self, value: u8) -> &'a mut W {
60 self.w.bits = (self.w.bits & !0x7f) | (value as u32 & 0x7f);
61 self.w
62 }
63}
64#[doc = "Field `ADDEN` reader - Address Enable"]
65pub struct ADDEN_R(crate::FieldReader<bool, bool>);
66impl ADDEN_R {
67 #[inline(always)]
68 pub(crate) fn new(bits: bool) -> Self {
69 ADDEN_R(crate::FieldReader::new(bits))
70 }
71}
72impl core::ops::Deref for ADDEN_R {
73 type Target = crate::FieldReader<bool, bool>;
74 #[inline(always)]
75 fn deref(&self) -> &Self::Target {
76 &self.0
77 }
78}
79#[doc = "Field `ADDEN` writer - Address Enable"]
80pub struct ADDEN_W<'a> {
81 w: &'a mut W,
82}
83impl<'a> ADDEN_W<'a> {
84 #[doc = r"Sets the field bit"]
85 #[inline(always)]
86 pub fn set_bit(self) -> &'a mut W {
87 self.bit(true)
88 }
89 #[doc = r"Clears the field bit"]
90 #[inline(always)]
91 pub fn clear_bit(self) -> &'a mut W {
92 self.bit(false)
93 }
94 #[doc = r"Writes raw bits to the field"]
95 #[inline(always)]
96 pub fn bit(self, value: bool) -> &'a mut W {
97 self.w.bits = (self.w.bits & !(0x01 << 7)) | ((value as u32 & 0x01) << 7);
98 self.w
99 }
100}
101#[doc = "Field `DETACH` reader - Detach"]
102pub struct DETACH_R(crate::FieldReader<bool, bool>);
103impl DETACH_R {
104 #[inline(always)]
105 pub(crate) fn new(bits: bool) -> Self {
106 DETACH_R(crate::FieldReader::new(bits))
107 }
108}
109impl core::ops::Deref for DETACH_R {
110 type Target = crate::FieldReader<bool, bool>;
111 #[inline(always)]
112 fn deref(&self) -> &Self::Target {
113 &self.0
114 }
115}
116#[doc = "Field `DETACH` writer - Detach"]
117pub struct DETACH_W<'a> {
118 w: &'a mut W,
119}
120impl<'a> DETACH_W<'a> {
121 #[doc = r"Sets the field bit"]
122 #[inline(always)]
123 pub fn set_bit(self) -> &'a mut W {
124 self.bit(true)
125 }
126 #[doc = r"Clears the field bit"]
127 #[inline(always)]
128 pub fn clear_bit(self) -> &'a mut W {
129 self.bit(false)
130 }
131 #[doc = r"Writes raw bits to the field"]
132 #[inline(always)]
133 pub fn bit(self, value: bool) -> &'a mut W {
134 self.w.bits = (self.w.bits & !(0x01 << 8)) | ((value as u32 & 0x01) << 8);
135 self.w
136 }
137}
138#[doc = "Field `RMWKUP` reader - Remote Wake-Up"]
139pub struct RMWKUP_R(crate::FieldReader<bool, bool>);
140impl RMWKUP_R {
141 #[inline(always)]
142 pub(crate) fn new(bits: bool) -> Self {
143 RMWKUP_R(crate::FieldReader::new(bits))
144 }
145}
146impl core::ops::Deref for RMWKUP_R {
147 type Target = crate::FieldReader<bool, bool>;
148 #[inline(always)]
149 fn deref(&self) -> &Self::Target {
150 &self.0
151 }
152}
153#[doc = "Field `RMWKUP` writer - Remote Wake-Up"]
154pub struct RMWKUP_W<'a> {
155 w: &'a mut W,
156}
157impl<'a> RMWKUP_W<'a> {
158 #[doc = r"Sets the field bit"]
159 #[inline(always)]
160 pub fn set_bit(self) -> &'a mut W {
161 self.bit(true)
162 }
163 #[doc = r"Clears the field bit"]
164 #[inline(always)]
165 pub fn clear_bit(self) -> &'a mut W {
166 self.bit(false)
167 }
168 #[doc = r"Writes raw bits to the field"]
169 #[inline(always)]
170 pub fn bit(self, value: bool) -> &'a mut W {
171 self.w.bits = (self.w.bits & !(0x01 << 9)) | ((value as u32 & 0x01) << 9);
172 self.w
173 }
174}
175#[doc = "Mode Configuration\n\nValue on reset: 0"]
176#[derive(Clone, Copy, Debug, PartialEq)]
177#[repr(u8)]
178pub enum SPDCONF_A {
179 #[doc = "0: The peripheral starts in Full-speed mode and performs a high-speed reset to switch to High-speed mode if the host is high-speed-capable."]
180 NORMAL = 0,
181 #[doc = "1: For a better consumption, if high speed is not needed."]
182 LOW_POWER = 1,
183}
184impl From<SPDCONF_A> for u8 {
185 #[inline(always)]
186 fn from(variant: SPDCONF_A) -> Self {
187 variant as _
188 }
189}
190#[doc = "Field `SPDCONF` reader - Mode Configuration"]
191pub struct SPDCONF_R(crate::FieldReader<u8, SPDCONF_A>);
192impl SPDCONF_R {
193 #[inline(always)]
194 pub(crate) fn new(bits: u8) -> Self {
195 SPDCONF_R(crate::FieldReader::new(bits))
196 }
197 #[doc = r"Get enumerated values variant"]
198 #[inline(always)]
199 pub fn variant(&self) -> Option<SPDCONF_A> {
200 match self.bits {
201 0 => Some(SPDCONF_A::NORMAL),
202 1 => Some(SPDCONF_A::LOW_POWER),
203 _ => None,
204 }
205 }
206 #[doc = "Checks if the value of the field is `NORMAL`"]
207 #[inline(always)]
208 pub fn is_normal(&self) -> bool {
209 **self == SPDCONF_A::NORMAL
210 }
211 #[doc = "Checks if the value of the field is `LOW_POWER`"]
212 #[inline(always)]
213 pub fn is_low_power(&self) -> bool {
214 **self == SPDCONF_A::LOW_POWER
215 }
216}
217impl core::ops::Deref for SPDCONF_R {
218 type Target = crate::FieldReader<u8, SPDCONF_A>;
219 #[inline(always)]
220 fn deref(&self) -> &Self::Target {
221 &self.0
222 }
223}
224#[doc = "Field `SPDCONF` writer - Mode Configuration"]
225pub struct SPDCONF_W<'a> {
226 w: &'a mut W,
227}
228impl<'a> SPDCONF_W<'a> {
229 #[doc = r"Writes `variant` to the field"]
230 #[inline(always)]
231 pub fn variant(self, variant: SPDCONF_A) -> &'a mut W {
232 unsafe { self.bits(variant.into()) }
233 }
234 #[doc = "The peripheral starts in Full-speed mode and performs a high-speed reset to switch to High-speed mode if the host is high-speed-capable."]
235 #[inline(always)]
236 pub fn normal(self) -> &'a mut W {
237 self.variant(SPDCONF_A::NORMAL)
238 }
239 #[doc = "For a better consumption, if high speed is not needed."]
240 #[inline(always)]
241 pub fn low_power(self) -> &'a mut W {
242 self.variant(SPDCONF_A::LOW_POWER)
243 }
244 #[doc = r"Writes raw bits to the field"]
245 #[inline(always)]
246 pub unsafe fn bits(self, value: u8) -> &'a mut W {
247 self.w.bits = (self.w.bits & !(0x03 << 10)) | ((value as u32 & 0x03) << 10);
248 self.w
249 }
250}
251#[doc = "Field `LS` reader - Low-Speed Mode Force"]
252pub struct LS_R(crate::FieldReader<bool, bool>);
253impl LS_R {
254 #[inline(always)]
255 pub(crate) fn new(bits: bool) -> Self {
256 LS_R(crate::FieldReader::new(bits))
257 }
258}
259impl core::ops::Deref for LS_R {
260 type Target = crate::FieldReader<bool, bool>;
261 #[inline(always)]
262 fn deref(&self) -> &Self::Target {
263 &self.0
264 }
265}
266#[doc = "Field `LS` writer - Low-Speed Mode Force"]
267pub struct LS_W<'a> {
268 w: &'a mut W,
269}
270impl<'a> LS_W<'a> {
271 #[doc = r"Sets the field bit"]
272 #[inline(always)]
273 pub fn set_bit(self) -> &'a mut W {
274 self.bit(true)
275 }
276 #[doc = r"Clears the field bit"]
277 #[inline(always)]
278 pub fn clear_bit(self) -> &'a mut W {
279 self.bit(false)
280 }
281 #[doc = r"Writes raw bits to the field"]
282 #[inline(always)]
283 pub fn bit(self, value: bool) -> &'a mut W {
284 self.w.bits = (self.w.bits & !(0x01 << 12)) | ((value as u32 & 0x01) << 12);
285 self.w
286 }
287}
288#[doc = "Field `TSTJ` reader - Test mode J"]
289pub struct TSTJ_R(crate::FieldReader<bool, bool>);
290impl TSTJ_R {
291 #[inline(always)]
292 pub(crate) fn new(bits: bool) -> Self {
293 TSTJ_R(crate::FieldReader::new(bits))
294 }
295}
296impl core::ops::Deref for TSTJ_R {
297 type Target = crate::FieldReader<bool, bool>;
298 #[inline(always)]
299 fn deref(&self) -> &Self::Target {
300 &self.0
301 }
302}
303#[doc = "Field `TSTJ` writer - Test mode J"]
304pub struct TSTJ_W<'a> {
305 w: &'a mut W,
306}
307impl<'a> TSTJ_W<'a> {
308 #[doc = r"Sets the field bit"]
309 #[inline(always)]
310 pub fn set_bit(self) -> &'a mut W {
311 self.bit(true)
312 }
313 #[doc = r"Clears the field bit"]
314 #[inline(always)]
315 pub fn clear_bit(self) -> &'a mut W {
316 self.bit(false)
317 }
318 #[doc = r"Writes raw bits to the field"]
319 #[inline(always)]
320 pub fn bit(self, value: bool) -> &'a mut W {
321 self.w.bits = (self.w.bits & !(0x01 << 13)) | ((value as u32 & 0x01) << 13);
322 self.w
323 }
324}
325#[doc = "Field `TSTK` reader - Test mode K"]
326pub struct TSTK_R(crate::FieldReader<bool, bool>);
327impl TSTK_R {
328 #[inline(always)]
329 pub(crate) fn new(bits: bool) -> Self {
330 TSTK_R(crate::FieldReader::new(bits))
331 }
332}
333impl core::ops::Deref for TSTK_R {
334 type Target = crate::FieldReader<bool, bool>;
335 #[inline(always)]
336 fn deref(&self) -> &Self::Target {
337 &self.0
338 }
339}
340#[doc = "Field `TSTK` writer - Test mode K"]
341pub struct TSTK_W<'a> {
342 w: &'a mut W,
343}
344impl<'a> TSTK_W<'a> {
345 #[doc = r"Sets the field bit"]
346 #[inline(always)]
347 pub fn set_bit(self) -> &'a mut W {
348 self.bit(true)
349 }
350 #[doc = r"Clears the field bit"]
351 #[inline(always)]
352 pub fn clear_bit(self) -> &'a mut W {
353 self.bit(false)
354 }
355 #[doc = r"Writes raw bits to the field"]
356 #[inline(always)]
357 pub fn bit(self, value: bool) -> &'a mut W {
358 self.w.bits = (self.w.bits & !(0x01 << 14)) | ((value as u32 & 0x01) << 14);
359 self.w
360 }
361}
362#[doc = "Field `TSTPCKT` reader - Test packet mode"]
363pub struct TSTPCKT_R(crate::FieldReader<bool, bool>);
364impl TSTPCKT_R {
365 #[inline(always)]
366 pub(crate) fn new(bits: bool) -> Self {
367 TSTPCKT_R(crate::FieldReader::new(bits))
368 }
369}
370impl core::ops::Deref for TSTPCKT_R {
371 type Target = crate::FieldReader<bool, bool>;
372 #[inline(always)]
373 fn deref(&self) -> &Self::Target {
374 &self.0
375 }
376}
377#[doc = "Field `TSTPCKT` writer - Test packet mode"]
378pub struct TSTPCKT_W<'a> {
379 w: &'a mut W,
380}
381impl<'a> TSTPCKT_W<'a> {
382 #[doc = r"Sets the field bit"]
383 #[inline(always)]
384 pub fn set_bit(self) -> &'a mut W {
385 self.bit(true)
386 }
387 #[doc = r"Clears the field bit"]
388 #[inline(always)]
389 pub fn clear_bit(self) -> &'a mut W {
390 self.bit(false)
391 }
392 #[doc = r"Writes raw bits to the field"]
393 #[inline(always)]
394 pub fn bit(self, value: bool) -> &'a mut W {
395 self.w.bits = (self.w.bits & !(0x01 << 15)) | ((value as u32 & 0x01) << 15);
396 self.w
397 }
398}
399#[doc = "Field `OPMODE2` reader - Specific Operational mode"]
400pub struct OPMODE2_R(crate::FieldReader<bool, bool>);
401impl OPMODE2_R {
402 #[inline(always)]
403 pub(crate) fn new(bits: bool) -> Self {
404 OPMODE2_R(crate::FieldReader::new(bits))
405 }
406}
407impl core::ops::Deref for OPMODE2_R {
408 type Target = crate::FieldReader<bool, bool>;
409 #[inline(always)]
410 fn deref(&self) -> &Self::Target {
411 &self.0
412 }
413}
414#[doc = "Field `OPMODE2` writer - Specific Operational mode"]
415pub struct OPMODE2_W<'a> {
416 w: &'a mut W,
417}
418impl<'a> OPMODE2_W<'a> {
419 #[doc = r"Sets the field bit"]
420 #[inline(always)]
421 pub fn set_bit(self) -> &'a mut W {
422 self.bit(true)
423 }
424 #[doc = r"Clears the field bit"]
425 #[inline(always)]
426 pub fn clear_bit(self) -> &'a mut W {
427 self.bit(false)
428 }
429 #[doc = r"Writes raw bits to the field"]
430 #[inline(always)]
431 pub fn bit(self, value: bool) -> &'a mut W {
432 self.w.bits = (self.w.bits & !(0x01 << 16)) | ((value as u32 & 0x01) << 16);
433 self.w
434 }
435}
436impl R {
437 #[doc = "Bits 0:6 - USB Address"]
438 #[inline(always)]
439 pub fn uadd(&self) -> UADD_R {
440 UADD_R::new((self.bits & 0x7f) as u8)
441 }
442 #[doc = "Bit 7 - Address Enable"]
443 #[inline(always)]
444 pub fn adden(&self) -> ADDEN_R {
445 ADDEN_R::new(((self.bits >> 7) & 0x01) != 0)
446 }
447 #[doc = "Bit 8 - Detach"]
448 #[inline(always)]
449 pub fn detach(&self) -> DETACH_R {
450 DETACH_R::new(((self.bits >> 8) & 0x01) != 0)
451 }
452 #[doc = "Bit 9 - Remote Wake-Up"]
453 #[inline(always)]
454 pub fn rmwkup(&self) -> RMWKUP_R {
455 RMWKUP_R::new(((self.bits >> 9) & 0x01) != 0)
456 }
457 #[doc = "Bits 10:11 - Mode Configuration"]
458 #[inline(always)]
459 pub fn spdconf(&self) -> SPDCONF_R {
460 SPDCONF_R::new(((self.bits >> 10) & 0x03) as u8)
461 }
462 #[doc = "Bit 12 - Low-Speed Mode Force"]
463 #[inline(always)]
464 pub fn ls(&self) -> LS_R {
465 LS_R::new(((self.bits >> 12) & 0x01) != 0)
466 }
467 #[doc = "Bit 13 - Test mode J"]
468 #[inline(always)]
469 pub fn tstj(&self) -> TSTJ_R {
470 TSTJ_R::new(((self.bits >> 13) & 0x01) != 0)
471 }
472 #[doc = "Bit 14 - Test mode K"]
473 #[inline(always)]
474 pub fn tstk(&self) -> TSTK_R {
475 TSTK_R::new(((self.bits >> 14) & 0x01) != 0)
476 }
477 #[doc = "Bit 15 - Test packet mode"]
478 #[inline(always)]
479 pub fn tstpckt(&self) -> TSTPCKT_R {
480 TSTPCKT_R::new(((self.bits >> 15) & 0x01) != 0)
481 }
482 #[doc = "Bit 16 - Specific Operational mode"]
483 #[inline(always)]
484 pub fn opmode2(&self) -> OPMODE2_R {
485 OPMODE2_R::new(((self.bits >> 16) & 0x01) != 0)
486 }
487}
488impl W {
489 #[doc = "Bits 0:6 - USB Address"]
490 #[inline(always)]
491 pub fn uadd(&mut self) -> UADD_W {
492 UADD_W { w: self }
493 }
494 #[doc = "Bit 7 - Address Enable"]
495 #[inline(always)]
496 pub fn adden(&mut self) -> ADDEN_W {
497 ADDEN_W { w: self }
498 }
499 #[doc = "Bit 8 - Detach"]
500 #[inline(always)]
501 pub fn detach(&mut self) -> DETACH_W {
502 DETACH_W { w: self }
503 }
504 #[doc = "Bit 9 - Remote Wake-Up"]
505 #[inline(always)]
506 pub fn rmwkup(&mut self) -> RMWKUP_W {
507 RMWKUP_W { w: self }
508 }
509 #[doc = "Bits 10:11 - Mode Configuration"]
510 #[inline(always)]
511 pub fn spdconf(&mut self) -> SPDCONF_W {
512 SPDCONF_W { w: self }
513 }
514 #[doc = "Bit 12 - Low-Speed Mode Force"]
515 #[inline(always)]
516 pub fn ls(&mut self) -> LS_W {
517 LS_W { w: self }
518 }
519 #[doc = "Bit 13 - Test mode J"]
520 #[inline(always)]
521 pub fn tstj(&mut self) -> TSTJ_W {
522 TSTJ_W { w: self }
523 }
524 #[doc = "Bit 14 - Test mode K"]
525 #[inline(always)]
526 pub fn tstk(&mut self) -> TSTK_W {
527 TSTK_W { w: self }
528 }
529 #[doc = "Bit 15 - Test packet mode"]
530 #[inline(always)]
531 pub fn tstpckt(&mut self) -> TSTPCKT_W {
532 TSTPCKT_W { w: self }
533 }
534 #[doc = "Bit 16 - Specific Operational mode"]
535 #[inline(always)]
536 pub fn opmode2(&mut self) -> OPMODE2_W {
537 OPMODE2_W { w: self }
538 }
539 #[doc = "Writes raw bits to the register."]
540 #[inline(always)]
541 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
542 self.0.bits(bits);
543 self
544 }
545}
546#[doc = "Device General Control 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 [usbhs_devctrl](index.html) module"]
547pub struct USBHS_DEVCTRL_SPEC;
548impl crate::RegisterSpec for USBHS_DEVCTRL_SPEC {
549 type Ux = u32;
550}
551#[doc = "`read()` method returns [usbhs_devctrl::R](R) reader structure"]
552impl crate::Readable for USBHS_DEVCTRL_SPEC {
553 type Reader = R;
554}
555#[doc = "`write(|w| ..)` method takes [usbhs_devctrl::W](W) writer structure"]
556impl crate::Writable for USBHS_DEVCTRL_SPEC {
557 type Writer = W;
558}
559#[doc = "`reset()` method sets USBHS_DEVCTRL to value 0"]
560impl crate::Resettable for USBHS_DEVCTRL_SPEC {
561 #[inline(always)]
562 fn reset_value() -> Self::Ux {
563 0
564 }
565}