Site Index
   Home
   File Upload
Google

Transfer Site
Main Site

EVM5502 UART Module

This module communicates through the on-chip 16C550 compatible UART. To use the module, you must use the EVM5502_UART_open() call to get a handle of type EVM5502_UART_Handle which is then passed as a parameter to the other functions.

Function Description
EVM5502_UART_open Initialize the UART module and return an active UART handle
EVM5502_UART_rget Read from a UART register
EVM5502_UART_rset Write to a UART register
EVM5502_UART_getChar Get an 8-bit byte through UART
EVM5502_UART_putChar Send an 8-bit byte through UART

EVM5502_UART_open()

Description
Open the UART at a specific baud rate and return a UART handle

Required Headers
evm5502.h
evm5502_uart.h

Required Libraries
evm5502bsl.lib

Function Prototype
EVM5502_UART_Handle EVM5502_UART_open(Int16 devid, Int16 baudrate, EVM5502_UART_Config *Config)

Parameters
devid - Device ID, always 0 on the EVM5502
baudrate - baud rate, use constants defined in evm5502_uart.h. Possible values are:

    EVM5502_UART_BAUD_56000
    EVM5502_UART_BAUD_38400
    EVM5502_UART_BAUD_19200
    EVM5502_UART_BAUD_9600
    EVM5502_UART_BAUD_4800
    EVM5502_UART_BAUD_2400
    EVM5502_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) */
    EVM5502_UART_Handle hUart;
    EVM5502_UART_Config uartcfg = {
        0x00, // IER
        0x00, // FCR
        0x03, // LCR
        0x00  // MCR
    }
    hUart = EVM5502_UART_open(0, 
                EVM5502_UART_BAUD_19200, &uartcfg);

EVM5502_UART_rget()

Description
Get the value of a UART register

Required Headers
evm5502.h
evm5502_uart.h

Required Libraries
evm5502bsl.lib

Function Prototype
Int16 EVM5502_UART_rget(EVM5502_UART_Handle hUart, Int16 regnum)

Parameters
hUart - UART handle (see EVM5502_UART_open() )
regnum - Index of register to get. Defined in evm5502_uart.h as EVM5502_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 = EVM5502_UART_rget(hUart, EVM5502_UART_LCR);

EVM5502_UART_rset()

Description
Set the value of a UART register

Required Headers
evm5502.h
evm5502_uart.h

Required Libraries
evm5502bsl.lib

Function Prototype
void EVM5502_UART_rset(EVM5502_UART_Handle hUart, Int16 regnum, Int16 regval)

Parameters
hUart - UART handle (see EVM5502_UART_open() )
regnum - index of register to get. Defined in evm5502_uart.h as EVM5502_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 */
    EVM5502_UART_rset(hUart, EVM5502_UART_LCR, 0x03);

EVM5502_UART_getChar()

Description
Get a character from the UART. Spins until a character is available

Required Headers
evm5502.h
evm5502_uart.h

Required Libraries
evm5502bsl.lib

Function Prototype
Int16 EVM5502_UART_getChar(EVM5502_UART_Handle hUart)

Parameters
hUart - UART handle (see EVM5502_UART_open() )

Return Value
Character value

Example

    /* Read a character from the UART */
    Int16 data;
    data = EVM5502_UART_getChar(hUart);

EVM5502_UART_putChar()

Description
Send a character to the UART. Spins until the UART transmitter is ready to accept data.

Required Headers
evm5502.h
evm5502_uart.h

Required Libraries
evm5502bsl.lib

Function Prototype
void EVM5502_UART_rset(EVM5502_UART_Handle hUart, Uint16 data)

Parameters
hUart - UART handle (see EVM5502_UART_open() )
data - Character to be sent

Return Value
None

Example

    /* Send the character A to the UART */
    EVM5502_UART_putChar( hUart, A );
©Copyright 2002-2011 Spectrum Digital, Inc. All Rights Reserved.