Check usb/jtag for incoming chars too

This commit is contained in:
Scott Shawcroft 2023-05-12 16:49:11 -07:00
parent 827eaeb1f9
commit bd097de277
No known key found for this signature in database
GPG Key ID: 0DFD512649C052DA

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) {