efm32lg900_pac/usb/
grxstsr.rs

1#[doc = "Register `GRXSTSR` reader"]
2pub struct R(crate::R<GRXSTSR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<GRXSTSR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<GRXSTSR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<GRXSTSR_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 = "Data PID (host or device)\n\nValue on reset: 0"]
21#[derive(Clone, Copy, Debug, PartialEq)]
22#[repr(u8)]
23pub enum DPID_A {
24    #[doc = "0: DATA0 PID."]
25    DATA0 = 0,
26    #[doc = "1: DATA1 PID."]
27    DATA1 = 1,
28    #[doc = "2: DATA2 PID."]
29    DATA2 = 2,
30    #[doc = "3: MDATA PID."]
31    MDATA = 3,
32}
33impl From<DPID_A> for u8 {
34    #[inline(always)]
35    fn from(variant: DPID_A) -> Self {
36        variant as _
37    }
38}
39#[doc = "Field `DPID` reader - Data PID (host or device)"]
40pub type DPID_R = crate::FieldReader<u8, DPID_A>;
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 = "Packet Status (host or device)\n\nValue on reset: 0"]
75#[derive(Clone, Copy, Debug, PartialEq)]
76#[repr(u8)]
77pub enum PKTSTS_A {
78    #[doc = "1: Device mode: Global OUT NAK (triggers an interrupt)."]
79    GOUTNAK = 1,
80    #[doc = "2: Host mode: IN data packet received. Device mode: OUT data packet received."]
81    PKTRCV = 2,
82    #[doc = "3: Host mode: IN transfer completed (triggers an interrupt). Device mode: OUT transfer completed (triggers an interrupt)."]
83    XFERCOMPL = 3,
84    #[doc = "4: Device mode: SETUP transaction completed (triggers an interrupt)."]
85    SETUPCOMPL = 4,
86    #[doc = "5: Host mode: Data toggle error (triggers an interrupt)."]
87    TGLERR = 5,
88    #[doc = "6: Device mode: SETUP data packet received."]
89    SETUPRCV = 6,
90    #[doc = "7: Host mode: Channel halted (triggers an interrupt)."]
91    CHLT = 7,
92}
93impl From<PKTSTS_A> for u8 {
94    #[inline(always)]
95    fn from(variant: PKTSTS_A) -> Self {
96        variant as _
97    }
98}
99#[doc = "Field `PKTSTS` reader - Packet Status (host or device)"]
100pub type PKTSTS_R = crate::FieldReader<u8, PKTSTS_A>;
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 Debug Read 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 [grxstsr](index.html) module"]
182pub struct GRXSTSR_SPEC;
183impl crate::RegisterSpec for GRXSTSR_SPEC {
184    type Ux = u32;
185}
186#[doc = "`read()` method returns [grxstsr::R](R) reader structure"]
187impl crate::Readable for GRXSTSR_SPEC {
188    type Reader = R;
189}
190#[doc = "`reset()` method sets GRXSTSR to value 0"]
191impl crate::Resettable for GRXSTSR_SPEC {
192    #[inline(always)]
193    fn reset_value() -> Self::Ux {
194        0
195    }
196}