Included size check for ISO buffers

This commit is contained in:
Nicholas R Dinsmore 2021-02-17 18:22:24 -05:00
parent 79b360f0a6
commit 27f4b6f5a4
1 changed files with 11 additions and 3 deletions

View File

@ -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