16#define UART_BASE 0xA130C1
19#define UART_CLK 24000000LU
23#define UART_BR 1500000LU
29#define UART_TX_FIFO_LEN 16
32#define DivWithRounding(dividend, divisor) ((((dividend)*2/(divisor))+1)/2)
34#define UART_DLM_VAL (DivWithRounding(UART_CLK, 16 * UART_BR)>>8)
37#define UART_DLL_VAL (DivWithRounding(UART_CLK, 16 * UART_BR) & 0xFF)
48#define UART_RHR (*((volatile uint8_t*)(UART_BASE + 0)))
50#define UART_THR (*((volatile uint8_t*)(UART_BASE + 0)))
52#define UART_IER (*((volatile uint8_t*)(UART_BASE + 2)))
54#define UART_FCR (*((volatile uint8_t*)(UART_BASE + 4)))
56#define UART_ISR (*((volatile uint8_t*)(UART_BASE + 4)))
58#define UART_LCR (*((volatile uint8_t*)(UART_BASE + 6)))
60#define UART_MCR (*((volatile uint8_t*)(UART_BASE + 8)))
62#define UART_LSR (*((volatile uint8_t*)(UART_BASE + 10)))
64#define UART_MSR (*((volatile uint8_t*)(UART_BASE + 12)))
66#define UART_SPR (*((volatile uint8_t*)(UART_BASE + 14)))
68#define UART_DLL (*((volatile uint8_t*)(UART_BASE + 0)))
70#define UART_DLM (*((volatile uint8_t*)(UART_BASE + 2)))
88#define UART_MCR__DTR 0x01
89#define UART_MCR__RTS 0x02
90#define UART_MCR__OUT1 0x04
91#define UART_MCR__OUT2 0x08
97#define UART_MSR__DSR 0x20
113#define uart_tx_ready() (UART_LSR & 0x20)
120#define uart_rx_ready() (UART_LSR & 0x01)
128#define uart_putc(c) do{UART_RHR = (c);}while(0);
136#define uart_getc() (UART_RHR)
144#define uart_set(reg, val) do{sh.reg = (val);UART_##reg = (val);}while(0)
152#define uart_get(reg) (sh.reg)
160#define uart_set_bits(reg, val) do{sh.reg |= (val); \
161 UART_##reg = sh.reg;}while(0)
169#define uart_clr_bits(reg, val) do{sh.reg &= ~(val); \
170 UART_##reg = sh.reg;}while(0)
175#define uart_reset_fifos() uart_set_bits(FCR, 0x07)
183#define uart_test(reg, val) reg = val; \
184 if (reg != val) return MW_ERR
void uart_init(void)
Initializes the driver. The baud rate is set to UART_BR, and the UART FIFOs are enabled....
UartShadow sh
Uart shadow registers. Do NOT access directly!
Structure with the shadow registers.
Definition 16c550.h:74
uint8_t MCR
Modem Control Register.
Definition 16c550.h:78
uint8_t FCR
FIFO Control Register.
Definition 16c550.h:76
uint8_t LCR
Line Control Register.
Definition 16c550.h:77
uint8_t IER
Interrupt Enable Register.
Definition 16c550.h:75