efm32gg_pac/efm32gg995/usb/
grxstsp.rs1#[doc = "Register `GRXSTSP` reader"]
2pub struct R(crate::R<GRXSTSP_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<GRXSTSP_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<GRXSTSP_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<GRXSTSP_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Field `CHEPNUM` reader - Channel Number host only / Endpoint Number device only"]
17pub type CHEPNUM_R = crate::FieldReader<u8, u8>;
18#[doc = "Field `BCNT` reader - Byte Count (host or device)"]
19pub type BCNT_R = crate::FieldReader<u16, u16>;
20#[doc = "Field `DPID` reader - Data PID (host or device)"]
21pub type DPID_R = crate::FieldReader<u8, DPID_A>;
22#[doc = "Data PID (host or device)\n\nValue on reset: 0"]
23#[derive(Clone, Copy, Debug, PartialEq, Eq)]
24#[repr(u8)]
25pub enum DPID_A {
26 #[doc = "0: DATA0 PID."]
27 DATA0 = 0,
28 #[doc = "1: DATA1 PID."]
29 DATA1 = 1,
30 #[doc = "2: DATA2 PID."]
31 DATA2 = 2,
32 #[doc = "3: MDATA PID."]
33 MDATA = 3,
34}
35impl From<DPID_A> for u8 {
36 #[inline(always)]
37 fn from(variant: DPID_A) -> Self {
38 variant as _
39 }
40}
41impl DPID_R {
42 #[doc = "Get enumerated values variant"]
43 #[inline(always)]
44 pub fn variant(&self) -> DPID_A {
45 match self.bits {
46 0 => DPID_A::DATA0,
47 1 => DPID_A::DATA1,
48 2 => DPID_A::DATA2,
49 3 => DPID_A::MDATA,
50 _ => unreachable!(),
51 }
52 }
53 #[doc = "Checks if the value of the field is `DATA0`"]
54 #[inline(always)]
55 pub fn is_data0(&self) -> bool {
56 *self == DPID_A::DATA0
57 }
58 #[doc = "Checks if the value of the field is `DATA1`"]
59 #[inline(always)]
60 pub fn is_data1(&self) -> bool {
61 *self == DPID_A::DATA1
62 }
63 #[doc = "Checks if the value of the field is `DATA2`"]
64 #[inline(always)]
65 pub fn is_data2(&self) -> bool {
66 *self == DPID_A::DATA2
67 }
68 #[doc = "Checks if the value of the field is `MDATA`"]
69 #[inline(always)]
70 pub fn is_mdata(&self) -> bool {
71 *self == DPID_A::MDATA
72 }
73}
74#[doc = "Field `PKTSTS` reader - Packet Status (host or device)"]
75pub type PKTSTS_R = crate::FieldReader<u8, PKTSTS_A>;
76#[doc = "Packet Status (host or device)\n\nValue on reset: 0"]
77#[derive(Clone, Copy, Debug, PartialEq, Eq)]
78#[repr(u8)]
79pub enum PKTSTS_A {
80 #[doc = "1: Device mode: Global OUT NAK (triggers an interrupt)."]
81 GOUTNAK = 1,
82 #[doc = "2: Host mode: IN data packet received. Device mode: OUT data packet received."]
83 PKTRCV = 2,
84 #[doc = "3: Host mode: IN transfer completed (triggers an interrupt). Device mode: OUT transfer completed (triggers an interrupt)."]
85 XFERCOMPL = 3,
86 #[doc = "4: Device mode: SETUP transaction completed (triggers an interrupt)."]
87 SETUPCOMPL = 4,
88 #[doc = "5: Host mode: Data toggle error (triggers an interrupt)."]
89 TGLERR = 5,
90 #[doc = "6: Device mode: SETUP data packet received."]
91 SETUPRCV = 6,
92 #[doc = "7: Host mode: Channel halted (triggers an interrupt)."]
93 CHLT = 7,
94}
95impl From<PKTSTS_A> for u8 {
96 #[inline(always)]
97 fn from(variant: PKTSTS_A) -> Self {
98 variant as _
99 }
100}
101impl PKTSTS_R {
102 #[doc = "Get enumerated values variant"]
103 #[inline(always)]
104 pub fn variant(&self) -> Option<PKTSTS_A> {
105 match self.bits {
106 1 => Some(PKTSTS_A::GOUTNAK),
107 2 => Some(PKTSTS_A::PKTRCV),
108 3 => Some(PKTSTS_A::XFERCOMPL),
109 4 => Some(PKTSTS_A::SETUPCOMPL),
110 5 => Some(PKTSTS_A::TGLERR),
111 6 => Some(PKTSTS_A::SETUPRCV),
112 7 => Some(PKTSTS_A::CHLT),
113 _ => None,
114 }
115 }
116 #[doc = "Checks if the value of the field is `GOUTNAK`"]
117 #[inline(always)]
118 pub fn is_goutnak(&self) -> bool {
119 *self == PKTSTS_A::GOUTNAK
120 }
121 #[doc = "Checks if the value of the field is `PKTRCV`"]
122 #[inline(always)]
123 pub fn is_pktrcv(&self) -> bool {
124 *self == PKTSTS_A::PKTRCV
125 }
126 #[doc = "Checks if the value of the field is `XFERCOMPL`"]
127 #[inline(always)]
128 pub fn is_xfercompl(&self) -> bool {
129 *self == PKTSTS_A::XFERCOMPL
130 }
131 #[doc = "Checks if the value of the field is `SETUPCOMPL`"]
132 #[inline(always)]
133 pub fn is_setupcompl(&self) -> bool {
134 *self == PKTSTS_A::SETUPCOMPL
135 }
136 #[doc = "Checks if the value of the field is `TGLERR`"]
137 #[inline(always)]
138 pub fn is_tglerr(&self) -> bool {
139 *self == PKTSTS_A::TGLERR
140 }
141 #[doc = "Checks if the value of the field is `SETUPRCV`"]
142 #[inline(always)]
143 pub fn is_setuprcv(&self) -> bool {
144 *self == PKTSTS_A::SETUPRCV
145 }
146 #[doc = "Checks if the value of the field is `CHLT`"]
147 #[inline(always)]
148 pub fn is_chlt(&self) -> bool {
149 *self == PKTSTS_A::CHLT
150 }
151}
152#[doc = "Field `FN` reader - Frame Number device only"]
153pub type FN_R = crate::FieldReader<u8, u8>;
154impl R {
155 #[doc = "Bits 0:3 - Channel Number host only / Endpoint Number device only"]
156 #[inline(always)]
157 pub fn chepnum(&self) -> CHEPNUM_R {
158 CHEPNUM_R::new((self.bits & 0x0f) as u8)
159 }
160 #[doc = "Bits 4:14 - Byte Count (host or device)"]
161 #[inline(always)]
162 pub fn bcnt(&self) -> BCNT_R {
163 BCNT_R::new(((self.bits >> 4) & 0x07ff) as u16)
164 }
165 #[doc = "Bits 15:16 - Data PID (host or device)"]
166 #[inline(always)]
167 pub fn dpid(&self) -> DPID_R {
168 DPID_R::new(((self.bits >> 15) & 3) as u8)
169 }
170 #[doc = "Bits 17:20 - Packet Status (host or device)"]
171 #[inline(always)]
172 pub fn pktsts(&self) -> PKTSTS_R {
173 PKTSTS_R::new(((self.bits >> 17) & 0x0f) as u8)
174 }
175 #[doc = "Bits 21:24 - Frame Number device only"]
176 #[inline(always)]
177 pub fn fn_(&self) -> FN_R {
178 FN_R::new(((self.bits >> 21) & 0x0f) as u8)
179 }
180}
181#[doc = "Receive Status Read and Pop Register\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [grxstsp](index.html) module"]
182pub struct GRXSTSP_SPEC;
183impl crate::RegisterSpec for GRXSTSP_SPEC {
184 type Ux = u32;
185}
186#[doc = "`read()` method returns [grxstsp::R](R) reader structure"]
187impl crate::Readable for GRXSTSP_SPEC {
188 type Reader = R;
189}
190#[doc = "`reset()` method sets GRXSTSP to value 0"]
191impl crate::Resettable for GRXSTSP_SPEC {
192 const RESET_VALUE: Self::Ux = 0;
193}