VxWorks Reference Manual : Libraries
sa1100Sio - Digital Semiconductor SA-1100 UART tty driver
sa1100DevInit( ) - initialise an SA1100 channel
sa1100Int( ) - handle an interrupt
This is the device driver for the Digital Semiconductor SA-1100 UARTs. This chip contains 5 serial ports, but only ports 1 and 3 are usable as UARTs, the others support Universal Serial Bus (USB), SDLC, IrDA Infrared Communications Port (ICP) and Multimedia Communications Port (MCP)/Synchronous Serial Port (SSP).
The UARTs are identical in design. They contain a universal asynchronous receiver/transmitter, and a baud-rate generator, The UARTs contain an 8-entry, 8-bit FIFO to buffer outgoing data and a 12-entry 11-bit FIFO to buffer incoming data. If a framing, overrun or parity error occurs during reception, the appropriate error bits are stored in the receive FIFO along with the received data. The only mode of operation supported is with the FIFOs enabled.
The UART design does not support modem control input or output signals e.g. DTR, RI, RTS, DCD, CTS and DSR.
An interrupt is generated when a framing, parity or receiver overrun error is present within the bottom four entries of the receive FIFO, when the transmit FIFO is half-empty or receive FIFO is one- to two-thirds full, when a begin and end of break is detected on the receiver, and when the receive FIFO is partially full and the receiver is idle for three or more frame periods.
Only asynchronous serial operation is supported by the UARTs which supports 7 or 8 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 SA1100_CHAN structure before calling sa1100DevInit( ).
The UART supports baud rates from 56.24 to 230.4 kbps.
An SA1100_CHAN data structure is used to describe each channel, this structure is described in h/drv/sio/sa1100Sio.h.
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.
This driver supports both polled and interrupt modes.
The driver is typically only called by the BSP. The directly callable routines in this modules are sa1100DevInit( ), and sa1100Int( ).
The BSP's sysHwInit( ) routine typically calls sysSerialHwInit( ), which initialises the hardware-specific fields in the SA1100_CHAN structure (e.g. register I/O addresses etc) before calling sa1100DevInit( ) 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/sa1100Sio.h" LOCAL SA1100_CHAN sa1100Chan[N_SA1100_UART_CHANS]; void sysSerialHwInit (void) { int i; for (i = 0; i < N_SA1100_UART_CHANNELS; i++) { sa1100Chan[i].regs = devParas[i].baseAdrs; sa1100Chan[i].baudRate = CONSOLE_BAUD_RATE; sa1100Chan[i].xtal = UART_XTAL_FREQ; sa1100Chan[i].level = devParas[i].intLevel; /* set up GPIO pins and UART pin reassignment */ ... /* * Initialise driver functions, getTxChar, putRcvChar * and channelMode and initialise UART */ sa1100DevInit(&sa1100Chan[i]); } }The BSP's sysHwInit2( ) routine typically calls sysSerialHwInit2( ), which connects the chips interrupts via intConnect( ) and enables those interrupts, as shown in the following example:
void sysSerialHwInit2 (void) { int i; for (i = 0; i < N_SA1100_UART_CHANNELS; i++) { /* connect and enable interrupts */ (void)intConnect (INUM_TO_IVEC(devParas[i].vector), sa1100Int, (int) &sa1100Chan[i]); intEnable (devParas[i].intLevel); } }
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 SA1100_CHAN structure.
sysSerialReset is called from sysToMonitor( ) and should reset the serial devices to an inactive state (prevent them from generating any interrupts).
drv/sio/sa1100Sio.h sioLib.h
sa1100Sio, Digital StrongARM SA-1100 Portable Communications Microcontroller, Data Sheet, Digital Semiconductor StrongARM SA-1100 Microprocessor Evaluation Platform, User's Guide
sa1100DevInit( ) - initialise an SA1100 channel
void sa1100DevInit ( SA1100_CHAN * pChan /* ptr to SA1100_CHAN describing this channel */ )
This routine initialises some SIO_CHAN function pointers and then resets the chip to a quiescent state. Before this routine is called, the BSP must already have initialised all the device addresses, etc. in the SA1100_CHAN structure.
N/A
sa1100Int( ) - handle an interrupt
void sa1100Int ( SA1100_CHAN * pChan /* ptr to SA1100_CHAN describing this channel */ )
This routine handles interrupts from the UART.
N/A