atsaml21e18a/usb/host/
ctrlb.rs

1#[doc = "Register `CTRLB` reader"]
2pub struct R(crate::R<CTRLB_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CTRLB_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CTRLB_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CTRLB_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CTRLB` writer"]
17pub struct W(crate::W<CTRLB_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CTRLB_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<CTRLB_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CTRLB_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `RESUME` reader - Send USB Resume"]
38pub type RESUME_R = crate::BitReader<bool>;
39#[doc = "Field `RESUME` writer - Send USB Resume"]
40pub type RESUME_W<'a, const O: u8> = crate::BitWriter<'a, u16, CTRLB_SPEC, bool, O>;
41#[doc = "Field `SPDCONF` reader - Speed Configuration for Host"]
42pub type SPDCONF_R = crate::FieldReader<u8, SPDCONFSELECT_A>;
43#[doc = "Speed Configuration for Host\n\nValue on reset: 0"]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45#[repr(u8)]
46pub enum SPDCONFSELECT_A {
47    #[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."]
48    NORMAL = 0,
49    #[doc = "3: Full-speed: the host remains in full-speed mode whatever is the peripheral speed capability. Relevant in UTMI mode only."]
50    FS = 3,
51}
52impl From<SPDCONFSELECT_A> for u8 {
53    #[inline(always)]
54    fn from(variant: SPDCONFSELECT_A) -> Self {
55        variant as _
56    }
57}
58impl SPDCONF_R {
59    #[doc = "Get enumerated values variant"]
60    #[inline(always)]
61    pub fn variant(&self) -> Option<SPDCONFSELECT_A> {
62        match self.bits {
63            0 => Some(SPDCONFSELECT_A::NORMAL),
64            3 => Some(SPDCONFSELECT_A::FS),
65            _ => None,
66        }
67    }
68    #[doc = "Checks if the value of the field is `NORMAL`"]
69    #[inline(always)]
70    pub fn is_normal(&self) -> bool {
71        *self == SPDCONFSELECT_A::NORMAL
72    }
73    #[doc = "Checks if the value of the field is `FS`"]
74    #[inline(always)]
75    pub fn is_fs(&self) -> bool {
76        *self == SPDCONFSELECT_A::FS
77    }
78}
79#[doc = "Field `SPDCONF` writer - Speed Configuration for Host"]
80pub type SPDCONF_W<'a, const O: u8> =
81    crate::FieldWriter<'a, u16, CTRLB_SPEC, u8, SPDCONFSELECT_A, 2, O>;
82impl<'a, const O: u8> SPDCONF_W<'a, O> {
83    #[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."]
84    #[inline(always)]
85    pub fn normal(self) -> &'a mut W {
86        self.variant(SPDCONFSELECT_A::NORMAL)
87    }
88    #[doc = "Full-speed: the host remains in full-speed mode whatever is the peripheral speed capability. Relevant in UTMI mode only."]
89    #[inline(always)]
90    pub fn fs(self) -> &'a mut W {
91        self.variant(SPDCONFSELECT_A::FS)
92    }
93}
94#[doc = "Field `AUTORESUME` reader - Auto Resume Enable"]
95pub type AUTORESUME_R = crate::BitReader<bool>;
96#[doc = "Field `AUTORESUME` writer - Auto Resume Enable"]
97pub type AUTORESUME_W<'a, const O: u8> = crate::BitWriter<'a, u16, CTRLB_SPEC, bool, O>;
98#[doc = "Field `TSTJ` reader - Test mode J"]
99pub type TSTJ_R = crate::BitReader<bool>;
100#[doc = "Field `TSTJ` writer - Test mode J"]
101pub type TSTJ_W<'a, const O: u8> = crate::BitWriter<'a, u16, CTRLB_SPEC, bool, O>;
102#[doc = "Field `TSTK` reader - Test mode K"]
103pub type TSTK_R = crate::BitReader<bool>;
104#[doc = "Field `TSTK` writer - Test mode K"]
105pub type TSTK_W<'a, const O: u8> = crate::BitWriter<'a, u16, CTRLB_SPEC, bool, O>;
106#[doc = "Field `SOFE` reader - Start of Frame Generation Enable"]
107pub type SOFE_R = crate::BitReader<bool>;
108#[doc = "Field `SOFE` writer - Start of Frame Generation Enable"]
109pub type SOFE_W<'a, const O: u8> = crate::BitWriter<'a, u16, CTRLB_SPEC, bool, O>;
110#[doc = "Field `BUSRESET` reader - Send USB Reset"]
111pub type BUSRESET_R = crate::BitReader<bool>;
112#[doc = "Field `BUSRESET` writer - Send USB Reset"]
113pub type BUSRESET_W<'a, const O: u8> = crate::BitWriter<'a, u16, CTRLB_SPEC, bool, O>;
114#[doc = "Field `VBUSOK` reader - VBUS is OK"]
115pub type VBUSOK_R = crate::BitReader<bool>;
116#[doc = "Field `VBUSOK` writer - VBUS is OK"]
117pub type VBUSOK_W<'a, const O: u8> = crate::BitWriter<'a, u16, CTRLB_SPEC, bool, O>;
118#[doc = "Field `L1RESUME` reader - Send L1 Resume"]
119pub type L1RESUME_R = crate::BitReader<bool>;
120#[doc = "Field `L1RESUME` writer - Send L1 Resume"]
121pub type L1RESUME_W<'a, const O: u8> = crate::BitWriter<'a, u16, CTRLB_SPEC, bool, O>;
122impl R {
123    #[doc = "Bit 1 - Send USB Resume"]
124    #[inline(always)]
125    pub fn resume(&self) -> RESUME_R {
126        RESUME_R::new(((self.bits >> 1) & 1) != 0)
127    }
128    #[doc = "Bits 2:3 - Speed Configuration for Host"]
129    #[inline(always)]
130    pub fn spdconf(&self) -> SPDCONF_R {
131        SPDCONF_R::new(((self.bits >> 2) & 3) as u8)
132    }
133    #[doc = "Bit 4 - Auto Resume Enable"]
134    #[inline(always)]
135    pub fn autoresume(&self) -> AUTORESUME_R {
136        AUTORESUME_R::new(((self.bits >> 4) & 1) != 0)
137    }
138    #[doc = "Bit 5 - Test mode J"]
139    #[inline(always)]
140    pub fn tstj(&self) -> TSTJ_R {
141        TSTJ_R::new(((self.bits >> 5) & 1) != 0)
142    }
143    #[doc = "Bit 6 - Test mode K"]
144    #[inline(always)]
145    pub fn tstk(&self) -> TSTK_R {
146        TSTK_R::new(((self.bits >> 6) & 1) != 0)
147    }
148    #[doc = "Bit 8 - Start of Frame Generation Enable"]
149    #[inline(always)]
150    pub fn sofe(&self) -> SOFE_R {
151        SOFE_R::new(((self.bits >> 8) & 1) != 0)
152    }
153    #[doc = "Bit 9 - Send USB Reset"]
154    #[inline(always)]
155    pub fn busreset(&self) -> BUSRESET_R {
156        BUSRESET_R::new(((self.bits >> 9) & 1) != 0)
157    }
158    #[doc = "Bit 10 - VBUS is OK"]
159    #[inline(always)]
160    pub fn vbusok(&self) -> VBUSOK_R {
161        VBUSOK_R::new(((self.bits >> 10) & 1) != 0)
162    }
163    #[doc = "Bit 11 - Send L1 Resume"]
164    #[inline(always)]
165    pub fn l1resume(&self) -> L1RESUME_R {
166        L1RESUME_R::new(((self.bits >> 11) & 1) != 0)
167    }
168}
169impl W {
170    #[doc = "Bit 1 - Send USB Resume"]
171    #[inline(always)]
172    #[must_use]
173    pub fn resume(&mut self) -> RESUME_W<1> {
174        RESUME_W::new(self)
175    }
176    #[doc = "Bits 2:3 - Speed Configuration for Host"]
177    #[inline(always)]
178    #[must_use]
179    pub fn spdconf(&mut self) -> SPDCONF_W<2> {
180        SPDCONF_W::new(self)
181    }
182    #[doc = "Bit 4 - Auto Resume Enable"]
183    #[inline(always)]
184    #[must_use]
185    pub fn autoresume(&mut self) -> AUTORESUME_W<4> {
186        AUTORESUME_W::new(self)
187    }
188    #[doc = "Bit 5 - Test mode J"]
189    #[inline(always)]
190    #[must_use]
191    pub fn tstj(&mut self) -> TSTJ_W<5> {
192        TSTJ_W::new(self)
193    }
194    #[doc = "Bit 6 - Test mode K"]
195    #[inline(always)]
196    #[must_use]
197    pub fn tstk(&mut self) -> TSTK_W<6> {
198        TSTK_W::new(self)
199    }
200    #[doc = "Bit 8 - Start of Frame Generation Enable"]
201    #[inline(always)]
202    #[must_use]
203    pub fn sofe(&mut self) -> SOFE_W<8> {
204        SOFE_W::new(self)
205    }
206    #[doc = "Bit 9 - Send USB Reset"]
207    #[inline(always)]
208    #[must_use]
209    pub fn busreset(&mut self) -> BUSRESET_W<9> {
210        BUSRESET_W::new(self)
211    }
212    #[doc = "Bit 10 - VBUS is OK"]
213    #[inline(always)]
214    #[must_use]
215    pub fn vbusok(&mut self) -> VBUSOK_W<10> {
216        VBUSOK_W::new(self)
217    }
218    #[doc = "Bit 11 - Send L1 Resume"]
219    #[inline(always)]
220    #[must_use]
221    pub fn l1resume(&mut self) -> L1RESUME_W<11> {
222        L1RESUME_W::new(self)
223    }
224    #[doc = "Writes raw bits to the register."]
225    #[inline(always)]
226    pub unsafe fn bits(&mut self, bits: u16) -> &mut Self {
227        self.0.bits(bits);
228        self
229    }
230}
231#[doc = "HOST Control B\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 [ctrlb](index.html) module"]
232pub struct CTRLB_SPEC;
233impl crate::RegisterSpec for CTRLB_SPEC {
234    type Ux = u16;
235}
236#[doc = "`read()` method returns [ctrlb::R](R) reader structure"]
237impl crate::Readable for CTRLB_SPEC {
238    type Reader = R;
239}
240#[doc = "`write(|w| ..)` method takes [ctrlb::W](W) writer structure"]
241impl crate::Writable for CTRLB_SPEC {
242    type Writer = W;
243    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
244    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
245}
246#[doc = "`reset()` method sets CTRLB to value 0"]
247impl crate::Resettable for CTRLB_SPEC {
248    const RESET_VALUE: Self::Ux = 0;
249}