Skip to content

Commit c773c61

Browse files
authored
Merge pull request #2629 from andrewleech/cdc-persistent-tx-buffer
Add option to make CDC TX buffer persistent.
2 parents 74e5749 + d01b2cf commit c773c61

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/class/cdc/cdc_device.c

+2
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,9 @@ void cdcd_reset(uint8_t rhport)
295295

296296
tu_memclr(p_cdc, ITF_MEM_RESET_SIZE);
297297
tu_fifo_clear(&p_cdc->rx_ff);
298+
#if !CFG_TUD_CDC_PERSISTENT_TX_BUFF
298299
tu_fifo_clear(&p_cdc->tx_ff);
300+
#endif
299301
tu_fifo_set_overwritable(&p_cdc->tx_ff, true);
300302
}
301303
}

src/class/cdc/cdc_device.h

+6
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@
4141
#define CFG_TUD_CDC_EP_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
4242
#endif
4343

44+
// By default the TX fifo buffer is cleared on connect / bus reset.
45+
// Enable this to persist any data in the fifo instead.
46+
#ifndef CFG_TUD_CDC_PERSISTENT_TX_BUFF
47+
#define CFG_TUD_CDC_PERSISTENT_TX_BUFF (0)
48+
#endif
49+
4450
#ifdef __cplusplus
4551
extern "C" {
4652
#endif

0 commit comments

Comments
 (0)