efm32hg309_pac/usb/
dctl.rs

1#[doc = "Register `DCTL` reader"]
2pub struct R(crate::R<DCTL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<DCTL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<DCTL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<DCTL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `DCTL` writer"]
17pub struct W(crate::W<DCTL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<DCTL_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<DCTL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<DCTL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `RMTWKUPSIG` reader - Remote Wakeup Signaling"]
38pub type RMTWKUPSIG_R = crate::BitReader<bool>;
39#[doc = "Field `RMTWKUPSIG` writer - Remote Wakeup Signaling"]
40pub type RMTWKUPSIG_W<'a> = crate::BitWriter<'a, u32, DCTL_SPEC, bool, 0>;
41#[doc = "Field `SFTDISCON` reader - Soft Disconnect"]
42pub type SFTDISCON_R = crate::BitReader<bool>;
43#[doc = "Field `SFTDISCON` writer - Soft Disconnect"]
44pub type SFTDISCON_W<'a> = crate::BitWriter<'a, u32, DCTL_SPEC, bool, 1>;
45#[doc = "Field `GNPINNAKSTS` reader - Global Non-periodic IN NAK Status"]
46pub type GNPINNAKSTS_R = crate::BitReader<bool>;
47#[doc = "Field `GOUTNAKSTS` reader - Global OUT NAK Status"]
48pub type GOUTNAKSTS_R = crate::BitReader<bool>;
49#[doc = "Test Control\n\nValue on reset: 0"]
50#[derive(Clone, Copy, Debug, PartialEq)]
51#[repr(u8)]
52pub enum TSTCTL_A {
53    #[doc = "0: Test mode disabled."]
54    DISABLE = 0,
55    #[doc = "1: Test_J mode."]
56    J = 1,
57    #[doc = "2: Test_K mode."]
58    K = 2,
59    #[doc = "3: Test_SE0_NAK mode."]
60    SE0NAK = 3,
61    #[doc = "4: Test_Packet mode."]
62    PACKET = 4,
63    #[doc = "5: Test_Force_Enable."]
64    FORCE = 5,
65}
66impl From<TSTCTL_A> for u8 {
67    #[inline(always)]
68    fn from(variant: TSTCTL_A) -> Self {
69        variant as _
70    }
71}
72#[doc = "Field `TSTCTL` reader - Test Control"]
73pub type TSTCTL_R = crate::FieldReader<u8, TSTCTL_A>;
74impl TSTCTL_R {
75    #[doc = "Get enumerated values variant"]
76    #[inline(always)]
77    pub fn variant(&self) -> Option<TSTCTL_A> {
78        match self.bits {
79            0 => Some(TSTCTL_A::DISABLE),
80            1 => Some(TSTCTL_A::J),
81            2 => Some(TSTCTL_A::K),
82            3 => Some(TSTCTL_A::SE0NAK),
83            4 => Some(TSTCTL_A::PACKET),
84            5 => Some(TSTCTL_A::FORCE),
85            _ => None,
86        }
87    }
88    #[doc = "Checks if the value of the field is `DISABLE`"]
89    #[inline(always)]
90    pub fn is_disable(&self) -> bool {
91        *self == TSTCTL_A::DISABLE
92    }
93    #[doc = "Checks if the value of the field is `J`"]
94    #[inline(always)]
95    pub fn is_j(&self) -> bool {
96        *self == TSTCTL_A::J
97    }
98    #[doc = "Checks if the value of the field is `K`"]
99    #[inline(always)]
100    pub fn is_k(&self) -> bool {
101        *self == TSTCTL_A::K
102    }
103    #[doc = "Checks if the value of the field is `SE0NAK`"]
104    #[inline(always)]
105    pub fn is_se0nak(&self) -> bool {
106        *self == TSTCTL_A::SE0NAK
107    }
108    #[doc = "Checks if the value of the field is `PACKET`"]
109    #[inline(always)]
110    pub fn is_packet(&self) -> bool {
111        *self == TSTCTL_A::PACKET
112    }
113    #[doc = "Checks if the value of the field is `FORCE`"]
114    #[inline(always)]
115    pub fn is_force(&self) -> bool {
116        *self == TSTCTL_A::FORCE
117    }
118}
119#[doc = "Field `TSTCTL` writer - Test Control"]
120pub type TSTCTL_W<'a> = crate::FieldWriter<'a, u32, DCTL_SPEC, u8, TSTCTL_A, 3, 4>;
121impl<'a> TSTCTL_W<'a> {
122    #[doc = "Test mode disabled."]
123    #[inline(always)]
124    pub fn disable(self) -> &'a mut W {
125        self.variant(TSTCTL_A::DISABLE)
126    }
127    #[doc = "Test_J mode."]
128    #[inline(always)]
129    pub fn j(self) -> &'a mut W {
130        self.variant(TSTCTL_A::J)
131    }
132    #[doc = "Test_K mode."]
133    #[inline(always)]
134    pub fn k(self) -> &'a mut W {
135        self.variant(TSTCTL_A::K)
136    }
137    #[doc = "Test_SE0_NAK mode."]
138    #[inline(always)]
139    pub fn se0nak(self) -> &'a mut W {
140        self.variant(TSTCTL_A::SE0NAK)
141    }
142    #[doc = "Test_Packet mode."]
143    #[inline(always)]
144    pub fn packet(self) -> &'a mut W {
145        self.variant(TSTCTL_A::PACKET)
146    }
147    #[doc = "Test_Force_Enable."]
148    #[inline(always)]
149    pub fn force(self) -> &'a mut W {
150        self.variant(TSTCTL_A::FORCE)
151    }
152}
153#[doc = "Field `SGNPINNAK` writer - Set Global Non-periodic IN NAK"]
154pub type SGNPINNAK_W<'a> = crate::BitWriter<'a, u32, DCTL_SPEC, bool, 7>;
155#[doc = "Field `CGNPINNAK` writer - Clear Global Non-periodic IN NAK"]
156pub type CGNPINNAK_W<'a> = crate::BitWriter<'a, u32, DCTL_SPEC, bool, 8>;
157#[doc = "Field `SGOUTNAK` writer - Set Global OUT NAK"]
158pub type SGOUTNAK_W<'a> = crate::BitWriter<'a, u32, DCTL_SPEC, bool, 9>;
159#[doc = "Field `CGOUTNAK` writer - Clear Global OUT NAK"]
160pub type CGOUTNAK_W<'a> = crate::BitWriter<'a, u32, DCTL_SPEC, bool, 10>;
161#[doc = "Field `PWRONPRGDONE` reader - Power-On Programming Done"]
162pub type PWRONPRGDONE_R = crate::BitReader<bool>;
163#[doc = "Field `PWRONPRGDONE` writer - Power-On Programming Done"]
164pub type PWRONPRGDONE_W<'a> = crate::BitWriter<'a, u32, DCTL_SPEC, bool, 11>;
165#[doc = "Field `IGNRFRMNUM` reader - Ignore Frame number For Isochronous End points"]
166pub type IGNRFRMNUM_R = crate::BitReader<bool>;
167#[doc = "Field `IGNRFRMNUM` writer - Ignore Frame number For Isochronous End points"]
168pub type IGNRFRMNUM_W<'a> = crate::BitWriter<'a, u32, DCTL_SPEC, bool, 15>;
169#[doc = "Field `NAKONBBLE` reader - NAK on Babble Error"]
170pub type NAKONBBLE_R = crate::BitReader<bool>;
171#[doc = "Field `NAKONBBLE` writer - NAK on Babble Error"]
172pub type NAKONBBLE_W<'a> = crate::BitWriter<'a, u32, DCTL_SPEC, bool, 16>;
173impl R {
174    #[doc = "Bit 0 - Remote Wakeup Signaling"]
175    #[inline(always)]
176    pub fn rmtwkupsig(&self) -> RMTWKUPSIG_R {
177        RMTWKUPSIG_R::new((self.bits & 1) != 0)
178    }
179    #[doc = "Bit 1 - Soft Disconnect"]
180    #[inline(always)]
181    pub fn sftdiscon(&self) -> SFTDISCON_R {
182        SFTDISCON_R::new(((self.bits >> 1) & 1) != 0)
183    }
184    #[doc = "Bit 2 - Global Non-periodic IN NAK Status"]
185    #[inline(always)]
186    pub fn gnpinnaksts(&self) -> GNPINNAKSTS_R {
187        GNPINNAKSTS_R::new(((self.bits >> 2) & 1) != 0)
188    }
189    #[doc = "Bit 3 - Global OUT NAK Status"]
190    #[inline(always)]
191    pub fn goutnaksts(&self) -> GOUTNAKSTS_R {
192        GOUTNAKSTS_R::new(((self.bits >> 3) & 1) != 0)
193    }
194    #[doc = "Bits 4:6 - Test Control"]
195    #[inline(always)]
196    pub fn tstctl(&self) -> TSTCTL_R {
197        TSTCTL_R::new(((self.bits >> 4) & 7) as u8)
198    }
199    #[doc = "Bit 11 - Power-On Programming Done"]
200    #[inline(always)]
201    pub fn pwronprgdone(&self) -> PWRONPRGDONE_R {
202        PWRONPRGDONE_R::new(((self.bits >> 11) & 1) != 0)
203    }
204    #[doc = "Bit 15 - Ignore Frame number For Isochronous End points"]
205    #[inline(always)]
206    pub fn ignrfrmnum(&self) -> IGNRFRMNUM_R {
207        IGNRFRMNUM_R::new(((self.bits >> 15) & 1) != 0)
208    }
209    #[doc = "Bit 16 - NAK on Babble Error"]
210    #[inline(always)]
211    pub fn nakonbble(&self) -> NAKONBBLE_R {
212        NAKONBBLE_R::new(((self.bits >> 16) & 1) != 0)
213    }
214}
215impl W {
216    #[doc = "Bit 0 - Remote Wakeup Signaling"]
217    #[inline(always)]
218    pub fn rmtwkupsig(&mut self) -> RMTWKUPSIG_W {
219        RMTWKUPSIG_W::new(self)
220    }
221    #[doc = "Bit 1 - Soft Disconnect"]
222    #[inline(always)]
223    pub fn sftdiscon(&mut self) -> SFTDISCON_W {
224        SFTDISCON_W::new(self)
225    }
226    #[doc = "Bits 4:6 - Test Control"]
227    #[inline(always)]
228    pub fn tstctl(&mut self) -> TSTCTL_W {
229        TSTCTL_W::new(self)
230    }
231    #[doc = "Bit 7 - Set Global Non-periodic IN NAK"]
232    #[inline(always)]
233    pub fn sgnpinnak(&mut self) -> SGNPINNAK_W {
234        SGNPINNAK_W::new(self)
235    }
236    #[doc = "Bit 8 - Clear Global Non-periodic IN NAK"]
237    #[inline(always)]
238    pub fn cgnpinnak(&mut self) -> CGNPINNAK_W {
239        CGNPINNAK_W::new(self)
240    }
241    #[doc = "Bit 9 - Set Global OUT NAK"]
242    #[inline(always)]
243    pub fn sgoutnak(&mut self) -> SGOUTNAK_W {
244        SGOUTNAK_W::new(self)
245    }
246    #[doc = "Bit 10 - Clear Global OUT NAK"]
247    #[inline(always)]
248    pub fn cgoutnak(&mut self) -> CGOUTNAK_W {
249        CGOUTNAK_W::new(self)
250    }
251    #[doc = "Bit 11 - Power-On Programming Done"]
252    #[inline(always)]
253    pub fn pwronprgdone(&mut self) -> PWRONPRGDONE_W {
254        PWRONPRGDONE_W::new(self)
255    }
256    #[doc = "Bit 15 - Ignore Frame number For Isochronous End points"]
257    #[inline(always)]
258    pub fn ignrfrmnum(&mut self) -> IGNRFRMNUM_W {
259        IGNRFRMNUM_W::new(self)
260    }
261    #[doc = "Bit 16 - NAK on Babble Error"]
262    #[inline(always)]
263    pub fn nakonbble(&mut self) -> NAKONBBLE_W {
264        NAKONBBLE_W::new(self)
265    }
266    #[doc = "Writes raw bits to the register."]
267    #[inline(always)]
268    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
269        self.0.bits(bits);
270        self
271    }
272}
273#[doc = "Device 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 [dctl](index.html) module"]
274pub struct DCTL_SPEC;
275impl crate::RegisterSpec for DCTL_SPEC {
276    type Ux = u32;
277}
278#[doc = "`read()` method returns [dctl::R](R) reader structure"]
279impl crate::Readable for DCTL_SPEC {
280    type Reader = R;
281}
282#[doc = "`write(|w| ..)` method takes [dctl::W](W) writer structure"]
283impl crate::Writable for DCTL_SPEC {
284    type Writer = W;
285}
286#[doc = "`reset()` method sets DCTL to value 0x02"]
287impl crate::Resettable for DCTL_SPEC {
288    #[inline(always)]
289    fn reset_value() -> Self::Ux {
290        0x02
291    }
292}