stm32f0/stm32f0x8/usb/
ep0r.rs

1#[doc = "Register `EP0R` reader"]
2pub struct R(crate::R<EP0R_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<EP0R_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<EP0R_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<EP0R_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `EP0R` writer"]
17pub struct W(crate::W<EP0R_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<EP0R_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<EP0R_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<EP0R_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `EA` reader - Endpoint address"]
38pub type EA_R = crate::FieldReader<u8, u8>;
39#[doc = "Field `EA` writer - Endpoint address"]
40pub type EA_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u32, EP0R_SPEC, u8, u8, 4, O>;
41#[doc = "Status bits, for transmission transfers\n\nValue on reset: 0"]
42#[derive(Clone, Copy, Debug, PartialEq)]
43#[repr(u8)]
44pub enum STAT_TX_A {
45    #[doc = "0: all transmission requests addressed to this endpoint are ignored"]
46    Disabled = 0,
47    #[doc = "1: the endpoint is stalled and all transmission requests result in a STALL handshake"]
48    Stall = 1,
49    #[doc = "2: the endpoint is naked and all transmission requests result in a NAK handshake"]
50    Nak = 2,
51    #[doc = "3: this endpoint is enabled for transmission"]
52    Valid = 3,
53}
54impl From<STAT_TX_A> for u8 {
55    #[inline(always)]
56    fn from(variant: STAT_TX_A) -> Self {
57        variant as _
58    }
59}
60#[doc = "Field `STAT_TX` reader - Status bits, for transmission transfers"]
61pub type STAT_TX_R = crate::FieldReader<u8, STAT_TX_A>;
62impl STAT_TX_R {
63    #[doc = "Get enumerated values variant"]
64    #[inline(always)]
65    pub fn variant(&self) -> STAT_TX_A {
66        match self.bits {
67            0 => STAT_TX_A::Disabled,
68            1 => STAT_TX_A::Stall,
69            2 => STAT_TX_A::Nak,
70            3 => STAT_TX_A::Valid,
71            _ => unreachable!(),
72        }
73    }
74    #[doc = "Checks if the value of the field is `Disabled`"]
75    #[inline(always)]
76    pub fn is_disabled(&self) -> bool {
77        *self == STAT_TX_A::Disabled
78    }
79    #[doc = "Checks if the value of the field is `Stall`"]
80    #[inline(always)]
81    pub fn is_stall(&self) -> bool {
82        *self == STAT_TX_A::Stall
83    }
84    #[doc = "Checks if the value of the field is `Nak`"]
85    #[inline(always)]
86    pub fn is_nak(&self) -> bool {
87        *self == STAT_TX_A::Nak
88    }
89    #[doc = "Checks if the value of the field is `Valid`"]
90    #[inline(always)]
91    pub fn is_valid(&self) -> bool {
92        *self == STAT_TX_A::Valid
93    }
94}
95#[doc = "Field `STAT_TX` writer - Status bits, for transmission transfers"]
96pub type STAT_TX_W<'a, const O: u8> =
97    crate::FieldWriterSafe<'a, u32, EP0R_SPEC, u8, STAT_TX_A, 2, O>;
98impl<'a, const O: u8> STAT_TX_W<'a, O> {
99    #[doc = "all transmission requests addressed to this endpoint are ignored"]
100    #[inline(always)]
101    pub fn disabled(self) -> &'a mut W {
102        self.variant(STAT_TX_A::Disabled)
103    }
104    #[doc = "the endpoint is stalled and all transmission requests result in a STALL handshake"]
105    #[inline(always)]
106    pub fn stall(self) -> &'a mut W {
107        self.variant(STAT_TX_A::Stall)
108    }
109    #[doc = "the endpoint is naked and all transmission requests result in a NAK handshake"]
110    #[inline(always)]
111    pub fn nak(self) -> &'a mut W {
112        self.variant(STAT_TX_A::Nak)
113    }
114    #[doc = "this endpoint is enabled for transmission"]
115    #[inline(always)]
116    pub fn valid(self) -> &'a mut W {
117        self.variant(STAT_TX_A::Valid)
118    }
119}
120#[doc = "Field `DTOG_TX` reader - Data Toggle, for transmission transfers"]
121pub type DTOG_TX_R = crate::BitReader<bool>;
122#[doc = "Field `DTOG_TX` writer - Data Toggle, for transmission transfers"]
123pub type DTOG_TX_W<'a, const O: u8> = crate::BitWriter<'a, u32, EP0R_SPEC, bool, O>;
124#[doc = "Field `CTR_TX` reader - Correct Transfer for transmission"]
125pub type CTR_TX_R = crate::BitReader<bool>;
126#[doc = "Field `CTR_TX` writer - Correct Transfer for transmission"]
127pub type CTR_TX_W<'a, const O: u8> = crate::BitWriter<'a, u32, EP0R_SPEC, bool, O>;
128#[doc = "Field `EP_KIND` reader - Endpoint kind"]
129pub type EP_KIND_R = crate::BitReader<bool>;
130#[doc = "Field `EP_KIND` writer - Endpoint kind"]
131pub type EP_KIND_W<'a, const O: u8> = crate::BitWriter<'a, u32, EP0R_SPEC, bool, O>;
132#[doc = "Endpoint type\n\nValue on reset: 0"]
133#[derive(Clone, Copy, Debug, PartialEq)]
134#[repr(u8)]
135pub enum EP_TYPE_A {
136    #[doc = "0: Bulk endpoint"]
137    Bulk = 0,
138    #[doc = "1: Control endpoint"]
139    Control = 1,
140    #[doc = "2: Iso endpoint"]
141    Iso = 2,
142    #[doc = "3: Interrupt endpoint"]
143    Interrupt = 3,
144}
145impl From<EP_TYPE_A> for u8 {
146    #[inline(always)]
147    fn from(variant: EP_TYPE_A) -> Self {
148        variant as _
149    }
150}
151#[doc = "Field `EP_TYPE` reader - Endpoint type"]
152pub type EP_TYPE_R = crate::FieldReader<u8, EP_TYPE_A>;
153impl EP_TYPE_R {
154    #[doc = "Get enumerated values variant"]
155    #[inline(always)]
156    pub fn variant(&self) -> EP_TYPE_A {
157        match self.bits {
158            0 => EP_TYPE_A::Bulk,
159            1 => EP_TYPE_A::Control,
160            2 => EP_TYPE_A::Iso,
161            3 => EP_TYPE_A::Interrupt,
162            _ => unreachable!(),
163        }
164    }
165    #[doc = "Checks if the value of the field is `Bulk`"]
166    #[inline(always)]
167    pub fn is_bulk(&self) -> bool {
168        *self == EP_TYPE_A::Bulk
169    }
170    #[doc = "Checks if the value of the field is `Control`"]
171    #[inline(always)]
172    pub fn is_control(&self) -> bool {
173        *self == EP_TYPE_A::Control
174    }
175    #[doc = "Checks if the value of the field is `Iso`"]
176    #[inline(always)]
177    pub fn is_iso(&self) -> bool {
178        *self == EP_TYPE_A::Iso
179    }
180    #[doc = "Checks if the value of the field is `Interrupt`"]
181    #[inline(always)]
182    pub fn is_interrupt(&self) -> bool {
183        *self == EP_TYPE_A::Interrupt
184    }
185}
186#[doc = "Field `EP_TYPE` writer - Endpoint type"]
187pub type EP_TYPE_W<'a, const O: u8> =
188    crate::FieldWriterSafe<'a, u32, EP0R_SPEC, u8, EP_TYPE_A, 2, O>;
189impl<'a, const O: u8> EP_TYPE_W<'a, O> {
190    #[doc = "Bulk endpoint"]
191    #[inline(always)]
192    pub fn bulk(self) -> &'a mut W {
193        self.variant(EP_TYPE_A::Bulk)
194    }
195    #[doc = "Control endpoint"]
196    #[inline(always)]
197    pub fn control(self) -> &'a mut W {
198        self.variant(EP_TYPE_A::Control)
199    }
200    #[doc = "Iso endpoint"]
201    #[inline(always)]
202    pub fn iso(self) -> &'a mut W {
203        self.variant(EP_TYPE_A::Iso)
204    }
205    #[doc = "Interrupt endpoint"]
206    #[inline(always)]
207    pub fn interrupt(self) -> &'a mut W {
208        self.variant(EP_TYPE_A::Interrupt)
209    }
210}
211#[doc = "Field `SETUP` reader - Setup transaction completed"]
212pub type SETUP_R = crate::BitReader<bool>;
213#[doc = "Field `SETUP` writer - Setup transaction completed"]
214pub type SETUP_W<'a, const O: u8> = crate::BitWriter<'a, u32, EP0R_SPEC, bool, O>;
215#[doc = "Status bits, for reception transfers\n\nValue on reset: 0"]
216#[derive(Clone, Copy, Debug, PartialEq)]
217#[repr(u8)]
218pub enum STAT_RX_A {
219    #[doc = "0: all reception requests addressed to this endpoint are ignored"]
220    Disabled = 0,
221    #[doc = "1: the endpoint is stalled and all reception requests result in a STALL handshake"]
222    Stall = 1,
223    #[doc = "2: the endpoint is naked and all reception requests result in a NAK handshake"]
224    Nak = 2,
225    #[doc = "3: this endpoint is enabled for reception"]
226    Valid = 3,
227}
228impl From<STAT_RX_A> for u8 {
229    #[inline(always)]
230    fn from(variant: STAT_RX_A) -> Self {
231        variant as _
232    }
233}
234#[doc = "Field `STAT_RX` reader - Status bits, for reception transfers"]
235pub type STAT_RX_R = crate::FieldReader<u8, STAT_RX_A>;
236impl STAT_RX_R {
237    #[doc = "Get enumerated values variant"]
238    #[inline(always)]
239    pub fn variant(&self) -> STAT_RX_A {
240        match self.bits {
241            0 => STAT_RX_A::Disabled,
242            1 => STAT_RX_A::Stall,
243            2 => STAT_RX_A::Nak,
244            3 => STAT_RX_A::Valid,
245            _ => unreachable!(),
246        }
247    }
248    #[doc = "Checks if the value of the field is `Disabled`"]
249    #[inline(always)]
250    pub fn is_disabled(&self) -> bool {
251        *self == STAT_RX_A::Disabled
252    }
253    #[doc = "Checks if the value of the field is `Stall`"]
254    #[inline(always)]
255    pub fn is_stall(&self) -> bool {
256        *self == STAT_RX_A::Stall
257    }
258    #[doc = "Checks if the value of the field is `Nak`"]
259    #[inline(always)]
260    pub fn is_nak(&self) -> bool {
261        *self == STAT_RX_A::Nak
262    }
263    #[doc = "Checks if the value of the field is `Valid`"]
264    #[inline(always)]
265    pub fn is_valid(&self) -> bool {
266        *self == STAT_RX_A::Valid
267    }
268}
269#[doc = "Field `STAT_RX` writer - Status bits, for reception transfers"]
270pub type STAT_RX_W<'a, const O: u8> =
271    crate::FieldWriterSafe<'a, u32, EP0R_SPEC, u8, STAT_RX_A, 2, O>;
272impl<'a, const O: u8> STAT_RX_W<'a, O> {
273    #[doc = "all reception requests addressed to this endpoint are ignored"]
274    #[inline(always)]
275    pub fn disabled(self) -> &'a mut W {
276        self.variant(STAT_RX_A::Disabled)
277    }
278    #[doc = "the endpoint is stalled and all reception requests result in a STALL handshake"]
279    #[inline(always)]
280    pub fn stall(self) -> &'a mut W {
281        self.variant(STAT_RX_A::Stall)
282    }
283    #[doc = "the endpoint is naked and all reception requests result in a NAK handshake"]
284    #[inline(always)]
285    pub fn nak(self) -> &'a mut W {
286        self.variant(STAT_RX_A::Nak)
287    }
288    #[doc = "this endpoint is enabled for reception"]
289    #[inline(always)]
290    pub fn valid(self) -> &'a mut W {
291        self.variant(STAT_RX_A::Valid)
292    }
293}
294#[doc = "Field `DTOG_RX` reader - Data Toggle, for reception transfers"]
295pub type DTOG_RX_R = crate::BitReader<bool>;
296#[doc = "Field `DTOG_RX` writer - Data Toggle, for reception transfers"]
297pub type DTOG_RX_W<'a, const O: u8> = crate::BitWriter<'a, u32, EP0R_SPEC, bool, O>;
298#[doc = "Field `CTR_RX` reader - Correct transfer for reception"]
299pub type CTR_RX_R = crate::BitReader<bool>;
300#[doc = "Field `CTR_RX` writer - Correct transfer for reception"]
301pub type CTR_RX_W<'a, const O: u8> = crate::BitWriter<'a, u32, EP0R_SPEC, bool, O>;
302impl R {
303    #[doc = "Bits 0:3 - Endpoint address"]
304    #[inline(always)]
305    pub fn ea(&self) -> EA_R {
306        EA_R::new((self.bits & 0x0f) as u8)
307    }
308    #[doc = "Bits 4:5 - Status bits, for transmission transfers"]
309    #[inline(always)]
310    pub fn stat_tx(&self) -> STAT_TX_R {
311        STAT_TX_R::new(((self.bits >> 4) & 3) as u8)
312    }
313    #[doc = "Bit 6 - Data Toggle, for transmission transfers"]
314    #[inline(always)]
315    pub fn dtog_tx(&self) -> DTOG_TX_R {
316        DTOG_TX_R::new(((self.bits >> 6) & 1) != 0)
317    }
318    #[doc = "Bit 7 - Correct Transfer for transmission"]
319    #[inline(always)]
320    pub fn ctr_tx(&self) -> CTR_TX_R {
321        CTR_TX_R::new(((self.bits >> 7) & 1) != 0)
322    }
323    #[doc = "Bit 8 - Endpoint kind"]
324    #[inline(always)]
325    pub fn ep_kind(&self) -> EP_KIND_R {
326        EP_KIND_R::new(((self.bits >> 8) & 1) != 0)
327    }
328    #[doc = "Bits 9:10 - Endpoint type"]
329    #[inline(always)]
330    pub fn ep_type(&self) -> EP_TYPE_R {
331        EP_TYPE_R::new(((self.bits >> 9) & 3) as u8)
332    }
333    #[doc = "Bit 11 - Setup transaction completed"]
334    #[inline(always)]
335    pub fn setup(&self) -> SETUP_R {
336        SETUP_R::new(((self.bits >> 11) & 1) != 0)
337    }
338    #[doc = "Bits 12:13 - Status bits, for reception transfers"]
339    #[inline(always)]
340    pub fn stat_rx(&self) -> STAT_RX_R {
341        STAT_RX_R::new(((self.bits >> 12) & 3) as u8)
342    }
343    #[doc = "Bit 14 - Data Toggle, for reception transfers"]
344    #[inline(always)]
345    pub fn dtog_rx(&self) -> DTOG_RX_R {
346        DTOG_RX_R::new(((self.bits >> 14) & 1) != 0)
347    }
348    #[doc = "Bit 15 - Correct transfer for reception"]
349    #[inline(always)]
350    pub fn ctr_rx(&self) -> CTR_RX_R {
351        CTR_RX_R::new(((self.bits >> 15) & 1) != 0)
352    }
353}
354impl W {
355    #[doc = "Bits 0:3 - Endpoint address"]
356    #[inline(always)]
357    pub fn ea(&mut self) -> EA_W<0> {
358        EA_W::new(self)
359    }
360    #[doc = "Bits 4:5 - Status bits, for transmission transfers"]
361    #[inline(always)]
362    pub fn stat_tx(&mut self) -> STAT_TX_W<4> {
363        STAT_TX_W::new(self)
364    }
365    #[doc = "Bit 6 - Data Toggle, for transmission transfers"]
366    #[inline(always)]
367    pub fn dtog_tx(&mut self) -> DTOG_TX_W<6> {
368        DTOG_TX_W::new(self)
369    }
370    #[doc = "Bit 7 - Correct Transfer for transmission"]
371    #[inline(always)]
372    pub fn ctr_tx(&mut self) -> CTR_TX_W<7> {
373        CTR_TX_W::new(self)
374    }
375    #[doc = "Bit 8 - Endpoint kind"]
376    #[inline(always)]
377    pub fn ep_kind(&mut self) -> EP_KIND_W<8> {
378        EP_KIND_W::new(self)
379    }
380    #[doc = "Bits 9:10 - Endpoint type"]
381    #[inline(always)]
382    pub fn ep_type(&mut self) -> EP_TYPE_W<9> {
383        EP_TYPE_W::new(self)
384    }
385    #[doc = "Bit 11 - Setup transaction completed"]
386    #[inline(always)]
387    pub fn setup(&mut self) -> SETUP_W<11> {
388        SETUP_W::new(self)
389    }
390    #[doc = "Bits 12:13 - Status bits, for reception transfers"]
391    #[inline(always)]
392    pub fn stat_rx(&mut self) -> STAT_RX_W<12> {
393        STAT_RX_W::new(self)
394    }
395    #[doc = "Bit 14 - Data Toggle, for reception transfers"]
396    #[inline(always)]
397    pub fn dtog_rx(&mut self) -> DTOG_RX_W<14> {
398        DTOG_RX_W::new(self)
399    }
400    #[doc = "Bit 15 - Correct transfer for reception"]
401    #[inline(always)]
402    pub fn ctr_rx(&mut self) -> CTR_RX_W<15> {
403        CTR_RX_W::new(self)
404    }
405    #[doc = "Writes raw bits to the register."]
406    #[inline(always)]
407    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
408        self.0.bits(bits);
409        self
410    }
411}
412#[doc = "endpoint 0 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 [ep0r](index.html) module"]
413pub struct EP0R_SPEC;
414impl crate::RegisterSpec for EP0R_SPEC {
415    type Ux = u32;
416}
417#[doc = "`read()` method returns [ep0r::R](R) reader structure"]
418impl crate::Readable for EP0R_SPEC {
419    type Reader = R;
420}
421#[doc = "`write(|w| ..)` method takes [ep0r::W](W) writer structure"]
422impl crate::Writable for EP0R_SPEC {
423    type Writer = W;
424}
425#[doc = "`reset()` method sets EP0R to value 0"]
426impl crate::Resettable for EP0R_SPEC {
427    #[inline(always)]
428    fn reset_value() -> Self::Ux {
429        0
430    }
431}