From a1f1941c3f965483e274993e43d18a9ede5e1f09 Mon Sep 17 00:00:00 2001 From: kkitayam <45088311+kkitayam@users.noreply.github.com> Date: Sat, 27 Mar 2021 16:03:04 +0900 Subject: [PATCH] fixed a OUT transfer did not completed multiple of the max packet size --- src/portable/renesas/usba/dcd_usba.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/portable/renesas/usba/dcd_usba.c b/src/portable/renesas/usba/dcd_usba.c index e7518b01f..844fa3856 100644 --- a/src/portable/renesas/usba/dcd_usba.c +++ b/src/portable/renesas/usba/dcd_usba.c @@ -261,7 +261,7 @@ static int write_fifo(volatile void *fifo, pipe_state_t* pipe, unsigned mps) return 0; } -/* 1 if the number of bytes read is less than 64 bytes +/* 1 if the number of bytes read is less than mps bytes * 0 otherwise */ static int read_fifo(volatile void *fifo, pipe_state_t* pipe, unsigned mps, size_t len) { @@ -272,12 +272,14 @@ static int read_fifo(volatile void *fifo, pipe_state_t* pipe, unsigned mps, size hw_fifo_t *reg = (hw_fifo_t*)fifo; uintptr_t addr = pipe->addr; - while (len--) { + unsigned loop = len; + while (loop--) { *(uint8_t *)addr = reg->u8; ++addr; } pipe->addr = addr; - if (rem < mps) return 1; + if (rem < mps) return 1; + if (rem == len) return 2; return 0; } @@ -419,7 +421,7 @@ static bool process_pipe_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, *ctr = USB_PIPECTR_PID_BUF; } } - //TU_LOG1("X %x %d\r\n", ep_addr, total_bytes); + // TU_LOG1("X %x %d\r\n", ep_addr, total_bytes); return true; }