stm32f0/stm32f0x1/usb/
bcdr.rs

1///Register `BCDR` reader
2pub type R = crate::R<BCDRrs>;
3///Register `BCDR` writer
4pub type W = crate::W<BCDRrs>;
5/**Battery charging detector (BCD) enable
6
7Value on reset: 0*/
8#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10pub enum BCDEN {
11    ///0: disable the BCD support
12    Disabled = 0,
13    ///1: enable the BCD support within the USB device
14    Enabled = 1,
15}
16impl From<BCDEN> for bool {
17    #[inline(always)]
18    fn from(variant: BCDEN) -> Self {
19        variant as u8 != 0
20    }
21}
22///Field `BCDEN` reader - Battery charging detector (BCD) enable
23pub type BCDEN_R = crate::BitReader<BCDEN>;
24impl BCDEN_R {
25    ///Get enumerated values variant
26    #[inline(always)]
27    pub const fn variant(&self) -> BCDEN {
28        match self.bits {
29            false => BCDEN::Disabled,
30            true => BCDEN::Enabled,
31        }
32    }
33    ///disable the BCD support
34    #[inline(always)]
35    pub fn is_disabled(&self) -> bool {
36        *self == BCDEN::Disabled
37    }
38    ///enable the BCD support within the USB device
39    #[inline(always)]
40    pub fn is_enabled(&self) -> bool {
41        *self == BCDEN::Enabled
42    }
43}
44///Field `BCDEN` writer - Battery charging detector (BCD) enable
45pub type BCDEN_W<'a, REG> = crate::BitWriter<'a, REG, BCDEN>;
46impl<'a, REG> BCDEN_W<'a, REG>
47where
48    REG: crate::Writable + crate::RegisterSpec,
49{
50    ///disable the BCD support
51    #[inline(always)]
52    pub fn disabled(self) -> &'a mut crate::W<REG> {
53        self.variant(BCDEN::Disabled)
54    }
55    ///enable the BCD support within the USB device
56    #[inline(always)]
57    pub fn enabled(self) -> &'a mut crate::W<REG> {
58        self.variant(BCDEN::Enabled)
59    }
60}
61/**Data contact detection (DCD) mode enable
62
63Value on reset: 0*/
64#[cfg_attr(feature = "defmt", derive(defmt::Format))]
65#[derive(Clone, Copy, Debug, PartialEq, Eq)]
66pub enum DCDEN {
67    ///0: Data contact detection (DCD) mode disabled
68    Disabled = 0,
69    ///1: Data contact detection (DCD) mode enabled
70    Enabled = 1,
71}
72impl From<DCDEN> for bool {
73    #[inline(always)]
74    fn from(variant: DCDEN) -> Self {
75        variant as u8 != 0
76    }
77}
78///Field `DCDEN` reader - Data contact detection (DCD) mode enable
79pub type DCDEN_R = crate::BitReader<DCDEN>;
80impl DCDEN_R {
81    ///Get enumerated values variant
82    #[inline(always)]
83    pub const fn variant(&self) -> DCDEN {
84        match self.bits {
85            false => DCDEN::Disabled,
86            true => DCDEN::Enabled,
87        }
88    }
89    ///Data contact detection (DCD) mode disabled
90    #[inline(always)]
91    pub fn is_disabled(&self) -> bool {
92        *self == DCDEN::Disabled
93    }
94    ///Data contact detection (DCD) mode enabled
95    #[inline(always)]
96    pub fn is_enabled(&self) -> bool {
97        *self == DCDEN::Enabled
98    }
99}
100///Field `DCDEN` writer - Data contact detection (DCD) mode enable
101pub type DCDEN_W<'a, REG> = crate::BitWriter<'a, REG, DCDEN>;
102impl<'a, REG> DCDEN_W<'a, REG>
103where
104    REG: crate::Writable + crate::RegisterSpec,
105{
106    ///Data contact detection (DCD) mode disabled
107    #[inline(always)]
108    pub fn disabled(self) -> &'a mut crate::W<REG> {
109        self.variant(DCDEN::Disabled)
110    }
111    ///Data contact detection (DCD) mode enabled
112    #[inline(always)]
113    pub fn enabled(self) -> &'a mut crate::W<REG> {
114        self.variant(DCDEN::Enabled)
115    }
116}
117/**Primary detection (PD) mode enable
118
119Value on reset: 0*/
120#[cfg_attr(feature = "defmt", derive(defmt::Format))]
121#[derive(Clone, Copy, Debug, PartialEq, Eq)]
122pub enum PDEN {
123    ///0: Primary detection (PD) mode disabled
124    Disabled = 0,
125    ///1: Primary detection (PD) mode enabled
126    Enabled = 1,
127}
128impl From<PDEN> for bool {
129    #[inline(always)]
130    fn from(variant: PDEN) -> Self {
131        variant as u8 != 0
132    }
133}
134///Field `PDEN` reader - Primary detection (PD) mode enable
135pub type PDEN_R = crate::BitReader<PDEN>;
136impl PDEN_R {
137    ///Get enumerated values variant
138    #[inline(always)]
139    pub const fn variant(&self) -> PDEN {
140        match self.bits {
141            false => PDEN::Disabled,
142            true => PDEN::Enabled,
143        }
144    }
145    ///Primary detection (PD) mode disabled
146    #[inline(always)]
147    pub fn is_disabled(&self) -> bool {
148        *self == PDEN::Disabled
149    }
150    ///Primary detection (PD) mode enabled
151    #[inline(always)]
152    pub fn is_enabled(&self) -> bool {
153        *self == PDEN::Enabled
154    }
155}
156///Field `PDEN` writer - Primary detection (PD) mode enable
157pub type PDEN_W<'a, REG> = crate::BitWriter<'a, REG, PDEN>;
158impl<'a, REG> PDEN_W<'a, REG>
159where
160    REG: crate::Writable + crate::RegisterSpec,
161{
162    ///Primary detection (PD) mode disabled
163    #[inline(always)]
164    pub fn disabled(self) -> &'a mut crate::W<REG> {
165        self.variant(PDEN::Disabled)
166    }
167    ///Primary detection (PD) mode enabled
168    #[inline(always)]
169    pub fn enabled(self) -> &'a mut crate::W<REG> {
170        self.variant(PDEN::Enabled)
171    }
172}
173/**Secondary detection (SD) mode enable
174
175Value on reset: 0*/
176#[cfg_attr(feature = "defmt", derive(defmt::Format))]
177#[derive(Clone, Copy, Debug, PartialEq, Eq)]
178pub enum SDEN {
179    ///0: Secondary detection (SD) mode disabled
180    Disabled = 0,
181    ///1: Secondary detection (SD) mode enabled
182    Enabled = 1,
183}
184impl From<SDEN> for bool {
185    #[inline(always)]
186    fn from(variant: SDEN) -> Self {
187        variant as u8 != 0
188    }
189}
190///Field `SDEN` reader - Secondary detection (SD) mode enable
191pub type SDEN_R = crate::BitReader<SDEN>;
192impl SDEN_R {
193    ///Get enumerated values variant
194    #[inline(always)]
195    pub const fn variant(&self) -> SDEN {
196        match self.bits {
197            false => SDEN::Disabled,
198            true => SDEN::Enabled,
199        }
200    }
201    ///Secondary detection (SD) mode disabled
202    #[inline(always)]
203    pub fn is_disabled(&self) -> bool {
204        *self == SDEN::Disabled
205    }
206    ///Secondary detection (SD) mode enabled
207    #[inline(always)]
208    pub fn is_enabled(&self) -> bool {
209        *self == SDEN::Enabled
210    }
211}
212///Field `SDEN` writer - Secondary detection (SD) mode enable
213pub type SDEN_W<'a, REG> = crate::BitWriter<'a, REG, SDEN>;
214impl<'a, REG> SDEN_W<'a, REG>
215where
216    REG: crate::Writable + crate::RegisterSpec,
217{
218    ///Secondary detection (SD) mode disabled
219    #[inline(always)]
220    pub fn disabled(self) -> &'a mut crate::W<REG> {
221        self.variant(SDEN::Disabled)
222    }
223    ///Secondary detection (SD) mode enabled
224    #[inline(always)]
225    pub fn enabled(self) -> &'a mut crate::W<REG> {
226        self.variant(SDEN::Enabled)
227    }
228}
229/**Data contact detection (DCD) status
230
231Value on reset: 0*/
232#[cfg_attr(feature = "defmt", derive(defmt::Format))]
233#[derive(Clone, Copy, Debug, PartialEq, Eq)]
234pub enum DCDET {
235    ///0: data lines contact not detected
236    NotDetected = 0,
237    ///1: data lines contact detected
238    Detected = 1,
239}
240impl From<DCDET> for bool {
241    #[inline(always)]
242    fn from(variant: DCDET) -> Self {
243        variant as u8 != 0
244    }
245}
246///Field `DCDET` reader - Data contact detection (DCD) status
247pub type DCDET_R = crate::BitReader<DCDET>;
248impl DCDET_R {
249    ///Get enumerated values variant
250    #[inline(always)]
251    pub const fn variant(&self) -> DCDET {
252        match self.bits {
253            false => DCDET::NotDetected,
254            true => DCDET::Detected,
255        }
256    }
257    ///data lines contact not detected
258    #[inline(always)]
259    pub fn is_not_detected(&self) -> bool {
260        *self == DCDET::NotDetected
261    }
262    ///data lines contact detected
263    #[inline(always)]
264    pub fn is_detected(&self) -> bool {
265        *self == DCDET::Detected
266    }
267}
268/**Primary detection (PD) status
269
270Value on reset: 0*/
271#[cfg_attr(feature = "defmt", derive(defmt::Format))]
272#[derive(Clone, Copy, Debug, PartialEq, Eq)]
273pub enum PDET {
274    ///0: no BCD support detected
275    NoBcd = 0,
276    ///1: BCD support detected
277    Bcd = 1,
278}
279impl From<PDET> for bool {
280    #[inline(always)]
281    fn from(variant: PDET) -> Self {
282        variant as u8 != 0
283    }
284}
285///Field `PDET` reader - Primary detection (PD) status
286pub type PDET_R = crate::BitReader<PDET>;
287impl PDET_R {
288    ///Get enumerated values variant
289    #[inline(always)]
290    pub const fn variant(&self) -> PDET {
291        match self.bits {
292            false => PDET::NoBcd,
293            true => PDET::Bcd,
294        }
295    }
296    ///no BCD support detected
297    #[inline(always)]
298    pub fn is_no_bcd(&self) -> bool {
299        *self == PDET::NoBcd
300    }
301    ///BCD support detected
302    #[inline(always)]
303    pub fn is_bcd(&self) -> bool {
304        *self == PDET::Bcd
305    }
306}
307/**Secondary detection (SD) status
308
309Value on reset: 0*/
310#[cfg_attr(feature = "defmt", derive(defmt::Format))]
311#[derive(Clone, Copy, Debug, PartialEq, Eq)]
312pub enum SDET {
313    ///0: CDP detected
314    Cdp = 0,
315    ///1: DCP detected
316    Dcp = 1,
317}
318impl From<SDET> for bool {
319    #[inline(always)]
320    fn from(variant: SDET) -> Self {
321        variant as u8 != 0
322    }
323}
324///Field `SDET` reader - Secondary detection (SD) status
325pub type SDET_R = crate::BitReader<SDET>;
326impl SDET_R {
327    ///Get enumerated values variant
328    #[inline(always)]
329    pub const fn variant(&self) -> SDET {
330        match self.bits {
331            false => SDET::Cdp,
332            true => SDET::Dcp,
333        }
334    }
335    ///CDP detected
336    #[inline(always)]
337    pub fn is_cdp(&self) -> bool {
338        *self == SDET::Cdp
339    }
340    ///DCP detected
341    #[inline(always)]
342    pub fn is_dcp(&self) -> bool {
343        *self == SDET::Dcp
344    }
345}
346/**DM pull-up detection status
347
348Value on reset: 0*/
349#[cfg_attr(feature = "defmt", derive(defmt::Format))]
350#[derive(Clone, Copy, Debug, PartialEq, Eq)]
351pub enum PS2DET {
352    ///0: Normal port detected
353    Normal = 0,
354    ///1: PS2 port or proprietary charger detected
355    Ps2 = 1,
356}
357impl From<PS2DET> for bool {
358    #[inline(always)]
359    fn from(variant: PS2DET) -> Self {
360        variant as u8 != 0
361    }
362}
363///Field `PS2DET` reader - DM pull-up detection status
364pub type PS2DET_R = crate::BitReader<PS2DET>;
365impl PS2DET_R {
366    ///Get enumerated values variant
367    #[inline(always)]
368    pub const fn variant(&self) -> PS2DET {
369        match self.bits {
370            false => PS2DET::Normal,
371            true => PS2DET::Ps2,
372        }
373    }
374    ///Normal port detected
375    #[inline(always)]
376    pub fn is_normal(&self) -> bool {
377        *self == PS2DET::Normal
378    }
379    ///PS2 port or proprietary charger detected
380    #[inline(always)]
381    pub fn is_ps2(&self) -> bool {
382        *self == PS2DET::Ps2
383    }
384}
385/**DP pull-up control
386
387Value on reset: 0*/
388#[cfg_attr(feature = "defmt", derive(defmt::Format))]
389#[derive(Clone, Copy, Debug, PartialEq, Eq)]
390pub enum DPPU {
391    ///0: signalize disconnect to the host when needed by the user software
392    Disabled = 0,
393    ///1: enable the embedded pull-up on the DP line
394    Enabled = 1,
395}
396impl From<DPPU> for bool {
397    #[inline(always)]
398    fn from(variant: DPPU) -> Self {
399        variant as u8 != 0
400    }
401}
402///Field `DPPU` reader - DP pull-up control
403pub type DPPU_R = crate::BitReader<DPPU>;
404impl DPPU_R {
405    ///Get enumerated values variant
406    #[inline(always)]
407    pub const fn variant(&self) -> DPPU {
408        match self.bits {
409            false => DPPU::Disabled,
410            true => DPPU::Enabled,
411        }
412    }
413    ///signalize disconnect to the host when needed by the user software
414    #[inline(always)]
415    pub fn is_disabled(&self) -> bool {
416        *self == DPPU::Disabled
417    }
418    ///enable the embedded pull-up on the DP line
419    #[inline(always)]
420    pub fn is_enabled(&self) -> bool {
421        *self == DPPU::Enabled
422    }
423}
424///Field `DPPU` writer - DP pull-up control
425pub type DPPU_W<'a, REG> = crate::BitWriter<'a, REG, DPPU>;
426impl<'a, REG> DPPU_W<'a, REG>
427where
428    REG: crate::Writable + crate::RegisterSpec,
429{
430    ///signalize disconnect to the host when needed by the user software
431    #[inline(always)]
432    pub fn disabled(self) -> &'a mut crate::W<REG> {
433        self.variant(DPPU::Disabled)
434    }
435    ///enable the embedded pull-up on the DP line
436    #[inline(always)]
437    pub fn enabled(self) -> &'a mut crate::W<REG> {
438        self.variant(DPPU::Enabled)
439    }
440}
441impl R {
442    ///Bit 0 - Battery charging detector (BCD) enable
443    #[inline(always)]
444    pub fn bcden(&self) -> BCDEN_R {
445        BCDEN_R::new((self.bits & 1) != 0)
446    }
447    ///Bit 1 - Data contact detection (DCD) mode enable
448    #[inline(always)]
449    pub fn dcden(&self) -> DCDEN_R {
450        DCDEN_R::new(((self.bits >> 1) & 1) != 0)
451    }
452    ///Bit 2 - Primary detection (PD) mode enable
453    #[inline(always)]
454    pub fn pden(&self) -> PDEN_R {
455        PDEN_R::new(((self.bits >> 2) & 1) != 0)
456    }
457    ///Bit 3 - Secondary detection (SD) mode enable
458    #[inline(always)]
459    pub fn sden(&self) -> SDEN_R {
460        SDEN_R::new(((self.bits >> 3) & 1) != 0)
461    }
462    ///Bit 4 - Data contact detection (DCD) status
463    #[inline(always)]
464    pub fn dcdet(&self) -> DCDET_R {
465        DCDET_R::new(((self.bits >> 4) & 1) != 0)
466    }
467    ///Bit 5 - Primary detection (PD) status
468    #[inline(always)]
469    pub fn pdet(&self) -> PDET_R {
470        PDET_R::new(((self.bits >> 5) & 1) != 0)
471    }
472    ///Bit 6 - Secondary detection (SD) status
473    #[inline(always)]
474    pub fn sdet(&self) -> SDET_R {
475        SDET_R::new(((self.bits >> 6) & 1) != 0)
476    }
477    ///Bit 7 - DM pull-up detection status
478    #[inline(always)]
479    pub fn ps2det(&self) -> PS2DET_R {
480        PS2DET_R::new(((self.bits >> 7) & 1) != 0)
481    }
482    ///Bit 15 - DP pull-up control
483    #[inline(always)]
484    pub fn dppu(&self) -> DPPU_R {
485        DPPU_R::new(((self.bits >> 15) & 1) != 0)
486    }
487}
488impl core::fmt::Debug for R {
489    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
490        f.debug_struct("BCDR")
491            .field("bcden", &self.bcden())
492            .field("dcden", &self.dcden())
493            .field("pden", &self.pden())
494            .field("sden", &self.sden())
495            .field("dcdet", &self.dcdet())
496            .field("pdet", &self.pdet())
497            .field("sdet", &self.sdet())
498            .field("ps2det", &self.ps2det())
499            .field("dppu", &self.dppu())
500            .finish()
501    }
502}
503impl W {
504    ///Bit 0 - Battery charging detector (BCD) enable
505    #[inline(always)]
506    pub fn bcden(&mut self) -> BCDEN_W<BCDRrs> {
507        BCDEN_W::new(self, 0)
508    }
509    ///Bit 1 - Data contact detection (DCD) mode enable
510    #[inline(always)]
511    pub fn dcden(&mut self) -> DCDEN_W<BCDRrs> {
512        DCDEN_W::new(self, 1)
513    }
514    ///Bit 2 - Primary detection (PD) mode enable
515    #[inline(always)]
516    pub fn pden(&mut self) -> PDEN_W<BCDRrs> {
517        PDEN_W::new(self, 2)
518    }
519    ///Bit 3 - Secondary detection (SD) mode enable
520    #[inline(always)]
521    pub fn sden(&mut self) -> SDEN_W<BCDRrs> {
522        SDEN_W::new(self, 3)
523    }
524    ///Bit 15 - DP pull-up control
525    #[inline(always)]
526    pub fn dppu(&mut self) -> DPPU_W<BCDRrs> {
527        DPPU_W::new(self, 15)
528    }
529}
530/**Battery charging detector
531
532You 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).
533
534See register [structure](https://stm32-rs.github.io/stm32-rs/STM32F0x1.html#USB:BCDR)*/
535pub struct BCDRrs;
536impl crate::RegisterSpec for BCDRrs {
537    type Ux = u32;
538}
539///`read()` method returns [`bcdr::R`](R) reader structure
540impl crate::Readable for BCDRrs {}
541///`write(|w| ..)` method takes [`bcdr::W`](W) writer structure
542impl crate::Writable for BCDRrs {
543    type Safety = crate::Unsafe;
544}
545///`reset()` method sets BCDR to value 0
546impl crate::Resettable for BCDRrs {}