From 794f7dd2940b200bcaa052a78b1f0a4adbf38f62 Mon Sep 17 00:00:00 2001 From: Wangjialin Date: Thu, 22 Dec 2016 12:08:15 +0800 Subject: [PATCH] bugfix: uart event mismatch 1. Fix bug of uart frame error and parity error interrupt mismatch in driver code, which will cause the corresponding interrupt can not be cleared correctly, and will finally cause a interrupt watch dog. 2. Add gpio pull-up for rx pin and cts pin. --- components/driver/uart.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/driver/uart.c b/components/driver/uart.c index e85c54d8c..b9ebc4b5f 100644 --- a/components/driver/uart.c +++ b/components/driver/uart.c @@ -387,6 +387,7 @@ esp_err_t uart_set_pin(uart_port_t uart_num, int tx_io_num, int rx_io_num, int r if(rx_io_num >= 0) { PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[rx_io_num], PIN_FUNC_GPIO); + gpio_set_pull_mode(rx_io_num, GPIO_PULLUP_ONLY); gpio_set_direction(rx_io_num, GPIO_MODE_INPUT); gpio_matrix_in(rx_io_num, rx_sig, 0); } @@ -397,6 +398,7 @@ esp_err_t uart_set_pin(uart_port_t uart_num, int tx_io_num, int rx_io_num, int r } if(cts_io_num >= 0) { PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[cts_io_num], PIN_FUNC_GPIO); + gpio_set_pull_mode(cts_io_num, GPIO_PULLUP_ONLY); gpio_set_direction(cts_io_num, GPIO_MODE_INPUT); gpio_matrix_in(cts_io_num, cts_sig, 0); } @@ -639,10 +641,10 @@ static void IRAM_ATTR uart_rx_intr_handler_default(void *param) uart_reg->int_clr.brk_det = 1; uart_event.type = UART_BREAK; } else if(uart_intr_status & UART_FRM_ERR_INT_ST_M) { - uart_reg->int_clr.parity_err = 1; + uart_reg->int_clr.frm_err = 1; uart_event.type = UART_FRAME_ERR; } else if(uart_intr_status & UART_PARITY_ERR_INT_ST_M) { - uart_reg->int_clr.frm_err = 1; + uart_reg->int_clr.parity_err = 1; uart_event.type = UART_PARITY_ERR; } else if(uart_intr_status & UART_TX_BRK_DONE_INT_ST_M) { UART_ENTER_CRITICAL_ISR(&uart_spinlock[uart_num]);