Skip to content

Commit 7ce4cfa

Browse files
maidnlfacchinm
authored andcommitted
renesas: added wait function for IN transaction
This fixes a problem found on MSD class where data read from from disks were sometimes partially overwritten by the status MSD message ("USBS..."). The function introduced wait for the hw fifo pipe to be empty, that prevent that new writing in the fife overwrite data which are not yet be transmitted by hw.
1 parent 7bf5923 commit 7ce4cfa

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: src/portable/renesas/rusb2/dcd_rusb2.c

+8
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,13 @@ static void pipe_read_packet_ff(rusb2_reg_t * rusb, tu_fifo_t *f, volatile void
266266
tu_fifo_advance_write_pointer(f, count);
267267
}
268268

269+
270+
static void wait_pipe_fifo_empty(rusb2_reg_t* rusb, uint8_t num) {
271+
TU_ASSERT(num);
272+
while( (rusb->PIPE_CTR[num-1] & RUSB2_PIPE_CTR_INBUFM_Msk) > 0 ) {}
273+
}
274+
275+
269276
//--------------------------------------------------------------------+
270277
// Pipe Transfer
271278
//--------------------------------------------------------------------+
@@ -339,6 +346,7 @@ static bool pipe_xfer_in(rusb2_reg_t* rusb, unsigned num)
339346
const unsigned rem = pipe->remaining;
340347

341348
if (!rem) {
349+
wait_pipe_fifo_empty(rusb, num);
342350
pipe->buf = NULL;
343351
return true;
344352
}

0 commit comments

Comments
 (0)