atsamd51p/usb/device/
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 `DETACH` reader - Detach"]
6pub type DetachR = crate::BitReader;
7#[doc = "Field `DETACH` writer - Detach"]
8pub type DetachW<'a, REG> = crate::BitWriter<'a, REG>;
9#[doc = "Field `UPRSM` reader - Upstream Resume"]
10pub type UprsmR = crate::BitReader;
11#[doc = "Field `UPRSM` writer - Upstream Resume"]
12pub type UprsmW<'a, REG> = crate::BitWriter<'a, REG>;
13#[doc = "Speed Configuration\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq, Eq)]
15#[repr(u8)]
16pub enum Spdconfselect {
17    #[doc = "0: FS : Full Speed"]
18    Fs = 0,
19    #[doc = "1: LS : Low Speed"]
20    Ls = 1,
21}
22impl From<Spdconfselect> for u8 {
23    #[inline(always)]
24    fn from(variant: Spdconfselect) -> Self {
25        variant as _
26    }
27}
28impl crate::FieldSpec for Spdconfselect {
29    type Ux = u8;
30}
31impl crate::IsEnum for Spdconfselect {}
32#[doc = "Field `SPDCONF` reader - Speed Configuration"]
33pub type SpdconfR = crate::FieldReader<Spdconfselect>;
34impl SpdconfR {
35    #[doc = "Get enumerated values variant"]
36    #[inline(always)]
37    pub const fn variant(&self) -> Option<Spdconfselect> {
38        match self.bits {
39            0 => Some(Spdconfselect::Fs),
40            1 => Some(Spdconfselect::Ls),
41            _ => None,
42        }
43    }
44    #[doc = "FS : Full Speed"]
45    #[inline(always)]
46    pub fn is_fs(&self) -> bool {
47        *self == Spdconfselect::Fs
48    }
49    #[doc = "LS : Low Speed"]
50    #[inline(always)]
51    pub fn is_ls(&self) -> bool {
52        *self == Spdconfselect::Ls
53    }
54}
55#[doc = "Field `SPDCONF` writer - Speed Configuration"]
56pub type SpdconfW<'a, REG> = crate::FieldWriter<'a, REG, 2, Spdconfselect>;
57impl<'a, REG> SpdconfW<'a, REG>
58where
59    REG: crate::Writable + crate::RegisterSpec,
60    REG::Ux: From<u8>,
61{
62    #[doc = "FS : Full Speed"]
63    #[inline(always)]
64    pub fn fs(self) -> &'a mut crate::W<REG> {
65        self.variant(Spdconfselect::Fs)
66    }
67    #[doc = "LS : Low Speed"]
68    #[inline(always)]
69    pub fn ls(self) -> &'a mut crate::W<REG> {
70        self.variant(Spdconfselect::Ls)
71    }
72}
73#[doc = "Field `NREPLY` reader - No Reply"]
74pub type NreplyR = crate::BitReader;
75#[doc = "Field `NREPLY` writer - No Reply"]
76pub type NreplyW<'a, REG> = crate::BitWriter<'a, REG>;
77#[doc = "Field `GNAK` reader - Global NAK"]
78pub type GnakR = crate::BitReader;
79#[doc = "Field `GNAK` writer - Global NAK"]
80pub type GnakW<'a, REG> = crate::BitWriter<'a, REG>;
81#[doc = "Link Power Management Handshake\n\nValue on reset: 0"]
82#[derive(Clone, Copy, Debug, PartialEq, Eq)]
83#[repr(u8)]
84pub enum Lpmhdskselect {
85    #[doc = "0: No handshake. LPM is not supported"]
86    No = 0,
87    #[doc = "1: ACK"]
88    Ack = 1,
89    #[doc = "2: NYET"]
90    Nyet = 2,
91}
92impl From<Lpmhdskselect> for u8 {
93    #[inline(always)]
94    fn from(variant: Lpmhdskselect) -> Self {
95        variant as _
96    }
97}
98impl crate::FieldSpec for Lpmhdskselect {
99    type Ux = u8;
100}
101impl crate::IsEnum for Lpmhdskselect {}
102#[doc = "Field `LPMHDSK` reader - Link Power Management Handshake"]
103pub type LpmhdskR = crate::FieldReader<Lpmhdskselect>;
104impl LpmhdskR {
105    #[doc = "Get enumerated values variant"]
106    #[inline(always)]
107    pub const fn variant(&self) -> Option<Lpmhdskselect> {
108        match self.bits {
109            0 => Some(Lpmhdskselect::No),
110            1 => Some(Lpmhdskselect::Ack),
111            2 => Some(Lpmhdskselect::Nyet),
112            _ => None,
113        }
114    }
115    #[doc = "No handshake. LPM is not supported"]
116    #[inline(always)]
117    pub fn is_no(&self) -> bool {
118        *self == Lpmhdskselect::No
119    }
120    #[doc = "ACK"]
121    #[inline(always)]
122    pub fn is_ack(&self) -> bool {
123        *self == Lpmhdskselect::Ack
124    }
125    #[doc = "NYET"]
126    #[inline(always)]
127    pub fn is_nyet(&self) -> bool {
128        *self == Lpmhdskselect::Nyet
129    }
130}
131#[doc = "Field `LPMHDSK` writer - Link Power Management Handshake"]
132pub type LpmhdskW<'a, REG> = crate::FieldWriter<'a, REG, 2, Lpmhdskselect>;
133impl<'a, REG> LpmhdskW<'a, REG>
134where
135    REG: crate::Writable + crate::RegisterSpec,
136    REG::Ux: From<u8>,
137{
138    #[doc = "No handshake. LPM is not supported"]
139    #[inline(always)]
140    pub fn no(self) -> &'a mut crate::W<REG> {
141        self.variant(Lpmhdskselect::No)
142    }
143    #[doc = "ACK"]
144    #[inline(always)]
145    pub fn ack(self) -> &'a mut crate::W<REG> {
146        self.variant(Lpmhdskselect::Ack)
147    }
148    #[doc = "NYET"]
149    #[inline(always)]
150    pub fn nyet(self) -> &'a mut crate::W<REG> {
151        self.variant(Lpmhdskselect::Nyet)
152    }
153}
154impl R {
155    #[doc = "Bit 0 - Detach"]
156    #[inline(always)]
157    pub fn detach(&self) -> DetachR {
158        DetachR::new((self.bits & 1) != 0)
159    }
160    #[doc = "Bit 1 - Upstream Resume"]
161    #[inline(always)]
162    pub fn uprsm(&self) -> UprsmR {
163        UprsmR::new(((self.bits >> 1) & 1) != 0)
164    }
165    #[doc = "Bits 2:3 - Speed Configuration"]
166    #[inline(always)]
167    pub fn spdconf(&self) -> SpdconfR {
168        SpdconfR::new(((self.bits >> 2) & 3) as u8)
169    }
170    #[doc = "Bit 4 - No Reply"]
171    #[inline(always)]
172    pub fn nreply(&self) -> NreplyR {
173        NreplyR::new(((self.bits >> 4) & 1) != 0)
174    }
175    #[doc = "Bit 9 - Global NAK"]
176    #[inline(always)]
177    pub fn gnak(&self) -> GnakR {
178        GnakR::new(((self.bits >> 9) & 1) != 0)
179    }
180    #[doc = "Bits 10:11 - Link Power Management Handshake"]
181    #[inline(always)]
182    pub fn lpmhdsk(&self) -> LpmhdskR {
183        LpmhdskR::new(((self.bits >> 10) & 3) as u8)
184    }
185}
186impl W {
187    #[doc = "Bit 0 - Detach"]
188    #[inline(always)]
189    #[must_use]
190    pub fn detach(&mut self) -> DetachW<CtrlbSpec> {
191        DetachW::new(self, 0)
192    }
193    #[doc = "Bit 1 - Upstream Resume"]
194    #[inline(always)]
195    #[must_use]
196    pub fn uprsm(&mut self) -> UprsmW<CtrlbSpec> {
197        UprsmW::new(self, 1)
198    }
199    #[doc = "Bits 2:3 - Speed Configuration"]
200    #[inline(always)]
201    #[must_use]
202    pub fn spdconf(&mut self) -> SpdconfW<CtrlbSpec> {
203        SpdconfW::new(self, 2)
204    }
205    #[doc = "Bit 4 - No Reply"]
206    #[inline(always)]
207    #[must_use]
208    pub fn nreply(&mut self) -> NreplyW<CtrlbSpec> {
209        NreplyW::new(self, 4)
210    }
211    #[doc = "Bit 9 - Global NAK"]
212    #[inline(always)]
213    #[must_use]
214    pub fn gnak(&mut self) -> GnakW<CtrlbSpec> {
215        GnakW::new(self, 9)
216    }
217    #[doc = "Bits 10:11 - Link Power Management Handshake"]
218    #[inline(always)]
219    #[must_use]
220    pub fn lpmhdsk(&mut self) -> LpmhdskW<CtrlbSpec> {
221        LpmhdskW::new(self, 10)
222    }
223}
224#[doc = "DEVICE 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)."]
225pub struct CtrlbSpec;
226impl crate::RegisterSpec for CtrlbSpec {
227    type Ux = u16;
228}
229#[doc = "`read()` method returns [`ctrlb::R`](R) reader structure"]
230impl crate::Readable for CtrlbSpec {}
231#[doc = "`write(|w| ..)` method takes [`ctrlb::W`](W) writer structure"]
232impl crate::Writable for CtrlbSpec {
233    type Safety = crate::Unsafe;
234    const ZERO_TO_MODIFY_FIELDS_BITMAP: u16 = 0;
235    const ONE_TO_MODIFY_FIELDS_BITMAP: u16 = 0;
236}
237#[doc = "`reset()` method sets CTRLB to value 0x01"]
238impl crate::Resettable for CtrlbSpec {
239    const RESET_VALUE: u16 = 0x01;
240}