efm32lg330_pac/usb/
hc6_tsiz.rs

1#[doc = "Register `HC6_TSIZ` reader"]
2pub struct R(crate::R<HC6_TSIZ_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<HC6_TSIZ_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<HC6_TSIZ_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<HC6_TSIZ_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `HC6_TSIZ` writer"]
17pub struct W(crate::W<HC6_TSIZ_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<HC6_TSIZ_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<HC6_TSIZ_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<HC6_TSIZ_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `XFERSIZE` reader - Transfer Size"]
38pub type XFERSIZE_R = crate::FieldReader<u32, u32>;
39#[doc = "Field `XFERSIZE` writer - Transfer Size"]
40pub type XFERSIZE_W<'a> = crate::FieldWriter<'a, u32, HC6_TSIZ_SPEC, u32, u32, 19, 0>;
41#[doc = "Field `PKTCNT` reader - Packet Count"]
42pub type PKTCNT_R = crate::FieldReader<u16, u16>;
43#[doc = "Field `PKTCNT` writer - Packet Count"]
44pub type PKTCNT_W<'a> = crate::FieldWriter<'a, u32, HC6_TSIZ_SPEC, u16, u16, 10, 19>;
45#[doc = "Packet ID\n\nValue on reset: 0"]
46#[derive(Clone, Copy, Debug, PartialEq)]
47#[repr(u8)]
48pub enum PID_A {
49    #[doc = "0: DATA0 PID."]
50    DATA0 = 0,
51    #[doc = "1: DATA2 PID."]
52    DATA2 = 1,
53    #[doc = "2: DATA1 PID."]
54    DATA1 = 2,
55    #[doc = "3: MDATA (non-control) / SETUP (control) PID."]
56    MDATA = 3,
57}
58impl From<PID_A> for u8 {
59    #[inline(always)]
60    fn from(variant: PID_A) -> Self {
61        variant as _
62    }
63}
64#[doc = "Field `PID` reader - Packet ID"]
65pub type PID_R = crate::FieldReader<u8, PID_A>;
66impl PID_R {
67    #[doc = "Get enumerated values variant"]
68    #[inline(always)]
69    pub fn variant(&self) -> PID_A {
70        match self.bits {
71            0 => PID_A::DATA0,
72            1 => PID_A::DATA2,
73            2 => PID_A::DATA1,
74            3 => PID_A::MDATA,
75            _ => unreachable!(),
76        }
77    }
78    #[doc = "Checks if the value of the field is `DATA0`"]
79    #[inline(always)]
80    pub fn is_data0(&self) -> bool {
81        *self == PID_A::DATA0
82    }
83    #[doc = "Checks if the value of the field is `DATA2`"]
84    #[inline(always)]
85    pub fn is_data2(&self) -> bool {
86        *self == PID_A::DATA2
87    }
88    #[doc = "Checks if the value of the field is `DATA1`"]
89    #[inline(always)]
90    pub fn is_data1(&self) -> bool {
91        *self == PID_A::DATA1
92    }
93    #[doc = "Checks if the value of the field is `MDATA`"]
94    #[inline(always)]
95    pub fn is_mdata(&self) -> bool {
96        *self == PID_A::MDATA
97    }
98}
99#[doc = "Field `PID` writer - Packet ID"]
100pub type PID_W<'a> = crate::FieldWriterSafe<'a, u32, HC6_TSIZ_SPEC, u8, PID_A, 2, 29>;
101impl<'a> PID_W<'a> {
102    #[doc = "DATA0 PID."]
103    #[inline(always)]
104    pub fn data0(self) -> &'a mut W {
105        self.variant(PID_A::DATA0)
106    }
107    #[doc = "DATA2 PID."]
108    #[inline(always)]
109    pub fn data2(self) -> &'a mut W {
110        self.variant(PID_A::DATA2)
111    }
112    #[doc = "DATA1 PID."]
113    #[inline(always)]
114    pub fn data1(self) -> &'a mut W {
115        self.variant(PID_A::DATA1)
116    }
117    #[doc = "MDATA (non-control) / SETUP (control) PID."]
118    #[inline(always)]
119    pub fn mdata(self) -> &'a mut W {
120        self.variant(PID_A::MDATA)
121    }
122}
123impl R {
124    #[doc = "Bits 0:18 - Transfer Size"]
125    #[inline(always)]
126    pub fn xfersize(&self) -> XFERSIZE_R {
127        XFERSIZE_R::new((self.bits & 0x0007_ffff) as u32)
128    }
129    #[doc = "Bits 19:28 - Packet Count"]
130    #[inline(always)]
131    pub fn pktcnt(&self) -> PKTCNT_R {
132        PKTCNT_R::new(((self.bits >> 19) & 0x03ff) as u16)
133    }
134    #[doc = "Bits 29:30 - Packet ID"]
135    #[inline(always)]
136    pub fn pid(&self) -> PID_R {
137        PID_R::new(((self.bits >> 29) & 3) as u8)
138    }
139}
140impl W {
141    #[doc = "Bits 0:18 - Transfer Size"]
142    #[inline(always)]
143    pub fn xfersize(&mut self) -> XFERSIZE_W {
144        XFERSIZE_W::new(self)
145    }
146    #[doc = "Bits 19:28 - Packet Count"]
147    #[inline(always)]
148    pub fn pktcnt(&mut self) -> PKTCNT_W {
149        PKTCNT_W::new(self)
150    }
151    #[doc = "Bits 29:30 - Packet ID"]
152    #[inline(always)]
153    pub fn pid(&mut self) -> PID_W {
154        PID_W::new(self)
155    }
156    #[doc = "Writes raw bits to the register."]
157    #[inline(always)]
158    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
159        self.0.bits(bits);
160        self
161    }
162}
163#[doc = "Host Channel x Transfer Size 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 [hc6_tsiz](index.html) module"]
164pub struct HC6_TSIZ_SPEC;
165impl crate::RegisterSpec for HC6_TSIZ_SPEC {
166    type Ux = u32;
167}
168#[doc = "`read()` method returns [hc6_tsiz::R](R) reader structure"]
169impl crate::Readable for HC6_TSIZ_SPEC {
170    type Reader = R;
171}
172#[doc = "`write(|w| ..)` method takes [hc6_tsiz::W](W) writer structure"]
173impl crate::Writable for HC6_TSIZ_SPEC {
174    type Writer = W;
175}
176#[doc = "`reset()` method sets HC6_TSIZ to value 0"]
177impl crate::Resettable for HC6_TSIZ_SPEC {
178    #[inline(always)]
179    fn reset_value() -> Self::Ux {
180        0
181    }
182}