rp2040_pac/usbctrl_regs/
sie_status.rs

1#[doc = "Register `SIE_STATUS` reader"]
2pub type R = crate::R<SIE_STATUS_SPEC>;
3#[doc = "Register `SIE_STATUS` writer"]
4pub type W = crate::W<SIE_STATUS_SPEC>;
5#[doc = "Field `VBUS_DETECTED` reader - Device: VBUS Detected"]
6pub type VBUS_DETECTED_R = crate::BitReader;
7#[doc = "Field `LINE_STATE` reader - USB bus line state"]
8pub type LINE_STATE_R = crate::FieldReader<LINE_STATE_A>;
9#[doc = "USB bus line state  
10
11Value on reset: 0"]
12#[derive(Clone, Copy, Debug, PartialEq, Eq)]
13#[repr(u8)]
14pub enum LINE_STATE_A {
15    #[doc = "0: SE0"]
16    SE0 = 0,
17    #[doc = "1: J"]
18    J = 1,
19    #[doc = "2: K"]
20    K = 2,
21    #[doc = "3: SE1"]
22    SE1 = 3,
23}
24impl From<LINE_STATE_A> for u8 {
25    #[inline(always)]
26    fn from(variant: LINE_STATE_A) -> Self {
27        variant as _
28    }
29}
30impl crate::FieldSpec for LINE_STATE_A {
31    type Ux = u8;
32}
33impl LINE_STATE_R {
34    #[doc = "Get enumerated values variant"]
35    #[inline(always)]
36    pub const fn variant(&self) -> LINE_STATE_A {
37        match self.bits {
38            0 => LINE_STATE_A::SE0,
39            1 => LINE_STATE_A::J,
40            2 => LINE_STATE_A::K,
41            3 => LINE_STATE_A::SE1,
42            _ => unreachable!(),
43        }
44    }
45    #[doc = "SE0"]
46    #[inline(always)]
47    pub fn is_se0(&self) -> bool {
48        *self == LINE_STATE_A::SE0
49    }
50    #[doc = "J"]
51    #[inline(always)]
52    pub fn is_j(&self) -> bool {
53        *self == LINE_STATE_A::J
54    }
55    #[doc = "K"]
56    #[inline(always)]
57    pub fn is_k(&self) -> bool {
58        *self == LINE_STATE_A::K
59    }
60    #[doc = "SE1"]
61    #[inline(always)]
62    pub fn is_se1(&self) -> bool {
63        *self == LINE_STATE_A::SE1
64    }
65}
66#[doc = "Field `SUSPENDED` reader - Bus in suspended state. Valid for device and host. Host and device will go into suspend if neither Keep Alive / SOF frames are enabled."]
67pub type SUSPENDED_R = crate::BitReader;
68#[doc = "Field `SUSPENDED` writer - Bus in suspended state. Valid for device and host. Host and device will go into suspend if neither Keep Alive / SOF frames are enabled."]
69pub type SUSPENDED_W<'a, REG> = crate::BitWriter1C<'a, REG>;
70#[doc = "Field `SPEED` reader - Host: device speed. Disconnected = 00, LS = 01, FS = 10"]
71pub type SPEED_R = crate::FieldReader;
72#[doc = "Field `SPEED` writer - Host: device speed. Disconnected = 00, LS = 01, FS = 10"]
73pub type SPEED_W<'a, REG> = crate::FieldWriter<'a, REG, 2>;
74#[doc = "Field `VBUS_OVER_CURR` reader - VBUS over current detected"]
75pub type VBUS_OVER_CURR_R = crate::BitReader;
76#[doc = "Field `RESUME` reader - Host: Device has initiated a remote resume. Device: host has initiated a resume."]
77pub type RESUME_R = crate::BitReader;
78#[doc = "Field `RESUME` writer - Host: Device has initiated a remote resume. Device: host has initiated a resume."]
79pub type RESUME_W<'a, REG> = crate::BitWriter1C<'a, REG>;
80#[doc = "Field `CONNECTED` reader - Device: connected"]
81pub type CONNECTED_R = crate::BitReader;
82#[doc = "Field `CONNECTED` writer - Device: connected"]
83pub type CONNECTED_W<'a, REG> = crate::BitWriter1C<'a, REG>;
84#[doc = "Field `SETUP_REC` reader - Device: Setup packet received"]
85pub type SETUP_REC_R = crate::BitReader;
86#[doc = "Field `SETUP_REC` writer - Device: Setup packet received"]
87pub type SETUP_REC_W<'a, REG> = crate::BitWriter1C<'a, REG>;
88#[doc = "Field `TRANS_COMPLETE` reader - Transaction complete.  
89
90 Raised by device if:  
91
92 * An IN or OUT packet is sent with the `LAST_BUFF` bit set in the buffer control register  
93
94 Raised by host if:  
95
96 * A setup packet is sent when no data in or data out transaction follows * An IN packet is received and the `LAST_BUFF` bit is set in the buffer control register * An IN packet is received with zero length * An OUT packet is sent and the `LAST_BUFF` bit is set"]
97pub type TRANS_COMPLETE_R = crate::BitReader;
98#[doc = "Field `TRANS_COMPLETE` writer - Transaction complete.  
99
100 Raised by device if:  
101
102 * An IN or OUT packet is sent with the `LAST_BUFF` bit set in the buffer control register  
103
104 Raised by host if:  
105
106 * A setup packet is sent when no data in or data out transaction follows * An IN packet is received and the `LAST_BUFF` bit is set in the buffer control register * An IN packet is received with zero length * An OUT packet is sent and the `LAST_BUFF` bit is set"]
107pub type TRANS_COMPLETE_W<'a, REG> = crate::BitWriter1C<'a, REG>;
108#[doc = "Field `BUS_RESET` reader - Device: bus reset received"]
109pub type BUS_RESET_R = crate::BitReader;
110#[doc = "Field `BUS_RESET` writer - Device: bus reset received"]
111pub type BUS_RESET_W<'a, REG> = crate::BitWriter1C<'a, REG>;
112#[doc = "Field `CRC_ERROR` reader - CRC Error. Raised by the Serial RX engine."]
113pub type CRC_ERROR_R = crate::BitReader;
114#[doc = "Field `CRC_ERROR` writer - CRC Error. Raised by the Serial RX engine."]
115pub type CRC_ERROR_W<'a, REG> = crate::BitWriter1C<'a, REG>;
116#[doc = "Field `BIT_STUFF_ERROR` reader - Bit Stuff Error. Raised by the Serial RX engine."]
117pub type BIT_STUFF_ERROR_R = crate::BitReader;
118#[doc = "Field `BIT_STUFF_ERROR` writer - Bit Stuff Error. Raised by the Serial RX engine."]
119pub type BIT_STUFF_ERROR_W<'a, REG> = crate::BitWriter1C<'a, REG>;
120#[doc = "Field `RX_OVERFLOW` reader - RX overflow is raised by the Serial RX engine if the incoming data is too fast."]
121pub type RX_OVERFLOW_R = crate::BitReader;
122#[doc = "Field `RX_OVERFLOW` writer - RX overflow is raised by the Serial RX engine if the incoming data is too fast."]
123pub type RX_OVERFLOW_W<'a, REG> = crate::BitWriter1C<'a, REG>;
124#[doc = "Field `RX_TIMEOUT` reader - RX timeout is raised by both the host and device if an ACK is not received in the maximum time specified by the USB spec."]
125pub type RX_TIMEOUT_R = crate::BitReader;
126#[doc = "Field `RX_TIMEOUT` writer - RX timeout is raised by both the host and device if an ACK is not received in the maximum time specified by the USB spec."]
127pub type RX_TIMEOUT_W<'a, REG> = crate::BitWriter1C<'a, REG>;
128#[doc = "Field `NAK_REC` reader - Host: NAK received"]
129pub type NAK_REC_R = crate::BitReader;
130#[doc = "Field `NAK_REC` writer - Host: NAK received"]
131pub type NAK_REC_W<'a, REG> = crate::BitWriter1C<'a, REG>;
132#[doc = "Field `STALL_REC` reader - Host: STALL received"]
133pub type STALL_REC_R = crate::BitReader;
134#[doc = "Field `STALL_REC` writer - Host: STALL received"]
135pub type STALL_REC_W<'a, REG> = crate::BitWriter1C<'a, REG>;
136#[doc = "Field `ACK_REC` reader - ACK received. Raised by both host and device."]
137pub type ACK_REC_R = crate::BitReader;
138#[doc = "Field `ACK_REC` writer - ACK received. Raised by both host and device."]
139pub type ACK_REC_W<'a, REG> = crate::BitWriter1C<'a, REG>;
140#[doc = "Field `DATA_SEQ_ERROR` reader - Data Sequence Error.  
141
142 The device can raise a sequence error in the following conditions:  
143
144 * A SETUP packet is received followed by a DATA1 packet (data phase should always be DATA0) * An OUT packet is received from the host but doesn't match the data pid in the buffer control register read from DPSRAM  
145
146 The host can raise a data sequence error in the following conditions:  
147
148 * An IN packet from the device has the wrong data PID"]
149pub type DATA_SEQ_ERROR_R = crate::BitReader;
150#[doc = "Field `DATA_SEQ_ERROR` writer - Data Sequence Error.  
151
152 The device can raise a sequence error in the following conditions:  
153
154 * A SETUP packet is received followed by a DATA1 packet (data phase should always be DATA0) * An OUT packet is received from the host but doesn't match the data pid in the buffer control register read from DPSRAM  
155
156 The host can raise a data sequence error in the following conditions:  
157
158 * An IN packet from the device has the wrong data PID"]
159pub type DATA_SEQ_ERROR_W<'a, REG> = crate::BitWriter1C<'a, REG>;
160impl R {
161    #[doc = "Bit 0 - Device: VBUS Detected"]
162    #[inline(always)]
163    pub fn vbus_detected(&self) -> VBUS_DETECTED_R {
164        VBUS_DETECTED_R::new((self.bits & 1) != 0)
165    }
166    #[doc = "Bits 2:3 - USB bus line state"]
167    #[inline(always)]
168    pub fn line_state(&self) -> LINE_STATE_R {
169        LINE_STATE_R::new(((self.bits >> 2) & 3) as u8)
170    }
171    #[doc = "Bit 4 - Bus in suspended state. Valid for device and host. Host and device will go into suspend if neither Keep Alive / SOF frames are enabled."]
172    #[inline(always)]
173    pub fn suspended(&self) -> SUSPENDED_R {
174        SUSPENDED_R::new(((self.bits >> 4) & 1) != 0)
175    }
176    #[doc = "Bits 8:9 - Host: device speed. Disconnected = 00, LS = 01, FS = 10"]
177    #[inline(always)]
178    pub fn speed(&self) -> SPEED_R {
179        SPEED_R::new(((self.bits >> 8) & 3) as u8)
180    }
181    #[doc = "Bit 10 - VBUS over current detected"]
182    #[inline(always)]
183    pub fn vbus_over_curr(&self) -> VBUS_OVER_CURR_R {
184        VBUS_OVER_CURR_R::new(((self.bits >> 10) & 1) != 0)
185    }
186    #[doc = "Bit 11 - Host: Device has initiated a remote resume. Device: host has initiated a resume."]
187    #[inline(always)]
188    pub fn resume(&self) -> RESUME_R {
189        RESUME_R::new(((self.bits >> 11) & 1) != 0)
190    }
191    #[doc = "Bit 16 - Device: connected"]
192    #[inline(always)]
193    pub fn connected(&self) -> CONNECTED_R {
194        CONNECTED_R::new(((self.bits >> 16) & 1) != 0)
195    }
196    #[doc = "Bit 17 - Device: Setup packet received"]
197    #[inline(always)]
198    pub fn setup_rec(&self) -> SETUP_REC_R {
199        SETUP_REC_R::new(((self.bits >> 17) & 1) != 0)
200    }
201    #[doc = "Bit 18 - Transaction complete.  
202
203 Raised by device if:  
204
205 * An IN or OUT packet is sent with the `LAST_BUFF` bit set in the buffer control register  
206
207 Raised by host if:  
208
209 * A setup packet is sent when no data in or data out transaction follows * An IN packet is received and the `LAST_BUFF` bit is set in the buffer control register * An IN packet is received with zero length * An OUT packet is sent and the `LAST_BUFF` bit is set"]
210    #[inline(always)]
211    pub fn trans_complete(&self) -> TRANS_COMPLETE_R {
212        TRANS_COMPLETE_R::new(((self.bits >> 18) & 1) != 0)
213    }
214    #[doc = "Bit 19 - Device: bus reset received"]
215    #[inline(always)]
216    pub fn bus_reset(&self) -> BUS_RESET_R {
217        BUS_RESET_R::new(((self.bits >> 19) & 1) != 0)
218    }
219    #[doc = "Bit 24 - CRC Error. Raised by the Serial RX engine."]
220    #[inline(always)]
221    pub fn crc_error(&self) -> CRC_ERROR_R {
222        CRC_ERROR_R::new(((self.bits >> 24) & 1) != 0)
223    }
224    #[doc = "Bit 25 - Bit Stuff Error. Raised by the Serial RX engine."]
225    #[inline(always)]
226    pub fn bit_stuff_error(&self) -> BIT_STUFF_ERROR_R {
227        BIT_STUFF_ERROR_R::new(((self.bits >> 25) & 1) != 0)
228    }
229    #[doc = "Bit 26 - RX overflow is raised by the Serial RX engine if the incoming data is too fast."]
230    #[inline(always)]
231    pub fn rx_overflow(&self) -> RX_OVERFLOW_R {
232        RX_OVERFLOW_R::new(((self.bits >> 26) & 1) != 0)
233    }
234    #[doc = "Bit 27 - RX timeout is raised by both the host and device if an ACK is not received in the maximum time specified by the USB spec."]
235    #[inline(always)]
236    pub fn rx_timeout(&self) -> RX_TIMEOUT_R {
237        RX_TIMEOUT_R::new(((self.bits >> 27) & 1) != 0)
238    }
239    #[doc = "Bit 28 - Host: NAK received"]
240    #[inline(always)]
241    pub fn nak_rec(&self) -> NAK_REC_R {
242        NAK_REC_R::new(((self.bits >> 28) & 1) != 0)
243    }
244    #[doc = "Bit 29 - Host: STALL received"]
245    #[inline(always)]
246    pub fn stall_rec(&self) -> STALL_REC_R {
247        STALL_REC_R::new(((self.bits >> 29) & 1) != 0)
248    }
249    #[doc = "Bit 30 - ACK received. Raised by both host and device."]
250    #[inline(always)]
251    pub fn ack_rec(&self) -> ACK_REC_R {
252        ACK_REC_R::new(((self.bits >> 30) & 1) != 0)
253    }
254    #[doc = "Bit 31 - Data Sequence Error.  
255
256 The device can raise a sequence error in the following conditions:  
257
258 * A SETUP packet is received followed by a DATA1 packet (data phase should always be DATA0) * An OUT packet is received from the host but doesn't match the data pid in the buffer control register read from DPSRAM  
259
260 The host can raise a data sequence error in the following conditions:  
261
262 * An IN packet from the device has the wrong data PID"]
263    #[inline(always)]
264    pub fn data_seq_error(&self) -> DATA_SEQ_ERROR_R {
265        DATA_SEQ_ERROR_R::new(((self.bits >> 31) & 1) != 0)
266    }
267}
268impl W {
269    #[doc = "Bit 4 - Bus in suspended state. Valid for device and host. Host and device will go into suspend if neither Keep Alive / SOF frames are enabled."]
270    #[inline(always)]
271    #[must_use]
272    pub fn suspended(&mut self) -> SUSPENDED_W<SIE_STATUS_SPEC> {
273        SUSPENDED_W::new(self, 4)
274    }
275    #[doc = "Bits 8:9 - Host: device speed. Disconnected = 00, LS = 01, FS = 10"]
276    #[inline(always)]
277    #[must_use]
278    pub fn speed(&mut self) -> SPEED_W<SIE_STATUS_SPEC> {
279        SPEED_W::new(self, 8)
280    }
281    #[doc = "Bit 11 - Host: Device has initiated a remote resume. Device: host has initiated a resume."]
282    #[inline(always)]
283    #[must_use]
284    pub fn resume(&mut self) -> RESUME_W<SIE_STATUS_SPEC> {
285        RESUME_W::new(self, 11)
286    }
287    #[doc = "Bit 16 - Device: connected"]
288    #[inline(always)]
289    #[must_use]
290    pub fn connected(&mut self) -> CONNECTED_W<SIE_STATUS_SPEC> {
291        CONNECTED_W::new(self, 16)
292    }
293    #[doc = "Bit 17 - Device: Setup packet received"]
294    #[inline(always)]
295    #[must_use]
296    pub fn setup_rec(&mut self) -> SETUP_REC_W<SIE_STATUS_SPEC> {
297        SETUP_REC_W::new(self, 17)
298    }
299    #[doc = "Bit 18 - Transaction complete.  
300
301 Raised by device if:  
302
303 * An IN or OUT packet is sent with the `LAST_BUFF` bit set in the buffer control register  
304
305 Raised by host if:  
306
307 * A setup packet is sent when no data in or data out transaction follows * An IN packet is received and the `LAST_BUFF` bit is set in the buffer control register * An IN packet is received with zero length * An OUT packet is sent and the `LAST_BUFF` bit is set"]
308    #[inline(always)]
309    #[must_use]
310    pub fn trans_complete(&mut self) -> TRANS_COMPLETE_W<SIE_STATUS_SPEC> {
311        TRANS_COMPLETE_W::new(self, 18)
312    }
313    #[doc = "Bit 19 - Device: bus reset received"]
314    #[inline(always)]
315    #[must_use]
316    pub fn bus_reset(&mut self) -> BUS_RESET_W<SIE_STATUS_SPEC> {
317        BUS_RESET_W::new(self, 19)
318    }
319    #[doc = "Bit 24 - CRC Error. Raised by the Serial RX engine."]
320    #[inline(always)]
321    #[must_use]
322    pub fn crc_error(&mut self) -> CRC_ERROR_W<SIE_STATUS_SPEC> {
323        CRC_ERROR_W::new(self, 24)
324    }
325    #[doc = "Bit 25 - Bit Stuff Error. Raised by the Serial RX engine."]
326    #[inline(always)]
327    #[must_use]
328    pub fn bit_stuff_error(&mut self) -> BIT_STUFF_ERROR_W<SIE_STATUS_SPEC> {
329        BIT_STUFF_ERROR_W::new(self, 25)
330    }
331    #[doc = "Bit 26 - RX overflow is raised by the Serial RX engine if the incoming data is too fast."]
332    #[inline(always)]
333    #[must_use]
334    pub fn rx_overflow(&mut self) -> RX_OVERFLOW_W<SIE_STATUS_SPEC> {
335        RX_OVERFLOW_W::new(self, 26)
336    }
337    #[doc = "Bit 27 - RX timeout is raised by both the host and device if an ACK is not received in the maximum time specified by the USB spec."]
338    #[inline(always)]
339    #[must_use]
340    pub fn rx_timeout(&mut self) -> RX_TIMEOUT_W<SIE_STATUS_SPEC> {
341        RX_TIMEOUT_W::new(self, 27)
342    }
343    #[doc = "Bit 28 - Host: NAK received"]
344    #[inline(always)]
345    #[must_use]
346    pub fn nak_rec(&mut self) -> NAK_REC_W<SIE_STATUS_SPEC> {
347        NAK_REC_W::new(self, 28)
348    }
349    #[doc = "Bit 29 - Host: STALL received"]
350    #[inline(always)]
351    #[must_use]
352    pub fn stall_rec(&mut self) -> STALL_REC_W<SIE_STATUS_SPEC> {
353        STALL_REC_W::new(self, 29)
354    }
355    #[doc = "Bit 30 - ACK received. Raised by both host and device."]
356    #[inline(always)]
357    #[must_use]
358    pub fn ack_rec(&mut self) -> ACK_REC_W<SIE_STATUS_SPEC> {
359        ACK_REC_W::new(self, 30)
360    }
361    #[doc = "Bit 31 - Data Sequence Error.  
362
363 The device can raise a sequence error in the following conditions:  
364
365 * A SETUP packet is received followed by a DATA1 packet (data phase should always be DATA0) * An OUT packet is received from the host but doesn't match the data pid in the buffer control register read from DPSRAM  
366
367 The host can raise a data sequence error in the following conditions:  
368
369 * An IN packet from the device has the wrong data PID"]
370    #[inline(always)]
371    #[must_use]
372    pub fn data_seq_error(&mut self) -> DATA_SEQ_ERROR_W<SIE_STATUS_SPEC> {
373        DATA_SEQ_ERROR_W::new(self, 31)
374    }
375    #[doc = r" Writes raw bits to the register."]
376    #[doc = r""]
377    #[doc = r" # Safety"]
378    #[doc = r""]
379    #[doc = r" Passing incorrect value can cause undefined behaviour. See reference manual"]
380    #[inline(always)]
381    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
382        self.bits = bits;
383        self
384    }
385}
386#[doc = "SIE status register  
387
388You can [`read`](crate::generic::Reg::read) this register and get [`sie_status::R`](R).  You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`sie_status::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
389pub struct SIE_STATUS_SPEC;
390impl crate::RegisterSpec for SIE_STATUS_SPEC {
391    type Ux = u32;
392}
393#[doc = "`read()` method returns [`sie_status::R`](R) reader structure"]
394impl crate::Readable for SIE_STATUS_SPEC {}
395#[doc = "`write(|w| ..)` method takes [`sie_status::W`](W) writer structure"]
396impl crate::Writable for SIE_STATUS_SPEC {
397    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
398    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0xff0f_0b10;
399}
400#[doc = "`reset()` method sets SIE_STATUS to value 0"]
401impl crate::Resettable for SIE_STATUS_SPEC {
402    const RESET_VALUE: u32 = 0;
403}