atsamd11c/usb/device/
ctrlb.rs
1#[doc = "Register `CTRLB` reader"]
2pub type R = crate::R<CtrlbSpec>;
3#[doc = "Register `CTRLB` writer"]
4pub type W = crate::W<CtrlbSpec>;
5#[doc = "Field `DETACH` reader - Detach"]
6pub type DetachR = crate::BitReader;
7#[doc = "Field `DETACH` writer - Detach"]
8pub type DetachW<'a, REG> = crate::BitWriter<'a, REG>;
9#[doc = "Field `UPRSM` reader - Upstream Resume"]
10pub type UprsmR = crate::BitReader;
11#[doc = "Field `UPRSM` writer - Upstream Resume"]
12pub type UprsmW<'a, REG> = crate::BitWriter<'a, REG>;
13#[doc = "Speed Configuration\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq, Eq)]
15#[repr(u8)]
16pub enum Spdconfselect {
17 #[doc = "0: FS : Full Speed"]
18 Fs = 0,
19 #[doc = "1: LS : Low Speed"]
20 Ls = 1,
21 #[doc = "2: HS : High Speed capable"]
22 Hs = 2,
23 #[doc = "3: HSTM: High Speed Test Mode (force high-speed mode for test mode)"]
24 Hstm = 3,
25}
26impl From<Spdconfselect> for u8 {
27 #[inline(always)]
28 fn from(variant: Spdconfselect) -> Self {
29 variant as _
30 }
31}
32impl crate::FieldSpec for Spdconfselect {
33 type Ux = u8;
34}
35impl crate::IsEnum for Spdconfselect {}
36#[doc = "Field `SPDCONF` reader - Speed Configuration"]
37pub type SpdconfR = crate::FieldReader<Spdconfselect>;
38impl SpdconfR {
39 #[doc = "Get enumerated values variant"]
40 #[inline(always)]
41 pub const fn variant(&self) -> Spdconfselect {
42 match self.bits {
43 0 => Spdconfselect::Fs,
44 1 => Spdconfselect::Ls,
45 2 => Spdconfselect::Hs,
46 3 => Spdconfselect::Hstm,
47 _ => unreachable!(),
48 }
49 }
50 #[doc = "FS : Full Speed"]
51 #[inline(always)]
52 pub fn is_fs(&self) -> bool {
53 *self == Spdconfselect::Fs
54 }
55 #[doc = "LS : Low Speed"]
56 #[inline(always)]
57 pub fn is_ls(&self) -> bool {
58 *self == Spdconfselect::Ls
59 }
60 #[doc = "HS : High Speed capable"]
61 #[inline(always)]
62 pub fn is_hs(&self) -> bool {
63 *self == Spdconfselect::Hs
64 }
65 #[doc = "HSTM: High Speed Test Mode (force high-speed mode for test mode)"]
66 #[inline(always)]
67 pub fn is_hstm(&self) -> bool {
68 *self == Spdconfselect::Hstm
69 }
70}
71#[doc = "Field `SPDCONF` writer - Speed Configuration"]
72pub type SpdconfW<'a, REG> = crate::FieldWriter<'a, REG, 2, Spdconfselect, crate::Safe>;
73impl<'a, REG> SpdconfW<'a, REG>
74where
75 REG: crate::Writable + crate::RegisterSpec,
76 REG::Ux: From<u8>,
77{
78 #[doc = "FS : Full Speed"]
79 #[inline(always)]
80 pub fn fs(self) -> &'a mut crate::W<REG> {
81 self.variant(Spdconfselect::Fs)
82 }
83 #[doc = "LS : Low Speed"]
84 #[inline(always)]
85 pub fn ls(self) -> &'a mut crate::W<REG> {
86 self.variant(Spdconfselect::Ls)
87 }
88 #[doc = "HS : High Speed capable"]
89 #[inline(always)]
90 pub fn hs(self) -> &'a mut crate::W<REG> {
91 self.variant(Spdconfselect::Hs)
92 }
93 #[doc = "HSTM: High Speed Test Mode (force high-speed mode for test mode)"]
94 #[inline(always)]
95 pub fn hstm(self) -> &'a mut crate::W<REG> {
96 self.variant(Spdconfselect::Hstm)
97 }
98}
99#[doc = "Field `NREPLY` reader - No Reply"]
100pub type NreplyR = crate::BitReader;
101#[doc = "Field `NREPLY` writer - No Reply"]
102pub type NreplyW<'a, REG> = crate::BitWriter<'a, REG>;
103#[doc = "Field `TSTJ` reader - Test mode J"]
104pub type TstjR = crate::BitReader;
105#[doc = "Field `TSTJ` writer - Test mode J"]
106pub type TstjW<'a, REG> = crate::BitWriter<'a, REG>;
107#[doc = "Field `TSTK` reader - Test mode K"]
108pub type TstkR = crate::BitReader;
109#[doc = "Field `TSTK` writer - Test mode K"]
110pub type TstkW<'a, REG> = crate::BitWriter<'a, REG>;
111#[doc = "Field `TSTPCKT` reader - Test packet mode"]
112pub type TstpcktR = crate::BitReader;
113#[doc = "Field `TSTPCKT` writer - Test packet mode"]
114pub type TstpcktW<'a, REG> = crate::BitWriter<'a, REG>;
115#[doc = "Field `OPMODE2` reader - Specific Operational Mode"]
116pub type Opmode2R = crate::BitReader;
117#[doc = "Field `OPMODE2` writer - Specific Operational Mode"]
118pub type Opmode2W<'a, REG> = crate::BitWriter<'a, REG>;
119#[doc = "Field `GNAK` reader - Global NAK"]
120pub type GnakR = crate::BitReader;
121#[doc = "Field `GNAK` writer - Global NAK"]
122pub type GnakW<'a, REG> = crate::BitWriter<'a, REG>;
123#[doc = "Link Power Management Handshake\n\nValue on reset: 0"]
124#[derive(Clone, Copy, Debug, PartialEq, Eq)]
125#[repr(u8)]
126pub enum Lpmhdskselect {
127 #[doc = "0: No handshake. LPM is not supported"]
128 No = 0,
129 #[doc = "1: ACK"]
130 Ack = 1,
131 #[doc = "2: NYET"]
132 Nyet = 2,
133 #[doc = "3: STALL"]
134 Stall = 3,
135}
136impl From<Lpmhdskselect> for u8 {
137 #[inline(always)]
138 fn from(variant: Lpmhdskselect) -> Self {
139 variant as _
140 }
141}
142impl crate::FieldSpec for Lpmhdskselect {
143 type Ux = u8;
144}
145impl crate::IsEnum for Lpmhdskselect {}
146#[doc = "Field `LPMHDSK` reader - Link Power Management Handshake"]
147pub type LpmhdskR = crate::FieldReader<Lpmhdskselect>;
148impl LpmhdskR {
149 #[doc = "Get enumerated values variant"]
150 #[inline(always)]
151 pub const fn variant(&self) -> Lpmhdskselect {
152 match self.bits {
153 0 => Lpmhdskselect::No,
154 1 => Lpmhdskselect::Ack,
155 2 => Lpmhdskselect::Nyet,
156 3 => Lpmhdskselect::Stall,
157 _ => unreachable!(),
158 }
159 }
160 #[doc = "No handshake. LPM is not supported"]
161 #[inline(always)]
162 pub fn is_no(&self) -> bool {
163 *self == Lpmhdskselect::No
164 }
165 #[doc = "ACK"]
166 #[inline(always)]
167 pub fn is_ack(&self) -> bool {
168 *self == Lpmhdskselect::Ack
169 }
170 #[doc = "NYET"]
171 #[inline(always)]
172 pub fn is_nyet(&self) -> bool {
173 *self == Lpmhdskselect::Nyet
174 }
175 #[doc = "STALL"]
176 #[inline(always)]
177 pub fn is_stall(&self) -> bool {
178 *self == Lpmhdskselect::Stall
179 }
180}
181#[doc = "Field `LPMHDSK` writer - Link Power Management Handshake"]
182pub type LpmhdskW<'a, REG> = crate::FieldWriter<'a, REG, 2, Lpmhdskselect, crate::Safe>;
183impl<'a, REG> LpmhdskW<'a, REG>
184where
185 REG: crate::Writable + crate::RegisterSpec,
186 REG::Ux: From<u8>,
187{
188 #[doc = "No handshake. LPM is not supported"]
189 #[inline(always)]
190 pub fn no(self) -> &'a mut crate::W<REG> {
191 self.variant(Lpmhdskselect::No)
192 }
193 #[doc = "ACK"]
194 #[inline(always)]
195 pub fn ack(self) -> &'a mut crate::W<REG> {
196 self.variant(Lpmhdskselect::Ack)
197 }
198 #[doc = "NYET"]
199 #[inline(always)]
200 pub fn nyet(self) -> &'a mut crate::W<REG> {
201 self.variant(Lpmhdskselect::Nyet)
202 }
203 #[doc = "STALL"]
204 #[inline(always)]
205 pub fn stall(self) -> &'a mut crate::W<REG> {
206 self.variant(Lpmhdskselect::Stall)
207 }
208}
209impl R {
210 #[doc = "Bit 0 - Detach"]
211 #[inline(always)]
212 pub fn detach(&self) -> DetachR {
213 DetachR::new((self.bits & 1) != 0)
214 }
215 #[doc = "Bit 1 - Upstream Resume"]
216 #[inline(always)]
217 pub fn uprsm(&self) -> UprsmR {
218 UprsmR::new(((self.bits >> 1) & 1) != 0)
219 }
220 #[doc = "Bits 2:3 - Speed Configuration"]
221 #[inline(always)]
222 pub fn spdconf(&self) -> SpdconfR {
223 SpdconfR::new(((self.bits >> 2) & 3) as u8)
224 }
225 #[doc = "Bit 4 - No Reply"]
226 #[inline(always)]
227 pub fn nreply(&self) -> NreplyR {
228 NreplyR::new(((self.bits >> 4) & 1) != 0)
229 }
230 #[doc = "Bit 5 - Test mode J"]
231 #[inline(always)]
232 pub fn tstj(&self) -> TstjR {
233 TstjR::new(((self.bits >> 5) & 1) != 0)
234 }
235 #[doc = "Bit 6 - Test mode K"]
236 #[inline(always)]
237 pub fn tstk(&self) -> TstkR {
238 TstkR::new(((self.bits >> 6) & 1) != 0)
239 }
240 #[doc = "Bit 7 - Test packet mode"]
241 #[inline(always)]
242 pub fn tstpckt(&self) -> TstpcktR {
243 TstpcktR::new(((self.bits >> 7) & 1) != 0)
244 }
245 #[doc = "Bit 8 - Specific Operational Mode"]
246 #[inline(always)]
247 pub fn opmode2(&self) -> Opmode2R {
248 Opmode2R::new(((self.bits >> 8) & 1) != 0)
249 }
250 #[doc = "Bit 9 - Global NAK"]
251 #[inline(always)]
252 pub fn gnak(&self) -> GnakR {
253 GnakR::new(((self.bits >> 9) & 1) != 0)
254 }
255 #[doc = "Bits 10:11 - Link Power Management Handshake"]
256 #[inline(always)]
257 pub fn lpmhdsk(&self) -> LpmhdskR {
258 LpmhdskR::new(((self.bits >> 10) & 3) as u8)
259 }
260}
261impl W {
262 #[doc = "Bit 0 - Detach"]
263 #[inline(always)]
264 #[must_use]
265 pub fn detach(&mut self) -> DetachW<CtrlbSpec> {
266 DetachW::new(self, 0)
267 }
268 #[doc = "Bit 1 - Upstream Resume"]
269 #[inline(always)]
270 #[must_use]
271 pub fn uprsm(&mut self) -> UprsmW<CtrlbSpec> {
272 UprsmW::new(self, 1)
273 }
274 #[doc = "Bits 2:3 - Speed Configuration"]
275 #[inline(always)]
276 #[must_use]
277 pub fn spdconf(&mut self) -> SpdconfW<CtrlbSpec> {
278 SpdconfW::new(self, 2)
279 }
280 #[doc = "Bit 4 - No Reply"]
281 #[inline(always)]
282 #[must_use]
283 pub fn nreply(&mut self) -> NreplyW<CtrlbSpec> {
284 NreplyW::new(self, 4)
285 }
286 #[doc = "Bit 5 - Test mode J"]
287 #[inline(always)]
288 #[must_use]
289 pub fn tstj(&mut self) -> TstjW<CtrlbSpec> {
290 TstjW::new(self, 5)
291 }
292 #[doc = "Bit 6 - Test mode K"]
293 #[inline(always)]
294 #[must_use]
295 pub fn tstk(&mut self) -> TstkW<CtrlbSpec> {
296 TstkW::new(self, 6)
297 }
298 #[doc = "Bit 7 - Test packet mode"]
299 #[inline(always)]
300 #[must_use]
301 pub fn tstpckt(&mut self) -> TstpcktW<CtrlbSpec> {
302 TstpcktW::new(self, 7)
303 }
304 #[doc = "Bit 8 - Specific Operational Mode"]
305 #[inline(always)]
306 #[must_use]
307 pub fn opmode2(&mut self) -> Opmode2W<CtrlbSpec> {
308 Opmode2W::new(self, 8)
309 }
310 #[doc = "Bit 9 - Global NAK"]
311 #[inline(always)]
312 #[must_use]
313 pub fn gnak(&mut self) -> GnakW<CtrlbSpec> {
314 GnakW::new(self, 9)
315 }
316 #[doc = "Bits 10:11 - Link Power Management Handshake"]
317 #[inline(always)]
318 #[must_use]
319 pub fn lpmhdsk(&mut self) -> LpmhdskW<CtrlbSpec> {
320 LpmhdskW::new(self, 10)
321 }
322}
323#[doc = "DEVICE Control B\n\nYou can [`read`](crate::Reg::read) this register and get [`ctrlb::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`ctrlb::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
324pub struct CtrlbSpec;
325impl crate::RegisterSpec for CtrlbSpec {
326 type Ux = u16;
327}
328#[doc = "`read()` method returns [`ctrlb::R`](R) reader structure"]
329impl crate::Readable for CtrlbSpec {}
330#[doc = "`write(|w| ..)` method takes [`ctrlb::W`](W) writer structure"]
331impl crate::Writable for CtrlbSpec {
332 type Safety = crate::Unsafe;
333 const ZERO_TO_MODIFY_FIELDS_BITMAP: u16 = 0;
334 const ONE_TO_MODIFY_FIELDS_BITMAP: u16 = 0;
335}
336#[doc = "`reset()` method sets CTRLB to value 0x01"]
337impl crate::Resettable for CtrlbSpec {
338 const RESET_VALUE: u16 = 0x01;
339}