Line 27... |
Line 27... |
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
/* This program is commented throughout in a fashion suitable for processing
|
/* This program is commented throughout in a fashion suitable for processing
|
with Doxygen. */
|
with Doxygen. */
|
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
|
|
#include "or1ksim-board.h"
|
#include "or1k-support.h"
|
#include "uart.h"
|
#include "uart.h"
|
|
|
|
|
/*! Macro to access a UART register */
|
/*! Macro to access a UART register */
|
#define UREG8(reg) REG8 (UART_BASE + reg)
|
#define UREG8(reg) REG8 (_board_uart_base + reg)
|
|
|
/*! Macro to check if transmit and transmit holding registers are both empty. */
|
/*! Macro to check if transmit and transmit holding registers are both empty. */
|
#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
|
#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
|
|
|
/*! Macro to wait until a char has been transmitted */
|
/*! Macro to wait until a char has been transmitted */
|
Line 84... |
Line 83... |
|
|
/* Set 8 bit char, 1 stop bit, no parity */
|
/* Set 8 bit char, 1 stop bit, no parity */
|
UREG8 (UART_LCR) = UART_LCR_WLEN8 & ~(UART_LCR_STOP | UART_LCR_PARITY);
|
UREG8 (UART_LCR) = UART_LCR_WLEN8 & ~(UART_LCR_STOP | UART_LCR_PARITY);
|
|
|
/* Set baud rate */
|
/* Set baud rate */
|
divisor = IN_CLK / (16 * UART_BAUD_RATE);
|
divisor = _board_clk_freq / (16 * _board_uart_baud);
|
|
|
UREG8 (UART_LCR) |= UART_LCR_DLAB;
|
UREG8 (UART_LCR) |= UART_LCR_DLAB;
|
UREG8 (UART_DLL) = divisor & 0x000000ff;
|
UREG8 (UART_DLL) = divisor & 0x000000ff;
|
UREG8 (UART_DLM) = (divisor >> 8) & 0x000000ff;
|
UREG8 (UART_DLM) = (divisor >> 8) & 0x000000ff;
|
UREG8 (UART_LCR) &= ~(UART_LCR_DLAB);
|
UREG8 (UART_LCR) &= ~(UART_LCR_DLAB);
|