stm32f1/stm32f101/usb/
daddr.rs

1///Register `DADDR` reader
2pub type R = crate::R<DADDRrs>;
3///Register `DADDR` writer
4pub type W = crate::W<DADDRrs>;
5///Field `ADD` reader - Device address
6pub type ADD_R = crate::FieldReader;
7///Field `ADD` writer - Device address
8pub type ADD_W<'a, REG> = crate::FieldWriter<'a, REG, 7, u8, crate::Safe>;
9/**Enable function
10
11Value on reset: 0*/
12#[cfg_attr(feature = "defmt", derive(defmt::Format))]
13#[derive(Clone, Copy, Debug, PartialEq, Eq)]
14pub enum EF {
15    ///0: USB device disabled
16    Disabled = 0,
17    ///1: USB device enabled
18    Enabled = 1,
19}
20impl From<EF> for bool {
21    #[inline(always)]
22    fn from(variant: EF) -> Self {
23        variant as u8 != 0
24    }
25}
26///Field `EF` reader - Enable function
27pub type EF_R = crate::BitReader<EF>;
28impl EF_R {
29    ///Get enumerated values variant
30    #[inline(always)]
31    pub const fn variant(&self) -> EF {
32        match self.bits {
33            false => EF::Disabled,
34            true => EF::Enabled,
35        }
36    }
37    ///USB device disabled
38    #[inline(always)]
39    pub fn is_disabled(&self) -> bool {
40        *self == EF::Disabled
41    }
42    ///USB device enabled
43    #[inline(always)]
44    pub fn is_enabled(&self) -> bool {
45        *self == EF::Enabled
46    }
47}
48///Field `EF` writer - Enable function
49pub type EF_W<'a, REG> = crate::BitWriter<'a, REG, EF>;
50impl<'a, REG> EF_W<'a, REG>
51where
52    REG: crate::Writable + crate::RegisterSpec,
53{
54    ///USB device disabled
55    #[inline(always)]
56    pub fn disabled(self) -> &'a mut crate::W<REG> {
57        self.variant(EF::Disabled)
58    }
59    ///USB device enabled
60    #[inline(always)]
61    pub fn enabled(self) -> &'a mut crate::W<REG> {
62        self.variant(EF::Enabled)
63    }
64}
65impl R {
66    ///Bits 0:6 - Device address
67    #[inline(always)]
68    pub fn add(&self) -> ADD_R {
69        ADD_R::new((self.bits & 0x7f) as u8)
70    }
71    ///Bit 7 - Enable function
72    #[inline(always)]
73    pub fn ef(&self) -> EF_R {
74        EF_R::new(((self.bits >> 7) & 1) != 0)
75    }
76}
77impl core::fmt::Debug for R {
78    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
79        f.debug_struct("DADDR")
80            .field("add", &self.add())
81            .field("ef", &self.ef())
82            .finish()
83    }
84}
85impl W {
86    ///Bits 0:6 - Device address
87    #[inline(always)]
88    pub fn add(&mut self) -> ADD_W<DADDRrs> {
89        ADD_W::new(self, 0)
90    }
91    ///Bit 7 - Enable function
92    #[inline(always)]
93    pub fn ef(&mut self) -> EF_W<DADDRrs> {
94        EF_W::new(self, 7)
95    }
96}
97/**device address
98
99You can [`read`](crate::Reg::read) this register and get [`daddr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`daddr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api).
100
101See register [structure](https://stm32-rs.github.io/stm32-rs/STM32F101.html#USB:DADDR)*/
102pub struct DADDRrs;
103impl crate::RegisterSpec for DADDRrs {
104    type Ux = u32;
105}
106///`read()` method returns [`daddr::R`](R) reader structure
107impl crate::Readable for DADDRrs {}
108///`write(|w| ..)` method takes [`daddr::W`](W) writer structure
109impl crate::Writable for DADDRrs {
110    type Safety = crate::Unsafe;
111}
112///`reset()` method sets DADDR to value 0
113impl crate::Resettable for DADDRrs {}