mimxrt685s_pac/usbhsdcd/
status.rs1#[doc = "Register `STATUS` reader"]
2pub type R = crate::R<StatusSpec>;
3#[doc = "Charger Detection Sequence Results\n\nValue on reset: 0"]
4#[cfg_attr(feature = "defmt", derive(defmt::Format))]
5#[derive(Clone, Copy, Debug, PartialEq, Eq)]
6#[repr(u8)]
7pub enum SeqRes {
8 #[doc = "0: No results to report."]
9 NoResult = 0,
10 #[doc = "1: Attached to an SDP. Must comply with USB 2.0 by drawing only 2.5 mA (max) until connected."]
11 ConnSdp = 1,
12 #[doc = "2: Attached to a charging port. The exact meaning depends on bit 18 (value 0: Attached to either a CDP or a DCP. The charger type detection has not completed. value 1: Attached to a CDP. The charger type detection has completed.)"]
13 ConnCp = 2,
14 #[doc = "3: Attached to a DCP."]
15 ConnDcp = 3,
16}
17impl From<SeqRes> for u8 {
18 #[inline(always)]
19 fn from(variant: SeqRes) -> Self {
20 variant as _
21 }
22}
23impl crate::FieldSpec for SeqRes {
24 type Ux = u8;
25}
26impl crate::IsEnum for SeqRes {}
27#[doc = "Field `SEQ_RES` reader - Charger Detection Sequence Results"]
28pub type SeqResR = crate::FieldReader<SeqRes>;
29impl SeqResR {
30 #[doc = "Get enumerated values variant"]
31 #[inline(always)]
32 pub const fn variant(&self) -> SeqRes {
33 match self.bits {
34 0 => SeqRes::NoResult,
35 1 => SeqRes::ConnSdp,
36 2 => SeqRes::ConnCp,
37 3 => SeqRes::ConnDcp,
38 _ => unreachable!(),
39 }
40 }
41 #[doc = "No results to report."]
42 #[inline(always)]
43 pub fn is_no_result(&self) -> bool {
44 *self == SeqRes::NoResult
45 }
46 #[doc = "Attached to an SDP. Must comply with USB 2.0 by drawing only 2.5 mA (max) until connected."]
47 #[inline(always)]
48 pub fn is_conn_sdp(&self) -> bool {
49 *self == SeqRes::ConnSdp
50 }
51 #[doc = "Attached to a charging port. The exact meaning depends on bit 18 (value 0: Attached to either a CDP or a DCP. The charger type detection has not completed. value 1: Attached to a CDP. The charger type detection has completed.)"]
52 #[inline(always)]
53 pub fn is_conn_cp(&self) -> bool {
54 *self == SeqRes::ConnCp
55 }
56 #[doc = "Attached to a DCP."]
57 #[inline(always)]
58 pub fn is_conn_dcp(&self) -> bool {
59 *self == SeqRes::ConnDcp
60 }
61}
62#[doc = "Charger Detection Sequence Status\n\nValue on reset: 0"]
63#[cfg_attr(feature = "defmt", derive(defmt::Format))]
64#[derive(Clone, Copy, Debug, PartialEq, Eq)]
65#[repr(u8)]
66pub enum SeqStat {
67 #[doc = "0: The module is either not enabled, or the module is enabled but the data pins have not yet been detected."]
68 NoDataPinConn = 0,
69 #[doc = "1: Data pin contact detection is complete."]
70 DataPinConn = 1,
71 #[doc = "2: Charging port detection is complete."]
72 CpDetDone = 2,
73 #[doc = "3: Charger type detection is complete."]
74 CtDetDone = 3,
75}
76impl From<SeqStat> for u8 {
77 #[inline(always)]
78 fn from(variant: SeqStat) -> Self {
79 variant as _
80 }
81}
82impl crate::FieldSpec for SeqStat {
83 type Ux = u8;
84}
85impl crate::IsEnum for SeqStat {}
86#[doc = "Field `SEQ_STAT` reader - Charger Detection Sequence Status"]
87pub type SeqStatR = crate::FieldReader<SeqStat>;
88impl SeqStatR {
89 #[doc = "Get enumerated values variant"]
90 #[inline(always)]
91 pub const fn variant(&self) -> SeqStat {
92 match self.bits {
93 0 => SeqStat::NoDataPinConn,
94 1 => SeqStat::DataPinConn,
95 2 => SeqStat::CpDetDone,
96 3 => SeqStat::CtDetDone,
97 _ => unreachable!(),
98 }
99 }
100 #[doc = "The module is either not enabled, or the module is enabled but the data pins have not yet been detected."]
101 #[inline(always)]
102 pub fn is_no_data_pin_conn(&self) -> bool {
103 *self == SeqStat::NoDataPinConn
104 }
105 #[doc = "Data pin contact detection is complete."]
106 #[inline(always)]
107 pub fn is_data_pin_conn(&self) -> bool {
108 *self == SeqStat::DataPinConn
109 }
110 #[doc = "Charging port detection is complete."]
111 #[inline(always)]
112 pub fn is_cp_det_done(&self) -> bool {
113 *self == SeqStat::CpDetDone
114 }
115 #[doc = "Charger type detection is complete."]
116 #[inline(always)]
117 pub fn is_ct_det_done(&self) -> bool {
118 *self == SeqStat::CtDetDone
119 }
120}
121#[doc = "Error Flag\n\nValue on reset: 0"]
122#[cfg_attr(feature = "defmt", derive(defmt::Format))]
123#[derive(Clone, Copy, Debug, PartialEq, Eq)]
124pub enum Err {
125 #[doc = "0: No sequence errors."]
126 NoSeqErr = 0,
127 #[doc = "1: Error in the detection sequence. See the SEQ_STAT field to determine the phase in which the error occurred."]
128 SeqErr = 1,
129}
130impl From<Err> for bool {
131 #[inline(always)]
132 fn from(variant: Err) -> Self {
133 variant as u8 != 0
134 }
135}
136#[doc = "Field `ERR` reader - Error Flag"]
137pub type ErrR = crate::BitReader<Err>;
138impl ErrR {
139 #[doc = "Get enumerated values variant"]
140 #[inline(always)]
141 pub const fn variant(&self) -> Err {
142 match self.bits {
143 false => Err::NoSeqErr,
144 true => Err::SeqErr,
145 }
146 }
147 #[doc = "No sequence errors."]
148 #[inline(always)]
149 pub fn is_no_seq_err(&self) -> bool {
150 *self == Err::NoSeqErr
151 }
152 #[doc = "Error in the detection sequence. See the SEQ_STAT field to determine the phase in which the error occurred."]
153 #[inline(always)]
154 pub fn is_seq_err(&self) -> bool {
155 *self == Err::SeqErr
156 }
157}
158#[doc = "Timeout Flag\n\nValue on reset: 0"]
159#[cfg_attr(feature = "defmt", derive(defmt::Format))]
160#[derive(Clone, Copy, Debug, PartialEq, Eq)]
161pub enum To {
162 #[doc = "0: The detection sequence has not been running for over 1 s."]
163 NoTimeout = 0,
164 #[doc = "1: It has been over 1 s since the data pin contact was detected and debounced."]
165 Timeout = 1,
166}
167impl From<To> for bool {
168 #[inline(always)]
169 fn from(variant: To) -> Self {
170 variant as u8 != 0
171 }
172}
173#[doc = "Field `TO` reader - Timeout Flag"]
174pub type ToR = crate::BitReader<To>;
175impl ToR {
176 #[doc = "Get enumerated values variant"]
177 #[inline(always)]
178 pub const fn variant(&self) -> To {
179 match self.bits {
180 false => To::NoTimeout,
181 true => To::Timeout,
182 }
183 }
184 #[doc = "The detection sequence has not been running for over 1 s."]
185 #[inline(always)]
186 pub fn is_no_timeout(&self) -> bool {
187 *self == To::NoTimeout
188 }
189 #[doc = "It has been over 1 s since the data pin contact was detected and debounced."]
190 #[inline(always)]
191 pub fn is_timeout(&self) -> bool {
192 *self == To::Timeout
193 }
194}
195#[doc = "Active Status Indicator\n\nValue on reset: 0"]
196#[cfg_attr(feature = "defmt", derive(defmt::Format))]
197#[derive(Clone, Copy, Debug, PartialEq, Eq)]
198pub enum Active {
199 #[doc = "0: The sequence is not running."]
200 SeqNotRunning = 0,
201 #[doc = "1: The sequence is running."]
202 SeqRunning = 1,
203}
204impl From<Active> for bool {
205 #[inline(always)]
206 fn from(variant: Active) -> Self {
207 variant as u8 != 0
208 }
209}
210#[doc = "Field `ACTIVE` reader - Active Status Indicator"]
211pub type ActiveR = crate::BitReader<Active>;
212impl ActiveR {
213 #[doc = "Get enumerated values variant"]
214 #[inline(always)]
215 pub const fn variant(&self) -> Active {
216 match self.bits {
217 false => Active::SeqNotRunning,
218 true => Active::SeqRunning,
219 }
220 }
221 #[doc = "The sequence is not running."]
222 #[inline(always)]
223 pub fn is_seq_not_running(&self) -> bool {
224 *self == Active::SeqNotRunning
225 }
226 #[doc = "The sequence is running."]
227 #[inline(always)]
228 pub fn is_seq_running(&self) -> bool {
229 *self == Active::SeqRunning
230 }
231}
232impl R {
233 #[doc = "Bits 16:17 - Charger Detection Sequence Results"]
234 #[inline(always)]
235 pub fn seq_res(&self) -> SeqResR {
236 SeqResR::new(((self.bits >> 16) & 3) as u8)
237 }
238 #[doc = "Bits 18:19 - Charger Detection Sequence Status"]
239 #[inline(always)]
240 pub fn seq_stat(&self) -> SeqStatR {
241 SeqStatR::new(((self.bits >> 18) & 3) as u8)
242 }
243 #[doc = "Bit 20 - Error Flag"]
244 #[inline(always)]
245 pub fn err(&self) -> ErrR {
246 ErrR::new(((self.bits >> 20) & 1) != 0)
247 }
248 #[doc = "Bit 21 - Timeout Flag"]
249 #[inline(always)]
250 pub fn to(&self) -> ToR {
251 ToR::new(((self.bits >> 21) & 1) != 0)
252 }
253 #[doc = "Bit 22 - Active Status Indicator"]
254 #[inline(always)]
255 pub fn active(&self) -> ActiveR {
256 ActiveR::new(((self.bits >> 22) & 1) != 0)
257 }
258}
259#[cfg(feature = "debug")]
260impl core::fmt::Debug for R {
261 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
262 f.debug_struct("STATUS")
263 .field("seq_res", &self.seq_res())
264 .field("seq_stat", &self.seq_stat())
265 .field("err", &self.err())
266 .field("to", &self.to())
267 .field("active", &self.active())
268 .finish()
269 }
270}
271#[doc = "Status register\n\nYou can [`read`](crate::Reg::read) this register and get [`status::R`](R). See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
272pub struct StatusSpec;
273impl crate::RegisterSpec for StatusSpec {
274 type Ux = u32;
275}
276#[doc = "`read()` method returns [`status::R`](R) reader structure"]
277impl crate::Readable for StatusSpec {}
278#[doc = "`reset()` method sets STATUS to value 0"]
279impl crate::Resettable for StatusSpec {
280 const RESET_VALUE: u32 = 0;
281}