stm32wb 0.16.0

Device support crates for STM32WB devices
Documentation
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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
///Register `BCDR` reader
pub type R = crate::R<BCDRrs>;
///Register `BCDR` writer
pub type W = crate::W<BCDRrs>;
/**Battery charging detector (BCD) enable

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum BCDEN {
    ///0: disable the BCD support
    Disabled = 0,
    ///1: enable the BCD support within the USB device
    Enabled = 1,
}
impl From<BCDEN> for bool {
    #[inline(always)]
    fn from(variant: BCDEN) -> Self {
        variant as u8 != 0
    }
}
///Field `BCDEN` reader - Battery charging detector (BCD) enable
pub type BCDEN_R = crate::BitReader<BCDEN>;
impl BCDEN_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> BCDEN {
        match self.bits {
            false => BCDEN::Disabled,
            true => BCDEN::Enabled,
        }
    }
    ///disable the BCD support
    #[inline(always)]
    pub fn is_disabled(&self) -> bool {
        *self == BCDEN::Disabled
    }
    ///enable the BCD support within the USB device
    #[inline(always)]
    pub fn is_enabled(&self) -> bool {
        *self == BCDEN::Enabled
    }
}
///Field `BCDEN` writer - Battery charging detector (BCD) enable
pub type BCDEN_W<'a, REG> = crate::BitWriter<'a, REG, BCDEN>;
impl<'a, REG> BCDEN_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    ///disable the BCD support
    #[inline(always)]
    pub fn disabled(self) -> &'a mut crate::W<REG> {
        self.variant(BCDEN::Disabled)
    }
    ///enable the BCD support within the USB device
    #[inline(always)]
    pub fn enabled(self) -> &'a mut crate::W<REG> {
        self.variant(BCDEN::Enabled)
    }
}
/**Data contact detection (DCD) mode enable

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum DCDEN {
    ///0: Data contact detection (DCD) mode disabled
    Disabled = 0,
    ///1: Data contact detection (DCD) mode enabled
    Enabled = 1,
}
impl From<DCDEN> for bool {
    #[inline(always)]
    fn from(variant: DCDEN) -> Self {
        variant as u8 != 0
    }
}
///Field `DCDEN` reader - Data contact detection (DCD) mode enable
pub type DCDEN_R = crate::BitReader<DCDEN>;
impl DCDEN_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> DCDEN {
        match self.bits {
            false => DCDEN::Disabled,
            true => DCDEN::Enabled,
        }
    }
    ///Data contact detection (DCD) mode disabled
    #[inline(always)]
    pub fn is_disabled(&self) -> bool {
        *self == DCDEN::Disabled
    }
    ///Data contact detection (DCD) mode enabled
    #[inline(always)]
    pub fn is_enabled(&self) -> bool {
        *self == DCDEN::Enabled
    }
}
///Field `DCDEN` writer - Data contact detection (DCD) mode enable
pub type DCDEN_W<'a, REG> = crate::BitWriter<'a, REG, DCDEN>;
impl<'a, REG> DCDEN_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    ///Data contact detection (DCD) mode disabled
    #[inline(always)]
    pub fn disabled(self) -> &'a mut crate::W<REG> {
        self.variant(DCDEN::Disabled)
    }
    ///Data contact detection (DCD) mode enabled
    #[inline(always)]
    pub fn enabled(self) -> &'a mut crate::W<REG> {
        self.variant(DCDEN::Enabled)
    }
}
/**Primary detection (PD) mode enable

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum PDEN {
    ///0: Primary detection (PD) mode disabled
    Disabled = 0,
    ///1: Primary detection (PD) mode enabled
    Enabled = 1,
}
impl From<PDEN> for bool {
    #[inline(always)]
    fn from(variant: PDEN) -> Self {
        variant as u8 != 0
    }
}
///Field `PDEN` reader - Primary detection (PD) mode enable
pub type PDEN_R = crate::BitReader<PDEN>;
impl PDEN_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> PDEN {
        match self.bits {
            false => PDEN::Disabled,
            true => PDEN::Enabled,
        }
    }
    ///Primary detection (PD) mode disabled
    #[inline(always)]
    pub fn is_disabled(&self) -> bool {
        *self == PDEN::Disabled
    }
    ///Primary detection (PD) mode enabled
    #[inline(always)]
    pub fn is_enabled(&self) -> bool {
        *self == PDEN::Enabled
    }
}
///Field `PDEN` writer - Primary detection (PD) mode enable
pub type PDEN_W<'a, REG> = crate::BitWriter<'a, REG, PDEN>;
impl<'a, REG> PDEN_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    ///Primary detection (PD) mode disabled
    #[inline(always)]
    pub fn disabled(self) -> &'a mut crate::W<REG> {
        self.variant(PDEN::Disabled)
    }
    ///Primary detection (PD) mode enabled
    #[inline(always)]
    pub fn enabled(self) -> &'a mut crate::W<REG> {
        self.variant(PDEN::Enabled)
    }
}
/**Secondary detection (SD) mode enable

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SDEN {
    ///0: Secondary detection (SD) mode disabled
    Disabled = 0,
    ///1: Secondary detection (SD) mode enabled
    Enabled = 1,
}
impl From<SDEN> for bool {
    #[inline(always)]
    fn from(variant: SDEN) -> Self {
        variant as u8 != 0
    }
}
///Field `SDEN` reader - Secondary detection (SD) mode enable
pub type SDEN_R = crate::BitReader<SDEN>;
impl SDEN_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> SDEN {
        match self.bits {
            false => SDEN::Disabled,
            true => SDEN::Enabled,
        }
    }
    ///Secondary detection (SD) mode disabled
    #[inline(always)]
    pub fn is_disabled(&self) -> bool {
        *self == SDEN::Disabled
    }
    ///Secondary detection (SD) mode enabled
    #[inline(always)]
    pub fn is_enabled(&self) -> bool {
        *self == SDEN::Enabled
    }
}
///Field `SDEN` writer - Secondary detection (SD) mode enable
pub type SDEN_W<'a, REG> = crate::BitWriter<'a, REG, SDEN>;
impl<'a, REG> SDEN_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    ///Secondary detection (SD) mode disabled
    #[inline(always)]
    pub fn disabled(self) -> &'a mut crate::W<REG> {
        self.variant(SDEN::Disabled)
    }
    ///Secondary detection (SD) mode enabled
    #[inline(always)]
    pub fn enabled(self) -> &'a mut crate::W<REG> {
        self.variant(SDEN::Enabled)
    }
}
/**Data contact detection (DCD) status

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum DCDET {
    ///0: data lines contact not detected
    NotDetected = 0,
    ///1: data lines contact detected
    Detected = 1,
}
impl From<DCDET> for bool {
    #[inline(always)]
    fn from(variant: DCDET) -> Self {
        variant as u8 != 0
    }
}
///Field `DCDET` reader - Data contact detection (DCD) status
pub type DCDET_R = crate::BitReader<DCDET>;
impl DCDET_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> DCDET {
        match self.bits {
            false => DCDET::NotDetected,
            true => DCDET::Detected,
        }
    }
    ///data lines contact not detected
    #[inline(always)]
    pub fn is_not_detected(&self) -> bool {
        *self == DCDET::NotDetected
    }
    ///data lines contact detected
    #[inline(always)]
    pub fn is_detected(&self) -> bool {
        *self == DCDET::Detected
    }
}
/**Primary detection (PD) status

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum PDET {
    ///0: no BCD support detected
    NoBcd = 0,
    ///1: BCD support detected
    Bcd = 1,
}
impl From<PDET> for bool {
    #[inline(always)]
    fn from(variant: PDET) -> Self {
        variant as u8 != 0
    }
}
///Field `PDET` reader - Primary detection (PD) status
pub type PDET_R = crate::BitReader<PDET>;
impl PDET_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> PDET {
        match self.bits {
            false => PDET::NoBcd,
            true => PDET::Bcd,
        }
    }
    ///no BCD support detected
    #[inline(always)]
    pub fn is_no_bcd(&self) -> bool {
        *self == PDET::NoBcd
    }
    ///BCD support detected
    #[inline(always)]
    pub fn is_bcd(&self) -> bool {
        *self == PDET::Bcd
    }
}
/**Secondary detection (SD) status

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SDET {
    ///0: CDP detected
    Cdp = 0,
    ///1: DCP detected
    Dcp = 1,
}
impl From<SDET> for bool {
    #[inline(always)]
    fn from(variant: SDET) -> Self {
        variant as u8 != 0
    }
}
///Field `SDET` reader - Secondary detection (SD) status
pub type SDET_R = crate::BitReader<SDET>;
impl SDET_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> SDET {
        match self.bits {
            false => SDET::Cdp,
            true => SDET::Dcp,
        }
    }
    ///CDP detected
    #[inline(always)]
    pub fn is_cdp(&self) -> bool {
        *self == SDET::Cdp
    }
    ///DCP detected
    #[inline(always)]
    pub fn is_dcp(&self) -> bool {
        *self == SDET::Dcp
    }
}
/**DM pull-up detection status

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum PS2DET {
    ///0: Normal port detected
    Normal = 0,
    ///1: PS2 port or proprietary charger detected
    Ps2 = 1,
}
impl From<PS2DET> for bool {
    #[inline(always)]
    fn from(variant: PS2DET) -> Self {
        variant as u8 != 0
    }
}
///Field `PS2DET` reader - DM pull-up detection status
pub type PS2DET_R = crate::BitReader<PS2DET>;
impl PS2DET_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> PS2DET {
        match self.bits {
            false => PS2DET::Normal,
            true => PS2DET::Ps2,
        }
    }
    ///Normal port detected
    #[inline(always)]
    pub fn is_normal(&self) -> bool {
        *self == PS2DET::Normal
    }
    ///PS2 port or proprietary charger detected
    #[inline(always)]
    pub fn is_ps2(&self) -> bool {
        *self == PS2DET::Ps2
    }
}
/**DP pull-up control

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum DPPU {
    ///0: signalize disconnect to the host when needed by the user software
    Disabled = 0,
    ///1: enable the embedded pull-up on the DP line
    Enabled = 1,
}
impl From<DPPU> for bool {
    #[inline(always)]
    fn from(variant: DPPU) -> Self {
        variant as u8 != 0
    }
}
///Field `DPPU` reader - DP pull-up control
pub type DPPU_R = crate::BitReader<DPPU>;
impl DPPU_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> DPPU {
        match self.bits {
            false => DPPU::Disabled,
            true => DPPU::Enabled,
        }
    }
    ///signalize disconnect to the host when needed by the user software
    #[inline(always)]
    pub fn is_disabled(&self) -> bool {
        *self == DPPU::Disabled
    }
    ///enable the embedded pull-up on the DP line
    #[inline(always)]
    pub fn is_enabled(&self) -> bool {
        *self == DPPU::Enabled
    }
}
///Field `DPPU` writer - DP pull-up control
pub type DPPU_W<'a, REG> = crate::BitWriter<'a, REG, DPPU>;
impl<'a, REG> DPPU_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    ///signalize disconnect to the host when needed by the user software
    #[inline(always)]
    pub fn disabled(self) -> &'a mut crate::W<REG> {
        self.variant(DPPU::Disabled)
    }
    ///enable the embedded pull-up on the DP line
    #[inline(always)]
    pub fn enabled(self) -> &'a mut crate::W<REG> {
        self.variant(DPPU::Enabled)
    }
}
impl R {
    ///Bit 0 - Battery charging detector (BCD) enable
    #[inline(always)]
    pub fn bcden(&self) -> BCDEN_R {
        BCDEN_R::new((self.bits & 1) != 0)
    }
    ///Bit 1 - Data contact detection (DCD) mode enable
    #[inline(always)]
    pub fn dcden(&self) -> DCDEN_R {
        DCDEN_R::new(((self.bits >> 1) & 1) != 0)
    }
    ///Bit 2 - Primary detection (PD) mode enable
    #[inline(always)]
    pub fn pden(&self) -> PDEN_R {
        PDEN_R::new(((self.bits >> 2) & 1) != 0)
    }
    ///Bit 3 - Secondary detection (SD) mode enable
    #[inline(always)]
    pub fn sden(&self) -> SDEN_R {
        SDEN_R::new(((self.bits >> 3) & 1) != 0)
    }
    ///Bit 4 - Data contact detection (DCD) status
    #[inline(always)]
    pub fn dcdet(&self) -> DCDET_R {
        DCDET_R::new(((self.bits >> 4) & 1) != 0)
    }
    ///Bit 5 - Primary detection (PD) status
    #[inline(always)]
    pub fn pdet(&self) -> PDET_R {
        PDET_R::new(((self.bits >> 5) & 1) != 0)
    }
    ///Bit 6 - Secondary detection (SD) status
    #[inline(always)]
    pub fn sdet(&self) -> SDET_R {
        SDET_R::new(((self.bits >> 6) & 1) != 0)
    }
    ///Bit 7 - DM pull-up detection status
    #[inline(always)]
    pub fn ps2det(&self) -> PS2DET_R {
        PS2DET_R::new(((self.bits >> 7) & 1) != 0)
    }
    ///Bit 15 - DP pull-up control
    #[inline(always)]
    pub fn dppu(&self) -> DPPU_R {
        DPPU_R::new(((self.bits >> 15) & 1) != 0)
    }
}
impl core::fmt::Debug for R {
    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
        f.debug_struct("BCDR")
            .field("bcden", &self.bcden())
            .field("dcden", &self.dcden())
            .field("pden", &self.pden())
            .field("sden", &self.sden())
            .field("dcdet", &self.dcdet())
            .field("pdet", &self.pdet())
            .field("sdet", &self.sdet())
            .field("ps2det", &self.ps2det())
            .field("dppu", &self.dppu())
            .finish()
    }
}
impl W {
    ///Bit 0 - Battery charging detector (BCD) enable
    #[inline(always)]
    pub fn bcden(&mut self) -> BCDEN_W<BCDRrs> {
        BCDEN_W::new(self, 0)
    }
    ///Bit 1 - Data contact detection (DCD) mode enable
    #[inline(always)]
    pub fn dcden(&mut self) -> DCDEN_W<BCDRrs> {
        DCDEN_W::new(self, 1)
    }
    ///Bit 2 - Primary detection (PD) mode enable
    #[inline(always)]
    pub fn pden(&mut self) -> PDEN_W<BCDRrs> {
        PDEN_W::new(self, 2)
    }
    ///Bit 3 - Secondary detection (SD) mode enable
    #[inline(always)]
    pub fn sden(&mut self) -> SDEN_W<BCDRrs> {
        SDEN_W::new(self, 3)
    }
    ///Bit 15 - DP pull-up control
    #[inline(always)]
    pub fn dppu(&mut self) -> DPPU_W<BCDRrs> {
        DPPU_W::new(self, 15)
    }
}
/**Battery charging detector(

You can [`read`](crate::Reg::read) this register and get [`bcdr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`bcdr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api).

See register [structure](https://stm32-rs.github.io/stm32-rs/STM32WB55.html#USB:BCDR)*/
pub struct BCDRrs;
impl crate::RegisterSpec for BCDRrs {
    type Ux = u16;
}
///`read()` method returns [`bcdr::R`](R) reader structure
impl crate::Readable for BCDRrs {}
///`write(|w| ..)` method takes [`bcdr::W`](W) writer structure
impl crate::Writable for BCDRrs {
    type Safety = crate::Unsafe;
}
///`reset()` method sets BCDR to value 0
impl crate::Resettable for BCDRrs {}