1#[doc = "Register `USBADDR` reader"]
2pub struct R(crate::R<USBADDR_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<USBADDR_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<USBADDR_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<USBADDR_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `USBADDR` writer"]
17pub struct W(crate::W<USBADDR_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<USBADDR_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<USBADDR_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<USBADDR_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `USBADDR` reader - USB AddressWhen the function controller is selected, these bits indicate the USB address assigned by the host when the SET_ADDRESS request is successfully processed."]
38pub type USBADDR_R = crate::FieldReader<u8, u8>;
39#[doc = "Field `USBADDR` writer - USB AddressWhen the function controller is selected, these bits indicate the USB address assigned by the host when the SET_ADDRESS request is successfully processed."]
40pub type USBADDR_W<'a, const O: u8> = crate::FieldWriter<'a, u16, USBADDR_SPEC, u8, u8, 7, O>;
41#[doc = "Field `STSRECOV` reader - Status Recovery"]
42pub type STSRECOV_R = crate::FieldReader<u8, STSRECOV_A>;
43#[doc = "Status Recovery\n\nValue on reset: 0"]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45#[repr(u8)]
46pub enum STSRECOV_A {
47 #[doc = "4: Return to the low-speed state (bits DVSTCTR0.RHST\\[2:0\\]
48= 001b;(Recovery when the host controller is selected))"]
49 _0100 = 4,
50 #[doc = "8: Return to the full-speed state (bits DVSTCTR0.RHST\\[2:0\\]
51= 010b;(Recovery when the host controller is selected))"]
52 _1000 = 8,
53 #[doc = "9: Return to the full-speed state (bits DVSTCTR0.RHST\\[2:0\\]
54= 010b), bits INTSTS0.DVSQ\\[2:0\\]
55= 001b (Default state);(Recovery when the function controller is selected)"]
56 _1001 = 9,
57 #[doc = "10: Return to the full-speed state (bits DVSTCTR0.RHST\\[2:0\\]
58= 010b), bits INTSTS0.DVSQ\\[2:0\\]
59= 010b (Address state);(Recovery when the function controller is selected)"]
60 _1010 = 10,
61 #[doc = "11: Return to the full-speed state (bits DVSTCTR0.RHST\\[2:0\\]
62= 010b), bits INTSTS0.DVSQ\\[2:0\\]
63= 011b (Configured state);(Recovery when the function controller is selected)"]
64 _1011 = 11,
65}
66impl From<STSRECOV_A> for u8 {
67 #[inline(always)]
68 fn from(variant: STSRECOV_A) -> Self {
69 variant as _
70 }
71}
72impl STSRECOV_R {
73 #[doc = "Get enumerated values variant"]
74 #[inline(always)]
75 pub fn variant(&self) -> Option<STSRECOV_A> {
76 match self.bits {
77 4 => Some(STSRECOV_A::_0100),
78 8 => Some(STSRECOV_A::_1000),
79 9 => Some(STSRECOV_A::_1001),
80 10 => Some(STSRECOV_A::_1010),
81 11 => Some(STSRECOV_A::_1011),
82 _ => None,
83 }
84 }
85 #[doc = "Checks if the value of the field is `_0100`"]
86 #[inline(always)]
87 pub fn is_0100(&self) -> bool {
88 *self == STSRECOV_A::_0100
89 }
90 #[doc = "Checks if the value of the field is `_1000`"]
91 #[inline(always)]
92 pub fn is_1000(&self) -> bool {
93 *self == STSRECOV_A::_1000
94 }
95 #[doc = "Checks if the value of the field is `_1001`"]
96 #[inline(always)]
97 pub fn is_1001(&self) -> bool {
98 *self == STSRECOV_A::_1001
99 }
100 #[doc = "Checks if the value of the field is `_1010`"]
101 #[inline(always)]
102 pub fn is_1010(&self) -> bool {
103 *self == STSRECOV_A::_1010
104 }
105 #[doc = "Checks if the value of the field is `_1011`"]
106 #[inline(always)]
107 pub fn is_1011(&self) -> bool {
108 *self == STSRECOV_A::_1011
109 }
110}
111#[doc = "Field `STSRECOV` writer - Status Recovery"]
112pub type STSRECOV_W<'a, const O: u8> =
113 crate::FieldWriter<'a, u16, USBADDR_SPEC, u8, STSRECOV_A, 4, O>;
114impl<'a, const O: u8> STSRECOV_W<'a, O> {
115 #[doc = "Return to the low-speed state (bits DVSTCTR0.RHST\\[2:0\\]
116= 001b;(Recovery when the host controller is selected))"]
117 #[inline(always)]
118 pub fn _0100(self) -> &'a mut W {
119 self.variant(STSRECOV_A::_0100)
120 }
121 #[doc = "Return to the full-speed state (bits DVSTCTR0.RHST\\[2:0\\]
122= 010b;(Recovery when the host controller is selected))"]
123 #[inline(always)]
124 pub fn _1000(self) -> &'a mut W {
125 self.variant(STSRECOV_A::_1000)
126 }
127 #[doc = "Return to the full-speed state (bits DVSTCTR0.RHST\\[2:0\\]
128= 010b), bits INTSTS0.DVSQ\\[2:0\\]
129= 001b (Default state);(Recovery when the function controller is selected)"]
130 #[inline(always)]
131 pub fn _1001(self) -> &'a mut W {
132 self.variant(STSRECOV_A::_1001)
133 }
134 #[doc = "Return to the full-speed state (bits DVSTCTR0.RHST\\[2:0\\]
135= 010b), bits INTSTS0.DVSQ\\[2:0\\]
136= 010b (Address state);(Recovery when the function controller is selected)"]
137 #[inline(always)]
138 pub fn _1010(self) -> &'a mut W {
139 self.variant(STSRECOV_A::_1010)
140 }
141 #[doc = "Return to the full-speed state (bits DVSTCTR0.RHST\\[2:0\\]
142= 010b), bits INTSTS0.DVSQ\\[2:0\\]
143= 011b (Configured state);(Recovery when the function controller is selected)"]
144 #[inline(always)]
145 pub fn _1011(self) -> &'a mut W {
146 self.variant(STSRECOV_A::_1011)
147 }
148}
149impl R {
150 #[doc = "Bits 0:6 - USB AddressWhen the function controller is selected, these bits indicate the USB address assigned by the host when the SET_ADDRESS request is successfully processed."]
151 #[inline(always)]
152 pub fn usbaddr(&self) -> USBADDR_R {
153 USBADDR_R::new((self.bits & 0x7f) as u8)
154 }
155 #[doc = "Bits 8:11 - Status Recovery"]
156 #[inline(always)]
157 pub fn stsrecov(&self) -> STSRECOV_R {
158 STSRECOV_R::new(((self.bits >> 8) & 0x0f) as u8)
159 }
160}
161impl W {
162 #[doc = "Bits 0:6 - USB AddressWhen the function controller is selected, these bits indicate the USB address assigned by the host when the SET_ADDRESS request is successfully processed."]
163 #[inline(always)]
164 #[must_use]
165 pub fn usbaddr(&mut self) -> USBADDR_W<0> {
166 USBADDR_W::new(self)
167 }
168 #[doc = "Bits 8:11 - Status Recovery"]
169 #[inline(always)]
170 #[must_use]
171 pub fn stsrecov(&mut self) -> STSRECOV_W<8> {
172 STSRECOV_W::new(self)
173 }
174 #[doc = "Writes raw bits to the register."]
175 #[inline(always)]
176 pub unsafe fn bits(&mut self, bits: u16) -> &mut Self {
177 self.0.bits(bits);
178 self
179 }
180}
181#[doc = "USB Address 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 [usbaddr](index.html) module"]
182pub struct USBADDR_SPEC;
183impl crate::RegisterSpec for USBADDR_SPEC {
184 type Ux = u16;
185}
186#[doc = "`read()` method returns [usbaddr::R](R) reader structure"]
187impl crate::Readable for USBADDR_SPEC {
188 type Reader = R;
189}
190#[doc = "`write(|w| ..)` method takes [usbaddr::W](W) writer structure"]
191impl crate::Writable for USBADDR_SPEC {
192 type Writer = W;
193 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
194 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
195}
196#[doc = "`reset()` method sets USBADDR to value 0"]
197impl crate::Resettable for USBADDR_SPEC {
198 const RESET_VALUE: Self::Ux = 0;
199}