diff options
| author | Arda <[email protected]> | 2014-11-24 11:57:31 +0800 |
|---|---|---|
| committer | Arda <[email protected]> | 2014-11-24 11:57:31 +0800 |
| commit | 143d3b82244b977735649e7d7c201d2affe67460 (patch) | |
| tree | 61503d3a150cef8d8184c858efc139b146b50cf6 /bsp/ls1bdev/drivers | |
| parent | bc2a890ab08d163ccea323f7e719c4fdf53050cd (diff) | |
| parent | 9ecd18411fc1344e3d080d844b60c7070c3fb4d8 (diff) | |
Merge pull request #2 from RT-Thread/master
update from official source
Diffstat (limited to 'bsp/ls1bdev/drivers')
| -rw-r--r-- | bsp/ls1bdev/drivers/board.c | 42 | ||||
| -rw-r--r-- | bsp/ls1bdev/drivers/uart.c | 11 |
2 files changed, 31 insertions, 22 deletions
diff --git a/bsp/ls1bdev/drivers/board.c b/bsp/ls1bdev/drivers/board.c index 06a985cf1b..307d8d28b0 100644 --- a/bsp/ls1bdev/drivers/board.c +++ b/bsp/ls1bdev/drivers/board.c @@ -71,6 +71,23 @@ void rt_hw_board_init(void) rt_kprintf("current sr: 0x%08x\n", read_c0_status()); } +#define __raw_out_put(unr) \ + while (*ptr) \ + { \ + if (*ptr == '\n') \ + { \ + /* FIFO status, contain valid data */ \ + while (!(UART_LSR(UART##unr##_BASE) & (UARTLSR_TE | UARTLSR_TFE))); \ + /* write data */ \ + UART_DAT(UART##unr##_BASE) = '\r'; \ + } \ + /* FIFO status, contain valid data */ \ + while (!(UART_LSR(UART##unr##_BASE) & (UARTLSR_TE | UARTLSR_TFE))); \ + /* write data */ \ + UART_DAT(UART##unr##_BASE) = *ptr; \ + ptr ++; \ + } + /* UART line status register value */ #define UARTLSR_ERROR (1 << 7) #define UARTLSR_TE (1 << 6) @@ -82,24 +99,13 @@ void rt_hw_board_init(void) #define UARTLSR_DR (1 << 0) void rt_hw_console_output(const char *ptr) { - /* stream mode */ - while (*ptr) - { - if (*ptr == '\n') - { - /* FIFO status, contain valid data */ - while (!(UART_LSR(UART0_BASE) & (UARTLSR_TE | UARTLSR_TFE))); - /* write data */ - UART_DAT(UART0_BASE) = '\r'; - } - - /* FIFO status, contain valid data */ - while (!(UART_LSR(UART0_BASE) & (UARTLSR_TE | UARTLSR_TFE))); - /* write data */ - UART_DAT(UART0_BASE) = *ptr; - - ptr ++; - } +#if defined(RT_USING_UART0) + __raw_out_put(0); +#elif defined(RT_USING_UART1) + __raw_out_put(1); +#elif defined(RT_USING_UART3) + __raw_out_put(3); +#endif } /*@}*/ diff --git a/bsp/ls1bdev/drivers/uart.c b/bsp/ls1bdev/drivers/uart.c index 4e897391fb..c4ddb581e6 100644 --- a/bsp/ls1bdev/drivers/uart.c +++ b/bsp/ls1bdev/drivers/uart.c @@ -249,13 +249,16 @@ void rt_hw_uart_init(void) uart->parent.type = RT_Device_Class_Char; rt_memset(uart->rx_buffer, 0, sizeof(uart->rx_buffer)); uart->read_index = uart->save_index = 0; - + #if defined(RT_USING_UART0) uart->hw_base = UART0_BASE; uart->irq = LS1B_UART0_IRQ; #elif defined(RT_USING_UART1) uart->hw_base = UART1_BASE; uart->irq = LS1B_UART1_IRQ; +#elif defined(RT_USING_UART3) + uart->hw_base = UART3_BASE; + uart->irq = LS1B_UART3_IRQ; #endif /* device interface */ @@ -267,9 +270,9 @@ void rt_hw_uart_init(void) uart->parent.control = RT_NULL; uart->parent.user_data = RT_NULL; - rt_device_register(&uart->parent, "uart0", - RT_DEVICE_FLAG_RDWR | - RT_DEVICE_FLAG_STREAM | + rt_device_register(&uart->parent, "uart0", + RT_DEVICE_FLAG_RDWR | + RT_DEVICE_FLAG_STREAM | RT_DEVICE_FLAG_INT_RX); } #endif /* end of UART */ |
