1#[doc = "Register `CONTROL` reader"]
2pub type R = crate::R<ControlSpec>;
3#[doc = "Register `CONTROL` writer"]
4pub type W = crate::W<ControlSpec>;
5#[doc = "VBUS Monitoring Source Select\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum VbusSourceSel {
9 #[doc = "1: Resistive divider attached to a GPIO pin"]
10 Resistive = 1,
11}
12impl From<VbusSourceSel> for bool {
13 #[inline(always)]
14 fn from(variant: VbusSourceSel) -> Self {
15 variant as u8 != 0
16 }
17}
18#[doc = "Field `VBUS_SOURCE_SEL` reader - VBUS Monitoring Source Select"]
19pub type VbusSourceSelR = crate::BitReader<VbusSourceSel>;
20impl VbusSourceSelR {
21 #[doc = "Get enumerated values variant"]
22 #[inline(always)]
23 pub const fn variant(&self) -> Option<VbusSourceSel> {
24 match self.bits {
25 true => Some(VbusSourceSel::Resistive),
26 _ => None,
27 }
28 }
29 #[doc = "Resistive divider attached to a GPIO pin"]
30 #[inline(always)]
31 pub fn is_resistive(&self) -> bool {
32 *self == VbusSourceSel::Resistive
33 }
34}
35#[doc = "Field `VBUS_SOURCE_SEL` writer - VBUS Monitoring Source Select"]
36pub type VbusSourceSelW<'a, REG> = crate::BitWriter<'a, REG, VbusSourceSel>;
37impl<'a, REG> VbusSourceSelW<'a, REG>
38where
39 REG: crate::Writable + crate::RegisterSpec,
40{
41 #[doc = "Resistive divider attached to a GPIO pin"]
42 #[inline(always)]
43 pub fn resistive(self) -> &'a mut crate::W<REG> {
44 self.variant(VbusSourceSel::Resistive)
45 }
46}
47#[doc = "VBUS Session Valid status\n\nValue on reset: 0"]
48#[cfg_attr(feature = "defmt", derive(defmt::Format))]
49#[derive(Clone, Copy, Debug, PartialEq, Eq)]
50pub enum SessVld {
51 #[doc = "0: Below"]
52 SessVldLow = 0,
53 #[doc = "1: Above"]
54 SessVldHigh = 1,
55}
56impl From<SessVld> for bool {
57 #[inline(always)]
58 fn from(variant: SessVld) -> Self {
59 variant as u8 != 0
60 }
61}
62#[doc = "Field `SESS_VLD` reader - VBUS Session Valid status"]
63pub type SessVldR = crate::BitReader<SessVld>;
64impl SessVldR {
65 #[doc = "Get enumerated values variant"]
66 #[inline(always)]
67 pub const fn variant(&self) -> SessVld {
68 match self.bits {
69 false => SessVld::SessVldLow,
70 true => SessVld::SessVldHigh,
71 }
72 }
73 #[doc = "Below"]
74 #[inline(always)]
75 pub fn is_sess_vld_low(&self) -> bool {
76 *self == SessVld::SessVldLow
77 }
78 #[doc = "Above"]
79 #[inline(always)]
80 pub fn is_sess_vld_high(&self) -> bool {
81 *self == SessVld::SessVldHigh
82 }
83}
84#[doc = "DP Pullup in Non-OTG Device Mode\n\nValue on reset: 0"]
85#[cfg_attr(feature = "defmt", derive(defmt::Format))]
86#[derive(Clone, Copy, Debug, PartialEq, Eq)]
87pub enum Dppullupnonotg {
88 #[doc = "0: Disable"]
89 DisDeviceDpPu = 0,
90 #[doc = "1: Enabled"]
91 EnDeviceDpPu = 1,
92}
93impl From<Dppullupnonotg> for bool {
94 #[inline(always)]
95 fn from(variant: Dppullupnonotg) -> Self {
96 variant as u8 != 0
97 }
98}
99#[doc = "Field `DPPULLUPNONOTG` reader - DP Pullup in Non-OTG Device Mode"]
100pub type DppullupnonotgR = crate::BitReader<Dppullupnonotg>;
101impl DppullupnonotgR {
102 #[doc = "Get enumerated values variant"]
103 #[inline(always)]
104 pub const fn variant(&self) -> Dppullupnonotg {
105 match self.bits {
106 false => Dppullupnonotg::DisDeviceDpPu,
107 true => Dppullupnonotg::EnDeviceDpPu,
108 }
109 }
110 #[doc = "Disable"]
111 #[inline(always)]
112 pub fn is_dis_device_dp_pu(&self) -> bool {
113 *self == Dppullupnonotg::DisDeviceDpPu
114 }
115 #[doc = "Enabled"]
116 #[inline(always)]
117 pub fn is_en_device_dp_pu(&self) -> bool {
118 *self == Dppullupnonotg::EnDeviceDpPu
119 }
120}
121#[doc = "Field `DPPULLUPNONOTG` writer - DP Pullup in Non-OTG Device Mode"]
122pub type DppullupnonotgW<'a, REG> = crate::BitWriter<'a, REG, Dppullupnonotg>;
123impl<'a, REG> DppullupnonotgW<'a, REG>
124where
125 REG: crate::Writable + crate::RegisterSpec,
126{
127 #[doc = "Disable"]
128 #[inline(always)]
129 pub fn dis_device_dp_pu(self) -> &'a mut crate::W<REG> {
130 self.variant(Dppullupnonotg::DisDeviceDpPu)
131 }
132 #[doc = "Enabled"]
133 #[inline(always)]
134 pub fn en_device_dp_pu(self) -> &'a mut crate::W<REG> {
135 self.variant(Dppullupnonotg::EnDeviceDpPu)
136 }
137}
138impl R {
139 #[doc = "Bit 0 - VBUS Monitoring Source Select"]
140 #[inline(always)]
141 pub fn vbus_source_sel(&self) -> VbusSourceSelR {
142 VbusSourceSelR::new((self.bits & 1) != 0)
143 }
144 #[doc = "Bit 1 - VBUS Session Valid status"]
145 #[inline(always)]
146 pub fn sess_vld(&self) -> SessVldR {
147 SessVldR::new(((self.bits >> 1) & 1) != 0)
148 }
149 #[doc = "Bit 4 - DP Pullup in Non-OTG Device Mode"]
150 #[inline(always)]
151 pub fn dppullupnonotg(&self) -> DppullupnonotgR {
152 DppullupnonotgR::new(((self.bits >> 4) & 1) != 0)
153 }
154}
155#[cfg(feature = "debug")]
156impl core::fmt::Debug for R {
157 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
158 f.debug_struct("CONTROL")
159 .field("vbus_source_sel", &self.vbus_source_sel())
160 .field("sess_vld", &self.sess_vld())
161 .field("dppullupnonotg", &self.dppullupnonotg())
162 .finish()
163 }
164}
165impl W {
166 #[doc = "Bit 0 - VBUS Monitoring Source Select"]
167 #[inline(always)]
168 pub fn vbus_source_sel(&mut self) -> VbusSourceSelW<'_, ControlSpec> {
169 VbusSourceSelW::new(self, 0)
170 }
171 #[doc = "Bit 4 - DP Pullup in Non-OTG Device Mode"]
172 #[inline(always)]
173 pub fn dppullupnonotg(&mut self) -> DppullupnonotgW<'_, ControlSpec> {
174 DppullupnonotgW::new(self, 4)
175 }
176}
177#[doc = "USB OTG Control\n\nYou can [`read`](crate::Reg::read) this register and get [`control::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`control::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
178pub struct ControlSpec;
179impl crate::RegisterSpec for ControlSpec {
180 type Ux = u8;
181}
182#[doc = "`read()` method returns [`control::R`](R) reader structure"]
183impl crate::Readable for ControlSpec {}
184#[doc = "`write(|w| ..)` method takes [`control::W`](W) writer structure"]
185impl crate::Writable for ControlSpec {
186 type Safety = crate::Unsafe;
187}
188#[doc = "`reset()` method sets CONTROL to value 0"]
189impl crate::Resettable for ControlSpec {}