efm32gg12b410_pac/usb/
hprt.rs1#[doc = "Register `HPRT` reader"]
2pub struct R(crate::R<HPRT_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<HPRT_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<HPRT_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<HPRT_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `HPRT` writer"]
17pub struct W(crate::W<HPRT_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<HPRT_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<HPRT_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<HPRT_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `PRTCONNSTS` reader - Port Connect Status"]
38pub type PRTCONNSTS_R = crate::BitReader<bool>;
39#[doc = "Field `PRTCONNDET` reader - Port Connect Detected"]
40pub type PRTCONNDET_R = crate::BitReader<bool>;
41#[doc = "Field `PRTCONNDET` writer - Port Connect Detected"]
42pub type PRTCONNDET_W<'a> = crate::BitWriter<'a, u32, HPRT_SPEC, bool, 1>;
43#[doc = "Field `PRTENA` reader - Port Enable"]
44pub type PRTENA_R = crate::BitReader<bool>;
45#[doc = "Field `PRTENA` writer - Port Enable"]
46pub type PRTENA_W<'a> = crate::BitWriter<'a, u32, HPRT_SPEC, bool, 2>;
47#[doc = "Field `PRTENCHNG` reader - Port Enable/Disable Change"]
48pub type PRTENCHNG_R = crate::BitReader<bool>;
49#[doc = "Field `PRTENCHNG` writer - Port Enable/Disable Change"]
50pub type PRTENCHNG_W<'a> = crate::BitWriter<'a, u32, HPRT_SPEC, bool, 3>;
51#[doc = "Field `PRTOVRCURRACT` reader - Port Overcurrent Active"]
52pub type PRTOVRCURRACT_R = crate::BitReader<bool>;
53#[doc = "Field `PRTOVRCURRCHNG` reader - Port Overcurrent Change"]
54pub type PRTOVRCURRCHNG_R = crate::BitReader<bool>;
55#[doc = "Field `PRTOVRCURRCHNG` writer - Port Overcurrent Change"]
56pub type PRTOVRCURRCHNG_W<'a> = crate::BitWriter<'a, u32, HPRT_SPEC, bool, 5>;
57#[doc = "Field `PRTRES` reader - Port Resume"]
58pub type PRTRES_R = crate::BitReader<bool>;
59#[doc = "Field `PRTRES` writer - Port Resume"]
60pub type PRTRES_W<'a> = crate::BitWriter<'a, u32, HPRT_SPEC, bool, 6>;
61#[doc = "Field `PRTSUSP` reader - Port Suspend"]
62pub type PRTSUSP_R = crate::BitReader<bool>;
63#[doc = "Field `PRTSUSP` writer - Port Suspend"]
64pub type PRTSUSP_W<'a> = crate::BitWriter<'a, u32, HPRT_SPEC, bool, 7>;
65#[doc = "Field `PRTRST` reader - Port Reset"]
66pub type PRTRST_R = crate::BitReader<bool>;
67#[doc = "Field `PRTRST` writer - Port Reset"]
68pub type PRTRST_W<'a> = crate::BitWriter<'a, u32, HPRT_SPEC, bool, 8>;
69#[doc = "Field `PRTLNSTS` reader - Port Line Status"]
70pub type PRTLNSTS_R = crate::FieldReader<u8, u8>;
71#[doc = "Field `PRTPWR` reader - Port Power"]
72pub type PRTPWR_R = crate::BitReader<bool>;
73#[doc = "Field `PRTPWR` writer - Port Power"]
74pub type PRTPWR_W<'a> = crate::BitWriter<'a, u32, HPRT_SPEC, bool, 12>;
75#[doc = "Port Test Control\n\nValue on reset: 0"]
76#[derive(Clone, Copy, Debug, PartialEq)]
77#[repr(u8)]
78pub enum PRTTSTCTL_A {
79 #[doc = "0: Test mode disabled."]
80 DISABLE = 0,
81 #[doc = "1: Test_J mode."]
82 J = 1,
83 #[doc = "2: Test_K mode."]
84 K = 2,
85 #[doc = "3: Test_SE0_NAK mode."]
86 SE0NAK = 3,
87 #[doc = "4: Test_Packet mode."]
88 PACKET = 4,
89 #[doc = "5: Test_Force_Enable."]
90 FORCE = 5,
91}
92impl From<PRTTSTCTL_A> for u8 {
93 #[inline(always)]
94 fn from(variant: PRTTSTCTL_A) -> Self {
95 variant as _
96 }
97}
98#[doc = "Field `PRTTSTCTL` reader - Port Test Control"]
99pub type PRTTSTCTL_R = crate::FieldReader<u8, PRTTSTCTL_A>;
100impl PRTTSTCTL_R {
101 #[doc = "Get enumerated values variant"]
102 #[inline(always)]
103 pub fn variant(&self) -> Option<PRTTSTCTL_A> {
104 match self.bits {
105 0 => Some(PRTTSTCTL_A::DISABLE),
106 1 => Some(PRTTSTCTL_A::J),
107 2 => Some(PRTTSTCTL_A::K),
108 3 => Some(PRTTSTCTL_A::SE0NAK),
109 4 => Some(PRTTSTCTL_A::PACKET),
110 5 => Some(PRTTSTCTL_A::FORCE),
111 _ => None,
112 }
113 }
114 #[doc = "Checks if the value of the field is `DISABLE`"]
115 #[inline(always)]
116 pub fn is_disable(&self) -> bool {
117 *self == PRTTSTCTL_A::DISABLE
118 }
119 #[doc = "Checks if the value of the field is `J`"]
120 #[inline(always)]
121 pub fn is_j(&self) -> bool {
122 *self == PRTTSTCTL_A::J
123 }
124 #[doc = "Checks if the value of the field is `K`"]
125 #[inline(always)]
126 pub fn is_k(&self) -> bool {
127 *self == PRTTSTCTL_A::K
128 }
129 #[doc = "Checks if the value of the field is `SE0NAK`"]
130 #[inline(always)]
131 pub fn is_se0nak(&self) -> bool {
132 *self == PRTTSTCTL_A::SE0NAK
133 }
134 #[doc = "Checks if the value of the field is `PACKET`"]
135 #[inline(always)]
136 pub fn is_packet(&self) -> bool {
137 *self == PRTTSTCTL_A::PACKET
138 }
139 #[doc = "Checks if the value of the field is `FORCE`"]
140 #[inline(always)]
141 pub fn is_force(&self) -> bool {
142 *self == PRTTSTCTL_A::FORCE
143 }
144}
145#[doc = "Field `PRTTSTCTL` writer - Port Test Control"]
146pub type PRTTSTCTL_W<'a> = crate::FieldWriter<'a, u32, HPRT_SPEC, u8, PRTTSTCTL_A, 4, 13>;
147impl<'a> PRTTSTCTL_W<'a> {
148 #[doc = "Test mode disabled."]
149 #[inline(always)]
150 pub fn disable(self) -> &'a mut W {
151 self.variant(PRTTSTCTL_A::DISABLE)
152 }
153 #[doc = "Test_J mode."]
154 #[inline(always)]
155 pub fn j(self) -> &'a mut W {
156 self.variant(PRTTSTCTL_A::J)
157 }
158 #[doc = "Test_K mode."]
159 #[inline(always)]
160 pub fn k(self) -> &'a mut W {
161 self.variant(PRTTSTCTL_A::K)
162 }
163 #[doc = "Test_SE0_NAK mode."]
164 #[inline(always)]
165 pub fn se0nak(self) -> &'a mut W {
166 self.variant(PRTTSTCTL_A::SE0NAK)
167 }
168 #[doc = "Test_Packet mode."]
169 #[inline(always)]
170 pub fn packet(self) -> &'a mut W {
171 self.variant(PRTTSTCTL_A::PACKET)
172 }
173 #[doc = "Test_Force_Enable."]
174 #[inline(always)]
175 pub fn force(self) -> &'a mut W {
176 self.variant(PRTTSTCTL_A::FORCE)
177 }
178}
179#[doc = "Port Speed\n\nValue on reset: 0"]
180#[derive(Clone, Copy, Debug, PartialEq)]
181#[repr(u8)]
182pub enum PRTSPD_A {
183 #[doc = "1: Full speed."]
184 FS = 1,
185 #[doc = "2: Low speed."]
186 LS = 2,
187}
188impl From<PRTSPD_A> for u8 {
189 #[inline(always)]
190 fn from(variant: PRTSPD_A) -> Self {
191 variant as _
192 }
193}
194#[doc = "Field `PRTSPD` reader - Port Speed"]
195pub type PRTSPD_R = crate::FieldReader<u8, PRTSPD_A>;
196impl PRTSPD_R {
197 #[doc = "Get enumerated values variant"]
198 #[inline(always)]
199 pub fn variant(&self) -> Option<PRTSPD_A> {
200 match self.bits {
201 1 => Some(PRTSPD_A::FS),
202 2 => Some(PRTSPD_A::LS),
203 _ => None,
204 }
205 }
206 #[doc = "Checks if the value of the field is `FS`"]
207 #[inline(always)]
208 pub fn is_fs(&self) -> bool {
209 *self == PRTSPD_A::FS
210 }
211 #[doc = "Checks if the value of the field is `LS`"]
212 #[inline(always)]
213 pub fn is_ls(&self) -> bool {
214 *self == PRTSPD_A::LS
215 }
216}
217impl R {
218 #[doc = "Bit 0 - Port Connect Status"]
219 #[inline(always)]
220 pub fn prtconnsts(&self) -> PRTCONNSTS_R {
221 PRTCONNSTS_R::new((self.bits & 1) != 0)
222 }
223 #[doc = "Bit 1 - Port Connect Detected"]
224 #[inline(always)]
225 pub fn prtconndet(&self) -> PRTCONNDET_R {
226 PRTCONNDET_R::new(((self.bits >> 1) & 1) != 0)
227 }
228 #[doc = "Bit 2 - Port Enable"]
229 #[inline(always)]
230 pub fn prtena(&self) -> PRTENA_R {
231 PRTENA_R::new(((self.bits >> 2) & 1) != 0)
232 }
233 #[doc = "Bit 3 - Port Enable/Disable Change"]
234 #[inline(always)]
235 pub fn prtenchng(&self) -> PRTENCHNG_R {
236 PRTENCHNG_R::new(((self.bits >> 3) & 1) != 0)
237 }
238 #[doc = "Bit 4 - Port Overcurrent Active"]
239 #[inline(always)]
240 pub fn prtovrcurract(&self) -> PRTOVRCURRACT_R {
241 PRTOVRCURRACT_R::new(((self.bits >> 4) & 1) != 0)
242 }
243 #[doc = "Bit 5 - Port Overcurrent Change"]
244 #[inline(always)]
245 pub fn prtovrcurrchng(&self) -> PRTOVRCURRCHNG_R {
246 PRTOVRCURRCHNG_R::new(((self.bits >> 5) & 1) != 0)
247 }
248 #[doc = "Bit 6 - Port Resume"]
249 #[inline(always)]
250 pub fn prtres(&self) -> PRTRES_R {
251 PRTRES_R::new(((self.bits >> 6) & 1) != 0)
252 }
253 #[doc = "Bit 7 - Port Suspend"]
254 #[inline(always)]
255 pub fn prtsusp(&self) -> PRTSUSP_R {
256 PRTSUSP_R::new(((self.bits >> 7) & 1) != 0)
257 }
258 #[doc = "Bit 8 - Port Reset"]
259 #[inline(always)]
260 pub fn prtrst(&self) -> PRTRST_R {
261 PRTRST_R::new(((self.bits >> 8) & 1) != 0)
262 }
263 #[doc = "Bits 10:11 - Port Line Status"]
264 #[inline(always)]
265 pub fn prtlnsts(&self) -> PRTLNSTS_R {
266 PRTLNSTS_R::new(((self.bits >> 10) & 3) as u8)
267 }
268 #[doc = "Bit 12 - Port Power"]
269 #[inline(always)]
270 pub fn prtpwr(&self) -> PRTPWR_R {
271 PRTPWR_R::new(((self.bits >> 12) & 1) != 0)
272 }
273 #[doc = "Bits 13:16 - Port Test Control"]
274 #[inline(always)]
275 pub fn prttstctl(&self) -> PRTTSTCTL_R {
276 PRTTSTCTL_R::new(((self.bits >> 13) & 0x0f) as u8)
277 }
278 #[doc = "Bits 17:18 - Port Speed"]
279 #[inline(always)]
280 pub fn prtspd(&self) -> PRTSPD_R {
281 PRTSPD_R::new(((self.bits >> 17) & 3) as u8)
282 }
283}
284impl W {
285 #[doc = "Bit 1 - Port Connect Detected"]
286 #[inline(always)]
287 pub fn prtconndet(&mut self) -> PRTCONNDET_W {
288 PRTCONNDET_W::new(self)
289 }
290 #[doc = "Bit 2 - Port Enable"]
291 #[inline(always)]
292 pub fn prtena(&mut self) -> PRTENA_W {
293 PRTENA_W::new(self)
294 }
295 #[doc = "Bit 3 - Port Enable/Disable Change"]
296 #[inline(always)]
297 pub fn prtenchng(&mut self) -> PRTENCHNG_W {
298 PRTENCHNG_W::new(self)
299 }
300 #[doc = "Bit 5 - Port Overcurrent Change"]
301 #[inline(always)]
302 pub fn prtovrcurrchng(&mut self) -> PRTOVRCURRCHNG_W {
303 PRTOVRCURRCHNG_W::new(self)
304 }
305 #[doc = "Bit 6 - Port Resume"]
306 #[inline(always)]
307 pub fn prtres(&mut self) -> PRTRES_W {
308 PRTRES_W::new(self)
309 }
310 #[doc = "Bit 7 - Port Suspend"]
311 #[inline(always)]
312 pub fn prtsusp(&mut self) -> PRTSUSP_W {
313 PRTSUSP_W::new(self)
314 }
315 #[doc = "Bit 8 - Port Reset"]
316 #[inline(always)]
317 pub fn prtrst(&mut self) -> PRTRST_W {
318 PRTRST_W::new(self)
319 }
320 #[doc = "Bit 12 - Port Power"]
321 #[inline(always)]
322 pub fn prtpwr(&mut self) -> PRTPWR_W {
323 PRTPWR_W::new(self)
324 }
325 #[doc = "Bits 13:16 - Port Test Control"]
326 #[inline(always)]
327 pub fn prttstctl(&mut self) -> PRTTSTCTL_W {
328 PRTTSTCTL_W::new(self)
329 }
330 #[doc = "Writes raw bits to the register."]
331 #[inline(always)]
332 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
333 self.0.bits(bits);
334 self
335 }
336}
337#[doc = "Host Port Control and Status 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 [hprt](index.html) module"]
338pub struct HPRT_SPEC;
339impl crate::RegisterSpec for HPRT_SPEC {
340 type Ux = u32;
341}
342#[doc = "`read()` method returns [hprt::R](R) reader structure"]
343impl crate::Readable for HPRT_SPEC {
344 type Reader = R;
345}
346#[doc = "`write(|w| ..)` method takes [hprt::W](W) writer structure"]
347impl crate::Writable for HPRT_SPEC {
348 type Writer = W;
349}
350#[doc = "`reset()` method sets HPRT to value 0"]
351impl crate::Resettable for HPRT_SPEC {
352 #[inline(always)]
353 fn reset_value() -> Self::Ux {
354 0
355 }
356}