add board_reset_to_bootloader(), try to implement that for ch32v203 but not working yet

This commit is contained in:
hathach
2024-07-05 15:40:02 +07:00
parent 13dedddd19
commit 8d5dbb9577
5 changed files with 57 additions and 2 deletions

View File

@@ -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
//--------------------------------------------------------------------+