atsamd51p/usb/device/
status.rs

1#[doc = "Register `STATUS` reader"]
2pub type R = crate::R<StatusSpec>;
3#[doc = "Speed Status\n\nValue on reset: 0"]
4#[derive(Clone, Copy, Debug, PartialEq, Eq)]
5#[repr(u8)]
6pub enum Speedselect {
7    #[doc = "0: Full-speed mode"]
8    Fs = 0,
9    #[doc = "1: Low-speed mode"]
10    Ls = 1,
11}
12impl From<Speedselect> for u8 {
13    #[inline(always)]
14    fn from(variant: Speedselect) -> Self {
15        variant as _
16    }
17}
18impl crate::FieldSpec for Speedselect {
19    type Ux = u8;
20}
21impl crate::IsEnum for Speedselect {}
22#[doc = "Field `SPEED` reader - Speed Status"]
23pub type SpeedR = crate::FieldReader<Speedselect>;
24impl SpeedR {
25    #[doc = "Get enumerated values variant"]
26    #[inline(always)]
27    pub const fn variant(&self) -> Option<Speedselect> {
28        match self.bits {
29            0 => Some(Speedselect::Fs),
30            1 => Some(Speedselect::Ls),
31            _ => None,
32        }
33    }
34    #[doc = "Full-speed mode"]
35    #[inline(always)]
36    pub fn is_fs(&self) -> bool {
37        *self == Speedselect::Fs
38    }
39    #[doc = "Low-speed mode"]
40    #[inline(always)]
41    pub fn is_ls(&self) -> bool {
42        *self == Speedselect::Ls
43    }
44}
45#[doc = "USB Line State Status\n\nValue on reset: 1"]
46#[derive(Clone, Copy, Debug, PartialEq, Eq)]
47#[repr(u8)]
48pub enum Linestateselect {
49    #[doc = "0: SE0/RESET"]
50    Se0reset = 0,
51    #[doc = "1: FS-J or LS-K State"]
52    Fsjlsk = 1,
53    #[doc = "2: FS-K or LS-J State"]
54    Fsklsj = 2,
55}
56impl From<Linestateselect> for u8 {
57    #[inline(always)]
58    fn from(variant: Linestateselect) -> Self {
59        variant as _
60    }
61}
62impl crate::FieldSpec for Linestateselect {
63    type Ux = u8;
64}
65impl crate::IsEnum for Linestateselect {}
66#[doc = "Field `LINESTATE` reader - USB Line State Status"]
67pub type LinestateR = crate::FieldReader<Linestateselect>;
68impl LinestateR {
69    #[doc = "Get enumerated values variant"]
70    #[inline(always)]
71    pub const fn variant(&self) -> Option<Linestateselect> {
72        match self.bits {
73            0 => Some(Linestateselect::Se0reset),
74            1 => Some(Linestateselect::Fsjlsk),
75            2 => Some(Linestateselect::Fsklsj),
76            _ => None,
77        }
78    }
79    #[doc = "SE0/RESET"]
80    #[inline(always)]
81    pub fn is_se0reset(&self) -> bool {
82        *self == Linestateselect::Se0reset
83    }
84    #[doc = "FS-J or LS-K State"]
85    #[inline(always)]
86    pub fn is_fsjlsk(&self) -> bool {
87        *self == Linestateselect::Fsjlsk
88    }
89    #[doc = "FS-K or LS-J State"]
90    #[inline(always)]
91    pub fn is_fsklsj(&self) -> bool {
92        *self == Linestateselect::Fsklsj
93    }
94}
95impl R {
96    #[doc = "Bits 2:3 - Speed Status"]
97    #[inline(always)]
98    pub fn speed(&self) -> SpeedR {
99        SpeedR::new((self.bits >> 2) & 3)
100    }
101    #[doc = "Bits 6:7 - USB Line State Status"]
102    #[inline(always)]
103    pub fn linestate(&self) -> LinestateR {
104        LinestateR::new((self.bits >> 6) & 3)
105    }
106}
107#[doc = "DEVICE Status\n\nYou can [`read`](crate::Reg::read) this register and get [`status::R`](R). See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
108pub struct StatusSpec;
109impl crate::RegisterSpec for StatusSpec {
110    type Ux = u8;
111}
112#[doc = "`read()` method returns [`status::R`](R) reader structure"]
113impl crate::Readable for StatusSpec {}
114#[doc = "`reset()` method sets STATUS to value 0x40"]
115impl crate::Resettable for StatusSpec {
116    const RESET_VALUE: u8 = 0x40;
117}