1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
#[doc = "Register `DCFG` reader"]
pub type R = crate::R<DCFG_SPEC>;
#[doc = "Register `DCFG` writer"]
pub type W = crate::W<DCFG_SPEC>;
#[doc = "Device Speed\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum DEV_SPD_A {
    #[doc = "3: Full speed (USB 1.1 transceiver clock is 48 MHz)"]
    VALUE4 = 3,
}
impl From<DEV_SPD_A> for u8 {
    #[inline(always)]
    fn from(variant: DEV_SPD_A) -> Self {
        variant as _
    }
}
impl crate::FieldSpec for DEV_SPD_A {
    type Ux = u8;
}
impl crate::IsEnum for DEV_SPD_A {}
#[doc = "Field `DevSpd` reader - Device Speed"]
pub type DEV_SPD_R = crate::FieldReader<DEV_SPD_A>;
impl DEV_SPD_R {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Option<DEV_SPD_A> {
        match self.bits {
            3 => Some(DEV_SPD_A::VALUE4),
            _ => None,
        }
    }
    #[doc = "Full speed (USB 1.1 transceiver clock is 48 MHz)"]
    #[inline(always)]
    pub fn is_value4(&self) -> bool {
        *self == DEV_SPD_A::VALUE4
    }
}
#[doc = "Field `DevSpd` writer - Device Speed"]
pub type DEV_SPD_W<'a, REG> = crate::FieldWriter<'a, REG, 2, DEV_SPD_A>;
impl<'a, REG> DEV_SPD_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
    REG::Ux: From<u8>,
{
    #[doc = "Full speed (USB 1.1 transceiver clock is 48 MHz)"]
    #[inline(always)]
    pub fn value4(self) -> &'a mut crate::W<REG> {
        self.variant(DEV_SPD_A::VALUE4)
    }
}
#[doc = "Non-Zero-Length Status OUT Handshake\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum NZSTS_OUTHSHK_A {
    #[doc = "1: Send a STALL handshake on a nonzero-length status OUT transaction and do not send the received OUT packet to the application."]
    VALUE1 = 1,
    #[doc = "0: Send the received OUT packet to the application (zero-length or nonzero-length) and send a handshake based on the NAK and STALL bits for the endpoint in the Device Endpoint Control register."]
    VALUE2 = 0,
}
impl From<NZSTS_OUTHSHK_A> for bool {
    #[inline(always)]
    fn from(variant: NZSTS_OUTHSHK_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `NZStsOUTHShk` reader - Non-Zero-Length Status OUT Handshake"]
pub type NZSTS_OUTHSHK_R = crate::BitReader<NZSTS_OUTHSHK_A>;
impl NZSTS_OUTHSHK_R {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> NZSTS_OUTHSHK_A {
        match self.bits {
            true => NZSTS_OUTHSHK_A::VALUE1,
            false => NZSTS_OUTHSHK_A::VALUE2,
        }
    }
    #[doc = "Send a STALL handshake on a nonzero-length status OUT transaction and do not send the received OUT packet to the application."]
    #[inline(always)]
    pub fn is_value1(&self) -> bool {
        *self == NZSTS_OUTHSHK_A::VALUE1
    }
    #[doc = "Send the received OUT packet to the application (zero-length or nonzero-length) and send a handshake based on the NAK and STALL bits for the endpoint in the Device Endpoint Control register."]
    #[inline(always)]
    pub fn is_value2(&self) -> bool {
        *self == NZSTS_OUTHSHK_A::VALUE2
    }
}
#[doc = "Field `NZStsOUTHShk` writer - Non-Zero-Length Status OUT Handshake"]
pub type NZSTS_OUTHSHK_W<'a, REG> = crate::BitWriter<'a, REG, NZSTS_OUTHSHK_A>;
impl<'a, REG> NZSTS_OUTHSHK_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    #[doc = "Send a STALL handshake on a nonzero-length status OUT transaction and do not send the received OUT packet to the application."]
    #[inline(always)]
    pub fn value1(self) -> &'a mut crate::W<REG> {
        self.variant(NZSTS_OUTHSHK_A::VALUE1)
    }
    #[doc = "Send the received OUT packet to the application (zero-length or nonzero-length) and send a handshake based on the NAK and STALL bits for the endpoint in the Device Endpoint Control register."]
    #[inline(always)]
    pub fn value2(self) -> &'a mut crate::W<REG> {
        self.variant(NZSTS_OUTHSHK_A::VALUE2)
    }
}
#[doc = "Field `DevAddr` reader - Device Address"]
pub type DEV_ADDR_R = crate::FieldReader;
#[doc = "Field `DevAddr` writer - Device Address"]
pub type DEV_ADDR_W<'a, REG> = crate::FieldWriter<'a, REG, 7>;
#[doc = "Periodic Frame Interval\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum PER_FR_INT_A {
    #[doc = "0: 80% of the frame interval"]
    VALUE1 = 0,
    #[doc = "1: 85%"]
    VALUE2 = 1,
    #[doc = "2: 90%"]
    VALUE3 = 2,
    #[doc = "3: 95%"]
    VALUE4 = 3,
}
impl From<PER_FR_INT_A> for u8 {
    #[inline(always)]
    fn from(variant: PER_FR_INT_A) -> Self {
        variant as _
    }
}
impl crate::FieldSpec for PER_FR_INT_A {
    type Ux = u8;
}
impl crate::IsEnum for PER_FR_INT_A {}
#[doc = "Field `PerFrInt` reader - Periodic Frame Interval"]
pub type PER_FR_INT_R = crate::FieldReader<PER_FR_INT_A>;
impl PER_FR_INT_R {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> PER_FR_INT_A {
        match self.bits {
            0 => PER_FR_INT_A::VALUE1,
            1 => PER_FR_INT_A::VALUE2,
            2 => PER_FR_INT_A::VALUE3,
            3 => PER_FR_INT_A::VALUE4,
            _ => unreachable!(),
        }
    }
    #[doc = "80% of the frame interval"]
    #[inline(always)]
    pub fn is_value1(&self) -> bool {
        *self == PER_FR_INT_A::VALUE1
    }
    #[doc = "85%"]
    #[inline(always)]
    pub fn is_value2(&self) -> bool {
        *self == PER_FR_INT_A::VALUE2
    }
    #[doc = "90%"]
    #[inline(always)]
    pub fn is_value3(&self) -> bool {
        *self == PER_FR_INT_A::VALUE3
    }
    #[doc = "95%"]
    #[inline(always)]
    pub fn is_value4(&self) -> bool {
        *self == PER_FR_INT_A::VALUE4
    }
}
#[doc = "Field `PerFrInt` writer - Periodic Frame Interval"]
pub type PER_FR_INT_W<'a, REG> = crate::FieldWriter<'a, REG, 2, PER_FR_INT_A, crate::Safe>;
impl<'a, REG> PER_FR_INT_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
    REG::Ux: From<u8>,
{
    #[doc = "80% of the frame interval"]
    #[inline(always)]
    pub fn value1(self) -> &'a mut crate::W<REG> {
        self.variant(PER_FR_INT_A::VALUE1)
    }
    #[doc = "85%"]
    #[inline(always)]
    pub fn value2(self) -> &'a mut crate::W<REG> {
        self.variant(PER_FR_INT_A::VALUE2)
    }
    #[doc = "90%"]
    #[inline(always)]
    pub fn value3(self) -> &'a mut crate::W<REG> {
        self.variant(PER_FR_INT_A::VALUE3)
    }
    #[doc = "95%"]
    #[inline(always)]
    pub fn value4(self) -> &'a mut crate::W<REG> {
        self.variant(PER_FR_INT_A::VALUE4)
    }
}
#[doc = "Field `DescDMA` reader - Enable Scatter/Gather DMA in Device mode."]
pub type DESC_DMA_R = crate::BitReader;
#[doc = "Field `DescDMA` writer - Enable Scatter/Gather DMA in Device mode."]
pub type DESC_DMA_W<'a, REG> = crate::BitWriter<'a, REG>;
#[doc = "Periodic Scheduling Interval\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum PER_SCH_INTVL_A {
    #[doc = "0: 25% of frame."]
    VALUE1 = 0,
    #[doc = "1: 50% of frame."]
    VALUE2 = 1,
    #[doc = "2: 75% of frame."]
    VALUE3 = 2,
}
impl From<PER_SCH_INTVL_A> for u8 {
    #[inline(always)]
    fn from(variant: PER_SCH_INTVL_A) -> Self {
        variant as _
    }
}
impl crate::FieldSpec for PER_SCH_INTVL_A {
    type Ux = u8;
}
impl crate::IsEnum for PER_SCH_INTVL_A {}
#[doc = "Field `PerSchIntvl` reader - Periodic Scheduling Interval"]
pub type PER_SCH_INTVL_R = crate::FieldReader<PER_SCH_INTVL_A>;
impl PER_SCH_INTVL_R {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Option<PER_SCH_INTVL_A> {
        match self.bits {
            0 => Some(PER_SCH_INTVL_A::VALUE1),
            1 => Some(PER_SCH_INTVL_A::VALUE2),
            2 => Some(PER_SCH_INTVL_A::VALUE3),
            _ => None,
        }
    }
    #[doc = "25% of frame."]
    #[inline(always)]
    pub fn is_value1(&self) -> bool {
        *self == PER_SCH_INTVL_A::VALUE1
    }
    #[doc = "50% of frame."]
    #[inline(always)]
    pub fn is_value2(&self) -> bool {
        *self == PER_SCH_INTVL_A::VALUE2
    }
    #[doc = "75% of frame."]
    #[inline(always)]
    pub fn is_value3(&self) -> bool {
        *self == PER_SCH_INTVL_A::VALUE3
    }
}
#[doc = "Field `PerSchIntvl` writer - Periodic Scheduling Interval"]
pub type PER_SCH_INTVL_W<'a, REG> = crate::FieldWriter<'a, REG, 2, PER_SCH_INTVL_A>;
impl<'a, REG> PER_SCH_INTVL_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
    REG::Ux: From<u8>,
{
    #[doc = "25% of frame."]
    #[inline(always)]
    pub fn value1(self) -> &'a mut crate::W<REG> {
        self.variant(PER_SCH_INTVL_A::VALUE1)
    }
    #[doc = "50% of frame."]
    #[inline(always)]
    pub fn value2(self) -> &'a mut crate::W<REG> {
        self.variant(PER_SCH_INTVL_A::VALUE2)
    }
    #[doc = "75% of frame."]
    #[inline(always)]
    pub fn value3(self) -> &'a mut crate::W<REG> {
        self.variant(PER_SCH_INTVL_A::VALUE3)
    }
}
impl R {
    #[doc = "Bits 0:1 - Device Speed"]
    #[inline(always)]
    pub fn dev_spd(&self) -> DEV_SPD_R {
        DEV_SPD_R::new((self.bits & 3) as u8)
    }
    #[doc = "Bit 2 - Non-Zero-Length Status OUT Handshake"]
    #[inline(always)]
    pub fn nzsts_outhshk(&self) -> NZSTS_OUTHSHK_R {
        NZSTS_OUTHSHK_R::new(((self.bits >> 2) & 1) != 0)
    }
    #[doc = "Bits 4:10 - Device Address"]
    #[inline(always)]
    pub fn dev_addr(&self) -> DEV_ADDR_R {
        DEV_ADDR_R::new(((self.bits >> 4) & 0x7f) as u8)
    }
    #[doc = "Bits 11:12 - Periodic Frame Interval"]
    #[inline(always)]
    pub fn per_fr_int(&self) -> PER_FR_INT_R {
        PER_FR_INT_R::new(((self.bits >> 11) & 3) as u8)
    }
    #[doc = "Bit 23 - Enable Scatter/Gather DMA in Device mode."]
    #[inline(always)]
    pub fn desc_dma(&self) -> DESC_DMA_R {
        DESC_DMA_R::new(((self.bits >> 23) & 1) != 0)
    }
    #[doc = "Bits 24:25 - Periodic Scheduling Interval"]
    #[inline(always)]
    pub fn per_sch_intvl(&self) -> PER_SCH_INTVL_R {
        PER_SCH_INTVL_R::new(((self.bits >> 24) & 3) as u8)
    }
}
impl W {
    #[doc = "Bits 0:1 - Device Speed"]
    #[inline(always)]
    #[must_use]
    pub fn dev_spd(&mut self) -> DEV_SPD_W<DCFG_SPEC> {
        DEV_SPD_W::new(self, 0)
    }
    #[doc = "Bit 2 - Non-Zero-Length Status OUT Handshake"]
    #[inline(always)]
    #[must_use]
    pub fn nzsts_outhshk(&mut self) -> NZSTS_OUTHSHK_W<DCFG_SPEC> {
        NZSTS_OUTHSHK_W::new(self, 2)
    }
    #[doc = "Bits 4:10 - Device Address"]
    #[inline(always)]
    #[must_use]
    pub fn dev_addr(&mut self) -> DEV_ADDR_W<DCFG_SPEC> {
        DEV_ADDR_W::new(self, 4)
    }
    #[doc = "Bits 11:12 - Periodic Frame Interval"]
    #[inline(always)]
    #[must_use]
    pub fn per_fr_int(&mut self) -> PER_FR_INT_W<DCFG_SPEC> {
        PER_FR_INT_W::new(self, 11)
    }
    #[doc = "Bit 23 - Enable Scatter/Gather DMA in Device mode."]
    #[inline(always)]
    #[must_use]
    pub fn desc_dma(&mut self) -> DESC_DMA_W<DCFG_SPEC> {
        DESC_DMA_W::new(self, 23)
    }
    #[doc = "Bits 24:25 - Periodic Scheduling Interval"]
    #[inline(always)]
    #[must_use]
    pub fn per_sch_intvl(&mut self) -> PER_SCH_INTVL_W<DCFG_SPEC> {
        PER_SCH_INTVL_W::new(self, 24)
    }
}
#[doc = "Device Configuration Register\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`dcfg::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 [`dcfg::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
pub struct DCFG_SPEC;
impl crate::RegisterSpec for DCFG_SPEC {
    type Ux = u32;
}
#[doc = "`read()` method returns [`dcfg::R`](R) reader structure"]
impl crate::Readable for DCFG_SPEC {}
#[doc = "`write(|w| ..)` method takes [`dcfg::W`](W) writer structure"]
impl crate::Writable for DCFG_SPEC {
    type Safety = crate::Unsafe;
    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
}
#[doc = "`reset()` method sets DCFG to value 0x0820_0000"]
impl crate::Resettable for DCFG_SPEC {
    const RESET_VALUE: u32 = 0x0820_0000;
}