Skip to content

Commit 53485b4

Browse files
committed
tweak to dual host info device cdc to make it easier to pass hil test
1 parent 1f8968f commit 53485b4

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

examples/dual/host_info_to_device_cdc/src/main.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ static void usb_device_init(void) {
108108
tusb_init(BOARD_TUD_RHPORT, &dev_init);
109109
tud_cdc_configure_t cdc_cfg = TUD_CDC_CONFIGURE_DEFAULT();
110110
cdc_cfg.tx_persistent = true;
111+
cdc_cfg.tx_overwritabe_if_not_connected = false;
111112
tud_cdc_configure(&cdc_cfg);
112113
board_init_after_tusb();
113114
}
@@ -209,6 +210,13 @@ void tud_resume_cb(void) {
209210
}
210211

211212
void cdc_task(void) {
213+
if (!tud_cdc_connected()) {
214+
// delay a bit otherwise we can outpace host's terminal. Linux will set LineState (DTR) then Line Coding.
215+
// If we send data before Linux's terminal set Line Coding, it can be ignored --> missing data with hardware test loop
216+
tusb_time_delay_ms_api(50);
217+
return;
218+
}
219+
212220
for (uint8_t daddr = 1; daddr <= CFG_TUH_DEVICE_MAX; daddr++) {
213221
if (tuh_mounted(daddr)) {
214222
if (is_print[daddr]) {

examples/dual/host_info_to_device_cdc/src/tusb_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112

113113
// CDC FIFO size of TX and RX
114114
#define CFG_TUD_CDC_RX_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
115-
#define CFG_TUD_CDC_TX_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
115+
#define CFG_TUD_CDC_TX_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 256)
116116

117117
// CDC Endpoint transfer buffer size, more is faster
118118
#define CFG_TUD_CDC_EP_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)

0 commit comments

Comments
 (0)