atsamd21g/usb/host/
ctrlb.rs
1#[doc = "Register `CTRLB` reader"]
2pub type R = crate::R<CtrlbSpec>;
3#[doc = "Register `CTRLB` writer"]
4pub type W = crate::W<CtrlbSpec>;
5#[doc = "Field `RESUME` reader - Send USB Resume"]
6pub type ResumeR = crate::BitReader;
7#[doc = "Field `RESUME` writer - Send USB Resume"]
8pub type ResumeW<'a, REG> = crate::BitWriter<'a, REG>;
9#[doc = "Speed Configuration for Host\n\nValue on reset: 0"]
10#[derive(Clone, Copy, Debug, PartialEq, Eq)]
11#[repr(u8)]
12pub enum Spdconfselect {
13 #[doc = "0: Normal mode:the host starts in full-speed mode and performs a high-speed reset to switch to the high speed mode if the downstream peripheral is high-speed capable."]
14 Normal = 0,
15 #[doc = "3: Full-speed:the host remains in full-speed mode whatever is the peripheral speed capability. Relevant in UTMI mode only."]
16 Fs = 3,
17}
18impl From<Spdconfselect> for u8 {
19 #[inline(always)]
20 fn from(variant: Spdconfselect) -> Self {
21 variant as _
22 }
23}
24impl crate::FieldSpec for Spdconfselect {
25 type Ux = u8;
26}
27impl crate::IsEnum for Spdconfselect {}
28#[doc = "Field `SPDCONF` reader - Speed Configuration for Host"]
29pub type SpdconfR = crate::FieldReader<Spdconfselect>;
30impl SpdconfR {
31 #[doc = "Get enumerated values variant"]
32 #[inline(always)]
33 pub const fn variant(&self) -> Option<Spdconfselect> {
34 match self.bits {
35 0 => Some(Spdconfselect::Normal),
36 3 => Some(Spdconfselect::Fs),
37 _ => None,
38 }
39 }
40 #[doc = "Normal mode:the host starts in full-speed mode and performs a high-speed reset to switch to the high speed mode if the downstream peripheral is high-speed capable."]
41 #[inline(always)]
42 pub fn is_normal(&self) -> bool {
43 *self == Spdconfselect::Normal
44 }
45 #[doc = "Full-speed:the host remains in full-speed mode whatever is the peripheral speed capability. Relevant in UTMI mode only."]
46 #[inline(always)]
47 pub fn is_fs(&self) -> bool {
48 *self == Spdconfselect::Fs
49 }
50}
51#[doc = "Field `SPDCONF` writer - Speed Configuration for Host"]
52pub type SpdconfW<'a, REG> = crate::FieldWriter<'a, REG, 2, Spdconfselect>;
53impl<'a, REG> SpdconfW<'a, REG>
54where
55 REG: crate::Writable + crate::RegisterSpec,
56 REG::Ux: From<u8>,
57{
58 #[doc = "Normal mode:the host starts in full-speed mode and performs a high-speed reset to switch to the high speed mode if the downstream peripheral is high-speed capable."]
59 #[inline(always)]
60 pub fn normal(self) -> &'a mut crate::W<REG> {
61 self.variant(Spdconfselect::Normal)
62 }
63 #[doc = "Full-speed:the host remains in full-speed mode whatever is the peripheral speed capability. Relevant in UTMI mode only."]
64 #[inline(always)]
65 pub fn fs(self) -> &'a mut crate::W<REG> {
66 self.variant(Spdconfselect::Fs)
67 }
68}
69#[doc = "Field `TSTJ` reader - Test mode J"]
70pub type TstjR = crate::BitReader;
71#[doc = "Field `TSTJ` writer - Test mode J"]
72pub type TstjW<'a, REG> = crate::BitWriter<'a, REG>;
73#[doc = "Field `TSTK` reader - Test mode K"]
74pub type TstkR = crate::BitReader;
75#[doc = "Field `TSTK` writer - Test mode K"]
76pub type TstkW<'a, REG> = crate::BitWriter<'a, REG>;
77#[doc = "Field `SOFE` reader - Start of Frame Generation Enable"]
78pub type SofeR = crate::BitReader;
79#[doc = "Field `SOFE` writer - Start of Frame Generation Enable"]
80pub type SofeW<'a, REG> = crate::BitWriter<'a, REG>;
81#[doc = "Field `BUSRESET` reader - Send USB Reset"]
82pub type BusresetR = crate::BitReader;
83#[doc = "Field `BUSRESET` writer - Send USB Reset"]
84pub type BusresetW<'a, REG> = crate::BitWriter<'a, REG>;
85#[doc = "Field `VBUSOK` reader - VBUS is OK"]
86pub type VbusokR = crate::BitReader;
87#[doc = "Field `VBUSOK` writer - VBUS is OK"]
88pub type VbusokW<'a, REG> = crate::BitWriter<'a, REG>;
89#[doc = "Field `L1RESUME` reader - Send L1 Resume"]
90pub type L1resumeR = crate::BitReader;
91#[doc = "Field `L1RESUME` writer - Send L1 Resume"]
92pub type L1resumeW<'a, REG> = crate::BitWriter<'a, REG>;
93impl R {
94 #[doc = "Bit 1 - Send USB Resume"]
95 #[inline(always)]
96 pub fn resume(&self) -> ResumeR {
97 ResumeR::new(((self.bits >> 1) & 1) != 0)
98 }
99 #[doc = "Bits 2:3 - Speed Configuration for Host"]
100 #[inline(always)]
101 pub fn spdconf(&self) -> SpdconfR {
102 SpdconfR::new(((self.bits >> 2) & 3) as u8)
103 }
104 #[doc = "Bit 5 - Test mode J"]
105 #[inline(always)]
106 pub fn tstj(&self) -> TstjR {
107 TstjR::new(((self.bits >> 5) & 1) != 0)
108 }
109 #[doc = "Bit 6 - Test mode K"]
110 #[inline(always)]
111 pub fn tstk(&self) -> TstkR {
112 TstkR::new(((self.bits >> 6) & 1) != 0)
113 }
114 #[doc = "Bit 8 - Start of Frame Generation Enable"]
115 #[inline(always)]
116 pub fn sofe(&self) -> SofeR {
117 SofeR::new(((self.bits >> 8) & 1) != 0)
118 }
119 #[doc = "Bit 9 - Send USB Reset"]
120 #[inline(always)]
121 pub fn busreset(&self) -> BusresetR {
122 BusresetR::new(((self.bits >> 9) & 1) != 0)
123 }
124 #[doc = "Bit 10 - VBUS is OK"]
125 #[inline(always)]
126 pub fn vbusok(&self) -> VbusokR {
127 VbusokR::new(((self.bits >> 10) & 1) != 0)
128 }
129 #[doc = "Bit 11 - Send L1 Resume"]
130 #[inline(always)]
131 pub fn l1resume(&self) -> L1resumeR {
132 L1resumeR::new(((self.bits >> 11) & 1) != 0)
133 }
134}
135impl W {
136 #[doc = "Bit 1 - Send USB Resume"]
137 #[inline(always)]
138 #[must_use]
139 pub fn resume(&mut self) -> ResumeW<CtrlbSpec> {
140 ResumeW::new(self, 1)
141 }
142 #[doc = "Bits 2:3 - Speed Configuration for Host"]
143 #[inline(always)]
144 #[must_use]
145 pub fn spdconf(&mut self) -> SpdconfW<CtrlbSpec> {
146 SpdconfW::new(self, 2)
147 }
148 #[doc = "Bit 5 - Test mode J"]
149 #[inline(always)]
150 #[must_use]
151 pub fn tstj(&mut self) -> TstjW<CtrlbSpec> {
152 TstjW::new(self, 5)
153 }
154 #[doc = "Bit 6 - Test mode K"]
155 #[inline(always)]
156 #[must_use]
157 pub fn tstk(&mut self) -> TstkW<CtrlbSpec> {
158 TstkW::new(self, 6)
159 }
160 #[doc = "Bit 8 - Start of Frame Generation Enable"]
161 #[inline(always)]
162 #[must_use]
163 pub fn sofe(&mut self) -> SofeW<CtrlbSpec> {
164 SofeW::new(self, 8)
165 }
166 #[doc = "Bit 9 - Send USB Reset"]
167 #[inline(always)]
168 #[must_use]
169 pub fn busreset(&mut self) -> BusresetW<CtrlbSpec> {
170 BusresetW::new(self, 9)
171 }
172 #[doc = "Bit 10 - VBUS is OK"]
173 #[inline(always)]
174 #[must_use]
175 pub fn vbusok(&mut self) -> VbusokW<CtrlbSpec> {
176 VbusokW::new(self, 10)
177 }
178 #[doc = "Bit 11 - Send L1 Resume"]
179 #[inline(always)]
180 #[must_use]
181 pub fn l1resume(&mut self) -> L1resumeW<CtrlbSpec> {
182 L1resumeW::new(self, 11)
183 }
184}
185#[doc = "HOST Control B\n\nYou can [`read`](crate::Reg::read) this register and get [`ctrlb::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`ctrlb::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
186pub struct CtrlbSpec;
187impl crate::RegisterSpec for CtrlbSpec {
188 type Ux = u16;
189}
190#[doc = "`read()` method returns [`ctrlb::R`](R) reader structure"]
191impl crate::Readable for CtrlbSpec {}
192#[doc = "`write(|w| ..)` method takes [`ctrlb::W`](W) writer structure"]
193impl crate::Writable for CtrlbSpec {
194 type Safety = crate::Unsafe;
195 const ZERO_TO_MODIFY_FIELDS_BITMAP: u16 = 0;
196 const ONE_TO_MODIFY_FIELDS_BITMAP: u16 = 0;
197}
198#[doc = "`reset()` method sets CTRLB to value 0"]
199impl crate::Resettable for CtrlbSpec {
200 const RESET_VALUE: u16 = 0;
201}