efm32gg942_pac/usb/
doep5_tsiz.rs1#[doc = "Register `DOEP5_TSIZ` reader"]
2pub struct R(crate::R<DOEP5_TSIZ_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<DOEP5_TSIZ_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<DOEP5_TSIZ_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<DOEP5_TSIZ_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `DOEP5_TSIZ` writer"]
17pub struct W(crate::W<DOEP5_TSIZ_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<DOEP5_TSIZ_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<DOEP5_TSIZ_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<DOEP5_TSIZ_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `XFERSIZE` reader - Transfer Size"]
38pub type XFERSIZE_R = crate::FieldReader<u32, u32>;
39#[doc = "Field `XFERSIZE` writer - Transfer Size"]
40pub type XFERSIZE_W<'a> = crate::FieldWriter<'a, u32, DOEP5_TSIZ_SPEC, u32, u32, 19, 0>;
41#[doc = "Field `PKTCNT` reader - Packet Count"]
42pub type PKTCNT_R = crate::FieldReader<u16, u16>;
43#[doc = "Field `PKTCNT` writer - Packet Count"]
44pub type PKTCNT_W<'a> = crate::FieldWriter<'a, u32, DOEP5_TSIZ_SPEC, u16, u16, 10, 19>;
45#[doc = "Receive Data PID / SETUP Packet Count\n\nValue on reset: 0"]
46#[derive(Clone, Copy, Debug, PartialEq)]
47#[repr(u8)]
48pub enum RXDPIDSUPCNT_A {
49 #[doc = "0: DATA0 PID."]
50 DATA0 = 0,
51 #[doc = "1: DATA2 PID / 1 Packet."]
52 DATA2 = 1,
53 #[doc = "2: DATA1 PID / 2 Packets."]
54 DATA1 = 2,
55 #[doc = "3: MDATA PID / 3 Packets."]
56 MDATA = 3,
57}
58impl From<RXDPIDSUPCNT_A> for u8 {
59 #[inline(always)]
60 fn from(variant: RXDPIDSUPCNT_A) -> Self {
61 variant as _
62 }
63}
64#[doc = "Field `RXDPIDSUPCNT` reader - Receive Data PID / SETUP Packet Count"]
65pub type RXDPIDSUPCNT_R = crate::FieldReader<u8, RXDPIDSUPCNT_A>;
66impl RXDPIDSUPCNT_R {
67 #[doc = "Get enumerated values variant"]
68 #[inline(always)]
69 pub fn variant(&self) -> RXDPIDSUPCNT_A {
70 match self.bits {
71 0 => RXDPIDSUPCNT_A::DATA0,
72 1 => RXDPIDSUPCNT_A::DATA2,
73 2 => RXDPIDSUPCNT_A::DATA1,
74 3 => RXDPIDSUPCNT_A::MDATA,
75 _ => unreachable!(),
76 }
77 }
78 #[doc = "Checks if the value of the field is `DATA0`"]
79 #[inline(always)]
80 pub fn is_data0(&self) -> bool {
81 *self == RXDPIDSUPCNT_A::DATA0
82 }
83 #[doc = "Checks if the value of the field is `DATA2`"]
84 #[inline(always)]
85 pub fn is_data2(&self) -> bool {
86 *self == RXDPIDSUPCNT_A::DATA2
87 }
88 #[doc = "Checks if the value of the field is `DATA1`"]
89 #[inline(always)]
90 pub fn is_data1(&self) -> bool {
91 *self == RXDPIDSUPCNT_A::DATA1
92 }
93 #[doc = "Checks if the value of the field is `MDATA`"]
94 #[inline(always)]
95 pub fn is_mdata(&self) -> bool {
96 *self == RXDPIDSUPCNT_A::MDATA
97 }
98}
99impl R {
100 #[doc = "Bits 0:18 - Transfer Size"]
101 #[inline(always)]
102 pub fn xfersize(&self) -> XFERSIZE_R {
103 XFERSIZE_R::new((self.bits & 0x0007_ffff) as u32)
104 }
105 #[doc = "Bits 19:28 - Packet Count"]
106 #[inline(always)]
107 pub fn pktcnt(&self) -> PKTCNT_R {
108 PKTCNT_R::new(((self.bits >> 19) & 0x03ff) as u16)
109 }
110 #[doc = "Bits 29:30 - Receive Data PID / SETUP Packet Count"]
111 #[inline(always)]
112 pub fn rxdpidsupcnt(&self) -> RXDPIDSUPCNT_R {
113 RXDPIDSUPCNT_R::new(((self.bits >> 29) & 3) as u8)
114 }
115}
116impl W {
117 #[doc = "Bits 0:18 - Transfer Size"]
118 #[inline(always)]
119 pub fn xfersize(&mut self) -> XFERSIZE_W {
120 XFERSIZE_W::new(self)
121 }
122 #[doc = "Bits 19:28 - Packet Count"]
123 #[inline(always)]
124 pub fn pktcnt(&mut self) -> PKTCNT_W {
125 PKTCNT_W::new(self)
126 }
127 #[doc = "Writes raw bits to the register."]
128 #[inline(always)]
129 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
130 self.0.bits(bits);
131 self
132 }
133}
134#[doc = "Device OUT Endpoint x+1 Transfer Size 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 [doep5_tsiz](index.html) module"]
135pub struct DOEP5_TSIZ_SPEC;
136impl crate::RegisterSpec for DOEP5_TSIZ_SPEC {
137 type Ux = u32;
138}
139#[doc = "`read()` method returns [doep5_tsiz::R](R) reader structure"]
140impl crate::Readable for DOEP5_TSIZ_SPEC {
141 type Reader = R;
142}
143#[doc = "`write(|w| ..)` method takes [doep5_tsiz::W](W) writer structure"]
144impl crate::Writable for DOEP5_TSIZ_SPEC {
145 type Writer = W;
146}
147#[doc = "`reset()` method sets DOEP5_TSIZ to value 0"]
148impl crate::Resettable for DOEP5_TSIZ_SPEC {
149 #[inline(always)]
150 fn reset_value() -> Self::Ux {
151 0
152 }
153}