nrf52840_pac/usbd/
eventcause.rs

1#[doc = "Register `EVENTCAUSE` reader"]
2pub struct R(crate::R<EVENTCAUSE_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<EVENTCAUSE_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<EVENTCAUSE_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<EVENTCAUSE_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `EVENTCAUSE` writer"]
17pub struct W(crate::W<EVENTCAUSE_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<EVENTCAUSE_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<EVENTCAUSE_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<EVENTCAUSE_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `ISOOUTCRC` reader - CRC error was detected on isochronous OUT endpoint 8. Write '1' to clear."]
38pub type ISOOUTCRC_R = crate::BitReader<ISOOUTCRC_A>;
39#[doc = "CRC error was detected on isochronous OUT endpoint 8. Write '1' to clear.\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq)]
41pub enum ISOOUTCRC_A {
42    #[doc = "0: No error detected"]
43    NOT_DETECTED = 0,
44    #[doc = "1: Error detected"]
45    DETECTED = 1,
46}
47impl From<ISOOUTCRC_A> for bool {
48    #[inline(always)]
49    fn from(variant: ISOOUTCRC_A) -> Self {
50        variant as u8 != 0
51    }
52}
53impl ISOOUTCRC_R {
54    #[doc = "Get enumerated values variant"]
55    #[inline(always)]
56    pub fn variant(&self) -> ISOOUTCRC_A {
57        match self.bits {
58            false => ISOOUTCRC_A::NOT_DETECTED,
59            true => ISOOUTCRC_A::DETECTED,
60        }
61    }
62    #[doc = "Checks if the value of the field is `NOT_DETECTED`"]
63    #[inline(always)]
64    pub fn is_not_detected(&self) -> bool {
65        *self == ISOOUTCRC_A::NOT_DETECTED
66    }
67    #[doc = "Checks if the value of the field is `DETECTED`"]
68    #[inline(always)]
69    pub fn is_detected(&self) -> bool {
70        *self == ISOOUTCRC_A::DETECTED
71    }
72}
73#[doc = "Field `ISOOUTCRC` writer - CRC error was detected on isochronous OUT endpoint 8. Write '1' to clear."]
74pub type ISOOUTCRC_W<'a, const O: u8> =
75    crate::BitWriter1C<'a, u32, EVENTCAUSE_SPEC, ISOOUTCRC_A, O>;
76impl<'a, const O: u8> ISOOUTCRC_W<'a, O> {
77    #[doc = "No error detected"]
78    #[inline(always)]
79    pub fn not_detected(self) -> &'a mut W {
80        self.variant(ISOOUTCRC_A::NOT_DETECTED)
81    }
82    #[doc = "Error detected"]
83    #[inline(always)]
84    pub fn detected(self) -> &'a mut W {
85        self.variant(ISOOUTCRC_A::DETECTED)
86    }
87}
88#[doc = "Field `SUSPEND` reader - Signals that USB lines have been idle long enough for the device to enter suspend. Write '1' to clear."]
89pub type SUSPEND_R = crate::BitReader<SUSPEND_A>;
90#[doc = "Signals that USB lines have been idle long enough for the device to enter suspend. Write '1' to clear.\n\nValue on reset: 0"]
91#[derive(Clone, Copy, Debug, PartialEq)]
92pub enum SUSPEND_A {
93    #[doc = "0: Suspend not detected"]
94    NOT_DETECTED = 0,
95    #[doc = "1: Suspend detected"]
96    DETECTED = 1,
97}
98impl From<SUSPEND_A> for bool {
99    #[inline(always)]
100    fn from(variant: SUSPEND_A) -> Self {
101        variant as u8 != 0
102    }
103}
104impl SUSPEND_R {
105    #[doc = "Get enumerated values variant"]
106    #[inline(always)]
107    pub fn variant(&self) -> SUSPEND_A {
108        match self.bits {
109            false => SUSPEND_A::NOT_DETECTED,
110            true => SUSPEND_A::DETECTED,
111        }
112    }
113    #[doc = "Checks if the value of the field is `NOT_DETECTED`"]
114    #[inline(always)]
115    pub fn is_not_detected(&self) -> bool {
116        *self == SUSPEND_A::NOT_DETECTED
117    }
118    #[doc = "Checks if the value of the field is `DETECTED`"]
119    #[inline(always)]
120    pub fn is_detected(&self) -> bool {
121        *self == SUSPEND_A::DETECTED
122    }
123}
124#[doc = "Field `SUSPEND` writer - Signals that USB lines have been idle long enough for the device to enter suspend. Write '1' to clear."]
125pub type SUSPEND_W<'a, const O: u8> = crate::BitWriter1C<'a, u32, EVENTCAUSE_SPEC, SUSPEND_A, O>;
126impl<'a, const O: u8> SUSPEND_W<'a, O> {
127    #[doc = "Suspend not detected"]
128    #[inline(always)]
129    pub fn not_detected(self) -> &'a mut W {
130        self.variant(SUSPEND_A::NOT_DETECTED)
131    }
132    #[doc = "Suspend detected"]
133    #[inline(always)]
134    pub fn detected(self) -> &'a mut W {
135        self.variant(SUSPEND_A::DETECTED)
136    }
137}
138#[doc = "Field `RESUME` reader - Signals that a RESUME condition (K state or activity restart) has been detected on USB lines. Write '1' to clear."]
139pub type RESUME_R = crate::BitReader<RESUME_A>;
140#[doc = "Signals that a RESUME condition (K state or activity restart) has been detected on USB lines. Write '1' to clear.\n\nValue on reset: 0"]
141#[derive(Clone, Copy, Debug, PartialEq)]
142pub enum RESUME_A {
143    #[doc = "0: Resume not detected"]
144    NOT_DETECTED = 0,
145    #[doc = "1: Resume detected"]
146    DETECTED = 1,
147}
148impl From<RESUME_A> for bool {
149    #[inline(always)]
150    fn from(variant: RESUME_A) -> Self {
151        variant as u8 != 0
152    }
153}
154impl RESUME_R {
155    #[doc = "Get enumerated values variant"]
156    #[inline(always)]
157    pub fn variant(&self) -> RESUME_A {
158        match self.bits {
159            false => RESUME_A::NOT_DETECTED,
160            true => RESUME_A::DETECTED,
161        }
162    }
163    #[doc = "Checks if the value of the field is `NOT_DETECTED`"]
164    #[inline(always)]
165    pub fn is_not_detected(&self) -> bool {
166        *self == RESUME_A::NOT_DETECTED
167    }
168    #[doc = "Checks if the value of the field is `DETECTED`"]
169    #[inline(always)]
170    pub fn is_detected(&self) -> bool {
171        *self == RESUME_A::DETECTED
172    }
173}
174#[doc = "Field `RESUME` writer - Signals that a RESUME condition (K state or activity restart) has been detected on USB lines. Write '1' to clear."]
175pub type RESUME_W<'a, const O: u8> = crate::BitWriter1C<'a, u32, EVENTCAUSE_SPEC, RESUME_A, O>;
176impl<'a, const O: u8> RESUME_W<'a, O> {
177    #[doc = "Resume not detected"]
178    #[inline(always)]
179    pub fn not_detected(self) -> &'a mut W {
180        self.variant(RESUME_A::NOT_DETECTED)
181    }
182    #[doc = "Resume detected"]
183    #[inline(always)]
184    pub fn detected(self) -> &'a mut W {
185        self.variant(RESUME_A::DETECTED)
186    }
187}
188#[doc = "Field `USBWUALLOWED` reader - USB MAC has been woken up and operational. Write '1' to clear."]
189pub type USBWUALLOWED_R = crate::BitReader<USBWUALLOWED_A>;
190#[doc = "USB MAC has been woken up and operational. Write '1' to clear.\n\nValue on reset: 0"]
191#[derive(Clone, Copy, Debug, PartialEq)]
192pub enum USBWUALLOWED_A {
193    #[doc = "0: Wake up not allowed"]
194    NOT_ALLOWED = 0,
195    #[doc = "1: Wake up allowed"]
196    ALLOWED = 1,
197}
198impl From<USBWUALLOWED_A> for bool {
199    #[inline(always)]
200    fn from(variant: USBWUALLOWED_A) -> Self {
201        variant as u8 != 0
202    }
203}
204impl USBWUALLOWED_R {
205    #[doc = "Get enumerated values variant"]
206    #[inline(always)]
207    pub fn variant(&self) -> USBWUALLOWED_A {
208        match self.bits {
209            false => USBWUALLOWED_A::NOT_ALLOWED,
210            true => USBWUALLOWED_A::ALLOWED,
211        }
212    }
213    #[doc = "Checks if the value of the field is `NOT_ALLOWED`"]
214    #[inline(always)]
215    pub fn is_not_allowed(&self) -> bool {
216        *self == USBWUALLOWED_A::NOT_ALLOWED
217    }
218    #[doc = "Checks if the value of the field is `ALLOWED`"]
219    #[inline(always)]
220    pub fn is_allowed(&self) -> bool {
221        *self == USBWUALLOWED_A::ALLOWED
222    }
223}
224#[doc = "Field `USBWUALLOWED` writer - USB MAC has been woken up and operational. Write '1' to clear."]
225pub type USBWUALLOWED_W<'a, const O: u8> =
226    crate::BitWriter1C<'a, u32, EVENTCAUSE_SPEC, USBWUALLOWED_A, O>;
227impl<'a, const O: u8> USBWUALLOWED_W<'a, O> {
228    #[doc = "Wake up not allowed"]
229    #[inline(always)]
230    pub fn not_allowed(self) -> &'a mut W {
231        self.variant(USBWUALLOWED_A::NOT_ALLOWED)
232    }
233    #[doc = "Wake up allowed"]
234    #[inline(always)]
235    pub fn allowed(self) -> &'a mut W {
236        self.variant(USBWUALLOWED_A::ALLOWED)
237    }
238}
239#[doc = "Field `READY` reader - USB device is ready for normal operation. Write '1' to clear."]
240pub type READY_R = crate::BitReader<READY_A>;
241#[doc = "USB device is ready for normal operation. Write '1' to clear.\n\nValue on reset: 0"]
242#[derive(Clone, Copy, Debug, PartialEq)]
243pub enum READY_A {
244    #[doc = "0: USBEVENT was not issued due to USBD peripheral ready"]
245    NOT_DETECTED = 0,
246    #[doc = "1: USBD peripheral is ready"]
247    READY = 1,
248}
249impl From<READY_A> for bool {
250    #[inline(always)]
251    fn from(variant: READY_A) -> Self {
252        variant as u8 != 0
253    }
254}
255impl READY_R {
256    #[doc = "Get enumerated values variant"]
257    #[inline(always)]
258    pub fn variant(&self) -> READY_A {
259        match self.bits {
260            false => READY_A::NOT_DETECTED,
261            true => READY_A::READY,
262        }
263    }
264    #[doc = "Checks if the value of the field is `NOT_DETECTED`"]
265    #[inline(always)]
266    pub fn is_not_detected(&self) -> bool {
267        *self == READY_A::NOT_DETECTED
268    }
269    #[doc = "Checks if the value of the field is `READY`"]
270    #[inline(always)]
271    pub fn is_ready(&self) -> bool {
272        *self == READY_A::READY
273    }
274}
275#[doc = "Field `READY` writer - USB device is ready for normal operation. Write '1' to clear."]
276pub type READY_W<'a, const O: u8> = crate::BitWriter1C<'a, u32, EVENTCAUSE_SPEC, READY_A, O>;
277impl<'a, const O: u8> READY_W<'a, O> {
278    #[doc = "USBEVENT was not issued due to USBD peripheral ready"]
279    #[inline(always)]
280    pub fn not_detected(self) -> &'a mut W {
281        self.variant(READY_A::NOT_DETECTED)
282    }
283    #[doc = "USBD peripheral is ready"]
284    #[inline(always)]
285    pub fn ready(self) -> &'a mut W {
286        self.variant(READY_A::READY)
287    }
288}
289impl R {
290    #[doc = "Bit 0 - CRC error was detected on isochronous OUT endpoint 8. Write '1' to clear."]
291    #[inline(always)]
292    pub fn isooutcrc(&self) -> ISOOUTCRC_R {
293        ISOOUTCRC_R::new((self.bits & 1) != 0)
294    }
295    #[doc = "Bit 8 - Signals that USB lines have been idle long enough for the device to enter suspend. Write '1' to clear."]
296    #[inline(always)]
297    pub fn suspend(&self) -> SUSPEND_R {
298        SUSPEND_R::new(((self.bits >> 8) & 1) != 0)
299    }
300    #[doc = "Bit 9 - Signals that a RESUME condition (K state or activity restart) has been detected on USB lines. Write '1' to clear."]
301    #[inline(always)]
302    pub fn resume(&self) -> RESUME_R {
303        RESUME_R::new(((self.bits >> 9) & 1) != 0)
304    }
305    #[doc = "Bit 10 - USB MAC has been woken up and operational. Write '1' to clear."]
306    #[inline(always)]
307    pub fn usbwuallowed(&self) -> USBWUALLOWED_R {
308        USBWUALLOWED_R::new(((self.bits >> 10) & 1) != 0)
309    }
310    #[doc = "Bit 11 - USB device is ready for normal operation. Write '1' to clear."]
311    #[inline(always)]
312    pub fn ready(&self) -> READY_R {
313        READY_R::new(((self.bits >> 11) & 1) != 0)
314    }
315}
316impl W {
317    #[doc = "Bit 0 - CRC error was detected on isochronous OUT endpoint 8. Write '1' to clear."]
318    #[inline(always)]
319    pub fn isooutcrc(&mut self) -> ISOOUTCRC_W<0> {
320        ISOOUTCRC_W::new(self)
321    }
322    #[doc = "Bit 8 - Signals that USB lines have been idle long enough for the device to enter suspend. Write '1' to clear."]
323    #[inline(always)]
324    pub fn suspend(&mut self) -> SUSPEND_W<8> {
325        SUSPEND_W::new(self)
326    }
327    #[doc = "Bit 9 - Signals that a RESUME condition (K state or activity restart) has been detected on USB lines. Write '1' to clear."]
328    #[inline(always)]
329    pub fn resume(&mut self) -> RESUME_W<9> {
330        RESUME_W::new(self)
331    }
332    #[doc = "Bit 10 - USB MAC has been woken up and operational. Write '1' to clear."]
333    #[inline(always)]
334    pub fn usbwuallowed(&mut self) -> USBWUALLOWED_W<10> {
335        USBWUALLOWED_W::new(self)
336    }
337    #[doc = "Bit 11 - USB device is ready for normal operation. Write '1' to clear."]
338    #[inline(always)]
339    pub fn ready(&mut self) -> READY_W<11> {
340        READY_W::new(self)
341    }
342    #[doc = "Writes raw bits to the register."]
343    #[inline(always)]
344    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
345        self.0.bits(bits);
346        self
347    }
348}
349#[doc = "Details on what caused the USBEVENT event\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 [eventcause](index.html) module"]
350pub struct EVENTCAUSE_SPEC;
351impl crate::RegisterSpec for EVENTCAUSE_SPEC {
352    type Ux = u32;
353}
354#[doc = "`read()` method returns [eventcause::R](R) reader structure"]
355impl crate::Readable for EVENTCAUSE_SPEC {
356    type Reader = R;
357}
358#[doc = "`write(|w| ..)` method takes [eventcause::W](W) writer structure"]
359impl crate::Writable for EVENTCAUSE_SPEC {
360    type Writer = W;
361}
362#[doc = "`reset()` method sets EVENTCAUSE to value 0"]
363impl crate::Resettable for EVENTCAUSE_SPEC {
364    #[inline(always)]
365    fn reset_value() -> Self::Ux {
366        0
367    }
368}