Skip to content

Commit 05316bd

Browse files
sylvioalvesnashif
authored andcommitted
drivers: uart: esp32: avoid pin re-configuration on uart_configure()
Ensure uart_configure() only updates UART parameters without reassigning pin configuration. Pin assignment via pinctrl is now restricted to the initialization procedure, guaranteeing pins are set only when properly configured. Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
1 parent 5925d71 commit 05316bd

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

drivers/serial/uart_esp32.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,6 @@ static int uart_esp32_configure(const struct device *dev, const struct uart_conf
273273
uint32_t sclk_freq;
274274
uint32_t inv_mask = 0;
275275

276-
int ret = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
277-
278-
if (ret < 0) {
279-
return ret;
280-
}
281-
282276
if (!device_is_ready(config->clock_dev)) {
283277
return -ENODEV;
284278
}
@@ -939,17 +933,23 @@ static int uart_esp32_async_rx_disable(const struct device *dev)
939933

940934
static int uart_esp32_init(const struct device *dev)
941935
{
936+
int ret;
942937
struct uart_esp32_data *data = dev->data;
943-
int ret = uart_esp32_configure(dev, &data->uart_config);
938+
const struct uart_esp32_config *config = dev->config;
944939

940+
ret = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
941+
if (ret < 0) {
942+
LOG_ERR("Error configuring UART pins (%d)", ret);
943+
return ret;
944+
}
945+
946+
ret = uart_esp32_configure(dev, &data->uart_config);
945947
if (ret < 0) {
946948
LOG_ERR("Error configuring UART (%d)", ret);
947949
return ret;
948950
}
949951

950952
#if CONFIG_UART_INTERRUPT_DRIVEN || CONFIG_UART_ASYNC_API
951-
const struct uart_esp32_config *config = dev->config;
952-
953953
ret = esp_intr_alloc(config->irq_source,
954954
ESP_PRIO_TO_FLAGS(config->irq_priority) |
955955
ESP_INT_FLAGS_CHECK(config->irq_flags),

0 commit comments

Comments
 (0)