atsamd51g/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: Low and Full Speed capable"]
14    Normal = 0,
15}
16impl From<Spdconfselect> for u8 {
17    #[inline(always)]
18    fn from(variant: Spdconfselect) -> Self {
19        variant as _
20    }
21}
22impl crate::FieldSpec for Spdconfselect {
23    type Ux = u8;
24}
25impl crate::IsEnum for Spdconfselect {}
26#[doc = "Field `SPDCONF` reader - Speed Configuration for Host"]
27pub type SpdconfR = crate::FieldReader<Spdconfselect>;
28impl SpdconfR {
29    #[doc = "Get enumerated values variant"]
30    #[inline(always)]
31    pub const fn variant(&self) -> Option<Spdconfselect> {
32        match self.bits {
33            0 => Some(Spdconfselect::Normal),
34            _ => None,
35        }
36    }
37    #[doc = "Low and Full Speed capable"]
38    #[inline(always)]
39    pub fn is_normal(&self) -> bool {
40        *self == Spdconfselect::Normal
41    }
42}
43#[doc = "Field `SPDCONF` writer - Speed Configuration for Host"]
44pub type SpdconfW<'a, REG> = crate::FieldWriter<'a, REG, 2, Spdconfselect>;
45impl<'a, REG> SpdconfW<'a, REG>
46where
47    REG: crate::Writable + crate::RegisterSpec,
48    REG::Ux: From<u8>,
49{
50    #[doc = "Low and Full Speed capable"]
51    #[inline(always)]
52    pub fn normal(self) -> &'a mut crate::W<REG> {
53        self.variant(Spdconfselect::Normal)
54    }
55}
56#[doc = "Field `AUTORESUME` reader - Auto Resume Enable"]
57pub type AutoresumeR = crate::BitReader;
58#[doc = "Field `AUTORESUME` writer - Auto Resume Enable"]
59pub type AutoresumeW<'a, REG> = crate::BitWriter<'a, REG>;
60#[doc = "Field `SOFE` reader - Start of Frame Generation Enable"]
61pub type SofeR = crate::BitReader;
62#[doc = "Field `SOFE` writer - Start of Frame Generation Enable"]
63pub type SofeW<'a, REG> = crate::BitWriter<'a, REG>;
64#[doc = "Field `BUSRESET` reader - Send USB Reset"]
65pub type BusresetR = crate::BitReader;
66#[doc = "Field `BUSRESET` writer - Send USB Reset"]
67pub type BusresetW<'a, REG> = crate::BitWriter<'a, REG>;
68#[doc = "Field `VBUSOK` reader - VBUS is OK"]
69pub type VbusokR = crate::BitReader;
70#[doc = "Field `VBUSOK` writer - VBUS is OK"]
71pub type VbusokW<'a, REG> = crate::BitWriter<'a, REG>;
72#[doc = "Field `L1RESUME` reader - Send L1 Resume"]
73pub type L1resumeR = crate::BitReader;
74#[doc = "Field `L1RESUME` writer - Send L1 Resume"]
75pub type L1resumeW<'a, REG> = crate::BitWriter<'a, REG>;
76impl R {
77    #[doc = "Bit 1 - Send USB Resume"]
78    #[inline(always)]
79    pub fn resume(&self) -> ResumeR {
80        ResumeR::new(((self.bits >> 1) & 1) != 0)
81    }
82    #[doc = "Bits 2:3 - Speed Configuration for Host"]
83    #[inline(always)]
84    pub fn spdconf(&self) -> SpdconfR {
85        SpdconfR::new(((self.bits >> 2) & 3) as u8)
86    }
87    #[doc = "Bit 4 - Auto Resume Enable"]
88    #[inline(always)]
89    pub fn autoresume(&self) -> AutoresumeR {
90        AutoresumeR::new(((self.bits >> 4) & 1) != 0)
91    }
92    #[doc = "Bit 8 - Start of Frame Generation Enable"]
93    #[inline(always)]
94    pub fn sofe(&self) -> SofeR {
95        SofeR::new(((self.bits >> 8) & 1) != 0)
96    }
97    #[doc = "Bit 9 - Send USB Reset"]
98    #[inline(always)]
99    pub fn busreset(&self) -> BusresetR {
100        BusresetR::new(((self.bits >> 9) & 1) != 0)
101    }
102    #[doc = "Bit 10 - VBUS is OK"]
103    #[inline(always)]
104    pub fn vbusok(&self) -> VbusokR {
105        VbusokR::new(((self.bits >> 10) & 1) != 0)
106    }
107    #[doc = "Bit 11 - Send L1 Resume"]
108    #[inline(always)]
109    pub fn l1resume(&self) -> L1resumeR {
110        L1resumeR::new(((self.bits >> 11) & 1) != 0)
111    }
112}
113impl W {
114    #[doc = "Bit 1 - Send USB Resume"]
115    #[inline(always)]
116    #[must_use]
117    pub fn resume(&mut self) -> ResumeW<CtrlbSpec> {
118        ResumeW::new(self, 1)
119    }
120    #[doc = "Bits 2:3 - Speed Configuration for Host"]
121    #[inline(always)]
122    #[must_use]
123    pub fn spdconf(&mut self) -> SpdconfW<CtrlbSpec> {
124        SpdconfW::new(self, 2)
125    }
126    #[doc = "Bit 4 - Auto Resume Enable"]
127    #[inline(always)]
128    #[must_use]
129    pub fn autoresume(&mut self) -> AutoresumeW<CtrlbSpec> {
130        AutoresumeW::new(self, 4)
131    }
132    #[doc = "Bit 8 - Start of Frame Generation Enable"]
133    #[inline(always)]
134    #[must_use]
135    pub fn sofe(&mut self) -> SofeW<CtrlbSpec> {
136        SofeW::new(self, 8)
137    }
138    #[doc = "Bit 9 - Send USB Reset"]
139    #[inline(always)]
140    #[must_use]
141    pub fn busreset(&mut self) -> BusresetW<CtrlbSpec> {
142        BusresetW::new(self, 9)
143    }
144    #[doc = "Bit 10 - VBUS is OK"]
145    #[inline(always)]
146    #[must_use]
147    pub fn vbusok(&mut self) -> VbusokW<CtrlbSpec> {
148        VbusokW::new(self, 10)
149    }
150    #[doc = "Bit 11 - Send L1 Resume"]
151    #[inline(always)]
152    #[must_use]
153    pub fn l1resume(&mut self) -> L1resumeW<CtrlbSpec> {
154        L1resumeW::new(self, 11)
155    }
156}
157#[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)."]
158pub struct CtrlbSpec;
159impl crate::RegisterSpec for CtrlbSpec {
160    type Ux = u16;
161}
162#[doc = "`read()` method returns [`ctrlb::R`](R) reader structure"]
163impl crate::Readable for CtrlbSpec {}
164#[doc = "`write(|w| ..)` method takes [`ctrlb::W`](W) writer structure"]
165impl crate::Writable for CtrlbSpec {
166    type Safety = crate::Unsafe;
167    const ZERO_TO_MODIFY_FIELDS_BITMAP: u16 = 0;
168    const ONE_TO_MODIFY_FIELDS_BITMAP: u16 = 0;
169}
170#[doc = "`reset()` method sets CTRLB to value 0"]
171impl crate::Resettable for CtrlbSpec {
172    const RESET_VALUE: u16 = 0;
173}