diff --git a/ports/espressif/boards/seeed_xiao_esp32c6/mpconfigboard.mk b/ports/espressif/boards/seeed_xiao_esp32c6/mpconfigboard.mk index e7ee13c027acd..9d95fe9444969 100644 --- a/ports/espressif/boards/seeed_xiao_esp32c6/mpconfigboard.mk +++ b/ports/espressif/boards/seeed_xiao_esp32c6/mpconfigboard.mk @@ -6,5 +6,3 @@ IDF_TARGET = esp32c6 CIRCUITPY_ESP_FLASH_MODE = qio CIRCUITPY_ESP_FLASH_FREQ = 80m CIRCUITPY_ESP_FLASH_SIZE = 4MB - -CIRCUITPY_ESP_USB_SERIAL_JTAG = 1 diff --git a/ports/espressif/common-hal/busio/UART.c b/ports/espressif/common-hal/busio/UART.c index 3967af44dbd12..a48c3f723732d 100644 --- a/ports/espressif/common-hal/busio/UART.c +++ b/ports/espressif/common-hal/busio/UART.c @@ -106,9 +106,22 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, self->timeout_ms = timeout * 1000; self->uart_num = UART_NUM_MAX; - for (uart_port_t num = 0; num < UART_NUM_MAX; num++) { + + // ESP32-C6 and ESP32-P4 both have a single LP (low power) UART, which is + // limited in what it can do and which pins it can use. Ignore it for now. + // Its UART number is higher than the numbers for the regular ("HP", high-power) UARTs. + + // SOC_UART_LP_NUM is not defined for chips without an LP UART. + #if defined(SOC_UART_LP_NUM) && (SOC_UART_LP_NUM >= 1) + #define UART_LIMIT LP_UART_NUM_0 + #else + #define UART_LIMIT UART_NUM_MAX + #endif + + for (uart_port_t num = 0; num < UART_LIMIT; num++) { if (!uart_is_driver_installed(num)) { self->uart_num = num; + break; } } if (self->uart_num == UART_NUM_MAX) { @@ -224,6 +237,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, int rx_num = -1; int rts_num = -1; int cts_num = -1; + if (have_tx) { claim_pin(tx); self->tx_pin = tx; @@ -254,9 +268,13 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, self->rts_pin = rs485_dir; rts_num = rs485_dir->number; } + if (uart_set_pin(self->uart_num, tx_num, rx_num, rts_num, cts_num) != ESP_OK) { + // Uninstall driver and clean up. + common_hal_busio_uart_deinit(self); raise_ValueError_invalid_pins(); } + if (have_rx) { // On ESP32-C3 and ESP32-S3 (at least), a junk byte with zero or more consecutive 1's can be // generated, even if the pin is pulled high (normal UART resting state) to begin with.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: