atsam3u4e/udphs/
eptcfg1.rs

1#[doc = "Register `EPTCFG1` reader"]
2pub type R = crate::R<Eptcfg1Spec>;
3#[doc = "Register `EPTCFG1` writer"]
4pub type W = crate::W<Eptcfg1Spec>;
5#[doc = "Endpoint Size\n\nValue on reset: 0"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7#[repr(u8)]
8pub enum EptSize {
9    #[doc = "0: 8 bytes"]
10    _8 = 0,
11    #[doc = "1: 16 bytes"]
12    _16 = 1,
13    #[doc = "2: 32 bytes"]
14    _32 = 2,
15    #[doc = "3: 64 bytes"]
16    _64 = 3,
17    #[doc = "4: 128 bytes"]
18    _128 = 4,
19    #[doc = "5: 256 bytes"]
20    _256 = 5,
21    #[doc = "6: 512 bytes"]
22    _512 = 6,
23    #[doc = "7: 1024 bytes"]
24    _1024 = 7,
25}
26impl From<EptSize> for u8 {
27    #[inline(always)]
28    fn from(variant: EptSize) -> Self {
29        variant as _
30    }
31}
32impl crate::FieldSpec for EptSize {
33    type Ux = u8;
34}
35impl crate::IsEnum for EptSize {}
36#[doc = "Field `EPT_SIZE` reader - Endpoint Size"]
37pub type EptSizeR = crate::FieldReader<EptSize>;
38impl EptSizeR {
39    #[doc = "Get enumerated values variant"]
40    #[inline(always)]
41    pub const fn variant(&self) -> EptSize {
42        match self.bits {
43            0 => EptSize::_8,
44            1 => EptSize::_16,
45            2 => EptSize::_32,
46            3 => EptSize::_64,
47            4 => EptSize::_128,
48            5 => EptSize::_256,
49            6 => EptSize::_512,
50            7 => EptSize::_1024,
51            _ => unreachable!(),
52        }
53    }
54    #[doc = "8 bytes"]
55    #[inline(always)]
56    pub fn is_8(&self) -> bool {
57        *self == EptSize::_8
58    }
59    #[doc = "16 bytes"]
60    #[inline(always)]
61    pub fn is_16(&self) -> bool {
62        *self == EptSize::_16
63    }
64    #[doc = "32 bytes"]
65    #[inline(always)]
66    pub fn is_32(&self) -> bool {
67        *self == EptSize::_32
68    }
69    #[doc = "64 bytes"]
70    #[inline(always)]
71    pub fn is_64(&self) -> bool {
72        *self == EptSize::_64
73    }
74    #[doc = "128 bytes"]
75    #[inline(always)]
76    pub fn is_128(&self) -> bool {
77        *self == EptSize::_128
78    }
79    #[doc = "256 bytes"]
80    #[inline(always)]
81    pub fn is_256(&self) -> bool {
82        *self == EptSize::_256
83    }
84    #[doc = "512 bytes"]
85    #[inline(always)]
86    pub fn is_512(&self) -> bool {
87        *self == EptSize::_512
88    }
89    #[doc = "1024 bytes"]
90    #[inline(always)]
91    pub fn is_1024(&self) -> bool {
92        *self == EptSize::_1024
93    }
94}
95#[doc = "Field `EPT_SIZE` writer - Endpoint Size"]
96pub type EptSizeW<'a, REG> = crate::FieldWriter<'a, REG, 3, EptSize, crate::Safe>;
97impl<'a, REG> EptSizeW<'a, REG>
98where
99    REG: crate::Writable + crate::RegisterSpec,
100    REG::Ux: From<u8>,
101{
102    #[doc = "8 bytes"]
103    #[inline(always)]
104    pub fn _8(self) -> &'a mut crate::W<REG> {
105        self.variant(EptSize::_8)
106    }
107    #[doc = "16 bytes"]
108    #[inline(always)]
109    pub fn _16(self) -> &'a mut crate::W<REG> {
110        self.variant(EptSize::_16)
111    }
112    #[doc = "32 bytes"]
113    #[inline(always)]
114    pub fn _32(self) -> &'a mut crate::W<REG> {
115        self.variant(EptSize::_32)
116    }
117    #[doc = "64 bytes"]
118    #[inline(always)]
119    pub fn _64(self) -> &'a mut crate::W<REG> {
120        self.variant(EptSize::_64)
121    }
122    #[doc = "128 bytes"]
123    #[inline(always)]
124    pub fn _128(self) -> &'a mut crate::W<REG> {
125        self.variant(EptSize::_128)
126    }
127    #[doc = "256 bytes"]
128    #[inline(always)]
129    pub fn _256(self) -> &'a mut crate::W<REG> {
130        self.variant(EptSize::_256)
131    }
132    #[doc = "512 bytes"]
133    #[inline(always)]
134    pub fn _512(self) -> &'a mut crate::W<REG> {
135        self.variant(EptSize::_512)
136    }
137    #[doc = "1024 bytes"]
138    #[inline(always)]
139    pub fn _1024(self) -> &'a mut crate::W<REG> {
140        self.variant(EptSize::_1024)
141    }
142}
143#[doc = "Field `EPT_DIR` reader - Endpoint Direction"]
144pub type EptDirR = crate::BitReader;
145#[doc = "Field `EPT_DIR` writer - Endpoint Direction"]
146pub type EptDirW<'a, REG> = crate::BitWriter<'a, REG>;
147#[doc = "Endpoint Type\n\nValue on reset: 0"]
148#[derive(Clone, Copy, Debug, PartialEq, Eq)]
149#[repr(u8)]
150pub enum EptType {
151    #[doc = "0: Control endpoint"]
152    Ctrl8 = 0,
153    #[doc = "1: Isochronous endpoint"]
154    Iso = 1,
155    #[doc = "2: Bulk endpoint"]
156    Bulk = 2,
157    #[doc = "3: Interrupt endpoint"]
158    Int = 3,
159}
160impl From<EptType> for u8 {
161    #[inline(always)]
162    fn from(variant: EptType) -> Self {
163        variant as _
164    }
165}
166impl crate::FieldSpec for EptType {
167    type Ux = u8;
168}
169impl crate::IsEnum for EptType {}
170#[doc = "Field `EPT_TYPE` reader - Endpoint Type"]
171pub type EptTypeR = crate::FieldReader<EptType>;
172impl EptTypeR {
173    #[doc = "Get enumerated values variant"]
174    #[inline(always)]
175    pub const fn variant(&self) -> EptType {
176        match self.bits {
177            0 => EptType::Ctrl8,
178            1 => EptType::Iso,
179            2 => EptType::Bulk,
180            3 => EptType::Int,
181            _ => unreachable!(),
182        }
183    }
184    #[doc = "Control endpoint"]
185    #[inline(always)]
186    pub fn is_ctrl8(&self) -> bool {
187        *self == EptType::Ctrl8
188    }
189    #[doc = "Isochronous endpoint"]
190    #[inline(always)]
191    pub fn is_iso(&self) -> bool {
192        *self == EptType::Iso
193    }
194    #[doc = "Bulk endpoint"]
195    #[inline(always)]
196    pub fn is_bulk(&self) -> bool {
197        *self == EptType::Bulk
198    }
199    #[doc = "Interrupt endpoint"]
200    #[inline(always)]
201    pub fn is_int(&self) -> bool {
202        *self == EptType::Int
203    }
204}
205#[doc = "Field `EPT_TYPE` writer - Endpoint Type"]
206pub type EptTypeW<'a, REG> = crate::FieldWriter<'a, REG, 2, EptType, crate::Safe>;
207impl<'a, REG> EptTypeW<'a, REG>
208where
209    REG: crate::Writable + crate::RegisterSpec,
210    REG::Ux: From<u8>,
211{
212    #[doc = "Control endpoint"]
213    #[inline(always)]
214    pub fn ctrl8(self) -> &'a mut crate::W<REG> {
215        self.variant(EptType::Ctrl8)
216    }
217    #[doc = "Isochronous endpoint"]
218    #[inline(always)]
219    pub fn iso(self) -> &'a mut crate::W<REG> {
220        self.variant(EptType::Iso)
221    }
222    #[doc = "Bulk endpoint"]
223    #[inline(always)]
224    pub fn bulk(self) -> &'a mut crate::W<REG> {
225        self.variant(EptType::Bulk)
226    }
227    #[doc = "Interrupt endpoint"]
228    #[inline(always)]
229    pub fn int(self) -> &'a mut crate::W<REG> {
230        self.variant(EptType::Int)
231    }
232}
233#[doc = "Number of Banks\n\nValue on reset: 0"]
234#[derive(Clone, Copy, Debug, PartialEq, Eq)]
235#[repr(u8)]
236pub enum BkNumber {
237    #[doc = "0: Zero bank, the endpoint is not mapped in memory"]
238    _0 = 0,
239    #[doc = "1: One bank (bank 0)"]
240    _1 = 1,
241    #[doc = "2: Double bank (Ping-Pong: bank0/bank1)"]
242    _2 = 2,
243    #[doc = "3: Triple bank (bank0/bank1/bank2)"]
244    _3 = 3,
245}
246impl From<BkNumber> for u8 {
247    #[inline(always)]
248    fn from(variant: BkNumber) -> Self {
249        variant as _
250    }
251}
252impl crate::FieldSpec for BkNumber {
253    type Ux = u8;
254}
255impl crate::IsEnum for BkNumber {}
256#[doc = "Field `BK_NUMBER` reader - Number of Banks"]
257pub type BkNumberR = crate::FieldReader<BkNumber>;
258impl BkNumberR {
259    #[doc = "Get enumerated values variant"]
260    #[inline(always)]
261    pub const fn variant(&self) -> BkNumber {
262        match self.bits {
263            0 => BkNumber::_0,
264            1 => BkNumber::_1,
265            2 => BkNumber::_2,
266            3 => BkNumber::_3,
267            _ => unreachable!(),
268        }
269    }
270    #[doc = "Zero bank, the endpoint is not mapped in memory"]
271    #[inline(always)]
272    pub fn is_0(&self) -> bool {
273        *self == BkNumber::_0
274    }
275    #[doc = "One bank (bank 0)"]
276    #[inline(always)]
277    pub fn is_1(&self) -> bool {
278        *self == BkNumber::_1
279    }
280    #[doc = "Double bank (Ping-Pong: bank0/bank1)"]
281    #[inline(always)]
282    pub fn is_2(&self) -> bool {
283        *self == BkNumber::_2
284    }
285    #[doc = "Triple bank (bank0/bank1/bank2)"]
286    #[inline(always)]
287    pub fn is_3(&self) -> bool {
288        *self == BkNumber::_3
289    }
290}
291#[doc = "Field `BK_NUMBER` writer - Number of Banks"]
292pub type BkNumberW<'a, REG> = crate::FieldWriter<'a, REG, 2, BkNumber, crate::Safe>;
293impl<'a, REG> BkNumberW<'a, REG>
294where
295    REG: crate::Writable + crate::RegisterSpec,
296    REG::Ux: From<u8>,
297{
298    #[doc = "Zero bank, the endpoint is not mapped in memory"]
299    #[inline(always)]
300    pub fn _0(self) -> &'a mut crate::W<REG> {
301        self.variant(BkNumber::_0)
302    }
303    #[doc = "One bank (bank 0)"]
304    #[inline(always)]
305    pub fn _1(self) -> &'a mut crate::W<REG> {
306        self.variant(BkNumber::_1)
307    }
308    #[doc = "Double bank (Ping-Pong: bank0/bank1)"]
309    #[inline(always)]
310    pub fn _2(self) -> &'a mut crate::W<REG> {
311        self.variant(BkNumber::_2)
312    }
313    #[doc = "Triple bank (bank0/bank1/bank2)"]
314    #[inline(always)]
315    pub fn _3(self) -> &'a mut crate::W<REG> {
316        self.variant(BkNumber::_3)
317    }
318}
319#[doc = "Field `NB_TRANS` reader - Number Of Transaction per Microframe"]
320pub type NbTransR = crate::FieldReader;
321#[doc = "Field `NB_TRANS` writer - Number Of Transaction per Microframe"]
322pub type NbTransW<'a, REG> = crate::FieldWriter<'a, REG, 2>;
323#[doc = "Field `EPT_MAPD` reader - Endpoint Mapped"]
324pub type EptMapdR = crate::BitReader;
325#[doc = "Field `EPT_MAPD` writer - Endpoint Mapped"]
326pub type EptMapdW<'a, REG> = crate::BitWriter<'a, REG>;
327impl R {
328    #[doc = "Bits 0:2 - Endpoint Size"]
329    #[inline(always)]
330    pub fn ept_size(&self) -> EptSizeR {
331        EptSizeR::new((self.bits & 7) as u8)
332    }
333    #[doc = "Bit 3 - Endpoint Direction"]
334    #[inline(always)]
335    pub fn ept_dir(&self) -> EptDirR {
336        EptDirR::new(((self.bits >> 3) & 1) != 0)
337    }
338    #[doc = "Bits 4:5 - Endpoint Type"]
339    #[inline(always)]
340    pub fn ept_type(&self) -> EptTypeR {
341        EptTypeR::new(((self.bits >> 4) & 3) as u8)
342    }
343    #[doc = "Bits 6:7 - Number of Banks"]
344    #[inline(always)]
345    pub fn bk_number(&self) -> BkNumberR {
346        BkNumberR::new(((self.bits >> 6) & 3) as u8)
347    }
348    #[doc = "Bits 8:9 - Number Of Transaction per Microframe"]
349    #[inline(always)]
350    pub fn nb_trans(&self) -> NbTransR {
351        NbTransR::new(((self.bits >> 8) & 3) as u8)
352    }
353    #[doc = "Bit 31 - Endpoint Mapped"]
354    #[inline(always)]
355    pub fn ept_mapd(&self) -> EptMapdR {
356        EptMapdR::new(((self.bits >> 31) & 1) != 0)
357    }
358}
359impl W {
360    #[doc = "Bits 0:2 - Endpoint Size"]
361    #[inline(always)]
362    #[must_use]
363    pub fn ept_size(&mut self) -> EptSizeW<Eptcfg1Spec> {
364        EptSizeW::new(self, 0)
365    }
366    #[doc = "Bit 3 - Endpoint Direction"]
367    #[inline(always)]
368    #[must_use]
369    pub fn ept_dir(&mut self) -> EptDirW<Eptcfg1Spec> {
370        EptDirW::new(self, 3)
371    }
372    #[doc = "Bits 4:5 - Endpoint Type"]
373    #[inline(always)]
374    #[must_use]
375    pub fn ept_type(&mut self) -> EptTypeW<Eptcfg1Spec> {
376        EptTypeW::new(self, 4)
377    }
378    #[doc = "Bits 6:7 - Number of Banks"]
379    #[inline(always)]
380    #[must_use]
381    pub fn bk_number(&mut self) -> BkNumberW<Eptcfg1Spec> {
382        BkNumberW::new(self, 6)
383    }
384    #[doc = "Bits 8:9 - Number Of Transaction per Microframe"]
385    #[inline(always)]
386    #[must_use]
387    pub fn nb_trans(&mut self) -> NbTransW<Eptcfg1Spec> {
388        NbTransW::new(self, 8)
389    }
390    #[doc = "Bit 31 - Endpoint Mapped"]
391    #[inline(always)]
392    #[must_use]
393    pub fn ept_mapd(&mut self) -> EptMapdW<Eptcfg1Spec> {
394        EptMapdW::new(self, 31)
395    }
396}
397#[doc = "UDPHS Endpoint Configuration Register (endpoint = 1)\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`eptcfg1::R`](R).  You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`eptcfg1::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
398pub struct Eptcfg1Spec;
399impl crate::RegisterSpec for Eptcfg1Spec {
400    type Ux = u32;
401}
402#[doc = "`read()` method returns [`eptcfg1::R`](R) reader structure"]
403impl crate::Readable for Eptcfg1Spec {}
404#[doc = "`write(|w| ..)` method takes [`eptcfg1::W`](W) writer structure"]
405impl crate::Writable for Eptcfg1Spec {
406    type Safety = crate::Unsafe;
407    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
408    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
409}
410#[doc = "`reset()` method sets EPTCFG1 to value 0"]
411impl crate::Resettable for Eptcfg1Spec {
412    const RESET_VALUE: u32 = 0;
413}