summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas R Dinsmore <[email protected]>2021-02-17 18:22:24 -0500
committerNicholas R Dinsmore <[email protected]>2021-02-17 18:22:24 -0500
commit27f4b6f5a4e122ba0413315472ff663e5b8417be (patch)
treeb9192a59aec0ddd18cd97a7c4cd545adf67b5240
parent79b360f0a6b980cb8b4826bbad0d2d6a4c9dae4b (diff)
Included size check for ISO buffers
-rw-r--r--src/portable/raspberrypi/rp2040/rp2040_usb.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/portable/raspberrypi/rp2040/rp2040_usb.c b/src/portable/raspberrypi/rp2040/rp2040_usb.c
index 036b52196..d3cbb2a21 100644
--- a/src/portable/raspberrypi/rp2040/rp2040_usb.c
+++ b/src/portable/raspberrypi/rp2040/rp2040_usb.c
@@ -156,13 +156,12 @@ void _hw_endpoint_xfer_start(struct hw_endpoint *ep, uint8_t *buffer, uint16_t t
// FIXME: What if low speed
if(ep->transfer_type == TUSB_XFER_ISOCHRONOUS)
{
- ep->transfer_size = total_len; //There is an assumption that the max buffer size of 1023 or 1024 was checked before this
+ ep->transfer_size = total_len > ep->wMaxPacketSize ? ep->wMaxPacketSize : total_len;
}
else
{
ep->transfer_size = total_len > 64 ? 64 : total_len;
}
- ep->transfer_size = total_len > 64 ? 64 : total_len;
ep->active = true;
ep->user_buf = buffer;
// Recalculate if this is the last buffer
@@ -240,7 +239,16 @@ bool _hw_endpoint_xfer_continue(struct hw_endpoint *ep)
// Now we have synced our state with the hardware. Is there more data to transfer?
uint remaining_bytes = ep->total_len - ep->len;
- ep->transfer_size = remaining_bytes > 64 ? 64 : remaining_bytes;
+ // ep->transfer_size = remaining_bytes > 64 ? 64 : remaining_bytes;
+
+ if(ep->transfer_type == TUSB_XFER_ISOCHRONOUS)
+ {
+ ep->transfer_size = remaining_bytes > ep->wMaxPacketSize ? ep->wMaxPacketSize : remaining_bytes;
+ }
+ else
+ {
+ ep->transfer_size = remaining_bytes > 64 ? 64 : remaining_bytes;
+ }
_hw_endpoint_update_last_buf(ep);
// Can happen because of programmer error so check for it