Skip to main content

mcxa_pac/usb0/endpoint/
endpt.rs

1#[doc = "Register `ENDPT` reader"]
2pub type R = crate::R<EndptSpec>;
3#[doc = "Register `ENDPT` writer"]
4pub type W = crate::W<EndptSpec>;
5#[doc = "Field `EPHSHK` reader - Endpoint Handshaking Enable"]
6pub type EphshkR = crate::BitReader;
7#[doc = "Field `EPHSHK` writer - Endpoint Handshaking Enable"]
8pub type EphshkW<'a, REG> = crate::BitWriter<'a, REG>;
9#[doc = "Field `EPSTALL` reader - Endpoint Stalled"]
10pub type EpstallR = crate::BitReader;
11#[doc = "Field `EPSTALL` writer - Endpoint Stalled"]
12pub type EpstallW<'a, REG> = crate::BitWriter<'a, REG>;
13#[doc = "Field `EPTXEN` reader - Endpoint for TX transfers enable"]
14pub type EptxenR = crate::BitReader;
15#[doc = "Field `EPTXEN` writer - Endpoint for TX transfers enable"]
16pub type EptxenW<'a, REG> = crate::BitWriter<'a, REG>;
17#[doc = "Field `EPRXEN` reader - Endpoint for RX transfers enable"]
18pub type EprxenR = crate::BitReader;
19#[doc = "Field `EPRXEN` writer - Endpoint for RX transfers enable"]
20pub type EprxenW<'a, REG> = crate::BitWriter<'a, REG>;
21#[doc = "Control Transfer Disable\n\nValue on reset: 0"]
22#[cfg_attr(feature = "defmt", derive(defmt::Format))]
23#[derive(Clone, Copy, Debug, PartialEq, Eq)]
24pub enum Epctldis {
25    #[doc = "0: Enable"]
26    Enable = 0,
27    #[doc = "1: Disable"]
28    Disable = 1,
29}
30impl From<Epctldis> for bool {
31    #[inline(always)]
32    fn from(variant: Epctldis) -> Self {
33        variant as u8 != 0
34    }
35}
36#[doc = "Field `EPCTLDIS` reader - Control Transfer Disable"]
37pub type EpctldisR = crate::BitReader<Epctldis>;
38impl EpctldisR {
39    #[doc = "Get enumerated values variant"]
40    #[inline(always)]
41    pub const fn variant(&self) -> Epctldis {
42        match self.bits {
43            false => Epctldis::Enable,
44            true => Epctldis::Disable,
45        }
46    }
47    #[doc = "Enable"]
48    #[inline(always)]
49    pub fn is_enable(&self) -> bool {
50        *self == Epctldis::Enable
51    }
52    #[doc = "Disable"]
53    #[inline(always)]
54    pub fn is_disable(&self) -> bool {
55        *self == Epctldis::Disable
56    }
57}
58#[doc = "Field `EPCTLDIS` writer - Control Transfer Disable"]
59pub type EpctldisW<'a, REG> = crate::BitWriter<'a, REG, Epctldis>;
60impl<'a, REG> EpctldisW<'a, REG>
61where
62    REG: crate::Writable + crate::RegisterSpec,
63{
64    #[doc = "Enable"]
65    #[inline(always)]
66    pub fn enable(self) -> &'a mut crate::W<REG> {
67        self.variant(Epctldis::Enable)
68    }
69    #[doc = "Disable"]
70    #[inline(always)]
71    pub fn disable(self) -> &'a mut crate::W<REG> {
72        self.variant(Epctldis::Disable)
73    }
74}
75#[doc = "Retry Disable\n\nValue on reset: 0"]
76#[cfg_attr(feature = "defmt", derive(defmt::Format))]
77#[derive(Clone, Copy, Debug, PartialEq, Eq)]
78pub enum Retrydis {
79    #[doc = "0: Retried NAK'ed transactions in hardware."]
80    Retried = 0,
81    #[doc = "1: Do not retry NAK'ed transactions. When a transaction is NAK'ed, the BDT PID field is updated with the NAK PID, and the TOKEN_DNE interrupt becomes 1."]
82    DoNotRetried = 1,
83}
84impl From<Retrydis> for bool {
85    #[inline(always)]
86    fn from(variant: Retrydis) -> Self {
87        variant as u8 != 0
88    }
89}
90#[doc = "Field `RETRYDIS` reader - Retry Disable"]
91pub type RetrydisR = crate::BitReader<Retrydis>;
92impl RetrydisR {
93    #[doc = "Get enumerated values variant"]
94    #[inline(always)]
95    pub const fn variant(&self) -> Retrydis {
96        match self.bits {
97            false => Retrydis::Retried,
98            true => Retrydis::DoNotRetried,
99        }
100    }
101    #[doc = "Retried NAK'ed transactions in hardware."]
102    #[inline(always)]
103    pub fn is_retried(&self) -> bool {
104        *self == Retrydis::Retried
105    }
106    #[doc = "Do not retry NAK'ed transactions. When a transaction is NAK'ed, the BDT PID field is updated with the NAK PID, and the TOKEN_DNE interrupt becomes 1."]
107    #[inline(always)]
108    pub fn is_do_not_retried(&self) -> bool {
109        *self == Retrydis::DoNotRetried
110    }
111}
112#[doc = "Field `RETRYDIS` writer - Retry Disable"]
113pub type RetrydisW<'a, REG> = crate::BitWriter<'a, REG, Retrydis>;
114impl<'a, REG> RetrydisW<'a, REG>
115where
116    REG: crate::Writable + crate::RegisterSpec,
117{
118    #[doc = "Retried NAK'ed transactions in hardware."]
119    #[inline(always)]
120    pub fn retried(self) -> &'a mut crate::W<REG> {
121        self.variant(Retrydis::Retried)
122    }
123    #[doc = "Do not retry NAK'ed transactions. When a transaction is NAK'ed, the BDT PID field is updated with the NAK PID, and the TOKEN_DNE interrupt becomes 1."]
124    #[inline(always)]
125    pub fn do_not_retried(self) -> &'a mut crate::W<REG> {
126        self.variant(Retrydis::DoNotRetried)
127    }
128}
129#[doc = "Host Without A Hub\n\nValue on reset: 0"]
130#[cfg_attr(feature = "defmt", derive(defmt::Format))]
131#[derive(Clone, Copy, Debug, PartialEq, Eq)]
132pub enum Hostwohub {
133    #[doc = "0: Connected using a hub (USBFS generates PRE_PID as required)"]
134    LsThruHub = 0,
135    #[doc = "1: Connected directly to host without a hub, or was used to attach"]
136    LsDirectConnect = 1,
137}
138impl From<Hostwohub> for bool {
139    #[inline(always)]
140    fn from(variant: Hostwohub) -> Self {
141        variant as u8 != 0
142    }
143}
144#[doc = "Field `HOSTWOHUB` reader - Host Without A Hub"]
145pub type HostwohubR = crate::BitReader<Hostwohub>;
146impl HostwohubR {
147    #[doc = "Get enumerated values variant"]
148    #[inline(always)]
149    pub const fn variant(&self) -> Hostwohub {
150        match self.bits {
151            false => Hostwohub::LsThruHub,
152            true => Hostwohub::LsDirectConnect,
153        }
154    }
155    #[doc = "Connected using a hub (USBFS generates PRE_PID as required)"]
156    #[inline(always)]
157    pub fn is_ls_thru_hub(&self) -> bool {
158        *self == Hostwohub::LsThruHub
159    }
160    #[doc = "Connected directly to host without a hub, or was used to attach"]
161    #[inline(always)]
162    pub fn is_ls_direct_connect(&self) -> bool {
163        *self == Hostwohub::LsDirectConnect
164    }
165}
166#[doc = "Field `HOSTWOHUB` writer - Host Without A Hub"]
167pub type HostwohubW<'a, REG> = crate::BitWriter<'a, REG, Hostwohub>;
168impl<'a, REG> HostwohubW<'a, REG>
169where
170    REG: crate::Writable + crate::RegisterSpec,
171{
172    #[doc = "Connected using a hub (USBFS generates PRE_PID as required)"]
173    #[inline(always)]
174    pub fn ls_thru_hub(self) -> &'a mut crate::W<REG> {
175        self.variant(Hostwohub::LsThruHub)
176    }
177    #[doc = "Connected directly to host without a hub, or was used to attach"]
178    #[inline(always)]
179    pub fn ls_direct_connect(self) -> &'a mut crate::W<REG> {
180        self.variant(Hostwohub::LsDirectConnect)
181    }
182}
183impl R {
184    #[doc = "Bit 0 - Endpoint Handshaking Enable"]
185    #[inline(always)]
186    pub fn ephshk(&self) -> EphshkR {
187        EphshkR::new((self.bits & 1) != 0)
188    }
189    #[doc = "Bit 1 - Endpoint Stalled"]
190    #[inline(always)]
191    pub fn epstall(&self) -> EpstallR {
192        EpstallR::new(((self.bits >> 1) & 1) != 0)
193    }
194    #[doc = "Bit 2 - Endpoint for TX transfers enable"]
195    #[inline(always)]
196    pub fn eptxen(&self) -> EptxenR {
197        EptxenR::new(((self.bits >> 2) & 1) != 0)
198    }
199    #[doc = "Bit 3 - Endpoint for RX transfers enable"]
200    #[inline(always)]
201    pub fn eprxen(&self) -> EprxenR {
202        EprxenR::new(((self.bits >> 3) & 1) != 0)
203    }
204    #[doc = "Bit 4 - Control Transfer Disable"]
205    #[inline(always)]
206    pub fn epctldis(&self) -> EpctldisR {
207        EpctldisR::new(((self.bits >> 4) & 1) != 0)
208    }
209    #[doc = "Bit 6 - Retry Disable"]
210    #[inline(always)]
211    pub fn retrydis(&self) -> RetrydisR {
212        RetrydisR::new(((self.bits >> 6) & 1) != 0)
213    }
214    #[doc = "Bit 7 - Host Without A Hub"]
215    #[inline(always)]
216    pub fn hostwohub(&self) -> HostwohubR {
217        HostwohubR::new(((self.bits >> 7) & 1) != 0)
218    }
219}
220#[cfg(feature = "debug")]
221impl core::fmt::Debug for R {
222    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
223        f.debug_struct("ENDPT")
224            .field("ephshk", &self.ephshk())
225            .field("epstall", &self.epstall())
226            .field("eptxen", &self.eptxen())
227            .field("eprxen", &self.eprxen())
228            .field("epctldis", &self.epctldis())
229            .field("retrydis", &self.retrydis())
230            .field("hostwohub", &self.hostwohub())
231            .finish()
232    }
233}
234impl W {
235    #[doc = "Bit 0 - Endpoint Handshaking Enable"]
236    #[inline(always)]
237    pub fn ephshk(&mut self) -> EphshkW<'_, EndptSpec> {
238        EphshkW::new(self, 0)
239    }
240    #[doc = "Bit 1 - Endpoint Stalled"]
241    #[inline(always)]
242    pub fn epstall(&mut self) -> EpstallW<'_, EndptSpec> {
243        EpstallW::new(self, 1)
244    }
245    #[doc = "Bit 2 - Endpoint for TX transfers enable"]
246    #[inline(always)]
247    pub fn eptxen(&mut self) -> EptxenW<'_, EndptSpec> {
248        EptxenW::new(self, 2)
249    }
250    #[doc = "Bit 3 - Endpoint for RX transfers enable"]
251    #[inline(always)]
252    pub fn eprxen(&mut self) -> EprxenW<'_, EndptSpec> {
253        EprxenW::new(self, 3)
254    }
255    #[doc = "Bit 4 - Control Transfer Disable"]
256    #[inline(always)]
257    pub fn epctldis(&mut self) -> EpctldisW<'_, EndptSpec> {
258        EpctldisW::new(self, 4)
259    }
260    #[doc = "Bit 6 - Retry Disable"]
261    #[inline(always)]
262    pub fn retrydis(&mut self) -> RetrydisW<'_, EndptSpec> {
263        RetrydisW::new(self, 6)
264    }
265    #[doc = "Bit 7 - Host Without A Hub"]
266    #[inline(always)]
267    pub fn hostwohub(&mut self) -> HostwohubW<'_, EndptSpec> {
268        HostwohubW::new(self, 7)
269    }
270}
271#[doc = "Endpoint Control\n\nYou can [`read`](crate::Reg::read) this register and get [`endpt::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`endpt::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
272pub struct EndptSpec;
273impl crate::RegisterSpec for EndptSpec {
274    type Ux = u8;
275}
276#[doc = "`read()` method returns [`endpt::R`](R) reader structure"]
277impl crate::Readable for EndptSpec {}
278#[doc = "`write(|w| ..)` method takes [`endpt::W`](W) writer structure"]
279impl crate::Writable for EndptSpec {
280    type Safety = crate::Unsafe;
281}
282#[doc = "`reset()` method sets ENDPT to value 0"]
283impl crate::Resettable for EndptSpec {}