VxWorks Reference Manual : Libraries

st16552Sio

NAME

st16552Sio - ST 16C552 DUART tty driver

ROUTINES

st16552DevInit( ) - initialise an ST16552 channel
st16552IntWr( ) - handle a transmitter interrupt
st16552IntRd( ) - handle a receiver interrupt
st16552IntEx( ) - miscellaneous interrupt processing
st16552Int( ) - interrupt level processing
st16552MuxInt( ) - multiplexed interrupt level processing

DESCRIPTION

This is the device driver for the Startech ST16C552 DUART, similar, but not quite identical to the National Semiconductor 16550 UART.

The chip is a dual universal asynchronous receiver/transmitter with 16 byte transmit and receive FIFOs and a programmable baud-rate generator. Full modem control capability is included and control over the four interrupts that can be generated: Tx, Rx, Line status, and modem status. Only the Rx and Tx interrupts are used by this driver. The FIFOs are enabled for both Tx and Rx by this driver.

Only asynchronous serial operation is supported by the UART which supports 5 to 8 bit bit word lengths with or without parity and with one or two stop bits. The only serial word format supported by the driver is 8 data bits, 1 stop bit, no parity, The default baud rate is determined by the BSP by filling in the ST16552_CHAN structure before calling st16552DevInit( ).

The exact baud rates supported by this driver will depend on the crystal fitted (and consequently the input clock to the baud-rate generator), but in general, baud rates from about 50 to about 115200 are possible.

DATA STRUCTURES

An ST16552_CHAN data structure is used to describe the two channels of the chip and, if necessary, an ST16552_MUX structure is used to describe the multiplexing of the interrupts for the two channels of the DUART. These structures are described in h/drv/sio/st16552Sio.h.

CALLBACKS

Servicing a "transmitter ready" interrupt involves making a callback to a higher level library in order to get a character to transmit. By default, this driver installs dummy callback routines which do nothing. A higher layer library that wants to use this driver (e.g. ttyDrv) will install its own callback routine using the SIO_INSTALL_CALLBACK ioctl command. Likewise, a receiver interrupt handler makes a callback to pass the character to the higher layer library.

MODES

This driver supports both polled and interrupt modes.

USAGE

The driver is typically only called by the BSP. The directly callable routines in this module are st16552DevInit( ), st16552Int( ), st16552IntRd( ), st16552IntWr( ), and st16552MuxInt.

The BSP's sysHwInit( ) routine typically calls sysSerialHwInit( ), which initialises all the hardware-specific values in the ST16552_CHAN structure before calling st16552DevInit( ) which resets the device and installs the driver function pointers. After this the UART will be enabled and ready to generate interrupts, but those interrupts will be disabled in the interrupt controller.

The following example shows the first parts of the initialisation:

#include "drv/sio/st16552Sio.h"

LOCAL ST16552_CHAN st16552Chan[N_16552_CHANNELS];

void sysSerialHwInit (void)
    {
    int i;

    for (i = 0; i < N_16552_CHANNELS; i++)
        {
        st16552Chan[i].regDelta = devParas[i].regSpace;
        st16552Chan[i].regs = devParas[i].baseAdrs;
        st16552Chan[i].baudRate = CONSOLE_BAUD_RATE;
        st16552Chan[i].xtal = UART_XTAL_FREQ;
        st16552Chan[i].level = devParas[i].intLevel;

        /*
         * Initialise driver functions, getTxChar, putRcvChar and
         * channelMode and init UART.
         */

        st16552DevInit(&st16552Chan[i]);
        }
    }
The BSP's sysHwInit2( ) routine typically calls sysSerialHwInit2( ), which connects the chips interrupts via intConnect( ) (either the single interrupt st16552Int, the three interrupts st16552IntWr, st16552IntRd, and st16552IntEx, or the multiplexed interrupt handler st16552MuxInt which will cope with both channels of a DUART producing the same interrupt). It then enables those interrupts in the interrupt controller as shown in the following example:

void sysSerialHwInit2 (void)
    {
    /* Connect the multiplexed interrupt handler */

    (void) intConnect (INUM_TO_IVEC(devParas[0].vector),
                        st16552MuxInt, (int) &st16552Mux);
    intEnable (devParas[0].intLevel);
    }

BSP

By convention all the BSP-specific serial initialisation is performed in a file called sysSerial.c, which is #include'ed by sysLib.c. sysSerial.c implements at least four functions, sysSerialHwInit( ) sysSerialHwInit2( ), sysSerialChanGet( ), and sysSerialReset( ). The first two have been described above, the others work as follows:

sysSerialChanGet is called by usrRoot to get the serial channel descriptor associated with a serial channel number. The routine takes a single parameter which is a channel number ranging between zero and NUM_TTY. It returns a pointer to the corresponding channel descriptor, SIO_CHAN *, which is just the address of the ST16552_CHAN strucure.

sysSerialReset is called from sysToMonitor( ) and should reset the serial devices to an inactive state (prevent them from generating any interrupts).

INCLUDE FILES

drv/sio/st16552Sio.h sioLib.h

SEE ALSO

st16552Sio, Startech ST16C552 Data Sheet


Libraries : Routines

st16552DevInit( )

NAME

st16552DevInit( ) - initialise an ST16552 channel

SYNOPSIS

void st16552DevInit
    (
    ST16552_CHAN * pChan
    )

DESCRIPTION

This routine initialises some SIO_CHAN function pointers and then resets the chip in a quiescent state. Before this routine is called, the BSP must already have initialised all the device addresses, etc. in the ST16552_CHAN structure.

RETURNS

N/A

SEE ALSO

st16552Sio


Libraries : Routines

st16552IntWr( )

NAME

st16552IntWr( ) - handle a transmitter interrupt

SYNOPSIS

void st16552IntWr
    (
    ST16552_CHAN * pChan /* ptr to struct describing channel */
    )

DESCRIPTION

This routine handles write interrupts from the UART.

RETURNS

N/A

SEE ALSO

st16552Sio


Libraries : Routines

st16552IntRd( )

NAME

st16552IntRd( ) - handle a receiver interrupt

SYNOPSIS

void st16552IntRd
    (
    ST16552_CHAN * pChan /* ptr to struct describing channel */
    )

DESCRIPTION

This routine handles read interrupts from the UART.

RETURNS

N/A

SEE ALSO

st16552Sio


Libraries : Routines

st16552IntEx( )

NAME

st16552IntEx( ) - miscellaneous interrupt processing

SYNOPSIS

void st16552IntEx
    (
    ST16552_CHAN * pChan /* ptr to struct describing channel */
    )

DESCRIPTION

This routine handles miscellaneous interrupts on the UART.

RETURNS

N/A

SEE ALSO

st16552Sio


Libraries : Routines

st16552Int( )

NAME

st16552Int( ) - interrupt level processing

SYNOPSIS

void st16552Int
    (
    ST16552_CHAN * pChan /* ptr to struct describing channel */
    )

DESCRIPTION

This routine handles interrupts from the UART.

RETURNS

N/A

SEE ALSO

st16552Sio


Libraries : Routines

st16552MuxInt( )

NAME

st16552MuxInt( ) - multiplexed interrupt level processing

SYNOPSIS

void st16552MuxInt
    (
    ST16552_MUX * pMux /* ptr to struct describing multiplexed chans */
    )

DESCRIPTION

This routine handles multiplexed interrupts from the DUART. It assumes that channels 0 and 1 are connected so that they produce the same interrupt.

RETURNS

N/A

SEE ALSO

st16552Sio