fix build errors

This commit is contained in:
Tomasz Duda 2024-02-03 00:03:02 +01:00
parent d6ce6a2f4c
commit 02b3e27cf2
3 changed files with 16 additions and 11 deletions

View File

@ -274,10 +274,16 @@ async def to_code(config):
add_idf_sdkconfig_option("CONFIG_ESP_CONSOLE_USB_CDC", True)
elif config[CONF_HARDWARE_UART] == USB_SERIAL_JTAG:
add_idf_sdkconfig_option("CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG", True)
if config[CONF_HARDWARE_UART] == USB_SERIAL_JTAG:
try:
uart_selection(USB_SERIAL_JTAG)
cg.add_build_flag("-DUSE_USB_SERIAL_JTAG")
elif config[CONF_HARDWARE_UART] == USB_CDC:
except cv.Invalid:
pass
try:
uart_selection(USB_CDC)
cg.add_build_flag("-DUSE_USB_CDC")
except cv.Invalid:
pass
# Register at end for safe mode
await cg.register_component(log, config)

View File

@ -39,11 +39,13 @@ enum UARTSelection {
#else
UART_SELECTION_UART0 = 0,
UART_SELECTION_UART1,
#if defined(USE_ESP32)
#if !defined(USE_ESP32_VARIANT_ESP32C3) && !defined(USE_ESP32_VARIANT_ESP32C6) && \
!defined(USE_ESP32_VARIANT_ESP32S2) && !defined(USE_ESP32_VARIANT_ESP32S3) && !defined(USE_ESP32_VARIANT_ESP32H2)
UART_SELECTION_UART2,
#endif // !USE_ESP32_VARIANT_ESP32C3 && !USE_ESP32_VARIANT_ESP32C6 && !USE_ESP32_VARIANT_ESP32S2 &&
// !USE_ESP32_VARIANT_ESP32S3 && !USE_ESP32_VARIANT_ESP32H2
#endif // USE_ESP32
#ifdef USE_USB_CDC
UART_SELECTION_USB_CDC,
#endif

View File

@ -63,7 +63,7 @@ static void init_usb_serial_jtag_() {
}
#endif
void init_uart_(uart_port_t uart_num, uint32_t baud_rate, int tx_buffer_size) {
void init_uart(uart_port_t uart_num, uint32_t baud_rate, int tx_buffer_size) {
uart_config_t uart_config{};
uart_config.baud_rate = (int) baud_rate;
uart_config.data_bits = UART_DATA_8_BITS;
@ -109,9 +109,6 @@ void Logger::pre_setup() {
#if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32C3)
case UART_SELECTION_USB_CDC:
#endif // USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3 || USE_ESP32_VARIANT_ESP32C3
#if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32S3)
case UART_SELECTION_USB_SERIAL_JTAG:
#endif // USE_ESP32_VARIANT_ESP32C3 || USE_ESP32_VARIANT_ESP32S3
#if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32C3)
#if ARDUINO_USB_CDC_ON_BOOT
this->hw_serial_ = &Serial;
@ -158,7 +155,7 @@ void Logger::pre_setup() {
// USE_ESP32_VARIANT_ESP32H2
}
if (this->uart_num_ >= 0) {
init_uart_(this->uart_num_, baud_rate_, tx_buffer_size_);
init_uart(this->uart_num_, baud_rate_, tx_buffer_size_);
}
#endif // USE_ESP_IDF
}
@ -181,12 +178,12 @@ const char *const UART_SELECTIONS[] = {
"UART2",
#endif // !USE_ESP32_VARIANT_ESP32C3 && !USE_ESP32_VARINT_ESP32C6 && !USE_ESP32_VARIANT_ESP32S2 &&
// !USE_ESP32_VARIANT_ESP32S3 && !USE_ESP32_VARIANT_ESP32H2
#if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3)
#ifdef USE_USB_CDC
"USB_CDC",
#endif // USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3
#if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32S3)
#endif
#ifdef USE_USB_SERIAL_JTAG
"USB_SERIAL_JTAG",
#endif // USE_ESP32_VARIANT_ESP32C3 || USE_ESP32_VARIANT_ESP32S3
#endif
};
const char *Logger::get_uart_selection_() { return UART_SELECTIONS[this->uart_]; }