Merge pull request #7973 from tannewt/maybe_help_c3

Check usb/jtag for incoming chars too
This commit is contained in:
Dan Halbert 2023-05-15 21:44:46 -04:00 committed by GitHub
commit afdc3a5ced
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -101,21 +101,28 @@ bool usb_serial_jtag_connected(void) {
}
char usb_serial_jtag_read_char(void) {
if (ringbuf_num_filled(&ringbuf) == 0) {
if (ringbuf_num_filled(&ringbuf) == 0 && !usb_serial_jtag_ll_rxfifo_data_available()) {
return -1;
}
char c = ringbuf_get(&ringbuf);
char c = -1;
if (ringbuf_num_filled(&ringbuf) > 0) {
c = ringbuf_get(&ringbuf);
}
// Maybe re-enable the recv interrupt if we've emptied the ringbuf.
if (ringbuf_num_filled(&ringbuf) == 0) {
usb_serial_jtag_ll_disable_intr_mask(USB_SERIAL_JTAG_INTR_SERIAL_OUT_RECV_PKT);
_copy_out_of_fifo();
usb_serial_jtag_ll_ena_intr_mask(USB_SERIAL_JTAG_INTR_SERIAL_OUT_RECV_PKT);
// May have only been ctrl-c.
if (c == -1 && ringbuf_num_filled(&ringbuf) > 0) {
c = ringbuf_get(&ringbuf);
}
}
return c;
}
bool usb_serial_jtag_bytes_available(void) {
return ringbuf_num_filled(&ringbuf) > 0;
return ringbuf_num_filled(&ringbuf) > 0 || usb_serial_jtag_ll_rxfifo_data_available();
}
void usb_serial_jtag_write(const char *text, uint32_t length) {