stm32_usbd2/pac/usb/
daddr.rs

1#[doc = "Reader of register DADDR"]
2pub type R = crate::pac::generic::R<u32, super::DADDR>;
3#[doc = "Writer for register DADDR"]
4pub type W = crate::pac::generic::W<u32, super::DADDR>;
5#[doc = "Register DADDR `reset()`'s with value 0"]
6impl crate::pac::generic::ResetValue for super::DADDR {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Reader of field `ADD`"]
14pub type ADD_R = crate::pac::generic::R<u8, u8>;
15#[doc = "Write proxy for field `ADD`"]
16pub struct ADD_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> ADD_W<'a> {
20    #[doc = r"Writes raw bits to the field"]
21    #[inline(always)]
22    pub fn bits(self, value: u8) -> &'a mut W {
23        self.w.bits = (self.w.bits & !0x7f) | ((value as u32) & 0x7f);
24        self.w
25    }
26}
27#[doc = "Enable function\n\nValue on reset: 0"]
28#[derive(Clone, Copy, Debug, PartialEq)]
29pub enum EF_A {
30    #[doc = "0: USB device disabled"]
31    DISABLED = 0,
32    #[doc = "1: USB device enabled"]
33    ENABLED = 1,
34}
35impl From<EF_A> for bool {
36    #[inline(always)]
37    fn from(variant: EF_A) -> Self {
38        variant as u8 != 0
39    }
40}
41#[doc = "Reader of field `EF`"]
42pub type EF_R = crate::pac::generic::R<bool, EF_A>;
43impl EF_R {
44    #[doc = r"Get enumerated values variant"]
45    #[inline(always)]
46    pub fn variant(&self) -> EF_A {
47        match self.bits {
48            false => EF_A::DISABLED,
49            true => EF_A::ENABLED,
50        }
51    }
52    #[doc = "Checks if the value of the field is `DISABLED`"]
53    #[inline(always)]
54    pub fn is_disabled(&self) -> bool {
55        *self == EF_A::DISABLED
56    }
57    #[doc = "Checks if the value of the field is `ENABLED`"]
58    #[inline(always)]
59    pub fn is_enabled(&self) -> bool {
60        *self == EF_A::ENABLED
61    }
62}
63#[doc = "Write proxy for field `EF`"]
64pub struct EF_W<'a> {
65    w: &'a mut W,
66}
67impl<'a> EF_W<'a> {
68    #[doc = r"Writes `variant` to the field"]
69    #[inline(always)]
70    pub fn variant(self, variant: EF_A) -> &'a mut W {
71        {
72            self.bit(variant.into())
73        }
74    }
75    #[doc = "USB device disabled"]
76    #[inline(always)]
77    pub fn disabled(self) -> &'a mut W {
78        self.variant(EF_A::DISABLED)
79    }
80    #[doc = "USB device enabled"]
81    #[inline(always)]
82    pub fn enabled(self) -> &'a mut W {
83        self.variant(EF_A::ENABLED)
84    }
85    #[doc = r"Sets the field bit"]
86    #[inline(always)]
87    pub fn set_bit(self) -> &'a mut W {
88        self.bit(true)
89    }
90    #[doc = r"Clears the field bit"]
91    #[inline(always)]
92    pub fn clear_bit(self) -> &'a mut W {
93        self.bit(false)
94    }
95    #[doc = r"Writes raw bits to the field"]
96    #[inline(always)]
97    pub fn bit(self, value: bool) -> &'a mut W {
98        self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u32) & 0x01) << 7);
99        self.w
100    }
101}
102impl R {
103    #[doc = "Bits 0:6 - Device address"]
104    #[inline(always)]
105    pub fn add(&self) -> ADD_R {
106        ADD_R::new((self.bits & 0x7f) as u8)
107    }
108    #[doc = "Bit 7 - Enable function"]
109    #[inline(always)]
110    pub fn ef(&self) -> EF_R {
111        EF_R::new(((self.bits >> 7) & 0x01) != 0)
112    }
113}
114impl W {
115    #[doc = "Bits 0:6 - Device address"]
116    #[inline(always)]
117    pub fn add(&mut self) -> ADD_W {
118        ADD_W { w: self }
119    }
120    #[doc = "Bit 7 - Enable function"]
121    #[inline(always)]
122    pub fn ef(&mut self) -> EF_W {
123        EF_W { w: self }
124    }
125}