efm32gg11b820/usb/
doep1_ctl.rs

1#[doc = "Reader of register DOEP1_CTL"]
2pub type R = crate::R<u32, super::DOEP1_CTL>;
3#[doc = "Writer for register DOEP1_CTL"]
4pub type W = crate::W<u32, super::DOEP1_CTL>;
5#[doc = "Register DOEP1_CTL `reset()`'s with value 0"]
6impl crate::ResetValue for super::DOEP1_CTL {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Reader of field `MPS`"]
14pub type MPS_R = crate::R<u16, u16>;
15#[doc = "Write proxy for field `MPS`"]
16pub struct MPS_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> MPS_W<'a> {
20    #[doc = r"Writes raw bits to the field"]
21    #[inline(always)]
22    pub unsafe fn bits(self, value: u16) -> &'a mut W {
23        self.w.bits = (self.w.bits & !0x07ff) | ((value as u32) & 0x07ff);
24        self.w
25    }
26}
27#[doc = "Reader of field `USBACTEP`"]
28pub type USBACTEP_R = crate::R<bool, bool>;
29#[doc = "Write proxy for field `USBACTEP`"]
30pub struct USBACTEP_W<'a> {
31    w: &'a mut W,
32}
33impl<'a> USBACTEP_W<'a> {
34    #[doc = r"Sets the field bit"]
35    #[inline(always)]
36    pub fn set_bit(self) -> &'a mut W {
37        self.bit(true)
38    }
39    #[doc = r"Clears the field bit"]
40    #[inline(always)]
41    pub fn clear_bit(self) -> &'a mut W {
42        self.bit(false)
43    }
44    #[doc = r"Writes raw bits to the field"]
45    #[inline(always)]
46    pub fn bit(self, value: bool) -> &'a mut W {
47        self.w.bits = (self.w.bits & !(0x01 << 15)) | (((value as u32) & 0x01) << 15);
48        self.w
49    }
50}
51#[doc = "Reader of field `DPID`"]
52pub type DPID_R = crate::R<bool, bool>;
53#[doc = "Reader of field `NAKSTS`"]
54pub type NAKSTS_R = crate::R<bool, bool>;
55#[doc = "Reader of field `EPTYPE`"]
56pub type EPTYPE_R = crate::R<u8, u8>;
57#[doc = "Write proxy for field `EPTYPE`"]
58pub struct EPTYPE_W<'a> {
59    w: &'a mut W,
60}
61impl<'a> EPTYPE_W<'a> {
62    #[doc = r"Writes raw bits to the field"]
63    #[inline(always)]
64    pub unsafe fn bits(self, value: u8) -> &'a mut W {
65        self.w.bits = (self.w.bits & !(0x03 << 18)) | (((value as u32) & 0x03) << 18);
66        self.w
67    }
68}
69#[doc = "Reader of field `SNP`"]
70pub type SNP_R = crate::R<bool, bool>;
71#[doc = "Write proxy for field `SNP`"]
72pub struct SNP_W<'a> {
73    w: &'a mut W,
74}
75impl<'a> SNP_W<'a> {
76    #[doc = r"Sets the field bit"]
77    #[inline(always)]
78    pub fn set_bit(self) -> &'a mut W {
79        self.bit(true)
80    }
81    #[doc = r"Clears the field bit"]
82    #[inline(always)]
83    pub fn clear_bit(self) -> &'a mut W {
84        self.bit(false)
85    }
86    #[doc = r"Writes raw bits to the field"]
87    #[inline(always)]
88    pub fn bit(self, value: bool) -> &'a mut W {
89        self.w.bits = (self.w.bits & !(0x01 << 20)) | (((value as u32) & 0x01) << 20);
90        self.w
91    }
92}
93#[doc = "Reader of field `STALL`"]
94pub type STALL_R = crate::R<bool, bool>;
95#[doc = "Write proxy for field `STALL`"]
96pub struct STALL_W<'a> {
97    w: &'a mut W,
98}
99impl<'a> STALL_W<'a> {
100    #[doc = r"Sets the field bit"]
101    #[inline(always)]
102    pub fn set_bit(self) -> &'a mut W {
103        self.bit(true)
104    }
105    #[doc = r"Clears the field bit"]
106    #[inline(always)]
107    pub fn clear_bit(self) -> &'a mut W {
108        self.bit(false)
109    }
110    #[doc = r"Writes raw bits to the field"]
111    #[inline(always)]
112    pub fn bit(self, value: bool) -> &'a mut W {
113        self.w.bits = (self.w.bits & !(0x01 << 21)) | (((value as u32) & 0x01) << 21);
114        self.w
115    }
116}
117#[doc = "Write proxy for field `CNAK`"]
118pub struct CNAK_W<'a> {
119    w: &'a mut W,
120}
121impl<'a> CNAK_W<'a> {
122    #[doc = r"Sets the field bit"]
123    #[inline(always)]
124    pub fn set_bit(self) -> &'a mut W {
125        self.bit(true)
126    }
127    #[doc = r"Clears the field bit"]
128    #[inline(always)]
129    pub fn clear_bit(self) -> &'a mut W {
130        self.bit(false)
131    }
132    #[doc = r"Writes raw bits to the field"]
133    #[inline(always)]
134    pub fn bit(self, value: bool) -> &'a mut W {
135        self.w.bits = (self.w.bits & !(0x01 << 26)) | (((value as u32) & 0x01) << 26);
136        self.w
137    }
138}
139#[doc = "Write proxy for field `SNAK`"]
140pub struct SNAK_W<'a> {
141    w: &'a mut W,
142}
143impl<'a> SNAK_W<'a> {
144    #[doc = r"Sets the field bit"]
145    #[inline(always)]
146    pub fn set_bit(self) -> &'a mut W {
147        self.bit(true)
148    }
149    #[doc = r"Clears the field bit"]
150    #[inline(always)]
151    pub fn clear_bit(self) -> &'a mut W {
152        self.bit(false)
153    }
154    #[doc = r"Writes raw bits to the field"]
155    #[inline(always)]
156    pub fn bit(self, value: bool) -> &'a mut W {
157        self.w.bits = (self.w.bits & !(0x01 << 27)) | (((value as u32) & 0x01) << 27);
158        self.w
159    }
160}
161#[doc = "Write proxy for field `SETD0PIDEF`"]
162pub struct SETD0PIDEF_W<'a> {
163    w: &'a mut W,
164}
165impl<'a> SETD0PIDEF_W<'a> {
166    #[doc = r"Sets the field bit"]
167    #[inline(always)]
168    pub fn set_bit(self) -> &'a mut W {
169        self.bit(true)
170    }
171    #[doc = r"Clears the field bit"]
172    #[inline(always)]
173    pub fn clear_bit(self) -> &'a mut W {
174        self.bit(false)
175    }
176    #[doc = r"Writes raw bits to the field"]
177    #[inline(always)]
178    pub fn bit(self, value: bool) -> &'a mut W {
179        self.w.bits = (self.w.bits & !(0x01 << 28)) | (((value as u32) & 0x01) << 28);
180        self.w
181    }
182}
183#[doc = "Write proxy for field `SETD1PIDOF`"]
184pub struct SETD1PIDOF_W<'a> {
185    w: &'a mut W,
186}
187impl<'a> SETD1PIDOF_W<'a> {
188    #[doc = r"Sets the field bit"]
189    #[inline(always)]
190    pub fn set_bit(self) -> &'a mut W {
191        self.bit(true)
192    }
193    #[doc = r"Clears the field bit"]
194    #[inline(always)]
195    pub fn clear_bit(self) -> &'a mut W {
196        self.bit(false)
197    }
198    #[doc = r"Writes raw bits to the field"]
199    #[inline(always)]
200    pub fn bit(self, value: bool) -> &'a mut W {
201        self.w.bits = (self.w.bits & !(0x01 << 29)) | (((value as u32) & 0x01) << 29);
202        self.w
203    }
204}
205#[doc = "Reader of field `EPDIS`"]
206pub type EPDIS_R = crate::R<bool, bool>;
207#[doc = "Write proxy for field `EPDIS`"]
208pub struct EPDIS_W<'a> {
209    w: &'a mut W,
210}
211impl<'a> EPDIS_W<'a> {
212    #[doc = r"Sets the field bit"]
213    #[inline(always)]
214    pub fn set_bit(self) -> &'a mut W {
215        self.bit(true)
216    }
217    #[doc = r"Clears the field bit"]
218    #[inline(always)]
219    pub fn clear_bit(self) -> &'a mut W {
220        self.bit(false)
221    }
222    #[doc = r"Writes raw bits to the field"]
223    #[inline(always)]
224    pub fn bit(self, value: bool) -> &'a mut W {
225        self.w.bits = (self.w.bits & !(0x01 << 30)) | (((value as u32) & 0x01) << 30);
226        self.w
227    }
228}
229#[doc = "Reader of field `EPENA`"]
230pub type EPENA_R = crate::R<bool, bool>;
231#[doc = "Write proxy for field `EPENA`"]
232pub struct EPENA_W<'a> {
233    w: &'a mut W,
234}
235impl<'a> EPENA_W<'a> {
236    #[doc = r"Sets the field bit"]
237    #[inline(always)]
238    pub fn set_bit(self) -> &'a mut W {
239        self.bit(true)
240    }
241    #[doc = r"Clears the field bit"]
242    #[inline(always)]
243    pub fn clear_bit(self) -> &'a mut W {
244        self.bit(false)
245    }
246    #[doc = r"Writes raw bits to the field"]
247    #[inline(always)]
248    pub fn bit(self, value: bool) -> &'a mut W {
249        self.w.bits = (self.w.bits & !(0x01 << 31)) | (((value as u32) & 0x01) << 31);
250        self.w
251    }
252}
253impl R {
254    #[doc = "Bits 0:10 - Maximum Packet Size"]
255    #[inline(always)]
256    pub fn mps(&self) -> MPS_R {
257        MPS_R::new((self.bits & 0x07ff) as u16)
258    }
259    #[doc = "Bit 15 - USB Active Endpoint"]
260    #[inline(always)]
261    pub fn usbactep(&self) -> USBACTEP_R {
262        USBACTEP_R::new(((self.bits >> 15) & 0x01) != 0)
263    }
264    #[doc = "Bit 16 - Endpoint Data PID"]
265    #[inline(always)]
266    pub fn dpid(&self) -> DPID_R {
267        DPID_R::new(((self.bits >> 16) & 0x01) != 0)
268    }
269    #[doc = "Bit 17 - NAK Status"]
270    #[inline(always)]
271    pub fn naksts(&self) -> NAKSTS_R {
272        NAKSTS_R::new(((self.bits >> 17) & 0x01) != 0)
273    }
274    #[doc = "Bits 18:19 - Endpoint Type"]
275    #[inline(always)]
276    pub fn eptype(&self) -> EPTYPE_R {
277        EPTYPE_R::new(((self.bits >> 18) & 0x03) as u8)
278    }
279    #[doc = "Bit 20 - Snoop Mode"]
280    #[inline(always)]
281    pub fn snp(&self) -> SNP_R {
282        SNP_R::new(((self.bits >> 20) & 0x01) != 0)
283    }
284    #[doc = "Bit 21 - Handshake"]
285    #[inline(always)]
286    pub fn stall(&self) -> STALL_R {
287        STALL_R::new(((self.bits >> 21) & 0x01) != 0)
288    }
289    #[doc = "Bit 30 - Endpoint Disable"]
290    #[inline(always)]
291    pub fn epdis(&self) -> EPDIS_R {
292        EPDIS_R::new(((self.bits >> 30) & 0x01) != 0)
293    }
294    #[doc = "Bit 31 - Endpoint Enable"]
295    #[inline(always)]
296    pub fn epena(&self) -> EPENA_R {
297        EPENA_R::new(((self.bits >> 31) & 0x01) != 0)
298    }
299}
300impl W {
301    #[doc = "Bits 0:10 - Maximum Packet Size"]
302    #[inline(always)]
303    pub fn mps(&mut self) -> MPS_W {
304        MPS_W { w: self }
305    }
306    #[doc = "Bit 15 - USB Active Endpoint"]
307    #[inline(always)]
308    pub fn usbactep(&mut self) -> USBACTEP_W {
309        USBACTEP_W { w: self }
310    }
311    #[doc = "Bits 18:19 - Endpoint Type"]
312    #[inline(always)]
313    pub fn eptype(&mut self) -> EPTYPE_W {
314        EPTYPE_W { w: self }
315    }
316    #[doc = "Bit 20 - Snoop Mode"]
317    #[inline(always)]
318    pub fn snp(&mut self) -> SNP_W {
319        SNP_W { w: self }
320    }
321    #[doc = "Bit 21 - Handshake"]
322    #[inline(always)]
323    pub fn stall(&mut self) -> STALL_W {
324        STALL_W { w: self }
325    }
326    #[doc = "Bit 26 - Clear NAK"]
327    #[inline(always)]
328    pub fn cnak(&mut self) -> CNAK_W {
329        CNAK_W { w: self }
330    }
331    #[doc = "Bit 27 - Set NAK"]
332    #[inline(always)]
333    pub fn snak(&mut self) -> SNAK_W {
334        SNAK_W { w: self }
335    }
336    #[doc = "Bit 28 - Set DATA0 PID"]
337    #[inline(always)]
338    pub fn setd0pidef(&mut self) -> SETD0PIDEF_W {
339        SETD0PIDEF_W { w: self }
340    }
341    #[doc = "Bit 29 - Set DATA1 PID"]
342    #[inline(always)]
343    pub fn setd1pidof(&mut self) -> SETD1PIDOF_W {
344        SETD1PIDOF_W { w: self }
345    }
346    #[doc = "Bit 30 - Endpoint Disable"]
347    #[inline(always)]
348    pub fn epdis(&mut self) -> EPDIS_W {
349        EPDIS_W { w: self }
350    }
351    #[doc = "Bit 31 - Endpoint Enable"]
352    #[inline(always)]
353    pub fn epena(&mut self) -> EPENA_W {
354        EPENA_W { w: self }
355    }
356}