EVM6418 UART Module
This module communicates through the on-chip 16C550 compatible UART. To use the module, you must use the EVM6418_UART_open() call to get a handle of type EVM6418_UART_Handle which is then passed as a parameter to the other functions.
EVM6418_UART_open()
Description
Open the UART at a specific baud rate and return a UART handle
Required Headers
evm6418.h
evm6418_uart.h
Required Libraries
evm6418bsl.lib
Function Prototype
EVM6418_UART_Handle EVM6418_UART_open(Int16 devid, Int16 baudrate, EVM6418_UART_Config *Config)
Parameters
devid - Device ID, always 0 on the EVM6418
baudrate - baud rate, use constants defined in evm6418_uart.h. Possible values are:
EVM6418_UART_BAUD_56000
EVM6418_UART_BAUD_38400
EVM6418_UART_BAUD_19200
EVM6418_UART_BAUD_9600
EVM6418_UART_BAUD_4800
EVM6418_UART_BAUD_2400
EVM6418_UART_BAUD_1200
config - pointer to a UART register config structure
Return Value
Active UART handle
Example
/* Open UART at 19200 baud in normal (non-FIFO mode) */
EVM6418_UART_Handle hUart;
EVM6418_UART_Config uartcfg = {
0x00, // IER
0x00, // FCR
0x03, // LCR
0x00 // MCR
}
hUart = EVM6418_UART_open(0, EVM6418_UART_BAUD_19200, &uartcfg);
EVM6418_UART_rget()
Description
Get the value of a UART register
Required Headers
evm6418.h
evm6418_uart.h
Required Libraries
evm6418bsl.lib
Function Prototype
Int16 EVM6418_UART_rget(EVM6418_UART_Handle hUart, Int16 regnum)
Parameters
hUart - UART handle (see EVM6418_UART_open( ))
regnum - Index of register to get. Defined in evm6418_uart.h as EVM6418_UART_XXX where XXX is the name of the register
Return Value
Value of register, only lower 8-bits will contain data
Example
/* Get the value of the LCR register */
Int16 data;
data = EVM6418_UART_rget(hUart, EVM6418_UART_LCR);
EVM6418_UART_rset()
Description
Set the value of a UART register
Required Headers
evm6418.h
evm6418_uart.h
Required Libraries
evm6418bsl.lib
Function Prototype
void EVM6418_UART_rset(EVM6418_UART_Handle hUart, Int16 regnum, Int16 regval)
Parameters
hUart - UART handle (see EVM6418_UART_open( ))
regnum - index of register to get. Defined in evm6418_uart.h as EVM6418_UART_XXX where XXX is the name of the register
regval - value to set the register to, only lower 8-bits are assigned
Return Value
None
Example
/* Set the value of the LCR register to 0x03 */
EVM6418_UART_rset(hUart, EVM6418_UART_LCR, 0x03);
EVM6418_UART_getChar()
Description
Get a character from the UART. Spins until a character is available
Required Headers
evm6418.h
evm6418_uart.h
Required Libraries
evm6418bsl.lib
Function Prototype
Int16 EVM6418_UART_getChar(EVM6418_UART_Handle hUart)
Parameters
hUart - UART handle (see EVM6418_UART_open() )
Return Value
Character value
Example
/* Read a character from the UART */
Int16 data;
data = EVM6418_UART_getChar(hUart);
EVM6418_UART_putChar()
Description
Send a character to the UART. Spins until the UART transmitter is ready to accept data.
Required Headers
evm6418.h
evm6418_uart.h
Required Libraries
evm6418bsl.lib
Function Prototype
void EVM6418_UART_rset(EVM6418_UART_Handle hUart, Uint16 data)
Parameters
hUart - UART handle (see EVM6418_UART_open() )
data - Character to be sent
Return Value
None
Example
/* Send the character ‘A’ to the UART */
EVM6418_UART_putChar( hUart, ‘A’ );
|