dcd_pic32: Add asserts transfer sanity check
TU_ASSERTS added to detect transfer inconsistency.
@@ -530,6 +530,7 @@ static void ep0_handle_rx(void)
transferred = rx_fifo_read(0, xfer->buffer + xfer->transferred);
xfer->transferred += transferred;
+ TU_ASSERT(xfer->transferred <= xfer->total_len,);
if (transferred < xfer->max_packet_size || xfer->transferred == xfer->total_len)
{
ep0_set_stage(EP0_STAGE_DATA_OUT_COMPLETE);
@@ -560,6 +561,7 @@ static void epn_handle_rx_int(uint8_t epnum)
transferred = rx_fifo_read(epnum, xfer->buffer + xfer->transferred);
USB_REGS->EPCSR[epnum].RXCSRL_HOSTbits.RXPKTRDY = 0;
xfer->transferred += transferred;
+ TU_ASSERT(xfer->transferred <= xfer->total_len,);
if (transferred < xfer->max_packet_size || xfer->transferred == xfer->total_len)
{
xfer_complete(xfer, XFER_RESULT_SUCCESS, true);
@@ -579,6 +581,7 @@ static void epn_handle_tx_int(uint8_t epnum)
else
{
xfer->transferred += xfer->last_packet_size;
+ TU_ASSERT(xfer->transferred <= xfer->total_len,);
if (xfer->last_packet_size < xfer->max_packet_size || xfer->transferred == xfer->total_len)
{
xfer->last_packet_size = 0;
