Skip to content

Commit b45b56c

Browse files
committed
emb(esp32c3): change USB Serial JTAG output to blocking mode
Change _write() implementation from non-blocking to blocking mode. Now waits until TX FIFO has space before writing instead of dropping characters when FIFO is full.
1 parent 832457e commit b45b56c

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

targets/device/esp/esp32c3.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -347,23 +347,23 @@ static inline int usb_serial_jtag_ll_write_txfifo(const uint8_t *buf, uint32_t w
347347
#include <sys/types.h>
348348

349349
/**
350-
* @brief Write one character to USB Serial JTAG (non-blocking, simplified)
350+
* @brief Write one character to USB Serial JTAG (blocking)
351351
*
352-
* If FIFO is full, character is dropped silently.
353-
* This is a bare-metal implementation without timeout or retry logic.
352+
* Waits until FIFO has space before writing.
354353
*/
355354
static void usb_serial_jtag_write_char(char c) {
356-
// Check if TX FIFO has space
357-
if (usb_serial_jtag_ll_txfifo_writable()) {
358-
uint8_t byte = (uint8_t)c;
359-
usb_serial_jtag_ll_write_txfifo(&byte, 1);
355+
// Wait until TX FIFO has space (blocking)
356+
while (!usb_serial_jtag_ll_txfifo_writable()) {
357+
// Busy wait
358+
}
360359

361-
// Flush on newline to ensure output is displayed immediately
362-
if (c == '\n') {
363-
usb_serial_jtag_ll_txfifo_flush();
364-
}
360+
uint8_t byte = (uint8_t)c;
361+
usb_serial_jtag_ll_write_txfifo(&byte, 1);
362+
363+
// Flush on newline to ensure output is displayed immediately
364+
if (c == '\n') {
365+
usb_serial_jtag_ll_txfifo_flush();
365366
}
366-
// If FIFO is full, character is dropped (non-blocking behavior)
367367
}
368368

369369
/**

0 commit comments

Comments
 (0)