From 164778a71682559670cc2549565b4d8d5f021fa9 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 28 May 2021 17:42:13 +0700 Subject: [PATCH] update limit each transfer not less than 64 --- src/portable/raspberrypi/rp2040/hcd_rp2040.c | 2 ++ src/portable/raspberrypi/rp2040/rp2040_usb.c | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/portable/raspberrypi/rp2040/hcd_rp2040.c b/src/portable/raspberrypi/rp2040/hcd_rp2040.c index 5201d1d4c..eff950de2 100644 --- a/src/portable/raspberrypi/rp2040/hcd_rp2040.c +++ b/src/portable/raspberrypi/rp2040/hcd_rp2040.c @@ -452,6 +452,7 @@ bool hcd_edpt_xfer(uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr, uint8_t * if (ep_addr != ep->ep_addr) { // Direction has flipped so re init it but with same properties + // TODO treat IN and OUT as invidual endpoints _hw_endpoint_init(ep, dev_addr, ep_addr, ep->wMaxPacketSize, ep->transfer_type, 0); } @@ -531,6 +532,7 @@ bool hcd_edpt_busy(uint8_t dev_addr, uint8_t ep_addr) bool hcd_edpt_stalled(uint8_t dev_addr, uint8_t ep_addr) { panic("hcd_pipe_stalled"); + return false; } bool hcd_edpt_clear_stall(uint8_t dev_addr, uint8_t ep_addr) diff --git a/src/portable/raspberrypi/rp2040/rp2040_usb.c b/src/portable/raspberrypi/rp2040/rp2040_usb.c index 98ffea9a3..88d94aaec 100644 --- a/src/portable/raspberrypi/rp2040/rp2040_usb.c +++ b/src/portable/raspberrypi/rp2040/rp2040_usb.c @@ -161,7 +161,10 @@ void _hw_endpoint_xfer_start(struct hw_endpoint *ep, uint8_t *buffer, uint16_t t // Fill in info now that we're kicking off the hw ep->total_len = total_len; ep->len = 0; - ep->transfer_size = tu_min16(total_len, ep->wMaxPacketSize); + + // Limit by packet size but not less 64 (i.e low speed 8 bytes EP0) + ep->transfer_size = tu_min16(total_len, tu_max16(64, ep->wMaxPacketSize)); + ep->active = true; ep->user_buf = buffer; #if TUSB_OPT_HOST_ENABLED @@ -240,8 +243,9 @@ bool _hw_endpoint_xfer_continue(struct hw_endpoint *ep) _hw_endpoint_xfer_sync(ep); // Now we have synced our state with the hardware. Is there more data to transfer? + // Limit by packet size but not less 64 (i.e low speed 8 bytes EP0) uint16_t remaining_bytes = ep->total_len - ep->len; - ep->transfer_size = tu_min16(remaining_bytes, ep->wMaxPacketSize); + ep->transfer_size = tu_min16(remaining_bytes, tu_max16(64, ep->wMaxPacketSize)); #if TUSB_OPT_HOST_ENABLED _hw_endpoint_update_last_buf(ep); #endif