xmc4800/usb0_ep0/
diepctl0.rs1#[doc = "Register `DIEPCTL0` reader"]
2pub type R = crate::R<DIEPCTL0_SPEC>;
3#[doc = "Register `DIEPCTL0` writer"]
4pub type W = crate::W<DIEPCTL0_SPEC>;
5#[doc = "Maximum Packet Size\n\nValue on reset: 0"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7#[repr(u8)]
8pub enum MPS_A {
9 #[doc = "0: 64 bytes"]
10 VALUE1 = 0,
11 #[doc = "1: 32 bytes"]
12 VALUE2 = 1,
13 #[doc = "2: 16 bytes"]
14 VALUE3 = 2,
15 #[doc = "3: 8 bytes"]
16 VALUE4 = 3,
17}
18impl From<MPS_A> for u8 {
19 #[inline(always)]
20 fn from(variant: MPS_A) -> Self {
21 variant as _
22 }
23}
24impl crate::FieldSpec for MPS_A {
25 type Ux = u8;
26}
27impl crate::IsEnum for MPS_A {}
28#[doc = "Field `MPS` reader - Maximum Packet Size"]
29pub type MPS_R = crate::FieldReader<MPS_A>;
30impl MPS_R {
31 #[doc = "Get enumerated values variant"]
32 #[inline(always)]
33 pub const fn variant(&self) -> MPS_A {
34 match self.bits {
35 0 => MPS_A::VALUE1,
36 1 => MPS_A::VALUE2,
37 2 => MPS_A::VALUE3,
38 3 => MPS_A::VALUE4,
39 _ => unreachable!(),
40 }
41 }
42 #[doc = "64 bytes"]
43 #[inline(always)]
44 pub fn is_value1(&self) -> bool {
45 *self == MPS_A::VALUE1
46 }
47 #[doc = "32 bytes"]
48 #[inline(always)]
49 pub fn is_value2(&self) -> bool {
50 *self == MPS_A::VALUE2
51 }
52 #[doc = "16 bytes"]
53 #[inline(always)]
54 pub fn is_value3(&self) -> bool {
55 *self == MPS_A::VALUE3
56 }
57 #[doc = "8 bytes"]
58 #[inline(always)]
59 pub fn is_value4(&self) -> bool {
60 *self == MPS_A::VALUE4
61 }
62}
63#[doc = "Field `MPS` writer - Maximum Packet Size"]
64pub type MPS_W<'a, REG> = crate::FieldWriter<'a, REG, 2, MPS_A, crate::Safe>;
65impl<'a, REG> MPS_W<'a, REG>
66where
67 REG: crate::Writable + crate::RegisterSpec,
68 REG::Ux: From<u8>,
69{
70 #[doc = "64 bytes"]
71 #[inline(always)]
72 pub fn value1(self) -> &'a mut crate::W<REG> {
73 self.variant(MPS_A::VALUE1)
74 }
75 #[doc = "32 bytes"]
76 #[inline(always)]
77 pub fn value2(self) -> &'a mut crate::W<REG> {
78 self.variant(MPS_A::VALUE2)
79 }
80 #[doc = "16 bytes"]
81 #[inline(always)]
82 pub fn value3(self) -> &'a mut crate::W<REG> {
83 self.variant(MPS_A::VALUE3)
84 }
85 #[doc = "8 bytes"]
86 #[inline(always)]
87 pub fn value4(self) -> &'a mut crate::W<REG> {
88 self.variant(MPS_A::VALUE4)
89 }
90}
91#[doc = "Field `USBActEP` reader - USB Active Endpoint"]
92pub type USBACT_EP_R = crate::BitReader;
93#[doc = "NAK Status\n\nValue on reset: 0"]
94#[derive(Clone, Copy, Debug, PartialEq, Eq)]
95pub enum NAKSTS_A {
96 #[doc = "0: The core is transmitting non-NAK handshakes based on the FIFO status"]
97 VALUE1 = 0,
98 #[doc = "1: The core is transmitting NAK handshakes on this endpoint."]
99 VALUE2 = 1,
100}
101impl From<NAKSTS_A> for bool {
102 #[inline(always)]
103 fn from(variant: NAKSTS_A) -> Self {
104 variant as u8 != 0
105 }
106}
107#[doc = "Field `NAKSts` reader - NAK Status"]
108pub type NAKSTS_R = crate::BitReader<NAKSTS_A>;
109impl NAKSTS_R {
110 #[doc = "Get enumerated values variant"]
111 #[inline(always)]
112 pub const fn variant(&self) -> NAKSTS_A {
113 match self.bits {
114 false => NAKSTS_A::VALUE1,
115 true => NAKSTS_A::VALUE2,
116 }
117 }
118 #[doc = "The core is transmitting non-NAK handshakes based on the FIFO status"]
119 #[inline(always)]
120 pub fn is_value1(&self) -> bool {
121 *self == NAKSTS_A::VALUE1
122 }
123 #[doc = "The core is transmitting NAK handshakes on this endpoint."]
124 #[inline(always)]
125 pub fn is_value2(&self) -> bool {
126 *self == NAKSTS_A::VALUE2
127 }
128}
129#[doc = "Field `EPType` reader - Endpoint Type"]
130pub type EPTYPE_R = crate::FieldReader;
131#[doc = "Field `Stall` reader - STALL Handshake"]
132pub type STALL_R = crate::BitReader;
133#[doc = "Field `Stall` writer - STALL Handshake"]
134pub type STALL_W<'a, REG> = crate::BitWriter<'a, REG>;
135#[doc = "Field `TxFNum` reader - TxFIFO Number"]
136pub type TX_FNUM_R = crate::FieldReader;
137#[doc = "Field `TxFNum` writer - TxFIFO Number"]
138pub type TX_FNUM_W<'a, REG> = crate::FieldWriter<'a, REG, 4>;
139#[doc = "Field `CNAK` writer - Clear NAK"]
140pub type CNAK_W<'a, REG> = crate::BitWriter<'a, REG>;
141#[doc = "Field `SNAK` writer - Set NAK"]
142pub type SNAK_W<'a, REG> = crate::BitWriter<'a, REG>;
143#[doc = "Field `EPDis` reader - Endpoint Disable"]
144pub type EPDIS_R = crate::BitReader;
145#[doc = "Field `EPDis` writer - Endpoint Disable"]
146pub type EPDIS_W<'a, REG> = crate::BitWriter<'a, REG>;
147#[doc = "Field `EPEna` reader - Endpoint Enable"]
148pub type EPENA_R = crate::BitReader;
149#[doc = "Field `EPEna` writer - Endpoint Enable"]
150pub type EPENA_W<'a, REG> = crate::BitWriter<'a, REG>;
151impl R {
152 #[doc = "Bits 0:1 - Maximum Packet Size"]
153 #[inline(always)]
154 pub fn mps(&self) -> MPS_R {
155 MPS_R::new((self.bits & 3) as u8)
156 }
157 #[doc = "Bit 15 - USB Active Endpoint"]
158 #[inline(always)]
159 pub fn usbact_ep(&self) -> USBACT_EP_R {
160 USBACT_EP_R::new(((self.bits >> 15) & 1) != 0)
161 }
162 #[doc = "Bit 17 - NAK Status"]
163 #[inline(always)]
164 pub fn naksts(&self) -> NAKSTS_R {
165 NAKSTS_R::new(((self.bits >> 17) & 1) != 0)
166 }
167 #[doc = "Bits 18:19 - Endpoint Type"]
168 #[inline(always)]
169 pub fn eptype(&self) -> EPTYPE_R {
170 EPTYPE_R::new(((self.bits >> 18) & 3) as u8)
171 }
172 #[doc = "Bit 21 - STALL Handshake"]
173 #[inline(always)]
174 pub fn stall(&self) -> STALL_R {
175 STALL_R::new(((self.bits >> 21) & 1) != 0)
176 }
177 #[doc = "Bits 22:25 - TxFIFO Number"]
178 #[inline(always)]
179 pub fn tx_fnum(&self) -> TX_FNUM_R {
180 TX_FNUM_R::new(((self.bits >> 22) & 0x0f) as u8)
181 }
182 #[doc = "Bit 30 - Endpoint Disable"]
183 #[inline(always)]
184 pub fn epdis(&self) -> EPDIS_R {
185 EPDIS_R::new(((self.bits >> 30) & 1) != 0)
186 }
187 #[doc = "Bit 31 - Endpoint Enable"]
188 #[inline(always)]
189 pub fn epena(&self) -> EPENA_R {
190 EPENA_R::new(((self.bits >> 31) & 1) != 0)
191 }
192}
193impl W {
194 #[doc = "Bits 0:1 - Maximum Packet Size"]
195 #[inline(always)]
196 pub fn mps(&mut self) -> MPS_W<DIEPCTL0_SPEC> {
197 MPS_W::new(self, 0)
198 }
199 #[doc = "Bit 21 - STALL Handshake"]
200 #[inline(always)]
201 pub fn stall(&mut self) -> STALL_W<DIEPCTL0_SPEC> {
202 STALL_W::new(self, 21)
203 }
204 #[doc = "Bits 22:25 - TxFIFO Number"]
205 #[inline(always)]
206 pub fn tx_fnum(&mut self) -> TX_FNUM_W<DIEPCTL0_SPEC> {
207 TX_FNUM_W::new(self, 22)
208 }
209 #[doc = "Bit 26 - Clear NAK"]
210 #[inline(always)]
211 pub fn cnak(&mut self) -> CNAK_W<DIEPCTL0_SPEC> {
212 CNAK_W::new(self, 26)
213 }
214 #[doc = "Bit 27 - Set NAK"]
215 #[inline(always)]
216 pub fn snak(&mut self) -> SNAK_W<DIEPCTL0_SPEC> {
217 SNAK_W::new(self, 27)
218 }
219 #[doc = "Bit 30 - Endpoint Disable"]
220 #[inline(always)]
221 pub fn epdis(&mut self) -> EPDIS_W<DIEPCTL0_SPEC> {
222 EPDIS_W::new(self, 30)
223 }
224 #[doc = "Bit 31 - Endpoint Enable"]
225 #[inline(always)]
226 pub fn epena(&mut self) -> EPENA_W<DIEPCTL0_SPEC> {
227 EPENA_W::new(self, 31)
228 }
229}
230#[doc = "Device Control IN Endpoint Control Register\n\nYou can [`read`](crate::Reg::read) this register and get [`diepctl0::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`diepctl0::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
231pub struct DIEPCTL0_SPEC;
232impl crate::RegisterSpec for DIEPCTL0_SPEC {
233 type Ux = u32;
234}
235#[doc = "`read()` method returns [`diepctl0::R`](R) reader structure"]
236impl crate::Readable for DIEPCTL0_SPEC {}
237#[doc = "`write(|w| ..)` method takes [`diepctl0::W`](W) writer structure"]
238impl crate::Writable for DIEPCTL0_SPEC {
239 type Safety = crate::Unsafe;
240 const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
241 const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
242}
243#[doc = "`reset()` method sets DIEPCTL0 to value 0x8000"]
244impl crate::Resettable for DIEPCTL0_SPEC {
245 const RESET_VALUE: u32 = 0x8000;
246}