atsam3x4e/uotghs/
devctrl.rs1#[doc = "Register `DEVCTRL` reader"]
2pub type R = crate::R<DevctrlSpec>;
3#[doc = "Register `DEVCTRL` writer"]
4pub type W = crate::W<DevctrlSpec>;
5#[doc = "Field `UADD` reader - USB Address"]
6pub type UaddR = crate::FieldReader;
7#[doc = "Field `UADD` writer - USB Address"]
8pub type UaddW<'a, REG> = crate::FieldWriter<'a, REG, 7>;
9#[doc = "Field `ADDEN` reader - Address Enable"]
10pub type AddenR = crate::BitReader;
11#[doc = "Field `ADDEN` writer - Address Enable"]
12pub type AddenW<'a, REG> = crate::BitWriter<'a, REG>;
13#[doc = "Field `DETACH` reader - Detach"]
14pub type DetachR = crate::BitReader;
15#[doc = "Field `DETACH` writer - Detach"]
16pub type DetachW<'a, REG> = crate::BitWriter<'a, REG>;
17#[doc = "Field `RMWKUP` reader - Remote Wake-Up"]
18pub type RmwkupR = crate::BitReader;
19#[doc = "Field `RMWKUP` writer - Remote Wake-Up"]
20pub type RmwkupW<'a, REG> = crate::BitWriter<'a, REG>;
21#[doc = "Mode Configuration\n\nValue on reset: 0"]
22#[derive(Clone, Copy, Debug, PartialEq, Eq)]
23#[repr(u8)]
24pub enum Spdconf {
25 #[doc = "0: The peripheral starts in full-speed mode and performs a high-speed reset to switch to the high-speed mode if the host is high-speed capable."]
26 Normal = 0,
27 #[doc = "1: For a better consumption, if high-speed is not needed."]
28 LowPower = 1,
29 #[doc = "2: Forced high speed."]
30 HighSpeed = 2,
31 #[doc = "3: The peripheral remains in full-speed mode whatever the host speed capability."]
32 ForcedFs = 3,
33}
34impl From<Spdconf> for u8 {
35 #[inline(always)]
36 fn from(variant: Spdconf) -> Self {
37 variant as _
38 }
39}
40impl crate::FieldSpec for Spdconf {
41 type Ux = u8;
42}
43impl crate::IsEnum for Spdconf {}
44#[doc = "Field `SPDCONF` reader - Mode Configuration"]
45pub type SpdconfR = crate::FieldReader<Spdconf>;
46impl SpdconfR {
47 #[doc = "Get enumerated values variant"]
48 #[inline(always)]
49 pub const fn variant(&self) -> Spdconf {
50 match self.bits {
51 0 => Spdconf::Normal,
52 1 => Spdconf::LowPower,
53 2 => Spdconf::HighSpeed,
54 3 => Spdconf::ForcedFs,
55 _ => unreachable!(),
56 }
57 }
58 #[doc = "The peripheral starts in full-speed mode and performs a high-speed reset to switch to the high-speed mode if the host is high-speed capable."]
59 #[inline(always)]
60 pub fn is_normal(&self) -> bool {
61 *self == Spdconf::Normal
62 }
63 #[doc = "For a better consumption, if high-speed is not needed."]
64 #[inline(always)]
65 pub fn is_low_power(&self) -> bool {
66 *self == Spdconf::LowPower
67 }
68 #[doc = "Forced high speed."]
69 #[inline(always)]
70 pub fn is_high_speed(&self) -> bool {
71 *self == Spdconf::HighSpeed
72 }
73 #[doc = "The peripheral remains in full-speed mode whatever the host speed capability."]
74 #[inline(always)]
75 pub fn is_forced_fs(&self) -> bool {
76 *self == Spdconf::ForcedFs
77 }
78}
79#[doc = "Field `SPDCONF` writer - Mode Configuration"]
80pub type SpdconfW<'a, REG> = crate::FieldWriter<'a, REG, 2, Spdconf, crate::Safe>;
81impl<'a, REG> SpdconfW<'a, REG>
82where
83 REG: crate::Writable + crate::RegisterSpec,
84 REG::Ux: From<u8>,
85{
86 #[doc = "The peripheral starts in full-speed mode and performs a high-speed reset to switch to the high-speed mode if the host is high-speed capable."]
87 #[inline(always)]
88 pub fn normal(self) -> &'a mut crate::W<REG> {
89 self.variant(Spdconf::Normal)
90 }
91 #[doc = "For a better consumption, if high-speed is not needed."]
92 #[inline(always)]
93 pub fn low_power(self) -> &'a mut crate::W<REG> {
94 self.variant(Spdconf::LowPower)
95 }
96 #[doc = "Forced high speed."]
97 #[inline(always)]
98 pub fn high_speed(self) -> &'a mut crate::W<REG> {
99 self.variant(Spdconf::HighSpeed)
100 }
101 #[doc = "The peripheral remains in full-speed mode whatever the host speed capability."]
102 #[inline(always)]
103 pub fn forced_fs(self) -> &'a mut crate::W<REG> {
104 self.variant(Spdconf::ForcedFs)
105 }
106}
107#[doc = "Field `LS` reader - Low-Speed Mode Force"]
108pub type LsR = crate::BitReader;
109#[doc = "Field `LS` writer - Low-Speed Mode Force"]
110pub type LsW<'a, REG> = crate::BitWriter<'a, REG>;
111#[doc = "Field `TSTJ` reader - Test mode J"]
112pub type TstjR = crate::BitReader;
113#[doc = "Field `TSTJ` writer - Test mode J"]
114pub type TstjW<'a, REG> = crate::BitWriter<'a, REG>;
115#[doc = "Field `TSTK` reader - Test mode K"]
116pub type TstkR = crate::BitReader;
117#[doc = "Field `TSTK` writer - Test mode K"]
118pub type TstkW<'a, REG> = crate::BitWriter<'a, REG>;
119#[doc = "Field `TSTPCKT` reader - Test packet mode"]
120pub type TstpcktR = crate::BitReader;
121#[doc = "Field `TSTPCKT` writer - Test packet mode"]
122pub type TstpcktW<'a, REG> = crate::BitWriter<'a, REG>;
123#[doc = "Field `OPMODE2` reader - Specific Operational mode"]
124pub type Opmode2R = crate::BitReader;
125#[doc = "Field `OPMODE2` writer - Specific Operational mode"]
126pub type Opmode2W<'a, REG> = crate::BitWriter<'a, REG>;
127impl R {
128 #[doc = "Bits 0:6 - USB Address"]
129 #[inline(always)]
130 pub fn uadd(&self) -> UaddR {
131 UaddR::new((self.bits & 0x7f) as u8)
132 }
133 #[doc = "Bit 7 - Address Enable"]
134 #[inline(always)]
135 pub fn adden(&self) -> AddenR {
136 AddenR::new(((self.bits >> 7) & 1) != 0)
137 }
138 #[doc = "Bit 8 - Detach"]
139 #[inline(always)]
140 pub fn detach(&self) -> DetachR {
141 DetachR::new(((self.bits >> 8) & 1) != 0)
142 }
143 #[doc = "Bit 9 - Remote Wake-Up"]
144 #[inline(always)]
145 pub fn rmwkup(&self) -> RmwkupR {
146 RmwkupR::new(((self.bits >> 9) & 1) != 0)
147 }
148 #[doc = "Bits 10:11 - Mode Configuration"]
149 #[inline(always)]
150 pub fn spdconf(&self) -> SpdconfR {
151 SpdconfR::new(((self.bits >> 10) & 3) as u8)
152 }
153 #[doc = "Bit 12 - Low-Speed Mode Force"]
154 #[inline(always)]
155 pub fn ls(&self) -> LsR {
156 LsR::new(((self.bits >> 12) & 1) != 0)
157 }
158 #[doc = "Bit 13 - Test mode J"]
159 #[inline(always)]
160 pub fn tstj(&self) -> TstjR {
161 TstjR::new(((self.bits >> 13) & 1) != 0)
162 }
163 #[doc = "Bit 14 - Test mode K"]
164 #[inline(always)]
165 pub fn tstk(&self) -> TstkR {
166 TstkR::new(((self.bits >> 14) & 1) != 0)
167 }
168 #[doc = "Bit 15 - Test packet mode"]
169 #[inline(always)]
170 pub fn tstpckt(&self) -> TstpcktR {
171 TstpcktR::new(((self.bits >> 15) & 1) != 0)
172 }
173 #[doc = "Bit 16 - Specific Operational mode"]
174 #[inline(always)]
175 pub fn opmode2(&self) -> Opmode2R {
176 Opmode2R::new(((self.bits >> 16) & 1) != 0)
177 }
178}
179impl W {
180 #[doc = "Bits 0:6 - USB Address"]
181 #[inline(always)]
182 #[must_use]
183 pub fn uadd(&mut self) -> UaddW<DevctrlSpec> {
184 UaddW::new(self, 0)
185 }
186 #[doc = "Bit 7 - Address Enable"]
187 #[inline(always)]
188 #[must_use]
189 pub fn adden(&mut self) -> AddenW<DevctrlSpec> {
190 AddenW::new(self, 7)
191 }
192 #[doc = "Bit 8 - Detach"]
193 #[inline(always)]
194 #[must_use]
195 pub fn detach(&mut self) -> DetachW<DevctrlSpec> {
196 DetachW::new(self, 8)
197 }
198 #[doc = "Bit 9 - Remote Wake-Up"]
199 #[inline(always)]
200 #[must_use]
201 pub fn rmwkup(&mut self) -> RmwkupW<DevctrlSpec> {
202 RmwkupW::new(self, 9)
203 }
204 #[doc = "Bits 10:11 - Mode Configuration"]
205 #[inline(always)]
206 #[must_use]
207 pub fn spdconf(&mut self) -> SpdconfW<DevctrlSpec> {
208 SpdconfW::new(self, 10)
209 }
210 #[doc = "Bit 12 - Low-Speed Mode Force"]
211 #[inline(always)]
212 #[must_use]
213 pub fn ls(&mut self) -> LsW<DevctrlSpec> {
214 LsW::new(self, 12)
215 }
216 #[doc = "Bit 13 - Test mode J"]
217 #[inline(always)]
218 #[must_use]
219 pub fn tstj(&mut self) -> TstjW<DevctrlSpec> {
220 TstjW::new(self, 13)
221 }
222 #[doc = "Bit 14 - Test mode K"]
223 #[inline(always)]
224 #[must_use]
225 pub fn tstk(&mut self) -> TstkW<DevctrlSpec> {
226 TstkW::new(self, 14)
227 }
228 #[doc = "Bit 15 - Test packet mode"]
229 #[inline(always)]
230 #[must_use]
231 pub fn tstpckt(&mut self) -> TstpcktW<DevctrlSpec> {
232 TstpcktW::new(self, 15)
233 }
234 #[doc = "Bit 16 - Specific Operational mode"]
235 #[inline(always)]
236 #[must_use]
237 pub fn opmode2(&mut self) -> Opmode2W<DevctrlSpec> {
238 Opmode2W::new(self, 16)
239 }
240}
241#[doc = "Device General Control Register\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`devctrl::R`](R). You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`devctrl::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
242pub struct DevctrlSpec;
243impl crate::RegisterSpec for DevctrlSpec {
244 type Ux = u32;
245}
246#[doc = "`read()` method returns [`devctrl::R`](R) reader structure"]
247impl crate::Readable for DevctrlSpec {}
248#[doc = "`write(|w| ..)` method takes [`devctrl::W`](W) writer structure"]
249impl crate::Writable for DevctrlSpec {
250 type Safety = crate::Unsafe;
251 const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
252 const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
253}
254#[doc = "`reset()` method sets DEVCTRL to value 0x0100"]
255impl crate::Resettable for DevctrlSpec {
256 const RESET_VALUE: u32 = 0x0100;
257}