atsamv71j19/usbhs/
usbhs_ctrl.rs

1#[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 = "Field `UID` reader - UID Pin Enable"]
186pub struct UID_R(crate::FieldReader<bool, bool>);
187impl UID_R {
188    #[inline(always)]
189    pub(crate) fn new(bits: bool) -> Self {
190        UID_R(crate::FieldReader::new(bits))
191    }
192}
193impl core::ops::Deref for UID_R {
194    type Target = crate::FieldReader<bool, bool>;
195    #[inline(always)]
196    fn deref(&self) -> &Self::Target {
197        &self.0
198    }
199}
200#[doc = "Field `UID` writer - UID Pin Enable"]
201pub struct UID_W<'a> {
202    w: &'a mut W,
203}
204impl<'a> UID_W<'a> {
205    #[doc = r"Sets the field bit"]
206    #[inline(always)]
207    pub fn set_bit(self) -> &'a mut W {
208        self.bit(true)
209    }
210    #[doc = r"Clears the field bit"]
211    #[inline(always)]
212    pub fn clear_bit(self) -> &'a mut W {
213        self.bit(false)
214    }
215    #[doc = r"Writes raw bits to the field"]
216    #[inline(always)]
217    pub fn bit(self, value: bool) -> &'a mut W {
218        self.w.bits = (self.w.bits & !(0x01 << 24)) | ((value as u32 & 0x01) << 24);
219        self.w
220    }
221}
222#[doc = "USBHS Mode\n\nValue on reset: 0"]
223#[derive(Clone, Copy, Debug, PartialEq)]
224pub enum UIMOD_A {
225    #[doc = "0: The module is in USB Host mode."]
226    HOST = 0,
227    #[doc = "1: The module is in USB Device mode."]
228    DEVICE = 1,
229}
230impl From<UIMOD_A> for bool {
231    #[inline(always)]
232    fn from(variant: UIMOD_A) -> Self {
233        variant as u8 != 0
234    }
235}
236#[doc = "Field `UIMOD` reader - USBHS Mode"]
237pub struct UIMOD_R(crate::FieldReader<bool, UIMOD_A>);
238impl UIMOD_R {
239    #[inline(always)]
240    pub(crate) fn new(bits: bool) -> Self {
241        UIMOD_R(crate::FieldReader::new(bits))
242    }
243    #[doc = r"Get enumerated values variant"]
244    #[inline(always)]
245    pub fn variant(&self) -> UIMOD_A {
246        match self.bits {
247            false => UIMOD_A::HOST,
248            true => UIMOD_A::DEVICE,
249        }
250    }
251    #[doc = "Checks if the value of the field is `HOST`"]
252    #[inline(always)]
253    pub fn is_host(&self) -> bool {
254        **self == UIMOD_A::HOST
255    }
256    #[doc = "Checks if the value of the field is `DEVICE`"]
257    #[inline(always)]
258    pub fn is_device(&self) -> bool {
259        **self == UIMOD_A::DEVICE
260    }
261}
262impl core::ops::Deref for UIMOD_R {
263    type Target = crate::FieldReader<bool, UIMOD_A>;
264    #[inline(always)]
265    fn deref(&self) -> &Self::Target {
266        &self.0
267    }
268}
269#[doc = "Field `UIMOD` writer - USBHS Mode"]
270pub struct UIMOD_W<'a> {
271    w: &'a mut W,
272}
273impl<'a> UIMOD_W<'a> {
274    #[doc = r"Writes `variant` to the field"]
275    #[inline(always)]
276    pub fn variant(self, variant: UIMOD_A) -> &'a mut W {
277        self.bit(variant.into())
278    }
279    #[doc = "The module is in USB Host mode."]
280    #[inline(always)]
281    pub fn host(self) -> &'a mut W {
282        self.variant(UIMOD_A::HOST)
283    }
284    #[doc = "The module is in USB Device mode."]
285    #[inline(always)]
286    pub fn device(self) -> &'a mut W {
287        self.variant(UIMOD_A::DEVICE)
288    }
289    #[doc = r"Sets the field bit"]
290    #[inline(always)]
291    pub fn set_bit(self) -> &'a mut W {
292        self.bit(true)
293    }
294    #[doc = r"Clears the field bit"]
295    #[inline(always)]
296    pub fn clear_bit(self) -> &'a mut W {
297        self.bit(false)
298    }
299    #[doc = r"Writes raw bits to the field"]
300    #[inline(always)]
301    pub fn bit(self, value: bool) -> &'a mut W {
302        self.w.bits = (self.w.bits & !(0x01 << 25)) | ((value as u32 & 0x01) << 25);
303        self.w
304    }
305}
306impl R {
307    #[doc = "Bit 4 - Remote Device Connection Error Interrupt Enable"]
308    #[inline(always)]
309    pub fn rderre(&self) -> RDERRE_R {
310        RDERRE_R::new(((self.bits >> 4) & 0x01) != 0)
311    }
312    #[doc = "Bit 8 - VBUS Hardware Control"]
313    #[inline(always)]
314    pub fn vbushwc(&self) -> VBUSHWC_R {
315        VBUSHWC_R::new(((self.bits >> 8) & 0x01) != 0)
316    }
317    #[doc = "Bit 14 - Freeze USB Clock"]
318    #[inline(always)]
319    pub fn frzclk(&self) -> FRZCLK_R {
320        FRZCLK_R::new(((self.bits >> 14) & 0x01) != 0)
321    }
322    #[doc = "Bit 15 - USBHS Enable"]
323    #[inline(always)]
324    pub fn usbe(&self) -> USBE_R {
325        USBE_R::new(((self.bits >> 15) & 0x01) != 0)
326    }
327    #[doc = "Bit 24 - UID Pin Enable"]
328    #[inline(always)]
329    pub fn uid(&self) -> UID_R {
330        UID_R::new(((self.bits >> 24) & 0x01) != 0)
331    }
332    #[doc = "Bit 25 - USBHS Mode"]
333    #[inline(always)]
334    pub fn uimod(&self) -> UIMOD_R {
335        UIMOD_R::new(((self.bits >> 25) & 0x01) != 0)
336    }
337}
338impl W {
339    #[doc = "Bit 4 - Remote Device Connection Error Interrupt Enable"]
340    #[inline(always)]
341    pub fn rderre(&mut self) -> RDERRE_W {
342        RDERRE_W { w: self }
343    }
344    #[doc = "Bit 8 - VBUS Hardware Control"]
345    #[inline(always)]
346    pub fn vbushwc(&mut self) -> VBUSHWC_W {
347        VBUSHWC_W { w: self }
348    }
349    #[doc = "Bit 14 - Freeze USB Clock"]
350    #[inline(always)]
351    pub fn frzclk(&mut self) -> FRZCLK_W {
352        FRZCLK_W { w: self }
353    }
354    #[doc = "Bit 15 - USBHS Enable"]
355    #[inline(always)]
356    pub fn usbe(&mut self) -> USBE_W {
357        USBE_W { w: self }
358    }
359    #[doc = "Bit 24 - UID Pin Enable"]
360    #[inline(always)]
361    pub fn uid(&mut self) -> UID_W {
362        UID_W { w: self }
363    }
364    #[doc = "Bit 25 - USBHS Mode"]
365    #[inline(always)]
366    pub fn uimod(&mut self) -> UIMOD_W {
367        UIMOD_W { w: self }
368    }
369    #[doc = "Writes raw bits to the register."]
370    #[inline(always)]
371    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
372        self.0.bits(bits);
373        self
374    }
375}
376#[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"]
377pub struct USBHS_CTRL_SPEC;
378impl crate::RegisterSpec for USBHS_CTRL_SPEC {
379    type Ux = u32;
380}
381#[doc = "`read()` method returns [usbhs_ctrl::R](R) reader structure"]
382impl crate::Readable for USBHS_CTRL_SPEC {
383    type Reader = R;
384}
385#[doc = "`write(|w| ..)` method takes [usbhs_ctrl::W](W) writer structure"]
386impl crate::Writable for USBHS_CTRL_SPEC {
387    type Writer = W;
388}
389#[doc = "`reset()` method sets USBHS_CTRL to value 0"]
390impl crate::Resettable for USBHS_CTRL_SPEC {
391    #[inline(always)]
392    fn reset_value() -> Self::Ux {
393        0
394    }
395}