|
SGDK
A free and open development kit for the Sega Mega Drive
|
Simple 16C550 UART chip driver. More...
Topics | |
| UartRegs | |
| 16C550 UART registers | |
| UartOuts | |
| Output pins controlled by the MCR UART register. | |
| UartIns | |
| Input pins readed in the MSR UART register. | |
| mw_ctrl_pins | |
| Pins used to control WiFi module. | |
Classes | |
| struct | UartShadow |
| Structure with the shadow registers. More... | |
Macros | |
| #define | UART_BASE 0xA130C1 |
| 16C550 UART base address | |
| #define | UART_CLK 24000000LU |
| Clock applied to 16C550 chip. Currently using 24 MHz crystal. | |
| #define | UART_BR 1500000LU |
| #define | UART_TX_FIFO_LEN 16 |
| Length of the TX FIFO in bytes. | |
| #define | UART_BUFLEN 1460 |
| #define | DivWithRounding(dividend, divisor) |
| Division with one bit rounding, useful for divisor calculations. | |
| #define | UART_DLM_VAL (DivWithRounding(UART_CLK, 16 * UART_BR)>>8) |
| Value to load on the UART divisor, high byte. | |
| #define | UART_DLL_VAL (DivWithRounding(UART_CLK, 16 * UART_BR) & 0xFF) |
| Value to load on the UART divisor, low byte. | |
| #define | uart_set(reg, val) |
| Sets a value in IER, FCR, LCR or MCR register. | |
| #define | uart_get(reg) |
| Gets value of IER, FCR, LCR or MCR register. | |
| #define | uart_set_bits(reg, val) |
| Sets bits in IER, FCR, LCR or MCR register. | |
| #define | uart_clr_bits(reg, val) |
| Clears bits in IER, FCR, LCR or MCR register. | |
| #define | uart_test(reg, val) |
| Test Connection with registers. | |
Functions | |
| void | uart_init (void) |
| Initializes the driver. The baud rate is set to UART_BR, and the UART FIFOs are enabled. This function must be called before using any other API call. | |
| bool | uart_is_present (void) |
| Check if uart is present. | |
| bool | uart_tx_ready () |
| Checks if UART transmit register/FIFO is ready. In FIFO mode, up to 16 characters can be loaded each time transmitter is ready. | |
| bool | uart_rx_ready () |
| Checks if UART receive register/FIFO has data available. | |
| void | uart_putc (u8 c) |
| Sends a character. Please make sure there is room in the transmit register/FIFO by calling uart_rx_ready() before using this function. | |
| u8 | uart_getc () |
| Returns a received character. Please make sure data is available by calling uart_rx_ready() before using this function. | |
| void | uart_reset_fifos () |
| Reset TX and RX FIFOs. | |
| void | uart_reset (void) |
| void | uart_start (void) |
| void | uart_line_sync (void) |
| Sends syncrhonization frame. | |
Variables | |
| UartShadow | sh |
| Uart shadow registers. Do NOT access directly! | |
Simple 16C550 UART chip driver.
| #define DivWithRounding | ( | dividend, | |
| divisor ) |
Division with one bit rounding, useful for divisor calculations.
| #define UART_BR 1500000LU |
Desired baud rate. Maximum achievable baudrate with 24 MHz crystal is 24000000/16 = 1.5 Mbps
| #define uart_clr_bits | ( | reg, | |
| val ) |
| #define uart_get | ( | reg | ) |
Gets value of IER, FCR, LCR or MCR register.
| [in] | reg | Register to read (IER, FCR, LCR or MCR). |
| #define uart_set | ( | reg, | |
| val ) |
Sets a value in IER, FCR, LCR or MCR register.
| [in] | reg | Register to modify (IER, FCR, LCR or MCR). |
| [in] | val | Value to set in IER, FCR, LCR or MCR register. |
| #define uart_set_bits | ( | reg, | |
| val ) |
| #define uart_test | ( | reg, | |
| val ) |
Test Connection with registers.
| [in] | reg | Register to modify |
| [in] | val | Bits set in val, will be readed from reg register. |
| u8 uart_getc | ( | ) |
Returns a received character. Please make sure data is available by calling uart_rx_ready() before using this function.
| void uart_line_sync | ( | void | ) |
Sends syncrhonization frame.
This function sends a chunk of 0x55 bytes to help physical layer to synchronize. It is usually not necessary to use this function, but might help some UART chips to compute an accurate clock.
| void uart_putc | ( | u8 | c | ) |
Sends a character. Please make sure there is room in the transmit register/FIFO by calling uart_rx_ready() before using this function.
| bool uart_rx_ready | ( | ) |
Checks if UART receive register/FIFO has data available.
| bool uart_tx_ready | ( | ) |
Checks if UART transmit register/FIFO is ready. In FIFO mode, up to 16 characters can be loaded each time transmitter is ready.