summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2021-06-07 14:33:24 +0700
committerhathach <[email protected]>2021-06-08 10:29:22 +0700
commit501de2a5e8232752defb28f8cd97f24595a61cf2 (patch)
treed8801d53a221a469cfc62b937be3858a24319f43 /src
parentce30109b5bdb3ecd82f08c9dd48fe0f6f7f1713e (diff)
fix computing transferred bytes with E4
Diffstat (limited to 'src')
-rw-r--r--src/portable/raspberrypi/rp2040/rp2040_usb.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/portable/raspberrypi/rp2040/rp2040_usb.c b/src/portable/raspberrypi/rp2040/rp2040_usb.c
index a0263612f..31381e6c2 100644
--- a/src/portable/raspberrypi/rp2040/rp2040_usb.c
+++ b/src/portable/raspberrypi/rp2040/rp2040_usb.c
@@ -205,10 +205,7 @@ void _hw_endpoint_xfer_sync(struct hw_endpoint *ep)
// Update hw endpoint struct with info from hardware
// after a buff status interrupt
- // Get the buffer state and amount of bytes we have
- // transferred
uint32_t buf_ctrl = _hw_endpoint_buffer_control_get_value32(ep);
- uint16_t transferred_bytes = buf_ctrl & USB_BUF_CTRL_LEN_MASK;
#if TUSB_OPT_HOST_ENABLED
// RP2040-E4
@@ -227,6 +224,9 @@ void _hw_endpoint_xfer_sync(struct hw_endpoint *ep)
// end::host_buf_sel_fix[]
#endif
+ // Get tranferred bytes after adjusted buf sel
+ uint16_t const transferred_bytes = buf_ctrl & USB_BUF_CTRL_LEN_MASK;
+
// We are continuing a transfer here. If we are TX, we have successfullly
// sent some data can increase the length we have sent
if (!ep->rx)
@@ -249,7 +249,7 @@ void _hw_endpoint_xfer_sync(struct hw_endpoint *ep)
// Sometimes the host will send less data than we expect...
// If this is a short out transfer update the total length of the transfer
// to be the current length
- if ((ep->rx) && (transferred_bytes < ep->transfer_size))
+ if ((ep->rx) && (transferred_bytes < ep->wMaxPacketSize))
{
pico_trace("Short rx transfer\n");
// Reduce total length as this is last packet
@@ -289,8 +289,7 @@ bool _hw_endpoint_xfer_continue(struct hw_endpoint *ep)
{
pico_trace("Completed transfer of %d bytes on ep %d %s\n",
ep->len, tu_edpt_number(ep->ep_addr), ep_dir_string[tu_edpt_dir(ep->ep_addr)]);
- // Notify caller we are done so it can notify the tinyusb
- // stack
+ // Notify caller we are done so it can notify the tinyusb stack
_hw_endpoint_lock_update(ep, -1);
return true;
}