Skip to content

Commit

Permalink
bsp: cvitek: fix cvitek uart driver can not repeat configure
Browse files Browse the repository at this point in the history
After first called from uart open, the dw8250_uart_configure
API cannot be called again. Otherwise, this will mess up the
device, and uart will not act properly to interrupt again.

Analysis: Configure uart device will close recive interrupte,
causing uart device to malfunction.

Solution: After configure uart device, enable the device's
recive interrupte.

Signed-off-by: Shicheng Chu <[email protected]>
Reviewed-by: Chen Wang <[email protected]>
  • Loading branch information
Z8MAN8 authored and mysterywolf committed Sep 4, 2024
1 parent 3174fcd commit cea7670
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bsp/cvitek/drivers/drv_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,15 @@ static rt_err_t dw8250_uart_configure(struct rt_serial_device *serial, struct se
rt_base_t base;
struct hw_uart_device *uart;
int clock_divisor;
int last_ier_state;

RT_ASSERT(serial != RT_NULL);
uart = (struct hw_uart_device *)serial->parent.user_data;
base = uart->hw_base;

while (!(dw8250_read32(base, UART_LSR) & UART_LSR_TEMT));

last_ier_state = dw8250_read32(base, UART_IER);
dw8250_write32(base, UART_IER, 0);
dw8250_write32(base, UART_MCR, UART_MCRVAL);
dw8250_write32(base, UART_FCR, UART_FCR_DEFVAL);
Expand All @@ -132,6 +134,8 @@ static rt_err_t dw8250_uart_configure(struct rt_serial_device *serial, struct se
clock_divisor = DIV_ROUND_CLOSEST(UART_INPUT_CLK, 16 * serial->config.baud_rate);
dw8250_uart_setbrg(base, clock_divisor);

dw8250_write32(base, UART_IER, last_ier_state);

return RT_EOK;
}

Expand Down

0 comments on commit cea7670

Please sign in to comment.