17#define UART_BASE 0xA130C1
20#define UART_CLK 24000000LU
24#define UART_BR 1500000LU
30#define UART_TX_FIFO_LEN 16
32#define UART_BUFLEN 1460
35#define DivWithRounding(dividend, divisor) ((((dividend)*2/(divisor))+1)/2)
37#define UART_DLM_VAL (DivWithRounding(UART_CLK, 16 * UART_BR)>>8)
40#define UART_DLL_VAL (DivWithRounding(UART_CLK, 16 * UART_BR) & 0xFF)
51#define UART_RHR (*((volatile uint8_t*)(UART_BASE + 0)))
53#define UART_THR (*((volatile uint8_t*)(UART_BASE + 0)))
55#define UART_IER (*((volatile uint8_t*)(UART_BASE + 2)))
57#define UART_FCR (*((volatile uint8_t*)(UART_BASE + 4)))
59#define UART_ISR (*((volatile uint8_t*)(UART_BASE + 4)))
61#define UART_LCR (*((volatile uint8_t*)(UART_BASE + 6)))
63#define UART_MCR (*((volatile uint8_t*)(UART_BASE + 8)))
65#define UART_LSR (*((volatile uint8_t*)(UART_BASE + 10)))
67#define UART_MSR (*((volatile uint8_t*)(UART_BASE + 12)))
69#define UART_SPR (*((volatile uint8_t*)(UART_BASE + 14)))
71#define UART_DLL (*((volatile uint8_t*)(UART_BASE + 0)))
73#define UART_DLM (*((volatile uint8_t*)(UART_BASE + 2)))
92#define UART_MCR__DTR 0x01
93#define UART_MCR__RTS 0x02
94#define UART_MCR__OUT1 0x04
95#define UART_MCR__OUT2 0x08
101#define UART_MSR__DSR 0x20
108#define MW__RESET UART_MCR__DTR
109#define MW__PRG UART_MCR__RTS
110#define MW__DCD UART_MSR__DSR
162#define uart_set(reg, val) do{sh.reg = (val);UART_##reg = (val);}while(0)
170#define uart_get(reg) (sh.reg)
178#define uart_set_bits(reg, val) do{sh.reg |= (val); \
179 UART_##reg = sh.reg;}while(0)
187#define uart_clr_bits(reg, val) do{sh.reg &= ~(val); \
188 UART_##reg = sh.reg;}while(0)
201#define uart_test(reg, val) reg = val;
205void uart_reset(
void);
207void uart_start(
void);
void uart_reset_fifos()
Reset TX and RX FIFOs.
void uart_init(void)
Initializes the driver. The baud rate is set to UART_BR, and the UART FIFOs are enabled....
void uart_line_sync(void)
Sends syncrhonization frame.
bool uart_tx_ready()
Checks if UART transmit register/FIFO is ready. In FIFO mode, up to 16 characters can be loaded each ...
bool uart_is_present(void)
Check if uart is present.
void uart_putc(u8 c)
Sends a character. Please make sure there is room in the transmit register/FIFO by calling uart_rx_re...
u8 uart_getc()
Returns a received character. Please make sure data is available by calling uart_rx_ready() before us...
bool uart_rx_ready()
Checks if UART receive register/FIFO has data available.
UartShadow sh
Uart shadow registers. Do NOT access directly!
MegaWiFi command message definitions.
Structure with the shadow registers.
Definition 16c550.h:78
uint8_t MCR
Modem Control Register.
Definition 16c550.h:82
uint8_t FCR
FIFO Control Register.
Definition 16c550.h:80
uint8_t LCR
Line Control Register.
Definition 16c550.h:81
uint8_t IER
Interrupt Enable Register.
Definition 16c550.h:79
unsigned char u8
Definition types.h:95