efm32gg990_pac/usb/
doep0ctl.rs1#[doc = "Register `DOEP0CTL` reader"]
2pub struct R(crate::R<DOEP0CTL_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<DOEP0CTL_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<DOEP0CTL_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<DOEP0CTL_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `DOEP0CTL` writer"]
17pub struct W(crate::W<DOEP0CTL_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<DOEP0CTL_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<DOEP0CTL_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<DOEP0CTL_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Maximum Packet Size\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum MPS_A {
41 #[doc = "0: 64 bytes."]
42 _64B = 0,
43 #[doc = "1: 32 bytes."]
44 _32B = 1,
45 #[doc = "2: 16 bytes."]
46 _16B = 2,
47 #[doc = "3: 8 bytes."]
48 _8B = 3,
49}
50impl From<MPS_A> for u8 {
51 #[inline(always)]
52 fn from(variant: MPS_A) -> Self {
53 variant as _
54 }
55}
56#[doc = "Field `MPS` reader - Maximum Packet Size"]
57pub type MPS_R = crate::FieldReader<u8, MPS_A>;
58impl MPS_R {
59 #[doc = "Get enumerated values variant"]
60 #[inline(always)]
61 pub fn variant(&self) -> MPS_A {
62 match self.bits {
63 0 => MPS_A::_64B,
64 1 => MPS_A::_32B,
65 2 => MPS_A::_16B,
66 3 => MPS_A::_8B,
67 _ => unreachable!(),
68 }
69 }
70 #[doc = "Checks if the value of the field is `_64B`"]
71 #[inline(always)]
72 pub fn is_64b(&self) -> bool {
73 *self == MPS_A::_64B
74 }
75 #[doc = "Checks if the value of the field is `_32B`"]
76 #[inline(always)]
77 pub fn is_32b(&self) -> bool {
78 *self == MPS_A::_32B
79 }
80 #[doc = "Checks if the value of the field is `_16B`"]
81 #[inline(always)]
82 pub fn is_16b(&self) -> bool {
83 *self == MPS_A::_16B
84 }
85 #[doc = "Checks if the value of the field is `_8B`"]
86 #[inline(always)]
87 pub fn is_8b(&self) -> bool {
88 *self == MPS_A::_8B
89 }
90}
91#[doc = "Field `USBACTEP` reader - USB Active Endpoint"]
92pub type USBACTEP_R = crate::BitReader<bool>;
93#[doc = "Field `NAKSTS` reader - NAK Status"]
94pub type NAKSTS_R = crate::BitReader<bool>;
95#[doc = "Field `EPTYPE` reader - Endpoint Type"]
96pub type EPTYPE_R = crate::FieldReader<u8, u8>;
97#[doc = "Field `SNP` reader - Snoop Mode"]
98pub type SNP_R = crate::BitReader<bool>;
99#[doc = "Field `SNP` writer - Snoop Mode"]
100pub type SNP_W<'a> = crate::BitWriter<'a, u32, DOEP0CTL_SPEC, bool, 20>;
101#[doc = "Field `STALL` reader - Handshake"]
102pub type STALL_R = crate::BitReader<bool>;
103#[doc = "Field `STALL` writer - Handshake"]
104pub type STALL_W<'a> = crate::BitWriter<'a, u32, DOEP0CTL_SPEC, bool, 21>;
105#[doc = "Field `CNAK` writer - Clear NAK"]
106pub type CNAK_W<'a> = crate::BitWriter<'a, u32, DOEP0CTL_SPEC, bool, 26>;
107#[doc = "Field `SNAK` writer - Set NAK"]
108pub type SNAK_W<'a> = crate::BitWriter<'a, u32, DOEP0CTL_SPEC, bool, 27>;
109#[doc = "Field `EPDIS` reader - Endpoint Disable"]
110pub type EPDIS_R = crate::BitReader<bool>;
111#[doc = "Field `EPENA` reader - Endpoint Enable"]
112pub type EPENA_R = crate::BitReader<bool>;
113#[doc = "Field `EPENA` writer - Endpoint Enable"]
114pub type EPENA_W<'a> = crate::BitWriter<'a, u32, DOEP0CTL_SPEC, bool, 31>;
115impl R {
116 #[doc = "Bits 0:1 - Maximum Packet Size"]
117 #[inline(always)]
118 pub fn mps(&self) -> MPS_R {
119 MPS_R::new((self.bits & 3) as u8)
120 }
121 #[doc = "Bit 15 - USB Active Endpoint"]
122 #[inline(always)]
123 pub fn usbactep(&self) -> USBACTEP_R {
124 USBACTEP_R::new(((self.bits >> 15) & 1) != 0)
125 }
126 #[doc = "Bit 17 - NAK Status"]
127 #[inline(always)]
128 pub fn naksts(&self) -> NAKSTS_R {
129 NAKSTS_R::new(((self.bits >> 17) & 1) != 0)
130 }
131 #[doc = "Bits 18:19 - Endpoint Type"]
132 #[inline(always)]
133 pub fn eptype(&self) -> EPTYPE_R {
134 EPTYPE_R::new(((self.bits >> 18) & 3) as u8)
135 }
136 #[doc = "Bit 20 - Snoop Mode"]
137 #[inline(always)]
138 pub fn snp(&self) -> SNP_R {
139 SNP_R::new(((self.bits >> 20) & 1) != 0)
140 }
141 #[doc = "Bit 21 - Handshake"]
142 #[inline(always)]
143 pub fn stall(&self) -> STALL_R {
144 STALL_R::new(((self.bits >> 21) & 1) != 0)
145 }
146 #[doc = "Bit 30 - Endpoint Disable"]
147 #[inline(always)]
148 pub fn epdis(&self) -> EPDIS_R {
149 EPDIS_R::new(((self.bits >> 30) & 1) != 0)
150 }
151 #[doc = "Bit 31 - Endpoint Enable"]
152 #[inline(always)]
153 pub fn epena(&self) -> EPENA_R {
154 EPENA_R::new(((self.bits >> 31) & 1) != 0)
155 }
156}
157impl W {
158 #[doc = "Bit 20 - Snoop Mode"]
159 #[inline(always)]
160 pub fn snp(&mut self) -> SNP_W {
161 SNP_W::new(self)
162 }
163 #[doc = "Bit 21 - Handshake"]
164 #[inline(always)]
165 pub fn stall(&mut self) -> STALL_W {
166 STALL_W::new(self)
167 }
168 #[doc = "Bit 26 - Clear NAK"]
169 #[inline(always)]
170 pub fn cnak(&mut self) -> CNAK_W {
171 CNAK_W::new(self)
172 }
173 #[doc = "Bit 27 - Set NAK"]
174 #[inline(always)]
175 pub fn snak(&mut self) -> SNAK_W {
176 SNAK_W::new(self)
177 }
178 #[doc = "Bit 31 - Endpoint Enable"]
179 #[inline(always)]
180 pub fn epena(&mut self) -> EPENA_W {
181 EPENA_W::new(self)
182 }
183 #[doc = "Writes raw bits to the register."]
184 #[inline(always)]
185 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
186 self.0.bits(bits);
187 self
188 }
189}
190#[doc = "Device OUT Endpoint 0 Control 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 [doep0ctl](index.html) module"]
191pub struct DOEP0CTL_SPEC;
192impl crate::RegisterSpec for DOEP0CTL_SPEC {
193 type Ux = u32;
194}
195#[doc = "`read()` method returns [doep0ctl::R](R) reader structure"]
196impl crate::Readable for DOEP0CTL_SPEC {
197 type Reader = R;
198}
199#[doc = "`write(|w| ..)` method takes [doep0ctl::W](W) writer structure"]
200impl crate::Writable for DOEP0CTL_SPEC {
201 type Writer = W;
202}
203#[doc = "`reset()` method sets DOEP0CTL to value 0x8000"]
204impl crate::Resettable for DOEP0CTL_SPEC {
205 #[inline(always)]
206 fn reset_value() -> Self::Ux {
207 0x8000
208 }
209}