summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiFiPhile <[email protected]>2024-05-08 12:17:45 +0200
committerGitHub <[email protected]>2024-05-08 12:17:45 +0200
commitc773c612fd4cd3ed9e69875a7553193dc730e363 (patch)
tree4a6cdd8da3b3d2cb700a49b34d55533a750070ff
parent74e57499baac36c4cccf76549259905162031e41 (diff)
parentd01b2cfc0e25e6d64f8d7a2d764c2620e0d9d71f (diff)
Merge pull request #2629 from andrewleech/cdc-persistent-tx-buffer
Add option to make CDC TX buffer persistent.
-rw-r--r--src/class/cdc/cdc_device.c2
-rw-r--r--src/class/cdc/cdc_device.h6
2 files changed, 8 insertions, 0 deletions
diff --git a/src/class/cdc/cdc_device.c b/src/class/cdc/cdc_device.c
index 2e0a0c30d..f36725eba 100644
--- a/src/class/cdc/cdc_device.c
+++ b/src/class/cdc/cdc_device.c
@@ -295,7 +295,9 @@ void cdcd_reset(uint8_t rhport)
tu_memclr(p_cdc, ITF_MEM_RESET_SIZE);
tu_fifo_clear(&p_cdc->rx_ff);
+ #if !CFG_TUD_CDC_PERSISTENT_TX_BUFF
tu_fifo_clear(&p_cdc->tx_ff);
+ #endif
tu_fifo_set_overwritable(&p_cdc->tx_ff, true);
}
}
diff --git a/src/class/cdc/cdc_device.h b/src/class/cdc/cdc_device.h
index 20e908451..db709b3bc 100644
--- a/src/class/cdc/cdc_device.h
+++ b/src/class/cdc/cdc_device.h
@@ -41,6 +41,12 @@
#define CFG_TUD_CDC_EP_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
#endif
+// By default the TX fifo buffer is cleared on connect / bus reset.
+// Enable this to persist any data in the fifo instead.
+#ifndef CFG_TUD_CDC_PERSISTENT_TX_BUFF
+ #define CFG_TUD_CDC_PERSISTENT_TX_BUFF (0)
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif