xmc4100/usb0/
grxstsr.rs

1#[doc = "Register `GRXSTSR` reader"]
2pub type R = crate::R<GRXSTSR_SPEC>;
3#[doc = "Field `EPNum` reader - Endpoint Number"]
4pub type EPNUM_R = crate::FieldReader;
5#[doc = "Field `BCnt` reader - Byte Count"]
6pub type BCNT_R = crate::FieldReader<u16>;
7#[doc = "Data PID\n\nValue on reset: 0"]
8#[derive(Clone, Copy, Debug, PartialEq, Eq)]
9#[repr(u8)]
10pub enum DPID_A {
11    #[doc = "0: DATA0"]
12    VALUE1 = 0,
13    #[doc = "2: DATA1"]
14    VALUE2 = 2,
15    #[doc = "1: DATA2"]
16    VALUE3 = 1,
17    #[doc = "3: MDATA"]
18    VALUE4 = 3,
19}
20impl From<DPID_A> for u8 {
21    #[inline(always)]
22    fn from(variant: DPID_A) -> Self {
23        variant as _
24    }
25}
26impl crate::FieldSpec for DPID_A {
27    type Ux = u8;
28}
29impl crate::IsEnum for DPID_A {}
30#[doc = "Field `DPID` reader - Data PID"]
31pub type DPID_R = crate::FieldReader<DPID_A>;
32impl DPID_R {
33    #[doc = "Get enumerated values variant"]
34    #[inline(always)]
35    pub const fn variant(&self) -> DPID_A {
36        match self.bits {
37            0 => DPID_A::VALUE1,
38            2 => DPID_A::VALUE2,
39            1 => DPID_A::VALUE3,
40            3 => DPID_A::VALUE4,
41            _ => unreachable!(),
42        }
43    }
44    #[doc = "DATA0"]
45    #[inline(always)]
46    pub fn is_value1(&self) -> bool {
47        *self == DPID_A::VALUE1
48    }
49    #[doc = "DATA1"]
50    #[inline(always)]
51    pub fn is_value2(&self) -> bool {
52        *self == DPID_A::VALUE2
53    }
54    #[doc = "DATA2"]
55    #[inline(always)]
56    pub fn is_value3(&self) -> bool {
57        *self == DPID_A::VALUE3
58    }
59    #[doc = "MDATA"]
60    #[inline(always)]
61    pub fn is_value4(&self) -> bool {
62        *self == DPID_A::VALUE4
63    }
64}
65#[doc = "Packet Status\n\nValue on reset: 0"]
66#[derive(Clone, Copy, Debug, PartialEq, Eq)]
67#[repr(u8)]
68pub enum PKT_STS_A {
69    #[doc = "1: Global OUT NAK (triggers an interrupt)"]
70    VALUE1 = 1,
71    #[doc = "2: OUT data packet received"]
72    VALUE2 = 2,
73    #[doc = "3: OUT transfer completed (triggers an interrupt)"]
74    VALUE3 = 3,
75    #[doc = "4: SETUP transaction completed (triggers an interrupt)"]
76    VALUE4 = 4,
77    #[doc = "6: SETUP data packet received"]
78    VALUE5 = 6,
79}
80impl From<PKT_STS_A> for u8 {
81    #[inline(always)]
82    fn from(variant: PKT_STS_A) -> Self {
83        variant as _
84    }
85}
86impl crate::FieldSpec for PKT_STS_A {
87    type Ux = u8;
88}
89impl crate::IsEnum for PKT_STS_A {}
90#[doc = "Field `PktSts` reader - Packet Status"]
91pub type PKT_STS_R = crate::FieldReader<PKT_STS_A>;
92impl PKT_STS_R {
93    #[doc = "Get enumerated values variant"]
94    #[inline(always)]
95    pub const fn variant(&self) -> Option<PKT_STS_A> {
96        match self.bits {
97            1 => Some(PKT_STS_A::VALUE1),
98            2 => Some(PKT_STS_A::VALUE2),
99            3 => Some(PKT_STS_A::VALUE3),
100            4 => Some(PKT_STS_A::VALUE4),
101            6 => Some(PKT_STS_A::VALUE5),
102            _ => None,
103        }
104    }
105    #[doc = "Global OUT NAK (triggers an interrupt)"]
106    #[inline(always)]
107    pub fn is_value1(&self) -> bool {
108        *self == PKT_STS_A::VALUE1
109    }
110    #[doc = "OUT data packet received"]
111    #[inline(always)]
112    pub fn is_value2(&self) -> bool {
113        *self == PKT_STS_A::VALUE2
114    }
115    #[doc = "OUT transfer completed (triggers an interrupt)"]
116    #[inline(always)]
117    pub fn is_value3(&self) -> bool {
118        *self == PKT_STS_A::VALUE3
119    }
120    #[doc = "SETUP transaction completed (triggers an interrupt)"]
121    #[inline(always)]
122    pub fn is_value4(&self) -> bool {
123        *self == PKT_STS_A::VALUE4
124    }
125    #[doc = "SETUP data packet received"]
126    #[inline(always)]
127    pub fn is_value5(&self) -> bool {
128        *self == PKT_STS_A::VALUE5
129    }
130}
131#[doc = "Field `FN` reader - Frame Number"]
132pub type FN_R = crate::FieldReader;
133impl R {
134    #[doc = "Bits 0:3 - Endpoint Number"]
135    #[inline(always)]
136    pub fn epnum(&self) -> EPNUM_R {
137        EPNUM_R::new((self.bits & 0x0f) as u8)
138    }
139    #[doc = "Bits 4:14 - Byte Count"]
140    #[inline(always)]
141    pub fn bcnt(&self) -> BCNT_R {
142        BCNT_R::new(((self.bits >> 4) & 0x07ff) as u16)
143    }
144    #[doc = "Bits 15:16 - Data PID"]
145    #[inline(always)]
146    pub fn dpid(&self) -> DPID_R {
147        DPID_R::new(((self.bits >> 15) & 3) as u8)
148    }
149    #[doc = "Bits 17:20 - Packet Status"]
150    #[inline(always)]
151    pub fn pkt_sts(&self) -> PKT_STS_R {
152        PKT_STS_R::new(((self.bits >> 17) & 0x0f) as u8)
153    }
154    #[doc = "Bits 21:24 - Frame Number"]
155    #[inline(always)]
156    pub fn fn_(&self) -> FN_R {
157        FN_R::new(((self.bits >> 21) & 0x0f) as u8)
158    }
159}
160#[doc = "Receive Status Debug Read Register\n\nYou can [`read`](crate::Reg::read) this register and get [`grxstsr::R`](R). See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
161pub struct GRXSTSR_SPEC;
162impl crate::RegisterSpec for GRXSTSR_SPEC {
163    type Ux = u32;
164}
165#[doc = "`read()` method returns [`grxstsr::R`](R) reader structure"]
166impl crate::Readable for GRXSTSR_SPEC {}
167#[doc = "`reset()` method sets GRXSTSR to value 0"]
168impl crate::Resettable for GRXSTSR_SPEC {
169    const RESET_VALUE: u32 = 0;
170}