atsame70q20/usbhs/
usbhs_hstctrl.rs1#[doc = "Register `USBHS_HSTCTRL` reader"]
2pub struct R(crate::R<USBHS_HSTCTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<USBHS_HSTCTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<USBHS_HSTCTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<USBHS_HSTCTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `USBHS_HSTCTRL` writer"]
17pub struct W(crate::W<USBHS_HSTCTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<USBHS_HSTCTRL_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<USBHS_HSTCTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<USBHS_HSTCTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `SOFE` reader - Start of Frame Generation Enable"]
38pub struct SOFE_R(crate::FieldReader<bool, bool>);
39impl SOFE_R {
40    #[inline(always)]
41    pub(crate) fn new(bits: bool) -> Self {
42        SOFE_R(crate::FieldReader::new(bits))
43    }
44}
45impl core::ops::Deref for SOFE_R {
46    type Target = crate::FieldReader<bool, bool>;
47    #[inline(always)]
48    fn deref(&self) -> &Self::Target {
49        &self.0
50    }
51}
52#[doc = "Field `SOFE` writer - Start of Frame Generation Enable"]
53pub struct SOFE_W<'a> {
54    w: &'a mut W,
55}
56impl<'a> SOFE_W<'a> {
57    #[doc = r"Sets the field bit"]
58    #[inline(always)]
59    pub fn set_bit(self) -> &'a mut W {
60        self.bit(true)
61    }
62    #[doc = r"Clears the field bit"]
63    #[inline(always)]
64    pub fn clear_bit(self) -> &'a mut W {
65        self.bit(false)
66    }
67    #[doc = r"Writes raw bits to the field"]
68    #[inline(always)]
69    pub fn bit(self, value: bool) -> &'a mut W {
70        self.w.bits = (self.w.bits & !(0x01 << 8)) | ((value as u32 & 0x01) << 8);
71        self.w
72    }
73}
74#[doc = "Field `RESET` reader - Send USB Reset"]
75pub struct RESET_R(crate::FieldReader<bool, bool>);
76impl RESET_R {
77    #[inline(always)]
78    pub(crate) fn new(bits: bool) -> Self {
79        RESET_R(crate::FieldReader::new(bits))
80    }
81}
82impl core::ops::Deref for RESET_R {
83    type Target = crate::FieldReader<bool, bool>;
84    #[inline(always)]
85    fn deref(&self) -> &Self::Target {
86        &self.0
87    }
88}
89#[doc = "Field `RESET` writer - Send USB Reset"]
90pub struct RESET_W<'a> {
91    w: &'a mut W,
92}
93impl<'a> RESET_W<'a> {
94    #[doc = r"Sets the field bit"]
95    #[inline(always)]
96    pub fn set_bit(self) -> &'a mut W {
97        self.bit(true)
98    }
99    #[doc = r"Clears the field bit"]
100    #[inline(always)]
101    pub fn clear_bit(self) -> &'a mut W {
102        self.bit(false)
103    }
104    #[doc = r"Writes raw bits to the field"]
105    #[inline(always)]
106    pub fn bit(self, value: bool) -> &'a mut W {
107        self.w.bits = (self.w.bits & !(0x01 << 9)) | ((value as u32 & 0x01) << 9);
108        self.w
109    }
110}
111#[doc = "Field `RESUME` reader - Send USB Resume"]
112pub struct RESUME_R(crate::FieldReader<bool, bool>);
113impl RESUME_R {
114    #[inline(always)]
115    pub(crate) fn new(bits: bool) -> Self {
116        RESUME_R(crate::FieldReader::new(bits))
117    }
118}
119impl core::ops::Deref for RESUME_R {
120    type Target = crate::FieldReader<bool, bool>;
121    #[inline(always)]
122    fn deref(&self) -> &Self::Target {
123        &self.0
124    }
125}
126#[doc = "Field `RESUME` writer - Send USB Resume"]
127pub struct RESUME_W<'a> {
128    w: &'a mut W,
129}
130impl<'a> RESUME_W<'a> {
131    #[doc = r"Sets the field bit"]
132    #[inline(always)]
133    pub fn set_bit(self) -> &'a mut W {
134        self.bit(true)
135    }
136    #[doc = r"Clears the field bit"]
137    #[inline(always)]
138    pub fn clear_bit(self) -> &'a mut W {
139        self.bit(false)
140    }
141    #[doc = r"Writes raw bits to the field"]
142    #[inline(always)]
143    pub fn bit(self, value: bool) -> &'a mut W {
144        self.w.bits = (self.w.bits & !(0x01 << 10)) | ((value as u32 & 0x01) << 10);
145        self.w
146    }
147}
148#[doc = "Mode Configuration\n\nValue on reset: 0"]
149#[derive(Clone, Copy, Debug, PartialEq)]
150#[repr(u8)]
151pub enum SPDCONF_A {
152    #[doc = "0: The host starts in Full-speed mode and performs a high-speed reset to switch to High-speed mode if the downstream peripheral is high-speed capable."]
153    NORMAL = 0,
154    #[doc = "1: For a better consumption, if high speed is not needed."]
155    LOW_POWER = 1,
156}
157impl From<SPDCONF_A> for u8 {
158    #[inline(always)]
159    fn from(variant: SPDCONF_A) -> Self {
160        variant as _
161    }
162}
163#[doc = "Field `SPDCONF` reader - Mode Configuration"]
164pub struct SPDCONF_R(crate::FieldReader<u8, SPDCONF_A>);
165impl SPDCONF_R {
166    #[inline(always)]
167    pub(crate) fn new(bits: u8) -> Self {
168        SPDCONF_R(crate::FieldReader::new(bits))
169    }
170    #[doc = r"Get enumerated values variant"]
171    #[inline(always)]
172    pub fn variant(&self) -> Option<SPDCONF_A> {
173        match self.bits {
174            0 => Some(SPDCONF_A::NORMAL),
175            1 => Some(SPDCONF_A::LOW_POWER),
176            _ => None,
177        }
178    }
179    #[doc = "Checks if the value of the field is `NORMAL`"]
180    #[inline(always)]
181    pub fn is_normal(&self) -> bool {
182        **self == SPDCONF_A::NORMAL
183    }
184    #[doc = "Checks if the value of the field is `LOW_POWER`"]
185    #[inline(always)]
186    pub fn is_low_power(&self) -> bool {
187        **self == SPDCONF_A::LOW_POWER
188    }
189}
190impl core::ops::Deref for SPDCONF_R {
191    type Target = crate::FieldReader<u8, SPDCONF_A>;
192    #[inline(always)]
193    fn deref(&self) -> &Self::Target {
194        &self.0
195    }
196}
197#[doc = "Field `SPDCONF` writer - Mode Configuration"]
198pub struct SPDCONF_W<'a> {
199    w: &'a mut W,
200}
201impl<'a> SPDCONF_W<'a> {
202    #[doc = r"Writes `variant` to the field"]
203    #[inline(always)]
204    pub fn variant(self, variant: SPDCONF_A) -> &'a mut W {
205        unsafe { self.bits(variant.into()) }
206    }
207    #[doc = "The host starts in Full-speed mode and performs a high-speed reset to switch to High-speed mode if the downstream peripheral is high-speed capable."]
208    #[inline(always)]
209    pub fn normal(self) -> &'a mut W {
210        self.variant(SPDCONF_A::NORMAL)
211    }
212    #[doc = "For a better consumption, if high speed is not needed."]
213    #[inline(always)]
214    pub fn low_power(self) -> &'a mut W {
215        self.variant(SPDCONF_A::LOW_POWER)
216    }
217    #[doc = r"Writes raw bits to the field"]
218    #[inline(always)]
219    pub unsafe fn bits(self, value: u8) -> &'a mut W {
220        self.w.bits = (self.w.bits & !(0x03 << 12)) | ((value as u32 & 0x03) << 12);
221        self.w
222    }
223}
224impl R {
225    #[doc = "Bit 8 - Start of Frame Generation Enable"]
226    #[inline(always)]
227    pub fn sofe(&self) -> SOFE_R {
228        SOFE_R::new(((self.bits >> 8) & 0x01) != 0)
229    }
230    #[doc = "Bit 9 - Send USB Reset"]
231    #[inline(always)]
232    pub fn reset(&self) -> RESET_R {
233        RESET_R::new(((self.bits >> 9) & 0x01) != 0)
234    }
235    #[doc = "Bit 10 - Send USB Resume"]
236    #[inline(always)]
237    pub fn resume(&self) -> RESUME_R {
238        RESUME_R::new(((self.bits >> 10) & 0x01) != 0)
239    }
240    #[doc = "Bits 12:13 - Mode Configuration"]
241    #[inline(always)]
242    pub fn spdconf(&self) -> SPDCONF_R {
243        SPDCONF_R::new(((self.bits >> 12) & 0x03) as u8)
244    }
245}
246impl W {
247    #[doc = "Bit 8 - Start of Frame Generation Enable"]
248    #[inline(always)]
249    pub fn sofe(&mut self) -> SOFE_W {
250        SOFE_W { w: self }
251    }
252    #[doc = "Bit 9 - Send USB Reset"]
253    #[inline(always)]
254    pub fn reset(&mut self) -> RESET_W {
255        RESET_W { w: self }
256    }
257    #[doc = "Bit 10 - Send USB Resume"]
258    #[inline(always)]
259    pub fn resume(&mut self) -> RESUME_W {
260        RESUME_W { w: self }
261    }
262    #[doc = "Bits 12:13 - Mode Configuration"]
263    #[inline(always)]
264    pub fn spdconf(&mut self) -> SPDCONF_W {
265        SPDCONF_W { w: self }
266    }
267    #[doc = "Writes raw bits to the register."]
268    #[inline(always)]
269    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
270        self.0.bits(bits);
271        self
272    }
273}
274#[doc = "Host General Control Register\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [usbhs_hstctrl](index.html) module"]
275pub struct USBHS_HSTCTRL_SPEC;
276impl crate::RegisterSpec for USBHS_HSTCTRL_SPEC {
277    type Ux = u32;
278}
279#[doc = "`read()` method returns [usbhs_hstctrl::R](R) reader structure"]
280impl crate::Readable for USBHS_HSTCTRL_SPEC {
281    type Reader = R;
282}
283#[doc = "`write(|w| ..)` method takes [usbhs_hstctrl::W](W) writer structure"]
284impl crate::Writable for USBHS_HSTCTRL_SPEC {
285    type Writer = W;
286}
287#[doc = "`reset()` method sets USBHS_HSTCTRL to value 0"]
288impl crate::Resettable for USBHS_HSTCTRL_SPEC {
289    #[inline(always)]
290    fn reset_value() -> Self::Ux {
291        0
292    }
293}