summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorhathach <[email protected]>2025-12-06 02:29:05 +0700
committerhathach <[email protected]>2025-12-06 02:29:05 +0700
commit2c78a2dd9c4c860004ebf06c1fcf5b3dd58cb48f (patch)
treea7c2e03b3592cd75173076e56efd7df4ab2bbb70 /src/common
parentc0113f0de10030509fec63abdfb55e0ded3e1063 (diff)
edpt stream only support non-fifo mode if needed CFG_TUSB_EDPT_STREAM_NO_FIFO_ENABLED
Diffstat (limited to 'src/common')
-rw-r--r--src/common/tusb_fifo.h7
-rw-r--r--src/common/tusb_private.h12
2 files changed, 16 insertions, 3 deletions
diff --git a/src/common/tusb_fifo.h b/src/common/tusb_fifo.h
index 42f154bca..94ab421bb 100644
--- a/src/common/tusb_fifo.h
+++ b/src/common/tusb_fifo.h
@@ -224,10 +224,11 @@ TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_fifo_write_n(tu_fifo_t *f, const
//--------------------------------------------------------------------+
// return overflowable count (index difference), which can be used to determine both fifo count and an overflow state
TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_ff_overflow_count(uint16_t depth, uint16_t wr_idx, uint16_t rd_idx) {
- if (wr_idx >= rd_idx) {
- return (uint16_t)(wr_idx - rd_idx);
+ const int32_t diff = (int32_t)wr_idx - (int32_t)rd_idx;
+ if (diff >= 0) {
+ return (uint16_t)diff;
} else {
- return (uint16_t)(2 * depth - (rd_idx - wr_idx));
+ return (uint16_t)(2 * depth + diff);
}
}
diff --git a/src/common/tusb_private.h b/src/common/tusb_private.h
index 8643bb020..0e9eef732 100644
--- a/src/common/tusb_private.h
+++ b/src/common/tusb_private.h
@@ -33,6 +33,18 @@
extern "C" {
#endif
+//--------------------------------------------------------------------+
+// Configuration
+//--------------------------------------------------------------------+
+
+#if CFG_TUD_ENABLED && CFG_TUD_VENDOR && (CFG_TUD_VENDOR_TX_BUFSIZE == 0 || CFG_TUD_VENDOR_RX_BUFSIZE == 0)
+ #define CFG_TUSB_EDPT_STREAM_NO_FIFO_ENABLED 1
+#endif
+
+#ifndef CFG_TUSB_EDPT_STREAM_NO_FIFO_ENABLED
+ #define CFG_TUSB_EDPT_STREAM_NO_FIFO_ENABLED 0
+#endif
+
#define TUP_USBIP_CONTROLLER_NUM 2
extern tusb_role_t _tusb_rhport_role[TUP_USBIP_CONTROLLER_NUM];