ra4w1/usbfs/
dcpctr.rs

1#[doc = "Register `DCPCTR` reader"]
2pub struct R(crate::R<DCPCTR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<DCPCTR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<DCPCTR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<DCPCTR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `DCPCTR` writer"]
17pub struct W(crate::W<DCPCTR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<DCPCTR_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<DCPCTR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<DCPCTR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `PID` reader - Response PID"]
38pub type PID_R = crate::FieldReader<u8, PID_A>;
39#[doc = "Response PID\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum PID_A {
43    #[doc = "0: NAK response"]
44    _00 = 0,
45    #[doc = "1: BUF response (depending on the buffer state)"]
46    _01 = 1,
47    #[doc = "2: STALL response"]
48    _10 = 2,
49    #[doc = "3: STALL response"]
50    _11 = 3,
51}
52impl From<PID_A> for u8 {
53    #[inline(always)]
54    fn from(variant: PID_A) -> Self {
55        variant as _
56    }
57}
58impl PID_R {
59    #[doc = "Get enumerated values variant"]
60    #[inline(always)]
61    pub fn variant(&self) -> PID_A {
62        match self.bits {
63            0 => PID_A::_00,
64            1 => PID_A::_01,
65            2 => PID_A::_10,
66            3 => PID_A::_11,
67            _ => unreachable!(),
68        }
69    }
70    #[doc = "Checks if the value of the field is `_00`"]
71    #[inline(always)]
72    pub fn is_00(&self) -> bool {
73        *self == PID_A::_00
74    }
75    #[doc = "Checks if the value of the field is `_01`"]
76    #[inline(always)]
77    pub fn is_01(&self) -> bool {
78        *self == PID_A::_01
79    }
80    #[doc = "Checks if the value of the field is `_10`"]
81    #[inline(always)]
82    pub fn is_10(&self) -> bool {
83        *self == PID_A::_10
84    }
85    #[doc = "Checks if the value of the field is `_11`"]
86    #[inline(always)]
87    pub fn is_11(&self) -> bool {
88        *self == PID_A::_11
89    }
90}
91#[doc = "Field `PID` writer - Response PID"]
92pub type PID_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u16, DCPCTR_SPEC, u8, PID_A, 2, O>;
93impl<'a, const O: u8> PID_W<'a, O> {
94    #[doc = "NAK response"]
95    #[inline(always)]
96    pub fn _00(self) -> &'a mut W {
97        self.variant(PID_A::_00)
98    }
99    #[doc = "BUF response (depending on the buffer state)"]
100    #[inline(always)]
101    pub fn _01(self) -> &'a mut W {
102        self.variant(PID_A::_01)
103    }
104    #[doc = "STALL response"]
105    #[inline(always)]
106    pub fn _10(self) -> &'a mut W {
107        self.variant(PID_A::_10)
108    }
109    #[doc = "STALL response"]
110    #[inline(always)]
111    pub fn _11(self) -> &'a mut W {
112        self.variant(PID_A::_11)
113    }
114}
115#[doc = "Field `CCPL` reader - Control Transfer End Enable"]
116pub type CCPL_R = crate::BitReader<CCPL_A>;
117#[doc = "Control Transfer End Enable\n\nValue on reset: 0"]
118#[derive(Clone, Copy, Debug, PartialEq, Eq)]
119pub enum CCPL_A {
120    #[doc = "0: Invalid"]
121    _0 = 0,
122    #[doc = "1: Completion of control transfer is enabled."]
123    _1 = 1,
124}
125impl From<CCPL_A> for bool {
126    #[inline(always)]
127    fn from(variant: CCPL_A) -> Self {
128        variant as u8 != 0
129    }
130}
131impl CCPL_R {
132    #[doc = "Get enumerated values variant"]
133    #[inline(always)]
134    pub fn variant(&self) -> CCPL_A {
135        match self.bits {
136            false => CCPL_A::_0,
137            true => CCPL_A::_1,
138        }
139    }
140    #[doc = "Checks if the value of the field is `_0`"]
141    #[inline(always)]
142    pub fn is_0(&self) -> bool {
143        *self == CCPL_A::_0
144    }
145    #[doc = "Checks if the value of the field is `_1`"]
146    #[inline(always)]
147    pub fn is_1(&self) -> bool {
148        *self == CCPL_A::_1
149    }
150}
151#[doc = "Field `CCPL` writer - Control Transfer End Enable"]
152pub type CCPL_W<'a, const O: u8> = crate::BitWriter<'a, u16, DCPCTR_SPEC, CCPL_A, O>;
153impl<'a, const O: u8> CCPL_W<'a, O> {
154    #[doc = "Invalid"]
155    #[inline(always)]
156    pub fn _0(self) -> &'a mut W {
157        self.variant(CCPL_A::_0)
158    }
159    #[doc = "Completion of control transfer is enabled."]
160    #[inline(always)]
161    pub fn _1(self) -> &'a mut W {
162        self.variant(CCPL_A::_1)
163    }
164}
165#[doc = "Field `PBUSY` reader - Pipe Busy"]
166pub type PBUSY_R = crate::BitReader<PBUSY_A>;
167#[doc = "Pipe Busy\n\nValue on reset: 0"]
168#[derive(Clone, Copy, Debug, PartialEq, Eq)]
169pub enum PBUSY_A {
170    #[doc = "0: DCP is not used for the transaction."]
171    _0 = 0,
172    #[doc = "1: DCP is used for the transaction."]
173    _1 = 1,
174}
175impl From<PBUSY_A> for bool {
176    #[inline(always)]
177    fn from(variant: PBUSY_A) -> Self {
178        variant as u8 != 0
179    }
180}
181impl PBUSY_R {
182    #[doc = "Get enumerated values variant"]
183    #[inline(always)]
184    pub fn variant(&self) -> PBUSY_A {
185        match self.bits {
186            false => PBUSY_A::_0,
187            true => PBUSY_A::_1,
188        }
189    }
190    #[doc = "Checks if the value of the field is `_0`"]
191    #[inline(always)]
192    pub fn is_0(&self) -> bool {
193        *self == PBUSY_A::_0
194    }
195    #[doc = "Checks if the value of the field is `_1`"]
196    #[inline(always)]
197    pub fn is_1(&self) -> bool {
198        *self == PBUSY_A::_1
199    }
200}
201#[doc = "Field `SQMON` reader - Sequence Toggle Bit Monitor"]
202pub type SQMON_R = crate::BitReader<SQMON_A>;
203#[doc = "Sequence Toggle Bit Monitor\n\nValue on reset: 1"]
204#[derive(Clone, Copy, Debug, PartialEq, Eq)]
205pub enum SQMON_A {
206    #[doc = "0: DATA0"]
207    _0 = 0,
208    #[doc = "1: DATA1"]
209    _1 = 1,
210}
211impl From<SQMON_A> for bool {
212    #[inline(always)]
213    fn from(variant: SQMON_A) -> Self {
214        variant as u8 != 0
215    }
216}
217impl SQMON_R {
218    #[doc = "Get enumerated values variant"]
219    #[inline(always)]
220    pub fn variant(&self) -> SQMON_A {
221        match self.bits {
222            false => SQMON_A::_0,
223            true => SQMON_A::_1,
224        }
225    }
226    #[doc = "Checks if the value of the field is `_0`"]
227    #[inline(always)]
228    pub fn is_0(&self) -> bool {
229        *self == SQMON_A::_0
230    }
231    #[doc = "Checks if the value of the field is `_1`"]
232    #[inline(always)]
233    pub fn is_1(&self) -> bool {
234        *self == SQMON_A::_1
235    }
236}
237#[doc = "Field `SQSET` reader - Sequence Toggle Bit Set"]
238pub type SQSET_R = crate::BitReader<SQSET_A>;
239#[doc = "Sequence Toggle Bit Set\n\nValue on reset: 0"]
240#[derive(Clone, Copy, Debug, PartialEq, Eq)]
241pub enum SQSET_A {
242    #[doc = "0: Invalid"]
243    _0 = 0,
244    #[doc = "1: Specifies DATA1."]
245    _1 = 1,
246}
247impl From<SQSET_A> for bool {
248    #[inline(always)]
249    fn from(variant: SQSET_A) -> Self {
250        variant as u8 != 0
251    }
252}
253impl SQSET_R {
254    #[doc = "Get enumerated values variant"]
255    #[inline(always)]
256    pub fn variant(&self) -> SQSET_A {
257        match self.bits {
258            false => SQSET_A::_0,
259            true => SQSET_A::_1,
260        }
261    }
262    #[doc = "Checks if the value of the field is `_0`"]
263    #[inline(always)]
264    pub fn is_0(&self) -> bool {
265        *self == SQSET_A::_0
266    }
267    #[doc = "Checks if the value of the field is `_1`"]
268    #[inline(always)]
269    pub fn is_1(&self) -> bool {
270        *self == SQSET_A::_1
271    }
272}
273#[doc = "Field `SQSET` writer - Sequence Toggle Bit Set"]
274pub type SQSET_W<'a, const O: u8> = crate::BitWriter<'a, u16, DCPCTR_SPEC, SQSET_A, O>;
275impl<'a, const O: u8> SQSET_W<'a, O> {
276    #[doc = "Invalid"]
277    #[inline(always)]
278    pub fn _0(self) -> &'a mut W {
279        self.variant(SQSET_A::_0)
280    }
281    #[doc = "Specifies DATA1."]
282    #[inline(always)]
283    pub fn _1(self) -> &'a mut W {
284        self.variant(SQSET_A::_1)
285    }
286}
287#[doc = "Field `SQCLR` reader - Sequence Toggle Bit Clear"]
288pub type SQCLR_R = crate::BitReader<SQCLR_A>;
289#[doc = "Sequence Toggle Bit Clear\n\nValue on reset: 0"]
290#[derive(Clone, Copy, Debug, PartialEq, Eq)]
291pub enum SQCLR_A {
292    #[doc = "0: Invalid"]
293    _0 = 0,
294    #[doc = "1: Specifies DATA0."]
295    _1 = 1,
296}
297impl From<SQCLR_A> for bool {
298    #[inline(always)]
299    fn from(variant: SQCLR_A) -> Self {
300        variant as u8 != 0
301    }
302}
303impl SQCLR_R {
304    #[doc = "Get enumerated values variant"]
305    #[inline(always)]
306    pub fn variant(&self) -> SQCLR_A {
307        match self.bits {
308            false => SQCLR_A::_0,
309            true => SQCLR_A::_1,
310        }
311    }
312    #[doc = "Checks if the value of the field is `_0`"]
313    #[inline(always)]
314    pub fn is_0(&self) -> bool {
315        *self == SQCLR_A::_0
316    }
317    #[doc = "Checks if the value of the field is `_1`"]
318    #[inline(always)]
319    pub fn is_1(&self) -> bool {
320        *self == SQCLR_A::_1
321    }
322}
323#[doc = "Field `SQCLR` writer - Sequence Toggle Bit Clear"]
324pub type SQCLR_W<'a, const O: u8> = crate::BitWriter<'a, u16, DCPCTR_SPEC, SQCLR_A, O>;
325impl<'a, const O: u8> SQCLR_W<'a, O> {
326    #[doc = "Invalid"]
327    #[inline(always)]
328    pub fn _0(self) -> &'a mut W {
329        self.variant(SQCLR_A::_0)
330    }
331    #[doc = "Specifies DATA0."]
332    #[inline(always)]
333    pub fn _1(self) -> &'a mut W {
334        self.variant(SQCLR_A::_1)
335    }
336}
337#[doc = "Field `SUREQCLR` reader - SUREQ Bit Clear"]
338pub type SUREQCLR_R = crate::BitReader<SUREQCLR_A>;
339#[doc = "SUREQ Bit Clear\n\nValue on reset: 0"]
340#[derive(Clone, Copy, Debug, PartialEq, Eq)]
341pub enum SUREQCLR_A {
342    #[doc = "0: Invalid"]
343    _0 = 0,
344    #[doc = "1: Clears the SUREQ bit to 0."]
345    _1 = 1,
346}
347impl From<SUREQCLR_A> for bool {
348    #[inline(always)]
349    fn from(variant: SUREQCLR_A) -> Self {
350        variant as u8 != 0
351    }
352}
353impl SUREQCLR_R {
354    #[doc = "Get enumerated values variant"]
355    #[inline(always)]
356    pub fn variant(&self) -> SUREQCLR_A {
357        match self.bits {
358            false => SUREQCLR_A::_0,
359            true => SUREQCLR_A::_1,
360        }
361    }
362    #[doc = "Checks if the value of the field is `_0`"]
363    #[inline(always)]
364    pub fn is_0(&self) -> bool {
365        *self == SUREQCLR_A::_0
366    }
367    #[doc = "Checks if the value of the field is `_1`"]
368    #[inline(always)]
369    pub fn is_1(&self) -> bool {
370        *self == SUREQCLR_A::_1
371    }
372}
373#[doc = "Field `SUREQCLR` writer - SUREQ Bit Clear"]
374pub type SUREQCLR_W<'a, const O: u8> = crate::BitWriter<'a, u16, DCPCTR_SPEC, SUREQCLR_A, O>;
375impl<'a, const O: u8> SUREQCLR_W<'a, O> {
376    #[doc = "Invalid"]
377    #[inline(always)]
378    pub fn _0(self) -> &'a mut W {
379        self.variant(SUREQCLR_A::_0)
380    }
381    #[doc = "Clears the SUREQ bit to 0."]
382    #[inline(always)]
383    pub fn _1(self) -> &'a mut W {
384        self.variant(SUREQCLR_A::_1)
385    }
386}
387#[doc = "Field `SUREQ` reader - Setup Token Transmission"]
388pub type SUREQ_R = crate::BitReader<SUREQ_A>;
389#[doc = "Setup Token Transmission\n\nValue on reset: 0"]
390#[derive(Clone, Copy, Debug, PartialEq, Eq)]
391pub enum SUREQ_A {
392    #[doc = "0: Invalid"]
393    _0 = 0,
394    #[doc = "1: Transmits the setup packet."]
395    _1 = 1,
396}
397impl From<SUREQ_A> for bool {
398    #[inline(always)]
399    fn from(variant: SUREQ_A) -> Self {
400        variant as u8 != 0
401    }
402}
403impl SUREQ_R {
404    #[doc = "Get enumerated values variant"]
405    #[inline(always)]
406    pub fn variant(&self) -> SUREQ_A {
407        match self.bits {
408            false => SUREQ_A::_0,
409            true => SUREQ_A::_1,
410        }
411    }
412    #[doc = "Checks if the value of the field is `_0`"]
413    #[inline(always)]
414    pub fn is_0(&self) -> bool {
415        *self == SUREQ_A::_0
416    }
417    #[doc = "Checks if the value of the field is `_1`"]
418    #[inline(always)]
419    pub fn is_1(&self) -> bool {
420        *self == SUREQ_A::_1
421    }
422}
423#[doc = "Field `SUREQ` writer - Setup Token Transmission"]
424pub type SUREQ_W<'a, const O: u8> = crate::BitWriter<'a, u16, DCPCTR_SPEC, SUREQ_A, O>;
425impl<'a, const O: u8> SUREQ_W<'a, O> {
426    #[doc = "Invalid"]
427    #[inline(always)]
428    pub fn _0(self) -> &'a mut W {
429        self.variant(SUREQ_A::_0)
430    }
431    #[doc = "Transmits the setup packet."]
432    #[inline(always)]
433    pub fn _1(self) -> &'a mut W {
434        self.variant(SUREQ_A::_1)
435    }
436}
437#[doc = "Field `BSTS` reader - Buffer Status"]
438pub type BSTS_R = crate::BitReader<BSTS_A>;
439#[doc = "Buffer Status\n\nValue on reset: 0"]
440#[derive(Clone, Copy, Debug, PartialEq, Eq)]
441pub enum BSTS_A {
442    #[doc = "0: Buffer access is disabled."]
443    _0 = 0,
444    #[doc = "1: Buffer access is enabled."]
445    _1 = 1,
446}
447impl From<BSTS_A> for bool {
448    #[inline(always)]
449    fn from(variant: BSTS_A) -> Self {
450        variant as u8 != 0
451    }
452}
453impl BSTS_R {
454    #[doc = "Get enumerated values variant"]
455    #[inline(always)]
456    pub fn variant(&self) -> BSTS_A {
457        match self.bits {
458            false => BSTS_A::_0,
459            true => BSTS_A::_1,
460        }
461    }
462    #[doc = "Checks if the value of the field is `_0`"]
463    #[inline(always)]
464    pub fn is_0(&self) -> bool {
465        *self == BSTS_A::_0
466    }
467    #[doc = "Checks if the value of the field is `_1`"]
468    #[inline(always)]
469    pub fn is_1(&self) -> bool {
470        *self == BSTS_A::_1
471    }
472}
473impl R {
474    #[doc = "Bits 0:1 - Response PID"]
475    #[inline(always)]
476    pub fn pid(&self) -> PID_R {
477        PID_R::new((self.bits & 3) as u8)
478    }
479    #[doc = "Bit 2 - Control Transfer End Enable"]
480    #[inline(always)]
481    pub fn ccpl(&self) -> CCPL_R {
482        CCPL_R::new(((self.bits >> 2) & 1) != 0)
483    }
484    #[doc = "Bit 5 - Pipe Busy"]
485    #[inline(always)]
486    pub fn pbusy(&self) -> PBUSY_R {
487        PBUSY_R::new(((self.bits >> 5) & 1) != 0)
488    }
489    #[doc = "Bit 6 - Sequence Toggle Bit Monitor"]
490    #[inline(always)]
491    pub fn sqmon(&self) -> SQMON_R {
492        SQMON_R::new(((self.bits >> 6) & 1) != 0)
493    }
494    #[doc = "Bit 7 - Sequence Toggle Bit Set"]
495    #[inline(always)]
496    pub fn sqset(&self) -> SQSET_R {
497        SQSET_R::new(((self.bits >> 7) & 1) != 0)
498    }
499    #[doc = "Bit 8 - Sequence Toggle Bit Clear"]
500    #[inline(always)]
501    pub fn sqclr(&self) -> SQCLR_R {
502        SQCLR_R::new(((self.bits >> 8) & 1) != 0)
503    }
504    #[doc = "Bit 11 - SUREQ Bit Clear"]
505    #[inline(always)]
506    pub fn sureqclr(&self) -> SUREQCLR_R {
507        SUREQCLR_R::new(((self.bits >> 11) & 1) != 0)
508    }
509    #[doc = "Bit 14 - Setup Token Transmission"]
510    #[inline(always)]
511    pub fn sureq(&self) -> SUREQ_R {
512        SUREQ_R::new(((self.bits >> 14) & 1) != 0)
513    }
514    #[doc = "Bit 15 - Buffer Status"]
515    #[inline(always)]
516    pub fn bsts(&self) -> BSTS_R {
517        BSTS_R::new(((self.bits >> 15) & 1) != 0)
518    }
519}
520impl W {
521    #[doc = "Bits 0:1 - Response PID"]
522    #[inline(always)]
523    #[must_use]
524    pub fn pid(&mut self) -> PID_W<0> {
525        PID_W::new(self)
526    }
527    #[doc = "Bit 2 - Control Transfer End Enable"]
528    #[inline(always)]
529    #[must_use]
530    pub fn ccpl(&mut self) -> CCPL_W<2> {
531        CCPL_W::new(self)
532    }
533    #[doc = "Bit 7 - Sequence Toggle Bit Set"]
534    #[inline(always)]
535    #[must_use]
536    pub fn sqset(&mut self) -> SQSET_W<7> {
537        SQSET_W::new(self)
538    }
539    #[doc = "Bit 8 - Sequence Toggle Bit Clear"]
540    #[inline(always)]
541    #[must_use]
542    pub fn sqclr(&mut self) -> SQCLR_W<8> {
543        SQCLR_W::new(self)
544    }
545    #[doc = "Bit 11 - SUREQ Bit Clear"]
546    #[inline(always)]
547    #[must_use]
548    pub fn sureqclr(&mut self) -> SUREQCLR_W<11> {
549        SUREQCLR_W::new(self)
550    }
551    #[doc = "Bit 14 - Setup Token Transmission"]
552    #[inline(always)]
553    #[must_use]
554    pub fn sureq(&mut self) -> SUREQ_W<14> {
555        SUREQ_W::new(self)
556    }
557    #[doc = "Writes raw bits to the register."]
558    #[inline(always)]
559    pub unsafe fn bits(&mut self, bits: u16) -> &mut Self {
560        self.0.bits(bits);
561        self
562    }
563}
564#[doc = "DCP 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 [dcpctr](index.html) module"]
565pub struct DCPCTR_SPEC;
566impl crate::RegisterSpec for DCPCTR_SPEC {
567    type Ux = u16;
568}
569#[doc = "`read()` method returns [dcpctr::R](R) reader structure"]
570impl crate::Readable for DCPCTR_SPEC {
571    type Reader = R;
572}
573#[doc = "`write(|w| ..)` method takes [dcpctr::W](W) writer structure"]
574impl crate::Writable for DCPCTR_SPEC {
575    type Writer = W;
576    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
577    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
578}
579#[doc = "`reset()` method sets DCPCTR to value 0x40"]
580impl crate::Resettable for DCPCTR_SPEC {
581    const RESET_VALUE: Self::Ux = 0x40;
582}