VxWorks Reference Manual : Libraries

coldfireSio

NAME

coldfireSio - coldfire Serial Communications driver

ROUTINES

coldfireDevInit( ) - intialize a COLDFIRE_CHAN
coldfireDevInit2( ) - intialize a COLDFIRE_CHAN, part 2
coldfireImrSetClr( ) - set and clear bits in the UART's interrupt mask register
coldfireImr( ) - return current interrupt mask register contents
coldfireAcrSetClr( ) - set and clear bits in the UART's aux control register
coldfireAcr( ) - return aux control register contents
coldfireOprSetClr( ) - set and clear bits in the output port register
coldfireOpr( ) - return the current state of the output register
coldfireInt( ) - handle all interrupts in one vector

DESCRIPTION

This is the driver for the UART contained in the ColdFire Microcontroller.

Only asynchronous serial operation is supported by this driver. The default serial settings are 8 data bits, 1 stop bit, no parity, 9600 buad, and software flow control. These default settings can be overridden by setting the COLDFIRE_CHAN options and baudRate fields to the desired values before calling coldfireDevInit. See sioLib.h for options values. The defaults for the module can be changed by redefining the macros COLDFIRE_DEFAULT_OPTIONS and COLDFIRE_DEFAULT_BAUD and recompiling this driver.

This driver uses the system clock as the input to the baud rate generator. The clkRate field must be set to the system clock rate in HZ for the baud rate calculations to work correctly. The actual range of supported baud rates depends on the system clock speed. For example, with a 25MHz system clock, the lowest baud rate is 24, and the highest is over 38400. Because the baud rate values are calculated on request, there is no checking that the requested baud rate is standard, you can set the UART to operate at 4357 baud if you wish.

USAGE

A COLDFIRE_CHAN structure is used to describe the chip.

The BSP's sysHwInit( ) routine typically calls sysSerialHwInit( ) which initializes all the H/W addresses in the COLDFIRE_CHAN structure before calling coldfireDevInit( ). This enables the chip to operate in polled mode, but not interrupt mode. Calling coldfireDevInit2( ) from the sysSerialHwInit2( ) routine allows interrupts to be enabled and interrupt mode operation to be used.

i.e.

#include "drv/multi/coldfireSio.h"

COLDFIRE_CHAN coldfireUart;                     /* my device structure */

#define INT_VEC_UART    (24+3)          /* use single vector, #27 */

sysSerialHwInit()
    {
    /* initialize the register pointers/data for uart */
    coldfireUart.clkRate        = MASTER_CLOCK;
    coldfireUart.intVec = INT_VEC_UART;
    coldfireUart.mr     = COLDFIRE_UART_MR(SIM_BASE);
    coldfireUart.sr     = COLDFIRE_UART_SR(SIM_BASE);
    coldfireUart.csr    = COLDFIRE_UART_CSR(SIM_BASE);
    coldfireUart.cr     = COLDFIRE_UART_CR(SIM_BASE);
    coldfireUart.rb     = COLDFIRE_UART_RB(SIM_BASE);
    coldfireUart.tb     = COLDFIRE_UART_TB(SIM_BASE);
    coldfireUart.ipcr   = COLDFIRE_UART_IPCR(SIM_BASE);
    coldfireUart.acr    = COLDFIRE_UART_ACR(SIM_BASE);
    coldfireUart.isr    = COLDFIRE_UART_ISR(SIM_BASE);
    coldfireUart.imr    = COLDFIRE_UART_IMR(SIM_BASE);
    coldfireUart.bg1    = COLDFIRE_UART_BG1(SIM_BASE);
    coldfireUart.bg2    = COLDFIRE_UART_BG2(SIM_BASE);
    coldfireUart.ivr    = COLDFIRE_UART_IVR(SIM_BASE);
    coldfireUart.ip     = COLDFIRE_UART_IP(SIM_BASE);
    coldfireUart.op1    = COLDFIRE_UART_OP1(SIM_BASE);
    coldfireUart.op2    = COLDFIRE_UART_OP2(SIM_BASE);

    coldfireDevInit (&coldfireUart);
    }
The BSP's sysHwInit2( ) routine typically calls sysSerialHwInit2( ) which connects the chips interrupts via intConnect( ) to the single interrupt handler coldfireInt. After the interrupt service routines are connected, the user then calls coldfireDevInit2( ) to allow the driver to turn on interrupt enable bits.

i.e.

sysSerialHwInit2 ()
    {
    /* connect single vector for 5204 */
    intConnect (INUM_TO_IVEC(MY_VEC), coldfireInt, (int)&coldfireUart);

    ...

    /* allow interrupts to be enabled */
    coldfireDevInit2 (&coldfireUart);
    }

SPECIAL CONSIDERATIONS

The CLOCAL hardware option presumes that CTS outputs are not wired as necessary. CLOCAL is one of the default options for this reason.

As to the output port, this driver does not manipulate the output port, or it's configuration register in any way. As stated above, if the user does not select the CLOCAL option then the output port bit must be wired correctly or the hardware flow control will not function as desired.

INCLUDE FILES

drv/sio/coldfireSio.h

SEE ALSO

coldfireSio


Libraries : Routines

coldfireDevInit( )

NAME

coldfireDevInit( ) - intialize a COLDFIRE_CHAN

SYNOPSIS

void coldfireDevInit
    (
    COLDFIRE_CHAN * pChan
    )

DESCRIPTION

The BSP must have already initialized all the device addresses, etc in coldfire_CHAN structure. This routine initializes some transmitter & 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

coldfireSio


Libraries : Routines

coldfireDevInit2( )

NAME

coldfireDevInit2( ) - intialize a COLDFIRE_CHAN, part 2

SYNOPSIS

void coldfireDevInit2
    (
    COLDFIRE_CHAN * pChan
    )

DESCRIPTION

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

RETURNS

N/A

SEE ALSO

coldfireSio


Libraries : Routines

coldfireImrSetClr( )

NAME

coldfireImrSetClr( ) - set and clear bits in the UART's interrupt mask register

SYNOPSIS

void coldfireImrSetClr
    (
    COLDFIRE_CHAN * pChan,
    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 UART's IMR.

This routine sets and clears bits in a local copy of the IMR, then writes that local copy to the UART. This means that all changes to the IMR must go through this routine. Otherwise, any direct changes to the IMR would be 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

coldfireSio


Libraries : Routines

coldfireImr( )

NAME

coldfireImr( ) - return current interrupt mask register contents

SYNOPSIS

UCHAR coldfireImr
    (
    COLDFIRE_CHAN * pChan
    )

DESCRIPTION

This routine returns the interrupt mask register contents. The imr is not directly readable, a copy of the last value written is kept in the UART data structure.

RETURNS

Returns interrupt mask register contents.

SEE ALSO

coldfireSio


Libraries : Routines

coldfireAcrSetClr( )

NAME

coldfireAcrSetClr( ) - set and clear bits in the UART's aux control register

SYNOPSIS

void coldfireAcrSetClr
    (
    COLDFIRE_CHAN * pChan,
    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 UART's ACR.

This routine sets and clears bits in a local copy of the ACR, then writes that local copy to the UART. This means that all changes to the ACR must go through this routine. Otherwise, any direct changes to the ACR would be 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

coldfireSio


Libraries : Routines

coldfireAcr( )

NAME

coldfireAcr( ) - return aux control register contents

SYNOPSIS

UCHAR coldfireAcr
    (
    COLDFIRE_CHAN * pChan
    )

DESCRIPTION

This routine returns the auxilliary control register contents. The acr is not directly readable, a copy of the last value written is kept in the UART data structure.

RETURNS

Returns auxilliary control register (acr) contents.

SEE ALSO

coldfireSio


Libraries : Routines

coldfireOprSetClr( )

NAME

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

SYNOPSIS

void coldfireOprSetClr
    (
    COLDFIRE_CHAN * pChan,
    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 UART's OPR.

A copy of the current opr contents is kept in the UART data structure.

RETURNS

N/A

SEE ALSO

coldfireSio


Libraries : Routines

coldfireOpr( )

NAME

coldfireOpr( ) - return the current state of the output register

SYNOPSIS

UCHAR coldfireOpr
    (
    COLDFIRE_CHAN * pChan
    )

DESCRIPTION

This routine returns the current state of the output register from the saved copy in the UART data structure. The actual opr contents are not directly readable.

RETURNS

Returns the current output register state.

SEE ALSO

coldfireSio


Libraries : Routines

coldfireInt( )

NAME

coldfireInt( ) - handle all interrupts in one vector

SYNOPSIS

void coldfireInt
    (
    COLDFIRE_CHAN * pChan
    )

DESCRIPTION

All interrupts share a single interrupt vector. We identify each interrupting source and service it. We must service all interrupt sources for those systems with edge- sensitive interrupt controllers.

RETURNS

N/A

SEE ALSO

coldfireSio