xmc4500/usb0_ep1/
diepctl_intbulk.rs

1#[doc = "Register `DIEPCTL_INTBULK` reader"]
2pub type R = crate::R<DIEPCTL_INTBULK_SPEC>;
3#[doc = "Register `DIEPCTL_INTBULK` writer"]
4pub type W = crate::W<DIEPCTL_INTBULK_SPEC>;
5#[doc = "Field `MPS` reader - Maximum Packet Size"]
6pub type MPS_R = crate::FieldReader<u16>;
7#[doc = "Field `MPS` writer - Maximum Packet Size"]
8pub type MPS_W<'a, REG> = crate::FieldWriter<'a, REG, 11, u16>;
9#[doc = "Field `USBActEP` reader - USB Active Endpoint"]
10pub type USBACT_EP_R = crate::BitReader;
11#[doc = "Field `USBActEP` writer - USB Active Endpoint"]
12pub type USBACT_EP_W<'a, REG> = crate::BitWriter<'a, REG>;
13#[doc = "Endpoint Data PID\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq, Eq)]
15pub enum DPID_A {
16    #[doc = "0: DATA0"]
17    VALUE1 = 0,
18    #[doc = "1: DATA1"]
19    VALUE2 = 1,
20}
21impl From<DPID_A> for bool {
22    #[inline(always)]
23    fn from(variant: DPID_A) -> Self {
24        variant as u8 != 0
25    }
26}
27#[doc = "Field `DPID` reader - Endpoint Data PID"]
28pub type DPID_R = crate::BitReader<DPID_A>;
29impl DPID_R {
30    #[doc = "Get enumerated values variant"]
31    #[inline(always)]
32    pub const fn variant(&self) -> DPID_A {
33        match self.bits {
34            false => DPID_A::VALUE1,
35            true => DPID_A::VALUE2,
36        }
37    }
38    #[doc = "DATA0"]
39    #[inline(always)]
40    pub fn is_value1(&self) -> bool {
41        *self == DPID_A::VALUE1
42    }
43    #[doc = "DATA1"]
44    #[inline(always)]
45    pub fn is_value2(&self) -> bool {
46        *self == DPID_A::VALUE2
47    }
48}
49#[doc = "NAK Status\n\nValue on reset: 0"]
50#[derive(Clone, Copy, Debug, PartialEq, Eq)]
51pub enum NAKSTS_A {
52    #[doc = "0: The core is transmitting non-NAK handshakes based on the FIFO status."]
53    VALUE1 = 0,
54    #[doc = "1: The core is transmitting NAK handshakes on this endpoint."]
55    VALUE2 = 1,
56}
57impl From<NAKSTS_A> for bool {
58    #[inline(always)]
59    fn from(variant: NAKSTS_A) -> Self {
60        variant as u8 != 0
61    }
62}
63#[doc = "Field `NAKSts` reader - NAK Status"]
64pub type NAKSTS_R = crate::BitReader<NAKSTS_A>;
65impl NAKSTS_R {
66    #[doc = "Get enumerated values variant"]
67    #[inline(always)]
68    pub const fn variant(&self) -> NAKSTS_A {
69        match self.bits {
70            false => NAKSTS_A::VALUE1,
71            true => NAKSTS_A::VALUE2,
72        }
73    }
74    #[doc = "The core is transmitting non-NAK handshakes based on the FIFO status."]
75    #[inline(always)]
76    pub fn is_value1(&self) -> bool {
77        *self == NAKSTS_A::VALUE1
78    }
79    #[doc = "The core is transmitting NAK handshakes on this endpoint."]
80    #[inline(always)]
81    pub fn is_value2(&self) -> bool {
82        *self == NAKSTS_A::VALUE2
83    }
84}
85#[doc = "Endpoint Type\n\nValue on reset: 0"]
86#[derive(Clone, Copy, Debug, PartialEq, Eq)]
87#[repr(u8)]
88pub enum EPTYPE_A {
89    #[doc = "0: Control"]
90    VALUE1 = 0,
91    #[doc = "1: Isochronous"]
92    VALUE2 = 1,
93    #[doc = "2: Bulk"]
94    VALUE3 = 2,
95    #[doc = "3: Interrupt"]
96    VALUE4 = 3,
97}
98impl From<EPTYPE_A> for u8 {
99    #[inline(always)]
100    fn from(variant: EPTYPE_A) -> Self {
101        variant as _
102    }
103}
104impl crate::FieldSpec for EPTYPE_A {
105    type Ux = u8;
106}
107impl crate::IsEnum for EPTYPE_A {}
108#[doc = "Field `EPType` reader - Endpoint Type"]
109pub type EPTYPE_R = crate::FieldReader<EPTYPE_A>;
110impl EPTYPE_R {
111    #[doc = "Get enumerated values variant"]
112    #[inline(always)]
113    pub const fn variant(&self) -> EPTYPE_A {
114        match self.bits {
115            0 => EPTYPE_A::VALUE1,
116            1 => EPTYPE_A::VALUE2,
117            2 => EPTYPE_A::VALUE3,
118            3 => EPTYPE_A::VALUE4,
119            _ => unreachable!(),
120        }
121    }
122    #[doc = "Control"]
123    #[inline(always)]
124    pub fn is_value1(&self) -> bool {
125        *self == EPTYPE_A::VALUE1
126    }
127    #[doc = "Isochronous"]
128    #[inline(always)]
129    pub fn is_value2(&self) -> bool {
130        *self == EPTYPE_A::VALUE2
131    }
132    #[doc = "Bulk"]
133    #[inline(always)]
134    pub fn is_value3(&self) -> bool {
135        *self == EPTYPE_A::VALUE3
136    }
137    #[doc = "Interrupt"]
138    #[inline(always)]
139    pub fn is_value4(&self) -> bool {
140        *self == EPTYPE_A::VALUE4
141    }
142}
143#[doc = "Field `EPType` writer - Endpoint Type"]
144pub type EPTYPE_W<'a, REG> = crate::FieldWriter<'a, REG, 2, EPTYPE_A, crate::Safe>;
145impl<'a, REG> EPTYPE_W<'a, REG>
146where
147    REG: crate::Writable + crate::RegisterSpec,
148    REG::Ux: From<u8>,
149{
150    #[doc = "Control"]
151    #[inline(always)]
152    pub fn value1(self) -> &'a mut crate::W<REG> {
153        self.variant(EPTYPE_A::VALUE1)
154    }
155    #[doc = "Isochronous"]
156    #[inline(always)]
157    pub fn value2(self) -> &'a mut crate::W<REG> {
158        self.variant(EPTYPE_A::VALUE2)
159    }
160    #[doc = "Bulk"]
161    #[inline(always)]
162    pub fn value3(self) -> &'a mut crate::W<REG> {
163        self.variant(EPTYPE_A::VALUE3)
164    }
165    #[doc = "Interrupt"]
166    #[inline(always)]
167    pub fn value4(self) -> &'a mut crate::W<REG> {
168        self.variant(EPTYPE_A::VALUE4)
169    }
170}
171#[doc = "Field `Snp` reader - Snoop Mode"]
172pub type SNP_R = crate::BitReader;
173#[doc = "Field `Snp` writer - Snoop Mode"]
174pub type SNP_W<'a, REG> = crate::BitWriter<'a, REG>;
175#[doc = "Field `Stall` reader - STALL Handshake"]
176pub type STALL_R = crate::BitReader;
177#[doc = "Field `Stall` writer - STALL Handshake"]
178pub type STALL_W<'a, REG> = crate::BitWriter<'a, REG>;
179#[doc = "Field `TxFNum` reader - TxFIFO Number"]
180pub type TX_FNUM_R = crate::FieldReader;
181#[doc = "Field `TxFNum` writer - TxFIFO Number"]
182pub type TX_FNUM_W<'a, REG> = crate::FieldWriter<'a, REG, 4>;
183#[doc = "Field `CNAK` writer - Clear NAK"]
184pub type CNAK_W<'a, REG> = crate::BitWriter<'a, REG>;
185#[doc = "Field `SNAK` writer - Set NAK"]
186pub type SNAK_W<'a, REG> = crate::BitWriter<'a, REG>;
187#[doc = "Field `SetD0PID` writer - Set DATA0 PID"]
188pub type SET_D0PID_W<'a, REG> = crate::BitWriter<'a, REG>;
189#[doc = "Field `SetD1PID` writer - 29 Set DATA1 PID"]
190pub type SET_D1PID_W<'a, REG> = crate::BitWriter<'a, REG>;
191#[doc = "Field `EPDis` reader - Endpoint Disable"]
192pub type EPDIS_R = crate::BitReader;
193#[doc = "Field `EPDis` writer - Endpoint Disable"]
194pub type EPDIS_W<'a, REG> = crate::BitWriter<'a, REG>;
195#[doc = "Field `EPEna` reader - Endpoint Enable"]
196pub type EPENA_R = crate::BitReader;
197#[doc = "Field `EPEna` writer - Endpoint Enable"]
198pub type EPENA_W<'a, REG> = crate::BitWriter<'a, REG>;
199impl R {
200    #[doc = "Bits 0:10 - Maximum Packet Size"]
201    #[inline(always)]
202    pub fn mps(&self) -> MPS_R {
203        MPS_R::new((self.bits & 0x07ff) as u16)
204    }
205    #[doc = "Bit 15 - USB Active Endpoint"]
206    #[inline(always)]
207    pub fn usbact_ep(&self) -> USBACT_EP_R {
208        USBACT_EP_R::new(((self.bits >> 15) & 1) != 0)
209    }
210    #[doc = "Bit 16 - Endpoint Data PID"]
211    #[inline(always)]
212    pub fn dpid(&self) -> DPID_R {
213        DPID_R::new(((self.bits >> 16) & 1) != 0)
214    }
215    #[doc = "Bit 17 - NAK Status"]
216    #[inline(always)]
217    pub fn naksts(&self) -> NAKSTS_R {
218        NAKSTS_R::new(((self.bits >> 17) & 1) != 0)
219    }
220    #[doc = "Bits 18:19 - Endpoint Type"]
221    #[inline(always)]
222    pub fn eptype(&self) -> EPTYPE_R {
223        EPTYPE_R::new(((self.bits >> 18) & 3) as u8)
224    }
225    #[doc = "Bit 20 - Snoop Mode"]
226    #[inline(always)]
227    pub fn snp(&self) -> SNP_R {
228        SNP_R::new(((self.bits >> 20) & 1) != 0)
229    }
230    #[doc = "Bit 21 - STALL Handshake"]
231    #[inline(always)]
232    pub fn stall(&self) -> STALL_R {
233        STALL_R::new(((self.bits >> 21) & 1) != 0)
234    }
235    #[doc = "Bits 22:25 - TxFIFO Number"]
236    #[inline(always)]
237    pub fn tx_fnum(&self) -> TX_FNUM_R {
238        TX_FNUM_R::new(((self.bits >> 22) & 0x0f) as u8)
239    }
240    #[doc = "Bit 30 - Endpoint Disable"]
241    #[inline(always)]
242    pub fn epdis(&self) -> EPDIS_R {
243        EPDIS_R::new(((self.bits >> 30) & 1) != 0)
244    }
245    #[doc = "Bit 31 - Endpoint Enable"]
246    #[inline(always)]
247    pub fn epena(&self) -> EPENA_R {
248        EPENA_R::new(((self.bits >> 31) & 1) != 0)
249    }
250}
251impl W {
252    #[doc = "Bits 0:10 - Maximum Packet Size"]
253    #[inline(always)]
254    pub fn mps(&mut self) -> MPS_W<DIEPCTL_INTBULK_SPEC> {
255        MPS_W::new(self, 0)
256    }
257    #[doc = "Bit 15 - USB Active Endpoint"]
258    #[inline(always)]
259    pub fn usbact_ep(&mut self) -> USBACT_EP_W<DIEPCTL_INTBULK_SPEC> {
260        USBACT_EP_W::new(self, 15)
261    }
262    #[doc = "Bits 18:19 - Endpoint Type"]
263    #[inline(always)]
264    pub fn eptype(&mut self) -> EPTYPE_W<DIEPCTL_INTBULK_SPEC> {
265        EPTYPE_W::new(self, 18)
266    }
267    #[doc = "Bit 20 - Snoop Mode"]
268    #[inline(always)]
269    pub fn snp(&mut self) -> SNP_W<DIEPCTL_INTBULK_SPEC> {
270        SNP_W::new(self, 20)
271    }
272    #[doc = "Bit 21 - STALL Handshake"]
273    #[inline(always)]
274    pub fn stall(&mut self) -> STALL_W<DIEPCTL_INTBULK_SPEC> {
275        STALL_W::new(self, 21)
276    }
277    #[doc = "Bits 22:25 - TxFIFO Number"]
278    #[inline(always)]
279    pub fn tx_fnum(&mut self) -> TX_FNUM_W<DIEPCTL_INTBULK_SPEC> {
280        TX_FNUM_W::new(self, 22)
281    }
282    #[doc = "Bit 26 - Clear NAK"]
283    #[inline(always)]
284    pub fn cnak(&mut self) -> CNAK_W<DIEPCTL_INTBULK_SPEC> {
285        CNAK_W::new(self, 26)
286    }
287    #[doc = "Bit 27 - Set NAK"]
288    #[inline(always)]
289    pub fn snak(&mut self) -> SNAK_W<DIEPCTL_INTBULK_SPEC> {
290        SNAK_W::new(self, 27)
291    }
292    #[doc = "Bit 28 - Set DATA0 PID"]
293    #[inline(always)]
294    pub fn set_d0pid(&mut self) -> SET_D0PID_W<DIEPCTL_INTBULK_SPEC> {
295        SET_D0PID_W::new(self, 28)
296    }
297    #[doc = "Bit 29 - 29 Set DATA1 PID"]
298    #[inline(always)]
299    pub fn set_d1pid(&mut self) -> SET_D1PID_W<DIEPCTL_INTBULK_SPEC> {
300        SET_D1PID_W::new(self, 29)
301    }
302    #[doc = "Bit 30 - Endpoint Disable"]
303    #[inline(always)]
304    pub fn epdis(&mut self) -> EPDIS_W<DIEPCTL_INTBULK_SPEC> {
305        EPDIS_W::new(self, 30)
306    }
307    #[doc = "Bit 31 - Endpoint Enable"]
308    #[inline(always)]
309    pub fn epena(&mut self) -> EPENA_W<DIEPCTL_INTBULK_SPEC> {
310        EPENA_W::new(self, 31)
311    }
312}
313#[doc = "Device Endpoint Control Register \\[INTBULK\\]\n\nYou can [`read`](crate::Reg::read) this register and get [`diepctl_intbulk::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`diepctl_intbulk::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
314pub struct DIEPCTL_INTBULK_SPEC;
315impl crate::RegisterSpec for DIEPCTL_INTBULK_SPEC {
316    type Ux = u32;
317}
318#[doc = "`read()` method returns [`diepctl_intbulk::R`](R) reader structure"]
319impl crate::Readable for DIEPCTL_INTBULK_SPEC {}
320#[doc = "`write(|w| ..)` method takes [`diepctl_intbulk::W`](W) writer structure"]
321impl crate::Writable for DIEPCTL_INTBULK_SPEC {
322    type Safety = crate::Unsafe;
323    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
324    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
325}
326#[doc = "`reset()` method sets DIEPCTL_INTBULK to value 0"]
327impl crate::Resettable for DIEPCTL_INTBULK_SPEC {
328    const RESET_VALUE: u32 = 0;
329}