atsams70q20/usbhs/
usbhs_ctrl.rs1#[doc = "Register `USBHS_CTRL` reader"]
2pub struct R(crate::R<USBHS_CTRL_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<USBHS_CTRL_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<USBHS_CTRL_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<USBHS_CTRL_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `USBHS_CTRL` writer"]
17pub struct W(crate::W<USBHS_CTRL_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<USBHS_CTRL_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_CTRL_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<USBHS_CTRL_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `RDERRE` reader - Remote Device Connection Error Interrupt Enable"]
38pub struct RDERRE_R(crate::FieldReader<bool, bool>);
39impl RDERRE_R {
40 #[inline(always)]
41 pub(crate) fn new(bits: bool) -> Self {
42 RDERRE_R(crate::FieldReader::new(bits))
43 }
44}
45impl core::ops::Deref for RDERRE_R {
46 type Target = crate::FieldReader<bool, bool>;
47 #[inline(always)]
48 fn deref(&self) -> &Self::Target {
49 &self.0
50 }
51}
52#[doc = "Field `RDERRE` writer - Remote Device Connection Error Interrupt Enable"]
53pub struct RDERRE_W<'a> {
54 w: &'a mut W,
55}
56impl<'a> RDERRE_W<'a> {
57 #[doc = r"Sets the field bit"]
58 #[inline(always)]
59 pub fn set_bit(self) -> &'a mut W {
60 self.bit(true)
61 }
62 #[doc = r"Clears the field bit"]
63 #[inline(always)]
64 pub fn clear_bit(self) -> &'a mut W {
65 self.bit(false)
66 }
67 #[doc = r"Writes raw bits to the field"]
68 #[inline(always)]
69 pub fn bit(self, value: bool) -> &'a mut W {
70 self.w.bits = (self.w.bits & !(0x01 << 4)) | ((value as u32 & 0x01) << 4);
71 self.w
72 }
73}
74#[doc = "Field `VBUSHWC` reader - VBUS Hardware Control"]
75pub struct VBUSHWC_R(crate::FieldReader<bool, bool>);
76impl VBUSHWC_R {
77 #[inline(always)]
78 pub(crate) fn new(bits: bool) -> Self {
79 VBUSHWC_R(crate::FieldReader::new(bits))
80 }
81}
82impl core::ops::Deref for VBUSHWC_R {
83 type Target = crate::FieldReader<bool, bool>;
84 #[inline(always)]
85 fn deref(&self) -> &Self::Target {
86 &self.0
87 }
88}
89#[doc = "Field `VBUSHWC` writer - VBUS Hardware Control"]
90pub struct VBUSHWC_W<'a> {
91 w: &'a mut W,
92}
93impl<'a> VBUSHWC_W<'a> {
94 #[doc = r"Sets the field bit"]
95 #[inline(always)]
96 pub fn set_bit(self) -> &'a mut W {
97 self.bit(true)
98 }
99 #[doc = r"Clears the field bit"]
100 #[inline(always)]
101 pub fn clear_bit(self) -> &'a mut W {
102 self.bit(false)
103 }
104 #[doc = r"Writes raw bits to the field"]
105 #[inline(always)]
106 pub fn bit(self, value: bool) -> &'a mut W {
107 self.w.bits = (self.w.bits & !(0x01 << 8)) | ((value as u32 & 0x01) << 8);
108 self.w
109 }
110}
111#[doc = "Field `FRZCLK` reader - Freeze USB Clock"]
112pub struct FRZCLK_R(crate::FieldReader<bool, bool>);
113impl FRZCLK_R {
114 #[inline(always)]
115 pub(crate) fn new(bits: bool) -> Self {
116 FRZCLK_R(crate::FieldReader::new(bits))
117 }
118}
119impl core::ops::Deref for FRZCLK_R {
120 type Target = crate::FieldReader<bool, bool>;
121 #[inline(always)]
122 fn deref(&self) -> &Self::Target {
123 &self.0
124 }
125}
126#[doc = "Field `FRZCLK` writer - Freeze USB Clock"]
127pub struct FRZCLK_W<'a> {
128 w: &'a mut W,
129}
130impl<'a> FRZCLK_W<'a> {
131 #[doc = r"Sets the field bit"]
132 #[inline(always)]
133 pub fn set_bit(self) -> &'a mut W {
134 self.bit(true)
135 }
136 #[doc = r"Clears the field bit"]
137 #[inline(always)]
138 pub fn clear_bit(self) -> &'a mut W {
139 self.bit(false)
140 }
141 #[doc = r"Writes raw bits to the field"]
142 #[inline(always)]
143 pub fn bit(self, value: bool) -> &'a mut W {
144 self.w.bits = (self.w.bits & !(0x01 << 14)) | ((value as u32 & 0x01) << 14);
145 self.w
146 }
147}
148#[doc = "Field `USBE` reader - USBHS Enable"]
149pub struct USBE_R(crate::FieldReader<bool, bool>);
150impl USBE_R {
151 #[inline(always)]
152 pub(crate) fn new(bits: bool) -> Self {
153 USBE_R(crate::FieldReader::new(bits))
154 }
155}
156impl core::ops::Deref for USBE_R {
157 type Target = crate::FieldReader<bool, bool>;
158 #[inline(always)]
159 fn deref(&self) -> &Self::Target {
160 &self.0
161 }
162}
163#[doc = "Field `USBE` writer - USBHS Enable"]
164pub struct USBE_W<'a> {
165 w: &'a mut W,
166}
167impl<'a> USBE_W<'a> {
168 #[doc = r"Sets the field bit"]
169 #[inline(always)]
170 pub fn set_bit(self) -> &'a mut W {
171 self.bit(true)
172 }
173 #[doc = r"Clears the field bit"]
174 #[inline(always)]
175 pub fn clear_bit(self) -> &'a mut W {
176 self.bit(false)
177 }
178 #[doc = r"Writes raw bits to the field"]
179 #[inline(always)]
180 pub fn bit(self, value: bool) -> &'a mut W {
181 self.w.bits = (self.w.bits & !(0x01 << 15)) | ((value as u32 & 0x01) << 15);
182 self.w
183 }
184}
185#[doc = "USBHS Mode\n\nValue on reset: 0"]
186#[derive(Clone, Copy, Debug, PartialEq)]
187pub enum UIMOD_A {
188 #[doc = "0: The module is in USB Host mode."]
189 HOST = 0,
190 #[doc = "1: The module is in USB Device mode."]
191 DEVICE = 1,
192}
193impl From<UIMOD_A> for bool {
194 #[inline(always)]
195 fn from(variant: UIMOD_A) -> Self {
196 variant as u8 != 0
197 }
198}
199#[doc = "Field `UIMOD` reader - USBHS Mode"]
200pub struct UIMOD_R(crate::FieldReader<bool, UIMOD_A>);
201impl UIMOD_R {
202 #[inline(always)]
203 pub(crate) fn new(bits: bool) -> Self {
204 UIMOD_R(crate::FieldReader::new(bits))
205 }
206 #[doc = r"Get enumerated values variant"]
207 #[inline(always)]
208 pub fn variant(&self) -> UIMOD_A {
209 match self.bits {
210 false => UIMOD_A::HOST,
211 true => UIMOD_A::DEVICE,
212 }
213 }
214 #[doc = "Checks if the value of the field is `HOST`"]
215 #[inline(always)]
216 pub fn is_host(&self) -> bool {
217 **self == UIMOD_A::HOST
218 }
219 #[doc = "Checks if the value of the field is `DEVICE`"]
220 #[inline(always)]
221 pub fn is_device(&self) -> bool {
222 **self == UIMOD_A::DEVICE
223 }
224}
225impl core::ops::Deref for UIMOD_R {
226 type Target = crate::FieldReader<bool, UIMOD_A>;
227 #[inline(always)]
228 fn deref(&self) -> &Self::Target {
229 &self.0
230 }
231}
232#[doc = "Field `UIMOD` writer - USBHS Mode"]
233pub struct UIMOD_W<'a> {
234 w: &'a mut W,
235}
236impl<'a> UIMOD_W<'a> {
237 #[doc = r"Writes `variant` to the field"]
238 #[inline(always)]
239 pub fn variant(self, variant: UIMOD_A) -> &'a mut W {
240 self.bit(variant.into())
241 }
242 #[doc = "The module is in USB Host mode."]
243 #[inline(always)]
244 pub fn host(self) -> &'a mut W {
245 self.variant(UIMOD_A::HOST)
246 }
247 #[doc = "The module is in USB Device mode."]
248 #[inline(always)]
249 pub fn device(self) -> &'a mut W {
250 self.variant(UIMOD_A::DEVICE)
251 }
252 #[doc = r"Sets the field bit"]
253 #[inline(always)]
254 pub fn set_bit(self) -> &'a mut W {
255 self.bit(true)
256 }
257 #[doc = r"Clears the field bit"]
258 #[inline(always)]
259 pub fn clear_bit(self) -> &'a mut W {
260 self.bit(false)
261 }
262 #[doc = r"Writes raw bits to the field"]
263 #[inline(always)]
264 pub fn bit(self, value: bool) -> &'a mut W {
265 self.w.bits = (self.w.bits & !(0x01 << 25)) | ((value as u32 & 0x01) << 25);
266 self.w
267 }
268}
269impl R {
270 #[doc = "Bit 4 - Remote Device Connection Error Interrupt Enable"]
271 #[inline(always)]
272 pub fn rderre(&self) -> RDERRE_R {
273 RDERRE_R::new(((self.bits >> 4) & 0x01) != 0)
274 }
275 #[doc = "Bit 8 - VBUS Hardware Control"]
276 #[inline(always)]
277 pub fn vbushwc(&self) -> VBUSHWC_R {
278 VBUSHWC_R::new(((self.bits >> 8) & 0x01) != 0)
279 }
280 #[doc = "Bit 14 - Freeze USB Clock"]
281 #[inline(always)]
282 pub fn frzclk(&self) -> FRZCLK_R {
283 FRZCLK_R::new(((self.bits >> 14) & 0x01) != 0)
284 }
285 #[doc = "Bit 15 - USBHS Enable"]
286 #[inline(always)]
287 pub fn usbe(&self) -> USBE_R {
288 USBE_R::new(((self.bits >> 15) & 0x01) != 0)
289 }
290 #[doc = "Bit 25 - USBHS Mode"]
291 #[inline(always)]
292 pub fn uimod(&self) -> UIMOD_R {
293 UIMOD_R::new(((self.bits >> 25) & 0x01) != 0)
294 }
295}
296impl W {
297 #[doc = "Bit 4 - Remote Device Connection Error Interrupt Enable"]
298 #[inline(always)]
299 pub fn rderre(&mut self) -> RDERRE_W {
300 RDERRE_W { w: self }
301 }
302 #[doc = "Bit 8 - VBUS Hardware Control"]
303 #[inline(always)]
304 pub fn vbushwc(&mut self) -> VBUSHWC_W {
305 VBUSHWC_W { w: self }
306 }
307 #[doc = "Bit 14 - Freeze USB Clock"]
308 #[inline(always)]
309 pub fn frzclk(&mut self) -> FRZCLK_W {
310 FRZCLK_W { w: self }
311 }
312 #[doc = "Bit 15 - USBHS Enable"]
313 #[inline(always)]
314 pub fn usbe(&mut self) -> USBE_W {
315 USBE_W { w: self }
316 }
317 #[doc = "Bit 25 - USBHS Mode"]
318 #[inline(always)]
319 pub fn uimod(&mut self) -> UIMOD_W {
320 UIMOD_W { w: self }
321 }
322 #[doc = "Writes raw bits to the register."]
323 #[inline(always)]
324 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
325 self.0.bits(bits);
326 self
327 }
328}
329#[doc = "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_ctrl](index.html) module"]
330pub struct USBHS_CTRL_SPEC;
331impl crate::RegisterSpec for USBHS_CTRL_SPEC {
332 type Ux = u32;
333}
334#[doc = "`read()` method returns [usbhs_ctrl::R](R) reader structure"]
335impl crate::Readable for USBHS_CTRL_SPEC {
336 type Reader = R;
337}
338#[doc = "`write(|w| ..)` method takes [usbhs_ctrl::W](W) writer structure"]
339impl crate::Writable for USBHS_CTRL_SPEC {
340 type Writer = W;
341}
342#[doc = "`reset()` method sets USBHS_CTRL to value 0"]
343impl crate::Resettable for USBHS_CTRL_SPEC {
344 #[inline(always)]
345 fn reset_value() -> Self::Ux {
346 0
347 }
348}