summaryrefslogtreecommitdiff
path: root/src/tusb.c
diff options
context:
space:
mode:
authorhathach <[email protected]>2025-11-21 17:02:56 +0700
committerhathach <[email protected]>2025-11-21 17:02:56 +0700
commitc9b623aa63d24d58a7a5e55dd296afd1261b2ab8 (patch)
treeb6f11dd1e945b2dac9b1841efa1aaca17a255134 /src/tusb.c
parentd0d56a51a15dbdb760f5607702cf4ceeb2451a9e (diff)
edpt stream support xfer_fifo for device CFG_TUD_EDPT_DEDICATED_HWFIFO
cdc device omit ep buffer when hwfifo is supported
Diffstat (limited to 'src/tusb.c')
-rw-r--r--src/tusb.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/tusb.c b/src/tusb.c
index 3852da76b..1b8fdc460 100644
--- a/src/tusb.c
+++ b/src/tusb.c
@@ -387,8 +387,12 @@ TU_ATTR_ALWAYS_INLINE static inline bool stream_xfer(uint8_t hwid, tu_edpt_strea
#endif
} else {
#if CFG_TUD_ENABLED
- return usbd_edpt_xfer(hwid, s->ep_addr, count ? s->ep_buf : NULL, count, false);
- #endif
+ if (s->ep_buf == NULL) {
+ return usbd_edpt_xfer_fifo(hwid, s->ep_addr, &s->ff, count, false);
+ } else {
+ return usbd_edpt_xfer(hwid, s->ep_addr, count ? s->ep_buf : NULL, count, false);
+ }
+ #endif
}
return false;
}
@@ -419,12 +423,17 @@ bool tu_edpt_stream_write_zlp_if_needed(uint8_t hwid, tu_edpt_stream_t* s, uint3
}
uint32_t tu_edpt_stream_write_xfer(uint8_t hwid, tu_edpt_stream_t* s) {
- // skip if no data
- TU_VERIFY(tu_fifo_count(&s->ff) > 0, 0);
+ const uint16_t ff_count = tu_fifo_count(&s->ff);
+ TU_VERIFY(ff_count > 0, 0); // skip if no data
TU_VERIFY(stream_claim(hwid, s), 0);
// Pull data from FIFO -> EP buf
- const uint16_t count = tu_fifo_read_n(&s->ff, s->ep_buf, s->ep_bufsize);
+ uint16_t count;
+ if (s->ep_buf == NULL) {
+ count = ff_count;
+ } else {
+ count = tu_fifo_read_n(&s->ff, s->ep_buf, s->ep_bufsize);
+ }
if (count > 0) {
TU_ASSERT(stream_xfer(hwid, s, count), 0);
@@ -441,7 +450,8 @@ uint32_t tu_edpt_stream_write(uint8_t hwid, tu_edpt_stream_t *s, const void *buf
TU_VERIFY(bufsize > 0); // TODO support ZLP
if (0 == tu_fifo_depth(&s->ff)) {
- // no fifo for buffered
+ // no fifo for buffered, ep_buf must be valid
+ TU_VERIFY(s->ep_buf != NULL, 0);
TU_VERIFY(stream_claim(hwid, s), 0);
const uint32_t xact_len = tu_min32(bufsize, s->ep_bufsize);
memcpy(s->ep_buf, buffer, xact_len);