diff options
| author | HiFiPhile <[email protected]> | 2025-12-13 13:54:53 +0100 |
|---|---|---|
| committer | HiFiPhile <[email protected]> | 2025-12-13 14:18:07 +0100 |
| commit | 8c5adcefbf64be17daa048414ba21552eab9c3a8 (patch) | |
| tree | aa9b1f2cd2ac0271af3c3931620d6ee813bd7bea | |
| parent | 54857210e6541b1e41970ab70f19d3cdf434011c (diff) | |
tusb: fix stream write logic without fifo
Signed-off-by: HiFiPhile <[email protected]>
| -rw-r--r-- | src/tusb.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/tusb.c b/src/tusb.c index 8ba9f0fff..8117c3e3e 100644 --- a/src/tusb.c +++ b/src/tusb.c @@ -411,27 +411,19 @@ uint32_t tu_edpt_stream_write_xfer(tu_edpt_stream_t *s) { } uint32_t tu_edpt_stream_write(tu_edpt_stream_t *s, const void *buffer, uint32_t bufsize) { - TU_VERIFY(bufsize > 0); - #if CFG_TUSB_EDPT_STREAM_NO_FIFO_ENABLED if (0 == tu_fifo_depth(&s->ff)) { - // non-fifo mode + // non-fifo mode: TX need ep buffer + TU_VERIFY(s->ep_buf != NULL, 0); TU_VERIFY(stream_claim(s), 0); - uint32_t xact_len; - if (s->ep_buf != NULL) { - // using ep buf - xact_len = tu_min32(bufsize, s->ep_bufsize); - memcpy(s->ep_buf, buffer, xact_len); - } else { - // using hwfifo - xact_len = bufsize; - } - TU_ASSERT(stream_xfer(s, (uint16_t)xact_len), 0); - + uint32_t xact_len = tu_min32(bufsize, s->ep_bufsize); + memcpy(s->ep_buf, buffer, xact_len); + TU_ASSERT(stream_xfer(s, (uint16_t) xact_len), 0); return xact_len; } else #endif { + TU_VERIFY(bufsize > 0); const uint16_t ret = tu_fifo_write_n(&s->ff, buffer, (uint16_t) bufsize); // flush if fifo has more than packet size or |
