summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorhathach <[email protected]>2024-01-20 01:42:31 +0700
committerhathach <[email protected]>2024-01-20 01:42:31 +0700
commit87d509d416ea7c250f4256f897f6cc9a7b7d2121 (patch)
treeedefa264a7aba27bfabb66b6168bdad9cc1e8af4 /examples
parent55cb713264a1fe531b548a05290ee8fe1289828f (diff)
make CFG_TUH_CDC_LINE_CODING_ON_ENUM optional for ch34x
Diffstat (limited to 'examples')
-rw-r--r--examples/host/cdc_msc_hid/src/cdc_app.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/examples/host/cdc_msc_hid/src/cdc_app.c b/examples/host/cdc_msc_hid/src/cdc_app.c
index 81052047c..e275e7943 100644
--- a/examples/host/cdc_msc_hid/src/cdc_app.c
+++ b/examples/host/cdc_msc_hid/src/cdc_app.c
@@ -85,13 +85,17 @@ void tuh_cdc_mount_cb(uint8_t idx) {
itf_info.desc.bInterfaceNumber);
#ifdef CFG_TUH_CDC_LINE_CODING_ON_ENUM
- // CFG_TUH_CDC_LINE_CODING_ON_ENUM must be defined for line coding is set by tinyusb in enumeration
- // otherwise you need to call tuh_cdc_set_line_coding() first
+ // If CFG_TUH_CDC_LINE_CODING_ON_ENUM is defined, line coding will be set by tinyusb stack
+ // while eneumerating new cdc device
cdc_line_coding_t line_coding = {0};
if (tuh_cdc_get_local_line_coding(idx, &line_coding)) {
printf(" Baudrate: %lu, Stop Bits : %u\r\n", line_coding.bit_rate, line_coding.stop_bits);
printf(" Parity : %u, Data Width: %u\r\n", line_coding.parity, line_coding.data_bits);
}
+#else
+ // Set Line Coding upon mounted
+ cdc_line_coding_t new_line_coding = { 115200, CDC_LINE_CODING_STOP_BITS_1, CDC_LINE_CODING_PARITY_NONE, 8 };
+ tuh_cdc_set_line_coding(idx, &new_line_coding, NULL, 0);
#endif
}