Skip to content

Commit

Permalink
Merge pull request #2245 from arduino/fix_msd_extraneus_bytes_on_reading
Browse files Browse the repository at this point in the history
Fix msd extraneus bytes on reading
  • Loading branch information
hathach authored Sep 12, 2023
2 parents 6d922de + 228acbe commit e9ba933
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/portable/renesas/rusb2/dcd_rusb2.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,14 @@ static void pipe_read_packet_ff(rusb2_reg_t * rusb, tu_fifo_t *f, volatile void
tu_fifo_advance_write_pointer(f, count);
}


static bool wait_pipe_fifo_empty(rusb2_reg_t* rusb, uint8_t num) {
TU_ASSERT(num);
while( (rusb->PIPE_CTR[num-1] & RUSB2_PIPE_CTR_INBUFM_Msk) > 0 ) {}
return true;
}


//--------------------------------------------------------------------+
// Pipe Transfer
//--------------------------------------------------------------------+
Expand Down Expand Up @@ -339,6 +347,7 @@ static bool pipe_xfer_in(rusb2_reg_t* rusb, unsigned num)
const unsigned rem = pipe->remaining;

if (!rem) {
wait_pipe_fifo_empty(rusb, num);
pipe->buf = NULL;
return true;
}
Expand Down

0 comments on commit e9ba933

Please sign in to comment.