Skip to main content

mcxa_pac/usb0/
errstat.rs

1#[doc = "Register `ERRSTAT` reader"]
2pub type R = crate::R<ErrstatSpec>;
3#[doc = "Register `ERRSTAT` writer"]
4pub type W = crate::W<ErrstatSpec>;
5#[doc = "PID Error Flag\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum Piderr {
9    #[doc = "0: Did not fail"]
10    IntNo = 0,
11    #[doc = "1: Failed"]
12    IntYes = 1,
13}
14impl From<Piderr> for bool {
15    #[inline(always)]
16    fn from(variant: Piderr) -> Self {
17        variant as u8 != 0
18    }
19}
20#[doc = "Field `PIDERR` reader - PID Error Flag"]
21pub type PiderrR = crate::BitReader<Piderr>;
22impl PiderrR {
23    #[doc = "Get enumerated values variant"]
24    #[inline(always)]
25    pub const fn variant(&self) -> Piderr {
26        match self.bits {
27            false => Piderr::IntNo,
28            true => Piderr::IntYes,
29        }
30    }
31    #[doc = "Did not fail"]
32    #[inline(always)]
33    pub fn is_int_no(&self) -> bool {
34        *self == Piderr::IntNo
35    }
36    #[doc = "Failed"]
37    #[inline(always)]
38    pub fn is_int_yes(&self) -> bool {
39        *self == Piderr::IntYes
40    }
41}
42#[doc = "Field `PIDERR` writer - PID Error Flag"]
43pub type PiderrW<'a, REG> = crate::BitWriter1C<'a, REG, Piderr>;
44impl<'a, REG> PiderrW<'a, REG>
45where
46    REG: crate::Writable + crate::RegisterSpec,
47{
48    #[doc = "Did not fail"]
49    #[inline(always)]
50    pub fn int_no(self) -> &'a mut crate::W<REG> {
51        self.variant(Piderr::IntNo)
52    }
53    #[doc = "Failed"]
54    #[inline(always)]
55    pub fn int_yes(self) -> &'a mut crate::W<REG> {
56        self.variant(Piderr::IntYes)
57    }
58}
59#[doc = "CRC5 Error or End of Frame Error Flag\n\nValue on reset: 0"]
60#[cfg_attr(feature = "defmt", derive(defmt::Format))]
61#[derive(Clone, Copy, Debug, PartialEq, Eq)]
62pub enum Crc5eof {
63    #[doc = "0: Interrupt did not occur"]
64    IntNo = 0,
65    #[doc = "1: Interrupt occurred"]
66    IntYes = 1,
67}
68impl From<Crc5eof> for bool {
69    #[inline(always)]
70    fn from(variant: Crc5eof) -> Self {
71        variant as u8 != 0
72    }
73}
74#[doc = "Field `CRC5EOF` reader - CRC5 Error or End of Frame Error Flag"]
75pub type Crc5eofR = crate::BitReader<Crc5eof>;
76impl Crc5eofR {
77    #[doc = "Get enumerated values variant"]
78    #[inline(always)]
79    pub const fn variant(&self) -> Crc5eof {
80        match self.bits {
81            false => Crc5eof::IntNo,
82            true => Crc5eof::IntYes,
83        }
84    }
85    #[doc = "Interrupt did not occur"]
86    #[inline(always)]
87    pub fn is_int_no(&self) -> bool {
88        *self == Crc5eof::IntNo
89    }
90    #[doc = "Interrupt occurred"]
91    #[inline(always)]
92    pub fn is_int_yes(&self) -> bool {
93        *self == Crc5eof::IntYes
94    }
95}
96#[doc = "Field `CRC5EOF` writer - CRC5 Error or End of Frame Error Flag"]
97pub type Crc5eofW<'a, REG> = crate::BitWriter1C<'a, REG, Crc5eof>;
98impl<'a, REG> Crc5eofW<'a, REG>
99where
100    REG: crate::Writable + crate::RegisterSpec,
101{
102    #[doc = "Interrupt did not occur"]
103    #[inline(always)]
104    pub fn int_no(self) -> &'a mut crate::W<REG> {
105        self.variant(Crc5eof::IntNo)
106    }
107    #[doc = "Interrupt occurred"]
108    #[inline(always)]
109    pub fn int_yes(self) -> &'a mut crate::W<REG> {
110        self.variant(Crc5eof::IntYes)
111    }
112}
113#[doc = "CRC16 Error Flag\n\nValue on reset: 0"]
114#[cfg_attr(feature = "defmt", derive(defmt::Format))]
115#[derive(Clone, Copy, Debug, PartialEq, Eq)]
116pub enum Crc16 {
117    #[doc = "0: Not rejected"]
118    IntNo = 0,
119    #[doc = "1: Rejected"]
120    IntYes = 1,
121}
122impl From<Crc16> for bool {
123    #[inline(always)]
124    fn from(variant: Crc16) -> Self {
125        variant as u8 != 0
126    }
127}
128#[doc = "Field `CRC16` reader - CRC16 Error Flag"]
129pub type Crc16R = crate::BitReader<Crc16>;
130impl Crc16R {
131    #[doc = "Get enumerated values variant"]
132    #[inline(always)]
133    pub const fn variant(&self) -> Crc16 {
134        match self.bits {
135            false => Crc16::IntNo,
136            true => Crc16::IntYes,
137        }
138    }
139    #[doc = "Not rejected"]
140    #[inline(always)]
141    pub fn is_int_no(&self) -> bool {
142        *self == Crc16::IntNo
143    }
144    #[doc = "Rejected"]
145    #[inline(always)]
146    pub fn is_int_yes(&self) -> bool {
147        *self == Crc16::IntYes
148    }
149}
150#[doc = "Field `CRC16` writer - CRC16 Error Flag"]
151pub type Crc16W<'a, REG> = crate::BitWriter1C<'a, REG, Crc16>;
152impl<'a, REG> Crc16W<'a, REG>
153where
154    REG: crate::Writable + crate::RegisterSpec,
155{
156    #[doc = "Not rejected"]
157    #[inline(always)]
158    pub fn int_no(self) -> &'a mut crate::W<REG> {
159        self.variant(Crc16::IntNo)
160    }
161    #[doc = "Rejected"]
162    #[inline(always)]
163    pub fn int_yes(self) -> &'a mut crate::W<REG> {
164        self.variant(Crc16::IntYes)
165    }
166}
167#[doc = "Data Field Not 8 Bits Flag\n\nValue on reset: 0"]
168#[cfg_attr(feature = "defmt", derive(defmt::Format))]
169#[derive(Clone, Copy, Debug, PartialEq, Eq)]
170pub enum Dfn8 {
171    #[doc = "0: Integer number of bytes"]
172    IntNo = 0,
173    #[doc = "1: Not an integer number of bytes"]
174    IntYes = 1,
175}
176impl From<Dfn8> for bool {
177    #[inline(always)]
178    fn from(variant: Dfn8) -> Self {
179        variant as u8 != 0
180    }
181}
182#[doc = "Field `DFN8` reader - Data Field Not 8 Bits Flag"]
183pub type Dfn8R = crate::BitReader<Dfn8>;
184impl Dfn8R {
185    #[doc = "Get enumerated values variant"]
186    #[inline(always)]
187    pub const fn variant(&self) -> Dfn8 {
188        match self.bits {
189            false => Dfn8::IntNo,
190            true => Dfn8::IntYes,
191        }
192    }
193    #[doc = "Integer number of bytes"]
194    #[inline(always)]
195    pub fn is_int_no(&self) -> bool {
196        *self == Dfn8::IntNo
197    }
198    #[doc = "Not an integer number of bytes"]
199    #[inline(always)]
200    pub fn is_int_yes(&self) -> bool {
201        *self == Dfn8::IntYes
202    }
203}
204#[doc = "Field `DFN8` writer - Data Field Not 8 Bits Flag"]
205pub type Dfn8W<'a, REG> = crate::BitWriter1C<'a, REG, Dfn8>;
206impl<'a, REG> Dfn8W<'a, REG>
207where
208    REG: crate::Writable + crate::RegisterSpec,
209{
210    #[doc = "Integer number of bytes"]
211    #[inline(always)]
212    pub fn int_no(self) -> &'a mut crate::W<REG> {
213        self.variant(Dfn8::IntNo)
214    }
215    #[doc = "Not an integer number of bytes"]
216    #[inline(always)]
217    pub fn int_yes(self) -> &'a mut crate::W<REG> {
218        self.variant(Dfn8::IntYes)
219    }
220}
221#[doc = "Bus Turnaround Timeout Error Flag\n\nValue on reset: 0"]
222#[cfg_attr(feature = "defmt", derive(defmt::Format))]
223#[derive(Clone, Copy, Debug, PartialEq, Eq)]
224pub enum Btoerr {
225    #[doc = "0: Not timed out"]
226    IntNo = 0,
227    #[doc = "1: Timed out"]
228    IntYes = 1,
229}
230impl From<Btoerr> for bool {
231    #[inline(always)]
232    fn from(variant: Btoerr) -> Self {
233        variant as u8 != 0
234    }
235}
236#[doc = "Field `BTOERR` reader - Bus Turnaround Timeout Error Flag"]
237pub type BtoerrR = crate::BitReader<Btoerr>;
238impl BtoerrR {
239    #[doc = "Get enumerated values variant"]
240    #[inline(always)]
241    pub const fn variant(&self) -> Btoerr {
242        match self.bits {
243            false => Btoerr::IntNo,
244            true => Btoerr::IntYes,
245        }
246    }
247    #[doc = "Not timed out"]
248    #[inline(always)]
249    pub fn is_int_no(&self) -> bool {
250        *self == Btoerr::IntNo
251    }
252    #[doc = "Timed out"]
253    #[inline(always)]
254    pub fn is_int_yes(&self) -> bool {
255        *self == Btoerr::IntYes
256    }
257}
258#[doc = "Field `BTOERR` writer - Bus Turnaround Timeout Error Flag"]
259pub type BtoerrW<'a, REG> = crate::BitWriter1C<'a, REG, Btoerr>;
260impl<'a, REG> BtoerrW<'a, REG>
261where
262    REG: crate::Writable + crate::RegisterSpec,
263{
264    #[doc = "Not timed out"]
265    #[inline(always)]
266    pub fn int_no(self) -> &'a mut crate::W<REG> {
267        self.variant(Btoerr::IntNo)
268    }
269    #[doc = "Timed out"]
270    #[inline(always)]
271    pub fn int_yes(self) -> &'a mut crate::W<REG> {
272        self.variant(Btoerr::IntYes)
273    }
274}
275#[doc = "DMA Access Error Flag\n\nValue on reset: 0"]
276#[cfg_attr(feature = "defmt", derive(defmt::Format))]
277#[derive(Clone, Copy, Debug, PartialEq, Eq)]
278pub enum Dmaerr {
279    #[doc = "0: Interrupt did not occur"]
280    IntNo = 0,
281    #[doc = "1: Interrupt occurred"]
282    IntYes = 1,
283}
284impl From<Dmaerr> for bool {
285    #[inline(always)]
286    fn from(variant: Dmaerr) -> Self {
287        variant as u8 != 0
288    }
289}
290#[doc = "Field `DMAERR` reader - DMA Access Error Flag"]
291pub type DmaerrR = crate::BitReader<Dmaerr>;
292impl DmaerrR {
293    #[doc = "Get enumerated values variant"]
294    #[inline(always)]
295    pub const fn variant(&self) -> Dmaerr {
296        match self.bits {
297            false => Dmaerr::IntNo,
298            true => Dmaerr::IntYes,
299        }
300    }
301    #[doc = "Interrupt did not occur"]
302    #[inline(always)]
303    pub fn is_int_no(&self) -> bool {
304        *self == Dmaerr::IntNo
305    }
306    #[doc = "Interrupt occurred"]
307    #[inline(always)]
308    pub fn is_int_yes(&self) -> bool {
309        *self == Dmaerr::IntYes
310    }
311}
312#[doc = "Field `DMAERR` writer - DMA Access Error Flag"]
313pub type DmaerrW<'a, REG> = crate::BitWriter1C<'a, REG, Dmaerr>;
314impl<'a, REG> DmaerrW<'a, REG>
315where
316    REG: crate::Writable + crate::RegisterSpec,
317{
318    #[doc = "Interrupt did not occur"]
319    #[inline(always)]
320    pub fn int_no(self) -> &'a mut crate::W<REG> {
321        self.variant(Dmaerr::IntNo)
322    }
323    #[doc = "Interrupt occurred"]
324    #[inline(always)]
325    pub fn int_yes(self) -> &'a mut crate::W<REG> {
326        self.variant(Dmaerr::IntYes)
327    }
328}
329#[doc = "BD Unavailable Error Flag\n\nValue on reset: 0"]
330#[cfg_attr(feature = "defmt", derive(defmt::Format))]
331#[derive(Clone, Copy, Debug, PartialEq, Eq)]
332pub enum Ownerr {
333    #[doc = "0: Interrupt did not occur"]
334    IntNo = 0,
335    #[doc = "1: Interrupt occurred"]
336    IntYes = 1,
337}
338impl From<Ownerr> for bool {
339    #[inline(always)]
340    fn from(variant: Ownerr) -> Self {
341        variant as u8 != 0
342    }
343}
344#[doc = "Field `OWNERR` reader - BD Unavailable Error Flag"]
345pub type OwnerrR = crate::BitReader<Ownerr>;
346impl OwnerrR {
347    #[doc = "Get enumerated values variant"]
348    #[inline(always)]
349    pub const fn variant(&self) -> Ownerr {
350        match self.bits {
351            false => Ownerr::IntNo,
352            true => Ownerr::IntYes,
353        }
354    }
355    #[doc = "Interrupt did not occur"]
356    #[inline(always)]
357    pub fn is_int_no(&self) -> bool {
358        *self == Ownerr::IntNo
359    }
360    #[doc = "Interrupt occurred"]
361    #[inline(always)]
362    pub fn is_int_yes(&self) -> bool {
363        *self == Ownerr::IntYes
364    }
365}
366#[doc = "Field `OWNERR` writer - BD Unavailable Error Flag"]
367pub type OwnerrW<'a, REG> = crate::BitWriter1C<'a, REG, Ownerr>;
368impl<'a, REG> OwnerrW<'a, REG>
369where
370    REG: crate::Writable + crate::RegisterSpec,
371{
372    #[doc = "Interrupt did not occur"]
373    #[inline(always)]
374    pub fn int_no(self) -> &'a mut crate::W<REG> {
375        self.variant(Ownerr::IntNo)
376    }
377    #[doc = "Interrupt occurred"]
378    #[inline(always)]
379    pub fn int_yes(self) -> &'a mut crate::W<REG> {
380        self.variant(Ownerr::IntYes)
381    }
382}
383#[doc = "Bit Stuff Error Flag\n\nValue on reset: 0"]
384#[cfg_attr(feature = "defmt", derive(defmt::Format))]
385#[derive(Clone, Copy, Debug, PartialEq, Eq)]
386pub enum Btserr {
387    #[doc = "0: Packet not rejected due to the error"]
388    IntNo = 0,
389    #[doc = "1: Packet rejected due to the error"]
390    IntYes = 1,
391}
392impl From<Btserr> for bool {
393    #[inline(always)]
394    fn from(variant: Btserr) -> Self {
395        variant as u8 != 0
396    }
397}
398#[doc = "Field `BTSERR` reader - Bit Stuff Error Flag"]
399pub type BtserrR = crate::BitReader<Btserr>;
400impl BtserrR {
401    #[doc = "Get enumerated values variant"]
402    #[inline(always)]
403    pub const fn variant(&self) -> Btserr {
404        match self.bits {
405            false => Btserr::IntNo,
406            true => Btserr::IntYes,
407        }
408    }
409    #[doc = "Packet not rejected due to the error"]
410    #[inline(always)]
411    pub fn is_int_no(&self) -> bool {
412        *self == Btserr::IntNo
413    }
414    #[doc = "Packet rejected due to the error"]
415    #[inline(always)]
416    pub fn is_int_yes(&self) -> bool {
417        *self == Btserr::IntYes
418    }
419}
420#[doc = "Field `BTSERR` writer - Bit Stuff Error Flag"]
421pub type BtserrW<'a, REG> = crate::BitWriter1C<'a, REG, Btserr>;
422impl<'a, REG> BtserrW<'a, REG>
423where
424    REG: crate::Writable + crate::RegisterSpec,
425{
426    #[doc = "Packet not rejected due to the error"]
427    #[inline(always)]
428    pub fn int_no(self) -> &'a mut crate::W<REG> {
429        self.variant(Btserr::IntNo)
430    }
431    #[doc = "Packet rejected due to the error"]
432    #[inline(always)]
433    pub fn int_yes(self) -> &'a mut crate::W<REG> {
434        self.variant(Btserr::IntYes)
435    }
436}
437impl R {
438    #[doc = "Bit 0 - PID Error Flag"]
439    #[inline(always)]
440    pub fn piderr(&self) -> PiderrR {
441        PiderrR::new((self.bits & 1) != 0)
442    }
443    #[doc = "Bit 1 - CRC5 Error or End of Frame Error Flag"]
444    #[inline(always)]
445    pub fn crc5eof(&self) -> Crc5eofR {
446        Crc5eofR::new(((self.bits >> 1) & 1) != 0)
447    }
448    #[doc = "Bit 2 - CRC16 Error Flag"]
449    #[inline(always)]
450    pub fn crc16(&self) -> Crc16R {
451        Crc16R::new(((self.bits >> 2) & 1) != 0)
452    }
453    #[doc = "Bit 3 - Data Field Not 8 Bits Flag"]
454    #[inline(always)]
455    pub fn dfn8(&self) -> Dfn8R {
456        Dfn8R::new(((self.bits >> 3) & 1) != 0)
457    }
458    #[doc = "Bit 4 - Bus Turnaround Timeout Error Flag"]
459    #[inline(always)]
460    pub fn btoerr(&self) -> BtoerrR {
461        BtoerrR::new(((self.bits >> 4) & 1) != 0)
462    }
463    #[doc = "Bit 5 - DMA Access Error Flag"]
464    #[inline(always)]
465    pub fn dmaerr(&self) -> DmaerrR {
466        DmaerrR::new(((self.bits >> 5) & 1) != 0)
467    }
468    #[doc = "Bit 6 - BD Unavailable Error Flag"]
469    #[inline(always)]
470    pub fn ownerr(&self) -> OwnerrR {
471        OwnerrR::new(((self.bits >> 6) & 1) != 0)
472    }
473    #[doc = "Bit 7 - Bit Stuff Error Flag"]
474    #[inline(always)]
475    pub fn btserr(&self) -> BtserrR {
476        BtserrR::new(((self.bits >> 7) & 1) != 0)
477    }
478}
479#[cfg(feature = "debug")]
480impl core::fmt::Debug for R {
481    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
482        f.debug_struct("ERRSTAT")
483            .field("piderr", &self.piderr())
484            .field("crc5eof", &self.crc5eof())
485            .field("crc16", &self.crc16())
486            .field("dfn8", &self.dfn8())
487            .field("btoerr", &self.btoerr())
488            .field("dmaerr", &self.dmaerr())
489            .field("ownerr", &self.ownerr())
490            .field("btserr", &self.btserr())
491            .finish()
492    }
493}
494impl W {
495    #[doc = "Bit 0 - PID Error Flag"]
496    #[inline(always)]
497    pub fn piderr(&mut self) -> PiderrW<'_, ErrstatSpec> {
498        PiderrW::new(self, 0)
499    }
500    #[doc = "Bit 1 - CRC5 Error or End of Frame Error Flag"]
501    #[inline(always)]
502    pub fn crc5eof(&mut self) -> Crc5eofW<'_, ErrstatSpec> {
503        Crc5eofW::new(self, 1)
504    }
505    #[doc = "Bit 2 - CRC16 Error Flag"]
506    #[inline(always)]
507    pub fn crc16(&mut self) -> Crc16W<'_, ErrstatSpec> {
508        Crc16W::new(self, 2)
509    }
510    #[doc = "Bit 3 - Data Field Not 8 Bits Flag"]
511    #[inline(always)]
512    pub fn dfn8(&mut self) -> Dfn8W<'_, ErrstatSpec> {
513        Dfn8W::new(self, 3)
514    }
515    #[doc = "Bit 4 - Bus Turnaround Timeout Error Flag"]
516    #[inline(always)]
517    pub fn btoerr(&mut self) -> BtoerrW<'_, ErrstatSpec> {
518        BtoerrW::new(self, 4)
519    }
520    #[doc = "Bit 5 - DMA Access Error Flag"]
521    #[inline(always)]
522    pub fn dmaerr(&mut self) -> DmaerrW<'_, ErrstatSpec> {
523        DmaerrW::new(self, 5)
524    }
525    #[doc = "Bit 6 - BD Unavailable Error Flag"]
526    #[inline(always)]
527    pub fn ownerr(&mut self) -> OwnerrW<'_, ErrstatSpec> {
528        OwnerrW::new(self, 6)
529    }
530    #[doc = "Bit 7 - Bit Stuff Error Flag"]
531    #[inline(always)]
532    pub fn btserr(&mut self) -> BtserrW<'_, ErrstatSpec> {
533        BtserrW::new(self, 7)
534    }
535}
536#[doc = "Error Interrupt Status\n\nYou can [`read`](crate::Reg::read) this register and get [`errstat::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`errstat::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
537pub struct ErrstatSpec;
538impl crate::RegisterSpec for ErrstatSpec {
539    type Ux = u8;
540}
541#[doc = "`read()` method returns [`errstat::R`](R) reader structure"]
542impl crate::Readable for ErrstatSpec {}
543#[doc = "`write(|w| ..)` method takes [`errstat::W`](W) writer structure"]
544impl crate::Writable for ErrstatSpec {
545    type Safety = crate::Unsafe;
546    const ONE_TO_MODIFY_FIELDS_BITMAP: u8 = 0xff;
547}
548#[doc = "`reset()` method sets ERRSTAT to value 0"]
549impl crate::Resettable for ErrstatSpec {}