/* * $Id: cons_ns16550.c,v 1.1 2008/08/19 16:35:35 nbrk Exp $ */ /* * ns16550 USART to be used by bootldr. */ #include #include #define IO_BASE 0x7c000000 #define USART0_BASE (IO_BASE + 0x3f8) #define USART1_BASE (IO_BASE + 0x2f8) #define UART_DR 0 /* TX/RX data register */ #define UART_LSR 5 /* line status register */ #define LST_DR 0x01 /* receiver data ready */ #define LSR_TEMT 0x40 /* transmitter empty */ void putchar(int c) { uint32_t dev; dev = USART0_BASE; /* poll TEMT */ while (((*(volatile uint32_t *)(dev + UART_LSR * 4)) & LSR_TEMT) != 0) ; /* write tx fifo */ *(volatile uint32_t *)(dev + UART_DR * 4) = (c & 0x7f); }