Skip to content

Commit d00ff3a

Browse files
committed
bsp: k230: update uart driver
Signed-off-by: Wang Chen <[email protected]>
1 parent f9108d6 commit d00ff3a

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

bsp/k230/drivers/interdrv/uart/drv_uart.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
#define UART_DEFAULT_BAUDRATE 115200
1919
#define UART_CLK 50000000
20-
#define UART_ADDR 0x91403000UL
21-
#define UART_IRQ 0x13
20+
#define UART_ADDR 0x91400000UL
21+
#define UART_IRQ 0x10
2222

2323

2424
#define UART_RBR (0x00) /* receive buffer register */
@@ -94,6 +94,7 @@
9494
struct device_uart
9595
{
9696
rt_ubase_t hw_base;
97+
void* pa_base;
9798
rt_uint32_t irqno;
9899
};
99100

@@ -251,7 +252,7 @@ static rt_err_t uart_control(struct rt_serial_device *serial, int cmd, void *arg
251252
return -RT_ENOMEM;
252253
}
253254

254-
mmap2->ret = lwp_map_user_phy(lwp_self(), RT_NULL, (void*)(uart->hw_base), mmap2->length, 0);
255+
mmap2->ret = lwp_map_user_phy(lwp_self(), RT_NULL, uart->pa_base, mmap2->length, 0);
255256
}
256257
break;
257258
}
@@ -311,12 +312,16 @@ static void rt_hw_uart_isr(int irq, void *param)
311312
}
312313
else if (lsr & (UART_LSR_DR | UART_LSR_BI))
313314
{
314-
#ifdef RT_USING_SERIAL_V2
315315
struct rt_serial_rx_fifo *rx_fifo;
316-
uint8_t data;
317-
318316
rx_fifo = (struct rt_serial_rx_fifo *)serial->serial_rx;
319-
RT_ASSERT(rx_fifo != RT_NULL);
317+
318+
if (rx_fifo == NULL)
319+
{
320+
readb((void*)(uart_base + UART_RBR));
321+
return;
322+
}
323+
#ifdef RT_USING_SERIAL_V2
324+
uint8_t data;
320325

321326
do {
322327
data = readb((void*)(uart_base + UART_RBR));
@@ -352,7 +357,8 @@ int rt_hw_uart_init(void)
352357
serial->config = config;
353358
serial->config.baud_rate = UART_DEFAULT_BAUDRATE;
354359

355-
uart->hw_base = (rt_base_t)rt_ioremap((void *)UART_ADDR, 0x1000);
360+
uart->pa_base = (void *)UART_ADDR;
361+
uart->hw_base = (rt_base_t)rt_ioremap(uart->pa_base, 0x1000);
356362
uart->irqno = UART_IRQ;
357363

358364
_uart_init((void*)(uart->hw_base));

0 commit comments

Comments
 (0)