mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
fix(uart): fix some uart port generate a RX BRK_DET intr on reset issue
Issue saw on S3 UART2 and some LP_UART ports
This commit is contained in:
@@ -218,6 +218,10 @@ static void uart_module_enable(uart_port_t uart_num)
|
||||
uart_ll_enable_bus_clock(uart_num, true);
|
||||
}
|
||||
if (uart_num != CONFIG_ESP_CONSOLE_UART_NUM) {
|
||||
// Workaround: Set RX signal to high to avoid false RX BRK_DET interrupt raised after register reset
|
||||
if (uart_context[uart_num].rx_io_num == -1) {
|
||||
esp_rom_gpio_connect_in_signal(GPIO_MATRIX_CONST_ONE_INPUT, UART_PERIPH_SIGNAL(uart_num, SOC_UART_RX_PIN_IDX), false);
|
||||
}
|
||||
HP_UART_BUS_CLK_ATOMIC() {
|
||||
uart_ll_reset_register(uart_num);
|
||||
}
|
||||
@@ -248,6 +252,16 @@ static void uart_module_enable(uart_port_t uart_num)
|
||||
}
|
||||
#if (SOC_UART_LP_NUM >= 1)
|
||||
else {
|
||||
// Workaround: Set RX signal to high to avoid false RX BRK_DET interrupt raised after register reset
|
||||
if (uart_context[uart_num].rx_io_num == -1) { // if RX pin is already configured, then workaround not needed, skip
|
||||
#if SOC_LP_GPIO_MATRIX_SUPPORTED
|
||||
lp_gpio_connect_in_signal(LP_GPIO_MATRIX_CONST_ONE_INPUT, UART_PERIPH_SIGNAL(uart_num, SOC_UART_RX_PIN_IDX), false);
|
||||
#else
|
||||
// the signal is directly connected to its LP IO pin, the only way is to enable its pullup
|
||||
uint32_t io_num = uart_periph_signal[uart_num].pins[SOC_UART_RX_PIN_IDX].default_gpio;
|
||||
gpio_pullup_en(io_num);
|
||||
#endif
|
||||
}
|
||||
LP_UART_BUS_CLK_ATOMIC() {
|
||||
lp_uart_ll_enable_bus_clock(TO_LP_UART_NUM(uart_num), true);
|
||||
lp_uart_ll_reset_register(TO_LP_UART_NUM(uart_num));
|
||||
@@ -713,6 +727,12 @@ static bool uart_try_set_iomux_pin(uart_port_t uart_num, int io_num, uint32_t id
|
||||
}
|
||||
rtc_gpio_init(io_num);
|
||||
rtc_gpio_iomux_func_sel(io_num, upin->iomux_func);
|
||||
// undo the workaround done in uart_module_enable for RX pin
|
||||
#if !SOC_LP_GPIO_MATRIX_SUPPORTED
|
||||
if (upin->input) {
|
||||
gpio_pullup_dis(io_num);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1952,12 +1972,6 @@ esp_err_t uart_driver_install(uart_port_t uart_num, int rx_buffer_size, int tx_b
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
uart_intr_config_t uart_intr = {
|
||||
.intr_enable_mask = UART_INTR_CONFIG_FLAG,
|
||||
.rxfifo_full_thresh = UART_THRESHOLD_NUM(uart_num, UART_FULL_THRESH_DEFAULT),
|
||||
.rx_timeout_thresh = UART_TOUT_THRESH_DEFAULT,
|
||||
.txfifo_empty_intr_thresh = UART_THRESHOLD_NUM(uart_num, UART_EMPTY_THRESH_DEFAULT),
|
||||
};
|
||||
uart_module_enable(uart_num);
|
||||
uart_hal_disable_intr_mask(&(uart_context[uart_num].hal), UART_LL_INTR_MASK);
|
||||
uart_hal_clr_intsts_mask(&(uart_context[uart_num].hal), UART_LL_INTR_MASK);
|
||||
@@ -1967,6 +1981,12 @@ esp_err_t uart_driver_install(uart_port_t uart_num, int rx_buffer_size, int tx_b
|
||||
&p_uart_obj[uart_num]->intr_handle);
|
||||
ESP_GOTO_ON_ERROR(ret, err, UART_TAG, "Could not allocate an interrupt for UART");
|
||||
|
||||
uart_intr_config_t uart_intr = {
|
||||
.intr_enable_mask = UART_INTR_CONFIG_FLAG,
|
||||
.rxfifo_full_thresh = UART_THRESHOLD_NUM(uart_num, UART_FULL_THRESH_DEFAULT),
|
||||
.rx_timeout_thresh = UART_TOUT_THRESH_DEFAULT,
|
||||
.txfifo_empty_intr_thresh = UART_THRESHOLD_NUM(uart_num, UART_EMPTY_THRESH_DEFAULT),
|
||||
};
|
||||
ret = uart_intr_config(uart_num, &uart_intr);
|
||||
ESP_GOTO_ON_ERROR(ret, err, UART_TAG, "Could not configure the interrupt for UART");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user