ls1bdev: don't hardcode the uart base address in rt_hw_console_output

This commit is contained in:
Grissiom 2014-08-18 15:14:22 +08:00
parent f1bc40d697
commit 259cfdc79f
1 changed files with 24 additions and 18 deletions

View File

@ -71,6 +71,23 @@ void rt_hw_board_init(void)
rt_kprintf("current sr: 0x%08x\n", read_c0_status()); 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 */ /* UART line status register value */
#define UARTLSR_ERROR (1 << 7) #define UARTLSR_ERROR (1 << 7)
#define UARTLSR_TE (1 << 6) #define UARTLSR_TE (1 << 6)
@ -82,24 +99,13 @@ void rt_hw_board_init(void)
#define UARTLSR_DR (1 << 0) #define UARTLSR_DR (1 << 0)
void rt_hw_console_output(const char *ptr) void rt_hw_console_output(const char *ptr)
{ {
/* stream mode */ #if defined(RT_USING_UART0)
while (*ptr) __raw_out_put(0);
{ #elif defined(RT_USING_UART1)
if (*ptr == '\n') __raw_out_put(1);
{ #elif defined(RT_USING_UART3)
/* FIFO status, contain valid data */ __raw_out_put(3);
while (!(UART_LSR(UART0_BASE) & (UARTLSR_TE | UARTLSR_TFE))); #endif
/* 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 ++;
}
} }
/*@}*/ /*@}*/