Jelajahi Sumber

update limit each transfer not less than 64

hathach 5 tahun lalu
induk
melakukan
164778a716

+ 2 - 0
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)

+ 6 - 2
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