efm32gg12b410_pac/usb/
dthrctl.rs

1#[doc = "Register `DTHRCTL` reader"]
2pub struct R(crate::R<DTHRCTL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<DTHRCTL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<DTHRCTL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<DTHRCTL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `DTHRCTL` writer"]
17pub struct W(crate::W<DTHRCTL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<DTHRCTL_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<DTHRCTL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<DTHRCTL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `NONISOTHREN` reader - Non-ISO IN Endpoints Threshold Enable"]
38pub type NONISOTHREN_R = crate::BitReader<bool>;
39#[doc = "Field `NONISOTHREN` writer - Non-ISO IN Endpoints Threshold Enable"]
40pub type NONISOTHREN_W<'a> = crate::BitWriter<'a, u32, DTHRCTL_SPEC, bool, 0>;
41#[doc = "Field `ISOTHREN` reader - ISO IN Endpoints Threshold Enable"]
42pub type ISOTHREN_R = crate::BitReader<bool>;
43#[doc = "Field `ISOTHREN` writer - ISO IN Endpoints Threshold Enable"]
44pub type ISOTHREN_W<'a> = crate::BitWriter<'a, u32, DTHRCTL_SPEC, bool, 1>;
45#[doc = "Field `TXTHRLEN` reader - Transmit Threshold Length"]
46pub type TXTHRLEN_R = crate::FieldReader<u16, u16>;
47#[doc = "Field `TXTHRLEN` writer - Transmit Threshold Length"]
48pub type TXTHRLEN_W<'a> = crate::FieldWriter<'a, u32, DTHRCTL_SPEC, u16, u16, 9, 2>;
49#[doc = "AHB Threshold Ratio\n\nValue on reset: 0"]
50#[derive(Clone, Copy, Debug, PartialEq)]
51#[repr(u8)]
52pub enum AHBTHRRATIO_A {
53    #[doc = "0: AHB threshold = MAC threshold."]
54    DIV1 = 0,
55    #[doc = "1: AHB threshold = MAC threshold / 2."]
56    DIV2 = 1,
57    #[doc = "2: AHB threshold = MAC threshold / 4."]
58    DIV4 = 2,
59    #[doc = "3: AHB threshold = MAC threshold / 8."]
60    DIV8 = 3,
61}
62impl From<AHBTHRRATIO_A> for u8 {
63    #[inline(always)]
64    fn from(variant: AHBTHRRATIO_A) -> Self {
65        variant as _
66    }
67}
68#[doc = "Field `AHBTHRRATIO` reader - AHB Threshold Ratio"]
69pub type AHBTHRRATIO_R = crate::FieldReader<u8, AHBTHRRATIO_A>;
70impl AHBTHRRATIO_R {
71    #[doc = "Get enumerated values variant"]
72    #[inline(always)]
73    pub fn variant(&self) -> AHBTHRRATIO_A {
74        match self.bits {
75            0 => AHBTHRRATIO_A::DIV1,
76            1 => AHBTHRRATIO_A::DIV2,
77            2 => AHBTHRRATIO_A::DIV4,
78            3 => AHBTHRRATIO_A::DIV8,
79            _ => unreachable!(),
80        }
81    }
82    #[doc = "Checks if the value of the field is `DIV1`"]
83    #[inline(always)]
84    pub fn is_div1(&self) -> bool {
85        *self == AHBTHRRATIO_A::DIV1
86    }
87    #[doc = "Checks if the value of the field is `DIV2`"]
88    #[inline(always)]
89    pub fn is_div2(&self) -> bool {
90        *self == AHBTHRRATIO_A::DIV2
91    }
92    #[doc = "Checks if the value of the field is `DIV4`"]
93    #[inline(always)]
94    pub fn is_div4(&self) -> bool {
95        *self == AHBTHRRATIO_A::DIV4
96    }
97    #[doc = "Checks if the value of the field is `DIV8`"]
98    #[inline(always)]
99    pub fn is_div8(&self) -> bool {
100        *self == AHBTHRRATIO_A::DIV8
101    }
102}
103#[doc = "Field `AHBTHRRATIO` writer - AHB Threshold Ratio"]
104pub type AHBTHRRATIO_W<'a> =
105    crate::FieldWriterSafe<'a, u32, DTHRCTL_SPEC, u8, AHBTHRRATIO_A, 2, 11>;
106impl<'a> AHBTHRRATIO_W<'a> {
107    #[doc = "AHB threshold = MAC threshold."]
108    #[inline(always)]
109    pub fn div1(self) -> &'a mut W {
110        self.variant(AHBTHRRATIO_A::DIV1)
111    }
112    #[doc = "AHB threshold = MAC threshold / 2."]
113    #[inline(always)]
114    pub fn div2(self) -> &'a mut W {
115        self.variant(AHBTHRRATIO_A::DIV2)
116    }
117    #[doc = "AHB threshold = MAC threshold / 4."]
118    #[inline(always)]
119    pub fn div4(self) -> &'a mut W {
120        self.variant(AHBTHRRATIO_A::DIV4)
121    }
122    #[doc = "AHB threshold = MAC threshold / 8."]
123    #[inline(always)]
124    pub fn div8(self) -> &'a mut W {
125        self.variant(AHBTHRRATIO_A::DIV8)
126    }
127}
128#[doc = "Field `RXTHREN` reader - Receive Threshold Enable"]
129pub type RXTHREN_R = crate::BitReader<bool>;
130#[doc = "Field `RXTHREN` writer - Receive Threshold Enable"]
131pub type RXTHREN_W<'a> = crate::BitWriter<'a, u32, DTHRCTL_SPEC, bool, 16>;
132#[doc = "Field `RXTHRLEN` reader - Receive Threshold Length"]
133pub type RXTHRLEN_R = crate::FieldReader<u16, u16>;
134#[doc = "Field `RXTHRLEN` writer - Receive Threshold Length"]
135pub type RXTHRLEN_W<'a> = crate::FieldWriter<'a, u32, DTHRCTL_SPEC, u16, u16, 9, 17>;
136#[doc = "Field `ARBPRKEN` reader - Arbiter Parking Enable"]
137pub type ARBPRKEN_R = crate::BitReader<bool>;
138#[doc = "Field `ARBPRKEN` writer - Arbiter Parking Enable"]
139pub type ARBPRKEN_W<'a> = crate::BitWriter<'a, u32, DTHRCTL_SPEC, bool, 27>;
140impl R {
141    #[doc = "Bit 0 - Non-ISO IN Endpoints Threshold Enable"]
142    #[inline(always)]
143    pub fn nonisothren(&self) -> NONISOTHREN_R {
144        NONISOTHREN_R::new((self.bits & 1) != 0)
145    }
146    #[doc = "Bit 1 - ISO IN Endpoints Threshold Enable"]
147    #[inline(always)]
148    pub fn isothren(&self) -> ISOTHREN_R {
149        ISOTHREN_R::new(((self.bits >> 1) & 1) != 0)
150    }
151    #[doc = "Bits 2:10 - Transmit Threshold Length"]
152    #[inline(always)]
153    pub fn txthrlen(&self) -> TXTHRLEN_R {
154        TXTHRLEN_R::new(((self.bits >> 2) & 0x01ff) as u16)
155    }
156    #[doc = "Bits 11:12 - AHB Threshold Ratio"]
157    #[inline(always)]
158    pub fn ahbthrratio(&self) -> AHBTHRRATIO_R {
159        AHBTHRRATIO_R::new(((self.bits >> 11) & 3) as u8)
160    }
161    #[doc = "Bit 16 - Receive Threshold Enable"]
162    #[inline(always)]
163    pub fn rxthren(&self) -> RXTHREN_R {
164        RXTHREN_R::new(((self.bits >> 16) & 1) != 0)
165    }
166    #[doc = "Bits 17:25 - Receive Threshold Length"]
167    #[inline(always)]
168    pub fn rxthrlen(&self) -> RXTHRLEN_R {
169        RXTHRLEN_R::new(((self.bits >> 17) & 0x01ff) as u16)
170    }
171    #[doc = "Bit 27 - Arbiter Parking Enable"]
172    #[inline(always)]
173    pub fn arbprken(&self) -> ARBPRKEN_R {
174        ARBPRKEN_R::new(((self.bits >> 27) & 1) != 0)
175    }
176}
177impl W {
178    #[doc = "Bit 0 - Non-ISO IN Endpoints Threshold Enable"]
179    #[inline(always)]
180    pub fn nonisothren(&mut self) -> NONISOTHREN_W {
181        NONISOTHREN_W::new(self)
182    }
183    #[doc = "Bit 1 - ISO IN Endpoints Threshold Enable"]
184    #[inline(always)]
185    pub fn isothren(&mut self) -> ISOTHREN_W {
186        ISOTHREN_W::new(self)
187    }
188    #[doc = "Bits 2:10 - Transmit Threshold Length"]
189    #[inline(always)]
190    pub fn txthrlen(&mut self) -> TXTHRLEN_W {
191        TXTHRLEN_W::new(self)
192    }
193    #[doc = "Bits 11:12 - AHB Threshold Ratio"]
194    #[inline(always)]
195    pub fn ahbthrratio(&mut self) -> AHBTHRRATIO_W {
196        AHBTHRRATIO_W::new(self)
197    }
198    #[doc = "Bit 16 - Receive Threshold Enable"]
199    #[inline(always)]
200    pub fn rxthren(&mut self) -> RXTHREN_W {
201        RXTHREN_W::new(self)
202    }
203    #[doc = "Bits 17:25 - Receive Threshold Length"]
204    #[inline(always)]
205    pub fn rxthrlen(&mut self) -> RXTHRLEN_W {
206        RXTHRLEN_W::new(self)
207    }
208    #[doc = "Bit 27 - Arbiter Parking Enable"]
209    #[inline(always)]
210    pub fn arbprken(&mut self) -> ARBPRKEN_W {
211        ARBPRKEN_W::new(self)
212    }
213    #[doc = "Writes raw bits to the register."]
214    #[inline(always)]
215    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
216        self.0.bits(bits);
217        self
218    }
219}
220#[doc = "Device Threshold 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 [dthrctl](index.html) module"]
221pub struct DTHRCTL_SPEC;
222impl crate::RegisterSpec for DTHRCTL_SPEC {
223    type Ux = u32;
224}
225#[doc = "`read()` method returns [dthrctl::R](R) reader structure"]
226impl crate::Readable for DTHRCTL_SPEC {
227    type Reader = R;
228}
229#[doc = "`write(|w| ..)` method takes [dthrctl::W](W) writer structure"]
230impl crate::Writable for DTHRCTL_SPEC {
231    type Writer = W;
232}
233#[doc = "`reset()` method sets DTHRCTL to value 0x0810_0020"]
234impl crate::Resettable for DTHRCTL_SPEC {
235    #[inline(always)]
236    fn reset_value() -> Self::Ux {
237        0x0810_0020
238    }
239}