atsam4lc2c_pac/usbc/
uecfg3.rs

1#[doc = "Register `UECFG3` reader"]
2pub struct R(crate::R<UECFG3_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<UECFG3_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<UECFG3_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<UECFG3_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `UECFG3` writer"]
17pub struct W(crate::W<UECFG3_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<UECFG3_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<UECFG3_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<UECFG3_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `EPBK` reader - Endpoint Bank"]
38pub type EPBK_R = crate::BitReader<EPBKSELECT_A>;
39#[doc = "Endpoint Bank\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41pub enum EPBKSELECT_A {
42    #[doc = "0: `0`"]
43    SINGLE = 0,
44    #[doc = "1: `1`"]
45    DOUBLE = 1,
46}
47impl From<EPBKSELECT_A> for bool {
48    #[inline(always)]
49    fn from(variant: EPBKSELECT_A) -> Self {
50        variant as u8 != 0
51    }
52}
53impl EPBK_R {
54    #[doc = "Get enumerated values variant"]
55    #[inline(always)]
56    pub fn variant(&self) -> EPBKSELECT_A {
57        match self.bits {
58            false => EPBKSELECT_A::SINGLE,
59            true => EPBKSELECT_A::DOUBLE,
60        }
61    }
62    #[doc = "Checks if the value of the field is `SINGLE`"]
63    #[inline(always)]
64    pub fn is_single(&self) -> bool {
65        *self == EPBKSELECT_A::SINGLE
66    }
67    #[doc = "Checks if the value of the field is `DOUBLE`"]
68    #[inline(always)]
69    pub fn is_double(&self) -> bool {
70        *self == EPBKSELECT_A::DOUBLE
71    }
72}
73#[doc = "Field `EPBK` writer - Endpoint Bank"]
74pub type EPBK_W<'a, const O: u8> = crate::BitWriter<'a, u32, UECFG3_SPEC, EPBKSELECT_A, O>;
75impl<'a, const O: u8> EPBK_W<'a, O> {
76    #[doc = "`0`"]
77    #[inline(always)]
78    pub fn single(self) -> &'a mut W {
79        self.variant(EPBKSELECT_A::SINGLE)
80    }
81    #[doc = "`1`"]
82    #[inline(always)]
83    pub fn double(self) -> &'a mut W {
84        self.variant(EPBKSELECT_A::DOUBLE)
85    }
86}
87#[doc = "Field `EPSIZE` reader - Endpoint Size"]
88pub type EPSIZE_R = crate::FieldReader<u8, EPSIZESELECT_A>;
89#[doc = "Endpoint Size\n\nValue on reset: 0"]
90#[derive(Clone, Copy, Debug, PartialEq, Eq)]
91#[repr(u8)]
92pub enum EPSIZESELECT_A {
93    #[doc = "0: `0`"]
94    _8 = 0,
95    #[doc = "1: `1`"]
96    _16 = 1,
97    #[doc = "2: `10`"]
98    _32 = 2,
99    #[doc = "3: `11`"]
100    _64 = 3,
101    #[doc = "4: `100`"]
102    _128 = 4,
103    #[doc = "5: `101`"]
104    _256 = 5,
105    #[doc = "6: `110`"]
106    _512 = 6,
107    #[doc = "7: `111`"]
108    _1024 = 7,
109}
110impl From<EPSIZESELECT_A> for u8 {
111    #[inline(always)]
112    fn from(variant: EPSIZESELECT_A) -> Self {
113        variant as _
114    }
115}
116impl EPSIZE_R {
117    #[doc = "Get enumerated values variant"]
118    #[inline(always)]
119    pub fn variant(&self) -> EPSIZESELECT_A {
120        match self.bits {
121            0 => EPSIZESELECT_A::_8,
122            1 => EPSIZESELECT_A::_16,
123            2 => EPSIZESELECT_A::_32,
124            3 => EPSIZESELECT_A::_64,
125            4 => EPSIZESELECT_A::_128,
126            5 => EPSIZESELECT_A::_256,
127            6 => EPSIZESELECT_A::_512,
128            7 => EPSIZESELECT_A::_1024,
129            _ => unreachable!(),
130        }
131    }
132    #[doc = "Checks if the value of the field is `_8`"]
133    #[inline(always)]
134    pub fn is_8(&self) -> bool {
135        *self == EPSIZESELECT_A::_8
136    }
137    #[doc = "Checks if the value of the field is `_16`"]
138    #[inline(always)]
139    pub fn is_16(&self) -> bool {
140        *self == EPSIZESELECT_A::_16
141    }
142    #[doc = "Checks if the value of the field is `_32`"]
143    #[inline(always)]
144    pub fn is_32(&self) -> bool {
145        *self == EPSIZESELECT_A::_32
146    }
147    #[doc = "Checks if the value of the field is `_64`"]
148    #[inline(always)]
149    pub fn is_64(&self) -> bool {
150        *self == EPSIZESELECT_A::_64
151    }
152    #[doc = "Checks if the value of the field is `_128`"]
153    #[inline(always)]
154    pub fn is_128(&self) -> bool {
155        *self == EPSIZESELECT_A::_128
156    }
157    #[doc = "Checks if the value of the field is `_256`"]
158    #[inline(always)]
159    pub fn is_256(&self) -> bool {
160        *self == EPSIZESELECT_A::_256
161    }
162    #[doc = "Checks if the value of the field is `_512`"]
163    #[inline(always)]
164    pub fn is_512(&self) -> bool {
165        *self == EPSIZESELECT_A::_512
166    }
167    #[doc = "Checks if the value of the field is `_1024`"]
168    #[inline(always)]
169    pub fn is_1024(&self) -> bool {
170        *self == EPSIZESELECT_A::_1024
171    }
172}
173#[doc = "Field `EPSIZE` writer - Endpoint Size"]
174pub type EPSIZE_W<'a, const O: u8> =
175    crate::FieldWriterSafe<'a, u32, UECFG3_SPEC, u8, EPSIZESELECT_A, 3, O>;
176impl<'a, const O: u8> EPSIZE_W<'a, O> {
177    #[doc = "`0`"]
178    #[inline(always)]
179    pub fn _8(self) -> &'a mut W {
180        self.variant(EPSIZESELECT_A::_8)
181    }
182    #[doc = "`1`"]
183    #[inline(always)]
184    pub fn _16(self) -> &'a mut W {
185        self.variant(EPSIZESELECT_A::_16)
186    }
187    #[doc = "`10`"]
188    #[inline(always)]
189    pub fn _32(self) -> &'a mut W {
190        self.variant(EPSIZESELECT_A::_32)
191    }
192    #[doc = "`11`"]
193    #[inline(always)]
194    pub fn _64(self) -> &'a mut W {
195        self.variant(EPSIZESELECT_A::_64)
196    }
197    #[doc = "`100`"]
198    #[inline(always)]
199    pub fn _128(self) -> &'a mut W {
200        self.variant(EPSIZESELECT_A::_128)
201    }
202    #[doc = "`101`"]
203    #[inline(always)]
204    pub fn _256(self) -> &'a mut W {
205        self.variant(EPSIZESELECT_A::_256)
206    }
207    #[doc = "`110`"]
208    #[inline(always)]
209    pub fn _512(self) -> &'a mut W {
210        self.variant(EPSIZESELECT_A::_512)
211    }
212    #[doc = "`111`"]
213    #[inline(always)]
214    pub fn _1024(self) -> &'a mut W {
215        self.variant(EPSIZESELECT_A::_1024)
216    }
217}
218#[doc = "Field `EPDIR` reader - Endpoint Direction"]
219pub type EPDIR_R = crate::BitReader<EPDIRSELECT_A>;
220#[doc = "Endpoint Direction\n\nValue on reset: 0"]
221#[derive(Clone, Copy, Debug, PartialEq, Eq)]
222pub enum EPDIRSELECT_A {
223    #[doc = "0: `0`"]
224    OUT = 0,
225    #[doc = "1: `1`"]
226    IN = 1,
227}
228impl From<EPDIRSELECT_A> for bool {
229    #[inline(always)]
230    fn from(variant: EPDIRSELECT_A) -> Self {
231        variant as u8 != 0
232    }
233}
234impl EPDIR_R {
235    #[doc = "Get enumerated values variant"]
236    #[inline(always)]
237    pub fn variant(&self) -> EPDIRSELECT_A {
238        match self.bits {
239            false => EPDIRSELECT_A::OUT,
240            true => EPDIRSELECT_A::IN,
241        }
242    }
243    #[doc = "Checks if the value of the field is `OUT`"]
244    #[inline(always)]
245    pub fn is_out(&self) -> bool {
246        *self == EPDIRSELECT_A::OUT
247    }
248    #[doc = "Checks if the value of the field is `IN`"]
249    #[inline(always)]
250    pub fn is_in(&self) -> bool {
251        *self == EPDIRSELECT_A::IN
252    }
253}
254#[doc = "Field `EPDIR` writer - Endpoint Direction"]
255pub type EPDIR_W<'a, const O: u8> = crate::BitWriter<'a, u32, UECFG3_SPEC, EPDIRSELECT_A, O>;
256impl<'a, const O: u8> EPDIR_W<'a, O> {
257    #[doc = "`0`"]
258    #[inline(always)]
259    pub fn out(self) -> &'a mut W {
260        self.variant(EPDIRSELECT_A::OUT)
261    }
262    #[doc = "`1`"]
263    #[inline(always)]
264    pub fn in_(self) -> &'a mut W {
265        self.variant(EPDIRSELECT_A::IN)
266    }
267}
268#[doc = "Field `EPTYPE` reader - Endpoint Type"]
269pub type EPTYPE_R = crate::FieldReader<u8, EPTYPESELECT_A>;
270#[doc = "Endpoint Type\n\nValue on reset: 0"]
271#[derive(Clone, Copy, Debug, PartialEq, Eq)]
272#[repr(u8)]
273pub enum EPTYPESELECT_A {
274    #[doc = "0: `0`"]
275    CONTROL = 0,
276    #[doc = "1: `1`"]
277    ISOCHRONOUS = 1,
278    #[doc = "2: `10`"]
279    BULK = 2,
280    #[doc = "3: `11`"]
281    INTERRUPT = 3,
282}
283impl From<EPTYPESELECT_A> for u8 {
284    #[inline(always)]
285    fn from(variant: EPTYPESELECT_A) -> Self {
286        variant as _
287    }
288}
289impl EPTYPE_R {
290    #[doc = "Get enumerated values variant"]
291    #[inline(always)]
292    pub fn variant(&self) -> EPTYPESELECT_A {
293        match self.bits {
294            0 => EPTYPESELECT_A::CONTROL,
295            1 => EPTYPESELECT_A::ISOCHRONOUS,
296            2 => EPTYPESELECT_A::BULK,
297            3 => EPTYPESELECT_A::INTERRUPT,
298            _ => unreachable!(),
299        }
300    }
301    #[doc = "Checks if the value of the field is `CONTROL`"]
302    #[inline(always)]
303    pub fn is_control(&self) -> bool {
304        *self == EPTYPESELECT_A::CONTROL
305    }
306    #[doc = "Checks if the value of the field is `ISOCHRONOUS`"]
307    #[inline(always)]
308    pub fn is_isochronous(&self) -> bool {
309        *self == EPTYPESELECT_A::ISOCHRONOUS
310    }
311    #[doc = "Checks if the value of the field is `BULK`"]
312    #[inline(always)]
313    pub fn is_bulk(&self) -> bool {
314        *self == EPTYPESELECT_A::BULK
315    }
316    #[doc = "Checks if the value of the field is `INTERRUPT`"]
317    #[inline(always)]
318    pub fn is_interrupt(&self) -> bool {
319        *self == EPTYPESELECT_A::INTERRUPT
320    }
321}
322#[doc = "Field `EPTYPE` writer - Endpoint Type"]
323pub type EPTYPE_W<'a, const O: u8> =
324    crate::FieldWriterSafe<'a, u32, UECFG3_SPEC, u8, EPTYPESELECT_A, 2, O>;
325impl<'a, const O: u8> EPTYPE_W<'a, O> {
326    #[doc = "`0`"]
327    #[inline(always)]
328    pub fn control(self) -> &'a mut W {
329        self.variant(EPTYPESELECT_A::CONTROL)
330    }
331    #[doc = "`1`"]
332    #[inline(always)]
333    pub fn isochronous(self) -> &'a mut W {
334        self.variant(EPTYPESELECT_A::ISOCHRONOUS)
335    }
336    #[doc = "`10`"]
337    #[inline(always)]
338    pub fn bulk(self) -> &'a mut W {
339        self.variant(EPTYPESELECT_A::BULK)
340    }
341    #[doc = "`11`"]
342    #[inline(always)]
343    pub fn interrupt(self) -> &'a mut W {
344        self.variant(EPTYPESELECT_A::INTERRUPT)
345    }
346}
347#[doc = "Field `REPNB` reader - Redirected Endpoint Number"]
348pub type REPNB_R = crate::FieldReader<u8, u8>;
349#[doc = "Field `REPNB` writer - Redirected Endpoint Number"]
350pub type REPNB_W<'a, const O: u8> = crate::FieldWriter<'a, u32, UECFG3_SPEC, u8, u8, 4, O>;
351impl R {
352    #[doc = "Bit 2 - Endpoint Bank"]
353    #[inline(always)]
354    pub fn epbk(&self) -> EPBK_R {
355        EPBK_R::new(((self.bits >> 2) & 1) != 0)
356    }
357    #[doc = "Bits 4:6 - Endpoint Size"]
358    #[inline(always)]
359    pub fn epsize(&self) -> EPSIZE_R {
360        EPSIZE_R::new(((self.bits >> 4) & 7) as u8)
361    }
362    #[doc = "Bit 8 - Endpoint Direction"]
363    #[inline(always)]
364    pub fn epdir(&self) -> EPDIR_R {
365        EPDIR_R::new(((self.bits >> 8) & 1) != 0)
366    }
367    #[doc = "Bits 11:12 - Endpoint Type"]
368    #[inline(always)]
369    pub fn eptype(&self) -> EPTYPE_R {
370        EPTYPE_R::new(((self.bits >> 11) & 3) as u8)
371    }
372    #[doc = "Bits 16:19 - Redirected Endpoint Number"]
373    #[inline(always)]
374    pub fn repnb(&self) -> REPNB_R {
375        REPNB_R::new(((self.bits >> 16) & 0x0f) as u8)
376    }
377}
378impl W {
379    #[doc = "Bit 2 - Endpoint Bank"]
380    #[inline(always)]
381    #[must_use]
382    pub fn epbk(&mut self) -> EPBK_W<2> {
383        EPBK_W::new(self)
384    }
385    #[doc = "Bits 4:6 - Endpoint Size"]
386    #[inline(always)]
387    #[must_use]
388    pub fn epsize(&mut self) -> EPSIZE_W<4> {
389        EPSIZE_W::new(self)
390    }
391    #[doc = "Bit 8 - Endpoint Direction"]
392    #[inline(always)]
393    #[must_use]
394    pub fn epdir(&mut self) -> EPDIR_W<8> {
395        EPDIR_W::new(self)
396    }
397    #[doc = "Bits 11:12 - Endpoint Type"]
398    #[inline(always)]
399    #[must_use]
400    pub fn eptype(&mut self) -> EPTYPE_W<11> {
401        EPTYPE_W::new(self)
402    }
403    #[doc = "Bits 16:19 - Redirected Endpoint Number"]
404    #[inline(always)]
405    #[must_use]
406    pub fn repnb(&mut self) -> REPNB_W<16> {
407        REPNB_W::new(self)
408    }
409    #[doc = "Writes raw bits to the register."]
410    #[inline(always)]
411    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
412        self.0.bits(bits);
413        self
414    }
415}
416#[doc = "Endpoint Configuration 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 [uecfg3](index.html) module"]
417pub struct UECFG3_SPEC;
418impl crate::RegisterSpec for UECFG3_SPEC {
419    type Ux = u32;
420}
421#[doc = "`read()` method returns [uecfg3::R](R) reader structure"]
422impl crate::Readable for UECFG3_SPEC {
423    type Reader = R;
424}
425#[doc = "`write(|w| ..)` method takes [uecfg3::W](W) writer structure"]
426impl crate::Writable for UECFG3_SPEC {
427    type Writer = W;
428    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
429    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
430}
431#[doc = "`reset()` method sets UECFG3 to value 0"]
432impl crate::Resettable for UECFG3_SPEC {
433    const RESET_VALUE: Self::Ux = 0;
434}