summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakimisu <[email protected]>2022-12-30 20:42:38 +0800
committersakimisu <[email protected]>2022-12-30 20:42:38 +0800
commit82cd954252edc12059d202cc3398be469392f668 (patch)
treec07ddd8e343244f5c78c3c94818ad39a39464216
parent2364d0a6baa05166d7474114da0d415b20984646 (diff)
retry when control transfer receives nak
-rw-r--r--port/dwc2/usb_hc_dwc2.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/port/dwc2/usb_hc_dwc2.c b/port/dwc2/usb_hc_dwc2.c
index f72e89c5..c12c9f57 100644
--- a/port/dwc2/usb_hc_dwc2.c
+++ b/port/dwc2/usb_hc_dwc2.c
@@ -192,6 +192,7 @@ static void dwc2_pipe_init(uint8_t ch_num, uint8_t devaddr, uint8_t ep_addr, uin
switch (ep_type) {
case USB_ENDPOINT_TYPE_CONTROL:
+ regval |= USB_OTG_HCINTMSK_NAKM;
case USB_ENDPOINT_TYPE_BULK:
break;
case USB_ENDPOINT_TYPE_INTERRUPT:
@@ -876,8 +877,6 @@ static void dwc2_inchan_irq_handler(uint8_t ch_num)
chan = &g_dwc2_hcd.pipe_pool[ch_num];
urb = chan->urb;
//printf("s1:%08x\r\n", chan_intstatus);
- for (uint32_t i = 0; i < 0xf; i++) {
- }
if ((chan_intstatus & USB_OTG_HCINT_XFRC) == USB_OTG_HCINT_XFRC) {
urb->errorcode = 0;
@@ -973,7 +972,13 @@ static void dwc2_inchan_irq_handler(uint8_t ch_num)
}
} else if (urb->errorcode == -EAGAIN) {
/* re-activate the channel */
- dwc2_bulk_intr_pipe_init(chan, urb->transfer_buffer, urb->transfer_buffer_length);
+ if (chan->ep_type == 0x00) {
+ dwc2_control_pipe_init(chan, urb->setup, urb->transfer_buffer, urb->transfer_buffer_length);
+ } else if (chan->ep_type == 0x03) {
+ dwc2_bulk_intr_pipe_init(chan, urb->transfer_buffer, urb->transfer_buffer_length);
+ } else {
+ }
+
} else {
dwc2_pipe_waitup(chan);
}
@@ -1096,7 +1101,13 @@ static void dwc2_outchan_irq_handler(uint8_t ch_num)
}
} else if (urb->errorcode == -EAGAIN) {
/* re-activate the channel */
- dwc2_bulk_intr_pipe_init(chan, urb->transfer_buffer, urb->transfer_buffer_length);
+ if (chan->ep_type == 0x00) {
+ dwc2_control_pipe_init(chan, urb->setup, urb->transfer_buffer, urb->transfer_buffer_length);
+ } else if (chan->ep_type == 0x03) {
+ dwc2_bulk_intr_pipe_init(chan, urb->transfer_buffer, urb->transfer_buffer_length);
+ } else {
+ }
+
} else {
dwc2_pipe_waitup(chan);
}