atsam4ls8a_pac/usbc/
usbfsm.rs1#[doc = "Register `USBFSM` reader"]
2pub struct R(crate::R<USBFSM_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<USBFSM_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<USBFSM_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<USBFSM_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Field `DRDSTATE` reader - DualRoleDevice state"]
17pub type DRDSTATE_R = crate::FieldReader<u8, DRDSTATESELECT_A>;
18#[doc = "DualRoleDevice state\n\nValue on reset: 9"]
19#[derive(Clone, Copy, Debug, PartialEq, Eq)]
20#[repr(u8)]
21pub enum DRDSTATESELECT_A {
22 #[doc = "0: `0`"]
23 A_IDLE = 0,
24 #[doc = "1: `1`"]
25 A_WAIT_VRISE = 1,
26 #[doc = "2: `10`"]
27 A_WAIT_BCON = 2,
28 #[doc = "3: `11`"]
29 A_HOST = 3,
30 #[doc = "4: `100`"]
31 A_SUSPEND = 4,
32 #[doc = "5: `101`"]
33 A_PERIPHERAL = 5,
34 #[doc = "6: `110`"]
35 A_WAIT_VFALL = 6,
36 #[doc = "7: `111`"]
37 A_VBUS_ERR = 7,
38 #[doc = "8: `1000`"]
39 A_WAIT_DISCHARGE = 8,
40 #[doc = "9: `1001`"]
41 B_IDLE = 9,
42 #[doc = "10: `1010`"]
43 B_PERIPHERAL = 10,
44 #[doc = "11: `1011`"]
45 B_WAIT_BEGIN_HNP = 11,
46 #[doc = "12: `1100`"]
47 B_WAIT_DISCHARGE = 12,
48 #[doc = "13: `1101`"]
49 B_WAIT_ACON = 13,
50 #[doc = "14: `1110`"]
51 B_HOST = 14,
52 #[doc = "15: `1111`"]
53 B_SRP_INIT = 15,
54}
55impl From<DRDSTATESELECT_A> for u8 {
56 #[inline(always)]
57 fn from(variant: DRDSTATESELECT_A) -> Self {
58 variant as _
59 }
60}
61impl DRDSTATE_R {
62 #[doc = "Get enumerated values variant"]
63 #[inline(always)]
64 pub fn variant(&self) -> DRDSTATESELECT_A {
65 match self.bits {
66 0 => DRDSTATESELECT_A::A_IDLE,
67 1 => DRDSTATESELECT_A::A_WAIT_VRISE,
68 2 => DRDSTATESELECT_A::A_WAIT_BCON,
69 3 => DRDSTATESELECT_A::A_HOST,
70 4 => DRDSTATESELECT_A::A_SUSPEND,
71 5 => DRDSTATESELECT_A::A_PERIPHERAL,
72 6 => DRDSTATESELECT_A::A_WAIT_VFALL,
73 7 => DRDSTATESELECT_A::A_VBUS_ERR,
74 8 => DRDSTATESELECT_A::A_WAIT_DISCHARGE,
75 9 => DRDSTATESELECT_A::B_IDLE,
76 10 => DRDSTATESELECT_A::B_PERIPHERAL,
77 11 => DRDSTATESELECT_A::B_WAIT_BEGIN_HNP,
78 12 => DRDSTATESELECT_A::B_WAIT_DISCHARGE,
79 13 => DRDSTATESELECT_A::B_WAIT_ACON,
80 14 => DRDSTATESELECT_A::B_HOST,
81 15 => DRDSTATESELECT_A::B_SRP_INIT,
82 _ => unreachable!(),
83 }
84 }
85 #[doc = "Checks if the value of the field is `A_IDLE`"]
86 #[inline(always)]
87 pub fn is_a_idle(&self) -> bool {
88 *self == DRDSTATESELECT_A::A_IDLE
89 }
90 #[doc = "Checks if the value of the field is `A_WAIT_VRISE`"]
91 #[inline(always)]
92 pub fn is_a_wait_vrise(&self) -> bool {
93 *self == DRDSTATESELECT_A::A_WAIT_VRISE
94 }
95 #[doc = "Checks if the value of the field is `A_WAIT_BCON`"]
96 #[inline(always)]
97 pub fn is_a_wait_bcon(&self) -> bool {
98 *self == DRDSTATESELECT_A::A_WAIT_BCON
99 }
100 #[doc = "Checks if the value of the field is `A_HOST`"]
101 #[inline(always)]
102 pub fn is_a_host(&self) -> bool {
103 *self == DRDSTATESELECT_A::A_HOST
104 }
105 #[doc = "Checks if the value of the field is `A_SUSPEND`"]
106 #[inline(always)]
107 pub fn is_a_suspend(&self) -> bool {
108 *self == DRDSTATESELECT_A::A_SUSPEND
109 }
110 #[doc = "Checks if the value of the field is `A_PERIPHERAL`"]
111 #[inline(always)]
112 pub fn is_a_peripheral(&self) -> bool {
113 *self == DRDSTATESELECT_A::A_PERIPHERAL
114 }
115 #[doc = "Checks if the value of the field is `A_WAIT_VFALL`"]
116 #[inline(always)]
117 pub fn is_a_wait_vfall(&self) -> bool {
118 *self == DRDSTATESELECT_A::A_WAIT_VFALL
119 }
120 #[doc = "Checks if the value of the field is `A_VBUS_ERR`"]
121 #[inline(always)]
122 pub fn is_a_vbus_err(&self) -> bool {
123 *self == DRDSTATESELECT_A::A_VBUS_ERR
124 }
125 #[doc = "Checks if the value of the field is `A_WAIT_DISCHARGE`"]
126 #[inline(always)]
127 pub fn is_a_wait_discharge(&self) -> bool {
128 *self == DRDSTATESELECT_A::A_WAIT_DISCHARGE
129 }
130 #[doc = "Checks if the value of the field is `B_IDLE`"]
131 #[inline(always)]
132 pub fn is_b_idle(&self) -> bool {
133 *self == DRDSTATESELECT_A::B_IDLE
134 }
135 #[doc = "Checks if the value of the field is `B_PERIPHERAL`"]
136 #[inline(always)]
137 pub fn is_b_peripheral(&self) -> bool {
138 *self == DRDSTATESELECT_A::B_PERIPHERAL
139 }
140 #[doc = "Checks if the value of the field is `B_WAIT_BEGIN_HNP`"]
141 #[inline(always)]
142 pub fn is_b_wait_begin_hnp(&self) -> bool {
143 *self == DRDSTATESELECT_A::B_WAIT_BEGIN_HNP
144 }
145 #[doc = "Checks if the value of the field is `B_WAIT_DISCHARGE`"]
146 #[inline(always)]
147 pub fn is_b_wait_discharge(&self) -> bool {
148 *self == DRDSTATESELECT_A::B_WAIT_DISCHARGE
149 }
150 #[doc = "Checks if the value of the field is `B_WAIT_ACON`"]
151 #[inline(always)]
152 pub fn is_b_wait_acon(&self) -> bool {
153 *self == DRDSTATESELECT_A::B_WAIT_ACON
154 }
155 #[doc = "Checks if the value of the field is `B_HOST`"]
156 #[inline(always)]
157 pub fn is_b_host(&self) -> bool {
158 *self == DRDSTATESELECT_A::B_HOST
159 }
160 #[doc = "Checks if the value of the field is `B_SRP_INIT`"]
161 #[inline(always)]
162 pub fn is_b_srp_init(&self) -> bool {
163 *self == DRDSTATESELECT_A::B_SRP_INIT
164 }
165}
166impl R {
167 #[doc = "Bits 0:3 - DualRoleDevice state"]
168 #[inline(always)]
169 pub fn drdstate(&self) -> DRDSTATE_R {
170 DRDSTATE_R::new((self.bits & 0x0f) as u8)
171 }
172}
173#[doc = "USB internal finite state machine\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [usbfsm](index.html) module"]
174pub struct USBFSM_SPEC;
175impl crate::RegisterSpec for USBFSM_SPEC {
176 type Ux = u32;
177}
178#[doc = "`read()` method returns [usbfsm::R](R) reader structure"]
179impl crate::Readable for USBFSM_SPEC {
180 type Reader = R;
181}
182#[doc = "`reset()` method sets USBFSM to value 0x09"]
183impl crate::Resettable for USBFSM_SPEC {
184 const RESET_VALUE: Self::Ux = 0x09;
185}