atsamd51p20a/usb/device/
ctrla.rs1#[doc = "Reader of register CTRLA"]
2pub type R = crate::R<u8, super::CTRLA>;
3#[doc = "Writer for register CTRLA"]
4pub type W = crate::W<u8, super::CTRLA>;
5#[doc = "Register CTRLA `reset()`'s with value 0"]
6impl crate::ResetValue for super::CTRLA {
7 type Type = u8;
8 #[inline(always)]
9 fn reset_value() -> Self::Type {
10 0
11 }
12}
13#[doc = "Reader of field `SWRST`"]
14pub type SWRST_R = crate::R<bool, bool>;
15#[doc = "Write proxy for field `SWRST`"]
16pub struct SWRST_W<'a> {
17 w: &'a mut W,
18}
19impl<'a> SWRST_W<'a> {
20 #[doc = r"Sets the field bit"]
21 #[inline(always)]
22 pub fn set_bit(self) -> &'a mut W {
23 self.bit(true)
24 }
25 #[doc = r"Clears the field bit"]
26 #[inline(always)]
27 pub fn clear_bit(self) -> &'a mut W {
28 self.bit(false)
29 }
30 #[doc = r"Writes raw bits to the field"]
31 #[inline(always)]
32 pub fn bit(self, value: bool) -> &'a mut W {
33 self.w.bits = (self.w.bits & !0x01) | ((value as u8) & 0x01);
34 self.w
35 }
36}
37#[doc = "Reader of field `ENABLE`"]
38pub type ENABLE_R = crate::R<bool, bool>;
39#[doc = "Write proxy for field `ENABLE`"]
40pub struct ENABLE_W<'a> {
41 w: &'a mut W,
42}
43impl<'a> ENABLE_W<'a> {
44 #[doc = r"Sets the field bit"]
45 #[inline(always)]
46 pub fn set_bit(self) -> &'a mut W {
47 self.bit(true)
48 }
49 #[doc = r"Clears the field bit"]
50 #[inline(always)]
51 pub fn clear_bit(self) -> &'a mut W {
52 self.bit(false)
53 }
54 #[doc = r"Writes raw bits to the field"]
55 #[inline(always)]
56 pub fn bit(self, value: bool) -> &'a mut W {
57 self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u8) & 0x01) << 1);
58 self.w
59 }
60}
61#[doc = "Reader of field `RUNSTDBY`"]
62pub type RUNSTDBY_R = crate::R<bool, bool>;
63#[doc = "Write proxy for field `RUNSTDBY`"]
64pub struct RUNSTDBY_W<'a> {
65 w: &'a mut W,
66}
67impl<'a> RUNSTDBY_W<'a> {
68 #[doc = r"Sets the field bit"]
69 #[inline(always)]
70 pub fn set_bit(self) -> &'a mut W {
71 self.bit(true)
72 }
73 #[doc = r"Clears the field bit"]
74 #[inline(always)]
75 pub fn clear_bit(self) -> &'a mut W {
76 self.bit(false)
77 }
78 #[doc = r"Writes raw bits to the field"]
79 #[inline(always)]
80 pub fn bit(self, value: bool) -> &'a mut W {
81 self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u8) & 0x01) << 2);
82 self.w
83 }
84}
85#[doc = "Operating Mode\n\nValue on reset: 0"]
86#[derive(Clone, Copy, Debug, PartialEq)]
87pub enum MODE_A {
88 #[doc = "0: Device Mode"]
89 DEVICE = 0,
90 #[doc = "1: Host Mode"]
91 HOST = 1,
92}
93impl From<MODE_A> for bool {
94 #[inline(always)]
95 fn from(variant: MODE_A) -> Self {
96 variant as u8 != 0
97 }
98}
99#[doc = "Reader of field `MODE`"]
100pub type MODE_R = crate::R<bool, MODE_A>;
101impl MODE_R {
102 #[doc = r"Get enumerated values variant"]
103 #[inline(always)]
104 pub fn variant(&self) -> MODE_A {
105 match self.bits {
106 false => MODE_A::DEVICE,
107 true => MODE_A::HOST,
108 }
109 }
110 #[doc = "Checks if the value of the field is `DEVICE`"]
111 #[inline(always)]
112 pub fn is_device(&self) -> bool {
113 *self == MODE_A::DEVICE
114 }
115 #[doc = "Checks if the value of the field is `HOST`"]
116 #[inline(always)]
117 pub fn is_host(&self) -> bool {
118 *self == MODE_A::HOST
119 }
120}
121#[doc = "Write proxy for field `MODE`"]
122pub struct MODE_W<'a> {
123 w: &'a mut W,
124}
125impl<'a> MODE_W<'a> {
126 #[doc = r"Writes `variant` to the field"]
127 #[inline(always)]
128 pub fn variant(self, variant: MODE_A) -> &'a mut W {
129 {
130 self.bit(variant.into())
131 }
132 }
133 #[doc = "Device Mode"]
134 #[inline(always)]
135 pub fn device(self) -> &'a mut W {
136 self.variant(MODE_A::DEVICE)
137 }
138 #[doc = "Host Mode"]
139 #[inline(always)]
140 pub fn host(self) -> &'a mut W {
141 self.variant(MODE_A::HOST)
142 }
143 #[doc = r"Sets the field bit"]
144 #[inline(always)]
145 pub fn set_bit(self) -> &'a mut W {
146 self.bit(true)
147 }
148 #[doc = r"Clears the field bit"]
149 #[inline(always)]
150 pub fn clear_bit(self) -> &'a mut W {
151 self.bit(false)
152 }
153 #[doc = r"Writes raw bits to the field"]
154 #[inline(always)]
155 pub fn bit(self, value: bool) -> &'a mut W {
156 self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u8) & 0x01) << 7);
157 self.w
158 }
159}
160impl R {
161 #[doc = "Bit 0 - Software Reset"]
162 #[inline(always)]
163 pub fn swrst(&self) -> SWRST_R {
164 SWRST_R::new((self.bits & 0x01) != 0)
165 }
166 #[doc = "Bit 1 - Enable"]
167 #[inline(always)]
168 pub fn enable(&self) -> ENABLE_R {
169 ENABLE_R::new(((self.bits >> 1) & 0x01) != 0)
170 }
171 #[doc = "Bit 2 - Run in Standby Mode"]
172 #[inline(always)]
173 pub fn runstdby(&self) -> RUNSTDBY_R {
174 RUNSTDBY_R::new(((self.bits >> 2) & 0x01) != 0)
175 }
176 #[doc = "Bit 7 - Operating Mode"]
177 #[inline(always)]
178 pub fn mode(&self) -> MODE_R {
179 MODE_R::new(((self.bits >> 7) & 0x01) != 0)
180 }
181}
182impl W {
183 #[doc = "Bit 0 - Software Reset"]
184 #[inline(always)]
185 pub fn swrst(&mut self) -> SWRST_W {
186 SWRST_W { w: self }
187 }
188 #[doc = "Bit 1 - Enable"]
189 #[inline(always)]
190 pub fn enable(&mut self) -> ENABLE_W {
191 ENABLE_W { w: self }
192 }
193 #[doc = "Bit 2 - Run in Standby Mode"]
194 #[inline(always)]
195 pub fn runstdby(&mut self) -> RUNSTDBY_W {
196 RUNSTDBY_W { w: self }
197 }
198 #[doc = "Bit 7 - Operating Mode"]
199 #[inline(always)]
200 pub fn mode(&mut self) -> MODE_W {
201 MODE_W { w: self }
202 }
203}