VxWorks Reference Manual : Libraries

m68681Sio

NAME

m68681Sio - M68681 serial communications driver

ROUTINES

m68681DevInit( ) - intialize a M68681_DUART
m68681DevInit2( ) - intialize a M68681_DUART, part 2
m68681ImrSetClr( ) - set and clear bits in the DUART interrupt-mask register
m68681Imr( ) - return the current contents of the DUART interrupt-mask register
m68681AcrSetClr( ) - set and clear bits in the DUART auxiliary control register
m68681Acr( ) - return the contents of the DUART auxiliary control register
m68681OprSetClr( ) - set and clear bits in the DUART output port register
m68681Opr( ) - return the current state of the DUART output port register
m68681OpcrSetClr( ) - set and clear bits in the DUART output port configuration register
m68681Opcr( ) - return the state of the DUART output port configuration register
m68681Int( ) - handle all DUART interrupts in one vector

DESCRIPTION

This is the driver for the M68681 DUART. This device includes two universal asynchronous receiver/transmitters, a baud rate generator, and a counter/timer device. This driver module provides control of the two serial channels and the baud-rate generator. The counter timer is controlled by a separate driver, src/drv/timer/m68681Timer.c.

A M68681_DUART structure is used to describe the chip. This data structure contains two M68681_CHAN structures which describe the chip's two serial channels. The M68681_DUART structure is defined in m68681Sio.h.

Only asynchronous serial operation is supported by this driver. The default serial settings are 8 data bits, 1 stop bit, no parity, 9600 baud, and software flow control. These default settings can be overridden on a channel-by-channel basis by setting the M68681_CHAN options and baudRate fields to the desired values before calling m68681DevInit( ). See sioLib.h for option values. The defaults for the module can be changed by redefining the macros M68681_DEFAULT_OPTIONS and M68681_DEFAULT_BAUD and recompiling this driver.

This driver supports baud rates of 75, 110, 134.5, 150, 300, 600, 1200, 2000, 2400, 4800, 1800, 9600, 19200, and 38400.

USAGE

The BSP's sysHwInit( ) routine typically calls sysSerialHwInit( ) which initializes all the hardware addresses in the M68681_DUART structure before calling m68681DevInit( ). This enables the chip to operate in polled mode, but not in interrupt mode. Calling m68681DevInit2( ) from the sysSerialHwInit2( ) routine allows interrupts to be enabled and interrupt-mode operation to be used.

The following example shows the first part of the initialization thorugh calling m68681DevInit( ):

#include "drv/sio/m68681Sio.h"

M68681_DUART myDuart;   /* my device structure */

#define MY_VEC  (71)    /* use single vector, #71 */

sysSerialHwInit()
    {
    /* initialize the register pointers for portA */
    myDuart.portA.mr    = M68681_MRA;
    myDuart.portA.sr    = M68681_SRA;
    myDuart.portA.csr   = M68681_CSRA;
    myDuart.portA.cr    = M68681_CRA;
    myDuart.portA.rb    = M68681_RHRA;
    myDuart.portA.tb    = M68681_THRA;

    /* initialize the register pointers for portB */
    myDuart.portB.mr = M68681_MRB;
    ...

    /* initialize the register pointers/data for main duart */
    myDuart.ivr         = MY_VEC;
    myDuart.ipcr        = M68681_IPCR;
    myDuart.acr         = M68681_ACR;
    myDuart.isr         = M68681_ISR;
    myDuart.imr         = M68681_IMR;
    myDuart.ip          = M68681_IP;
    myDuart.opcr        = M68681_OPCR;
    myDuart.sopbc       = M68681_SOPBC;
    myDuart.ropbc       = M68681_ROPBC;
    myDuart.ctroff      = M68681_CTROFF;
    myDuart.ctron       = M68681_CTRON;
    myDuart.ctlr        = M68681_CTLR;
    myDuart.ctur        = M68681_CTUR;


    m68681DevInit (&myDuart);
    }
The BSP's sysHwInit2( ) routine typically calls sysSerialHwInit2( ) which connects the chips interrupts via intConnect( ) to the single interrupt handler m68681Int( ). After the interrupt service routines are connected, the user then calls m68681DevInit2( ) to allow the driver to turn on interrupt enable bits, as shown in the following example:

sysSerialHwInit2 ()
    {
    /* connect single vector for 68681 */
    intConnect (INUM_TO_IVEC(MY_VEC), m68681Int, (int)&myDuart);

    ...

    /* allow interrupts to be enabled */
    m68681DevInit2 (&myDuart);
    }

SPECIAL CONSIDERATIONS

The CLOCAL hardware option presumes that OP0 and OP1 output bits are wired to the CTS outputs for channel 0 and channel 1 respectively. If not wired correctly, then the user must not select the CLOCAL option. CLOCAL is not one of the default options for this reason.

This driver does not manipulate the output port or its configuration register in any way. If the user selects the CLOCAL option, then the output port bit must be wired correctly or the hardware flow control will not function correctly.

INCLUDE FILES

drv/sio/m68681Sio.h

SEE ALSO

m68681Sio


Libraries : Routines

m68681DevInit( )

NAME

m68681DevInit( ) - intialize a M68681_DUART

SYNOPSIS

void m68681DevInit
    (
    M68681_DUART * pDuart
    )

DESCRIPTION

The BSP must already have initialized all the device addresses and register pointers in the M68681_DUART structure as described in m68681Sio. This routine initializes some transmitter and receiver status values to be used in the interrupt mask register and then resets the chip to a quiescent state.

RETURNS

N/A

SEE ALSO

m68681Sio


Libraries : Routines

m68681DevInit2( )

NAME

m68681DevInit2( ) - intialize a M68681_DUART, part 2

SYNOPSIS

void m68681DevInit2
    (
    M68681_DUART * pDuart
    )

DESCRIPTION

This routine is called as part of sysSerialHwInit2( ). It tells the driver that interrupt vectors are connected and that it is safe to allow interrupts to be enabled.

RETURNS

N/A

SEE ALSO

m68681Sio


Libraries : Routines

m68681ImrSetClr( )

NAME

m68681ImrSetClr( ) - set and clear bits in the DUART interrupt-mask register

SYNOPSIS

void m68681ImrSetClr
    (
    M68681_DUART * pDuart,
    UCHAR          setBits,  /* which bits to set in the IMR */
    UCHAR          clearBits /* which bits to clear in the IMR */
    )

DESCRIPTION

This routine sets and clears bits in the DUART interrupt-mask register (IMR). It sets and clears bits in a local copy of the IMR, then writes that local copy to the DUART. This means that all changes to the IMR must be performed by this routine. Any direct changes to the IMR are lost the next time this routine is called.

Set has priority over clear. Thus you can use this routine to update multiple bit fields by specifying the field mask as the clear bits.

RETURNS

N/A

SEE ALSO

m68681Sio


Libraries : Routines

m68681Imr( )

NAME

m68681Imr( ) - return the current contents of the DUART interrupt-mask register

SYNOPSIS

UCHAR m68681Imr
    (
    M68681_DUART * pDuart
    )

DESCRIPTION

This routine returns the contents of the interrupt-mask register (IMR). The IMR is not directly readable; a copy of the last value written is kept in the DUART data structure.

RETURNS

The contents of the interrupt-mask register.

SEE ALSO

m68681Sio


Libraries : Routines

m68681AcrSetClr( )

NAME

m68681AcrSetClr( ) - set and clear bits in the DUART auxiliary control register

SYNOPSIS

void m68681AcrSetClr
    (
    M68681_DUART * pDuart,
    UCHAR          setBits,  /* which bits to set in the ACR */
    UCHAR          clearBits /* which bits to clear in the ACR */
    )

DESCRIPTION

This routine sets and clears bits in the DUART auxiliary control register (ACR). It sets and clears bits in a local copy of the ACR, then writes that local copy to the DUART. This means that all changes to the ACR must be performed by this routine. Any direct changes to the ACR are lost the next time this routine is called.

Set has priority over clear. Thus you can use this routine to update multiple bit fields by specifying the field mask as the clear bits.

RETURNS

N/A

SEE ALSO

m68681Sio


Libraries : Routines

m68681Acr( )

NAME

m68681Acr( ) - return the contents of the DUART auxiliary control register

SYNOPSIS

UCHAR m68681Acr
    (
    M68681_DUART * pDuart
    )

DESCRIPTION

This routine returns the contents of the auxilliary control register (ACR). The ACR is not directly readable; a copy of the last value written is kept in the DUART data structure.

RETURNS

The contents of the auxilliary control register.

SEE ALSO

m68681Sio


Libraries : Routines

m68681OprSetClr( )

NAME

m68681OprSetClr( ) - set and clear bits in the DUART output port register

SYNOPSIS

void m68681OprSetClr
    (
    M68681_DUART * pDuart,
    UCHAR          setBits,  /* which bits to set in the OPR */
    UCHAR          clearBits /* which bits to clear in the OPR */
    )

DESCRIPTION

This routine sets and clears bits in the DUART output port register (OPR). It sets and clears bits in a local copy of the OPR, then writes that local copy to the DUART. This means that all changes to the OPR must be performed by this routine. Any direct changes to the OPR are lost the next time this routine is called.

Set has priority over clear. Thus you can use this routine to update multiple bit fields by specifying the field mask as the clear bits.

RETURNS

N/A

SEE ALSO

m68681Sio


Libraries : Routines

m68681Opr( )

NAME

m68681Opr( ) - return the current state of the DUART output port register

SYNOPSIS

UCHAR m68681Opr
    (
    M68681_DUART * pDuart
    )

DESCRIPTION

This routine returns the current state of the output port register (OPR) from the saved copy in the DUART data structure. The actual OPR contents are not directly readable.

RETURNS

The current state of the output port register.

SEE ALSO

m68681Sio


Libraries : Routines

m68681OpcrSetClr( )

NAME

m68681OpcrSetClr( ) - set and clear bits in the DUART output port configuration register

SYNOPSIS

void m68681OpcrSetClr
    (
    M68681_DUART * pDuart,
    UCHAR          setBits,  /* which bits to set in the OPCR */
    UCHAR          clearBits /* which bits to clear in the OPCR */
    )

DESCRIPTION

This routine sets and clears bits in the DUART output port configuration register (OPCR). It sets and clears bits in a local copy of the OPCR, then writes that local copy to the DUART. This means that all changes to the OPCR must be performed by this routine. Any direct changes to the OPCR are lost the next time this routine is called.

Set has priority over clear. Thus you can use this routine to update multiple bit fields by specifying the field mask as the clear bits.

RETURNS

N/A

SEE ALSO

m68681Sio


Libraries : Routines

m68681Opcr( )

NAME

m68681Opcr( ) - return the state of the DUART output port configuration register

SYNOPSIS

UCHAR m68681Opcr
    (
    M68681_DUART * pDuart
    )

DESCRIPTION

This routine returns the state of the output port configuration register (OPCR) from the saved copy in the DUART data structure. The actual OPCR contents are not directly readable.

RETURNS

The state of the output port configuration register.

SEE ALSO

m68681Sio


Libraries : Routines

m68681Int( )

NAME

m68681Int( ) - handle all DUART interrupts in one vector

SYNOPSIS

void m68681Int
    (
    M68681_DUART * pDuart
    )

DESCRIPTION

This routine handles all interrupts in a single interrupt vector. It identifies and services each interrupting source in turn, using edge-sensitive interrupt controllers.

RETURNS

N/A

SEE ALSO

m68681Sio