summaryrefslogtreecommitdiff
path: root/src/common
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/common
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/common')
-rw-r--r--src/common/tusb_fifo.h4
-rw-r--r--src/common/tusb_private.h6
2 files changed, 7 insertions, 3 deletions
diff --git a/src/common/tusb_fifo.h b/src/common/tusb_fifo.h
index c16216606..0b8e83760 100644
--- a/src/common/tusb_fifo.h
+++ b/src/common/tusb_fifo.h
@@ -48,6 +48,10 @@ extern "C" {
// for OS None, we don't get preempted
#define CFG_FIFO_MUTEX OSAL_MUTEX_REQUIRED
+#if CFG_TUD_EDPT_DEDICATED_HWFIFO || CFG_TUH_EDPT_DEDICATED_HWFIFO
+ #define CFG_TUSB_FIFO_ACCESS_FIXED_ADDR_RW32
+#endif
+
/* Write/Read index is always in the range of:
* 0 .. 2*depth-1
* The extra window allow us to determine the fifo state of empty or full with only 2 indices
diff --git a/src/common/tusb_private.h b/src/common/tusb_private.h
index be1264a71..48fd1d6d2 100644
--- a/src/common/tusb_private.h
+++ b/src/common/tusb_private.h
@@ -60,7 +60,7 @@ typedef struct {
uint8_t ep_addr;
uint16_t ep_bufsize;
- uint8_t* ep_buf; // TODO xfer_fifo can skip this buffer
+ uint8_t *ep_buf; // set to NULL to use xfer_fifo when CFG_TUD_EDPT_DEDICATED_HWFIFO = 1
tu_fifo_t ff;
// mutex: read if rx, otherwise write
@@ -98,7 +98,7 @@ bool tu_edpt_stream_init(tu_edpt_stream_t* s, bool is_host, bool is_tx, bool ove
// Deinit an endpoint stream
bool tu_edpt_stream_deinit(tu_edpt_stream_t* s);
-// Open an stream for an endpoint
+// Open an endpoint stream
TU_ATTR_ALWAYS_INLINE static inline void tu_edpt_stream_open(tu_edpt_stream_t* s, tusb_desc_endpoint_t const *desc_ep) {
s->ep_addr = desc_ep->bEndpointAddress;
s->is_mps512 = tu_edpt_packet_size(desc_ep) == 512;
@@ -150,7 +150,7 @@ uint32_t tu_edpt_stream_read_xfer(uint8_t hwid, tu_edpt_stream_t* s);
// Complete read transfer by writing EP -> FIFO. Must be called in the transfer complete callback
TU_ATTR_ALWAYS_INLINE static inline
void tu_edpt_stream_read_xfer_complete(tu_edpt_stream_t* s, uint32_t xferred_bytes) {
- if (0u != tu_fifo_depth(&s->ff)) {
+ if (0u != tu_fifo_depth(&s->ff) && s->ep_buf != NULL) {
tu_fifo_write_n(&s->ff, s->ep_buf, (uint16_t) xferred_bytes);
}
}