Merge pull request #7227 from jepler/serial-break-is-interrupt

Allow serial "break" to trigger KeyboardInterrupt
This commit is contained in:
Dan Halbert 2022-11-18 19:26:17 -05:00 committed by GitHub
commit 0f6c708cb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -341,7 +341,7 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ
#endif // CIRCUITPY_USB_VENDOR
#if MICROPY_KBD_EXCEPTION
#if MICROPY_KBD_EXCEPTION && CIRCUITPY_USB_CDC
/**
* Callback invoked when received an "wanted" char.
@ -359,4 +359,10 @@ void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char) {
}
}
void tud_cdc_send_break_cb(uint8_t itf, uint16_t duration_ms) {
if (usb_cdc_console_enabled() && mp_interrupt_char != -1 && itf == 0 && duration_ms > 0) {
mp_sched_keyboard_interrupt();
}
}
#endif