diff options
| author | Ha Thach <[email protected]> | 2021-06-10 11:35:51 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-06-10 11:35:51 +0700 |
| commit | 3c4ab6bd8adaa20d1fe0c417761d2810456dbcbd (patch) | |
| tree | cd6ea996cf0beec4b70a261a3970e0a43b7add79 /src | |
| parent | 14fc0987ac9d712fc933899572ed1dc02fd0ddcd (diff) | |
| parent | 501de2a5e8232752defb28f8cd97f24595a61cf2 (diff) | |
Merge pull request #883 from hathach/fix-rp2040-host-transferred-bytes
fix computing transferred bytes with E4
Diffstat (limited to 'src')
| -rw-r--r-- | src/portable/raspberrypi/rp2040/rp2040_usb.c | 11 |
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; } |
