diff options
| author | Ha Thach <[email protected]> | 2024-07-11 21:36:00 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-07-11 21:36:00 +0700 |
| commit | 65b3edbb091201c1b22dca9087a802e231824874 (patch) | |
| tree | 33e243f6b2dedf1c39a37dc2e7316d325e7e343b /examples/device | |
| parent | cb37a17ef7ed3dad86feb89e0fe2830e62a4346e (diff) | |
| parent | e251493a161b5a383fd7f8861e3bf7ea72bf872c (diff) | |
Merge pull request #2705 from hathach/v203-use-224kb
V203 use 224kb
Diffstat (limited to 'examples/device')
| -rw-r--r-- | examples/device/cdc_dual_ports/src/main.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/device/cdc_dual_ports/src/main.c b/examples/device/cdc_dual_ports/src/main.c index 1167a5d50..ef12186f2 100644 --- a/examples/device/cdc_dual_ports/src/main.c +++ b/examples/device/cdc_dual_ports/src/main.c @@ -119,6 +119,26 @@ static void cdc_task(void) { } } +// Invoked when cdc when line state changed e.g connected/disconnected +// Use to reset to DFU when disconnect with 1200 bps +void tud_cdc_line_state_cb(uint8_t instance, bool dtr, bool rts) { + (void)rts; + + // DTR = false is counted as disconnected + if (!dtr) { + // touch1200 only with first CDC instance (Serial) + if (instance == 0) { + cdc_line_coding_t coding; + tud_cdc_get_line_coding(&coding); + if (coding.bit_rate == 1200) { + if (board_reset_to_bootloader) { + board_reset_to_bootloader(); + } + } + } + } +} + //--------------------------------------------------------------------+ // BLINKING TASK //--------------------------------------------------------------------+ |
