Skip to content

Commit cea7670

Browse files
Solonix-Chumysterywolf
authored andcommitted
bsp: cvitek: fix cvitek uart driver can not repeat configure
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]>
1 parent 3174fcd commit cea7670

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Diff for: bsp/cvitek/drivers/drv_uart.c

+4
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,15 @@ static rt_err_t dw8250_uart_configure(struct rt_serial_device *serial, struct se
115115
rt_base_t base;
116116
struct hw_uart_device *uart;
117117
int clock_divisor;
118+
int last_ier_state;
118119

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

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

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

137+
dw8250_write32(base, UART_IER, last_ier_state);
138+
135139
return RT_EOK;
136140
}
137141

0 commit comments

Comments
 (0)