Skip to content

Commit 7bc1a5e

Browse files
committed
fix(usb): Fix log prints
1 parent 4c4714f commit 7bc1a5e

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

cores/esp32/HWCDC.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static void hw_cdc_isr_handler(void *arg) {
9191
if (tx_ring_buf != NULL && usb_serial_jtag_ll_txfifo_writable() == 1) {
9292
// We disable the interrupt here so that the interrupt won't be triggered if there is no data to send.
9393
usb_serial_jtag_ll_disable_intr_mask(USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY);
94-
size_t queued_size;
94+
size_t queued_size = 0;
9595
uint8_t *queued_buff = (uint8_t *)xRingbufferReceiveUpToFromISR(tx_ring_buf, &queued_size, 64);
9696
// If the hardware fifo is available, write in it. Otherwise, do nothing.
9797
if (queued_buff != NULL) { //Although tx_queued_bytes may be larger than 0. We may have interrupt before xRingbufferSend() was called.
@@ -249,6 +249,7 @@ static void ARDUINO_ISR_ATTR cdc0_write_char(char c) {
249249
xRingbufferSend(tx_ring_buf, (void *)(&c), 1, tx_timeout_ms / portTICK_PERIOD_MS);
250250
}
251251
usb_serial_jtag_ll_txfifo_flush();
252+
usb_serial_jtag_ll_ena_intr_mask(USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY);
252253
}
253254

254255
HWCDC::HWCDC() {
@@ -598,9 +599,9 @@ size_t HWCDC::read(uint8_t *buffer, size_t size) {
598599
void HWCDC::setDebugOutput(bool en) {
599600
if (en) {
600601
uartSetDebug(NULL);
601-
ets_install_putc1((void (*)(char)) & cdc0_write_char);
602+
ets_install_putc2((void (*)(char)) & cdc0_write_char);
602603
} else {
603-
ets_install_putc1(NULL);
604+
ets_install_putc2(NULL);
604605
}
605606
}
606607

cores/esp32/USBCDC.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,9 @@ uint32_t USBCDC::baudRate() {
417417
void USBCDC::setDebugOutput(bool en) {
418418
if (en) {
419419
uartSetDebug(NULL);
420-
ets_install_putc1((void (*)(char)) & cdc0_write_char);
420+
ets_install_putc2((void (*)(char)) & cdc0_write_char);
421421
} else {
422-
ets_install_putc1(NULL);
422+
ets_install_putc2(NULL);
423423
}
424424
}
425425

cores/esp32/esp32-hal-uart.c

+1
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,7 @@ void uart_install_putc() {
828828
#endif
829829
default: ets_install_putc1(NULL); break;
830830
}
831+
ets_install_putc2(NULL);
831832
}
832833

833834
// Routines that take care of UART mode in the HardwareSerial Class code

cores/esp32/main.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ void loopTask(void *pvParameters) {
4848
// sets UART0 (default console) RX/TX pins as already configured in boot or as defined in variants/pins_arduino.h
4949
Serial0.setPins(gpioNumberToDigitalPin(SOC_RX0), gpioNumberToDigitalPin(SOC_TX0));
5050
#endif
51-
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG && (!CONFIG_IDF_TARGET_ESP32C3 || !ARDUINO_USB_CDC_ON_BOOT)
51+
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
5252
printBeforeSetupInfo();
5353
#else
5454
if (shouldPrintChipDebugReport()) {
5555
printBeforeSetupInfo();
5656
}
5757
#endif
5858
setup();
59-
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG && (!CONFIG_IDF_TARGET_ESP32C3 || !ARDUINO_USB_CDC_ON_BOOT)
59+
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
6060
printAfterSetupInfo();
6161
#else
6262
if (shouldPrintChipDebugReport()) {

0 commit comments

Comments
 (0)