Hardware Summary The IBC Quad Serial board (assembly 4031) provides four electrically isolated asynchronous serial communication channels, at baud rates of up to 38.4 kbaud. Refer to the Design and Programming Notes for more detailed information. Software Summary The software library for the Quad Serial board provides functions to initialize, obtain status, read data, and write data, for the serial communications channels. A board identification and initialization function is provided to locate the board, insert an entry in the IBC Card table and initialize the Quad Serial hardware. Functions are also provided which initialize and respond to Quad Serial board interrupts. Directories and Files All files for the Quad Serial board software are located in the quad_ser directory. C Source for the library functions is contained in quad_ser.c. Hardware register offsets, various bit definitions, default values, definition of the Quad Serial_BoardEntry data structure and function prototypes for the function library are located in the header file quad_ser.h. An appropriate make file is also provided. Software Functionality Initialization All IBC Microcontroller applications execute an IBC board identification procedure at power up. For the Quad Serial board this function is called SerialBoardSearch. The function searches for Quad Serial boards at predefined addresses (80H & E0H) by calling the Quad SerialBoardInit function with the address as a parameter. The serialBoardInit function checks for the presence of a board by reading the Uart mode register for the specified board address and checking for an IBC bus timeout. A NULL serialBoardEntry pointer is returned if an IBC bus timeout occurs during the read. If the board responds then a serialBoardEntry data structure is allocated and initialized with appropriate default values. The serial channel is reset, default line parameters are set and the status LED on the board is switched ON. Serial Board Functions and Procedures The serialBoardFunctions procedure is intended to be called periodically or from a polling loop. The function checks a Virtual Serial Port timer and , if data is available sends it to the VME chassis every time period(50 ms). It also checks the serial board power supply status and reports alarms if necessary. The serialBoardIsr function is used to handle interrupts for the quad serial Uart. This function checks which channels have interrupts pending and services interrupts for these channels. It must also determine if it is a byte received interrupt or a transmit interrupt. In the byte received interrupt case the ISR checks for an open channel and if the receiver ready bit is set, then reads the received byte from the Uart, and writes that byte into the receive ring buffer. In addition there is a check for termination characters. When a termination character is received a counter is incremented in the Uart data structure. In the transmit interrupt case the ISR checks for a open channel, and tests the ready transmitter bit and the transmitting break flag. If these conditions are correct (open channel, transmitter ready and NOT transmitting a break) a byte is copied from the transmit ring buffer to the Uart. Library Commands The QuadSerOpenCmd library function is used to open a serial channel for data I/O read/write operations. This function must be executed before a port can be used for reading or writing data. The function takes a pointer to a IBC_BoardEntry a IBC_CardCount and a command buffer. This command sets flags in the Uart data structure to mark a quad serial port as open, then it writes to Uart control registers to set the port into a default state. An ERROR is returned if the IBC board specified does not exist or if an IBC bus timeout occurs while writing to the Uart command register. The QuadSerCloseCmd library function is used to close a serial channel after read/write functions are complete. This command sets flags in the Uart data structure to mark a quad serial port as closed. It then writes to Uart command registers to stop data from being sent or received. An ERROR is returned if the IBC board specified does not exist or if an IBC bus timeout occurs while writing to the Uart Command register The QuadSerReadCmd extracts the number of bytes to read from the command buffer, reads from the quad serial board then writes a data packet to the VME. The number of bytes is range checked so it cannot exceed the buffer size. An ERROR is returned if the serial board does not exist, if the channel number is invalid, or channel is not open. The QuadSerWriteCmd is used to write bytes toa quad serial board serial channel. This command extracts the number of bytes to write from the command buffer, then writes bytes from the command buffer to the quad serial board. An ERROR is returned if the serial board does not exist, if the channel number is invalid, or channel is not open. The QuadSerFlushCmd is used to flush the transmit and receive queues of a quad serial board serial channel. This command will initialize the ring buffers for both receive and transmit queues associated with the specified channel. An ERROR is returned if the serial board does not exist or if the channel number is invalid. The QuadSerRxBytesCmd is used to report the number of bytes in the receive queue of a quad serial board serial channel. This command calls a utility function, ring_entries, that returns the number of bytes in the receive queue associated with a specified channel of a quad serial Uart. It then writes a data packet containing this information to the VME. An ERROR is returned if the serial board does not exist or if the channel number is invalid. The QuadSerTxBytesCmd is used to report the number of bytes in the transmit queue of a quad serial board serial channel. This command calls a utility function, ring_entries, that returns the number of bytes in the transmit queue associated with the specified channel. It then writes a data packet containing this information to the VME. An ERROR is returned if the serial board does not exist or if the channel number is invalid. The QuadSerSendBreakCmd is used to enable or disable the Break condition for a quad serial board serial channel. This command extracts a Break mode parameter from the command buffer, then enables or disables the Break condition, depending on the Break mode, for the specified quad serial board and serial channel. An ERROR is returned if the serial board does not exist or if the channel number is invalid. The QuadSerVSPOpenCmd is used to enable Virtual Serial Port services for a channel of a quad serial board. This function must be called before Virtual Serial Port services can be used for a quad serial board channel. This command will reset the serial channel, flush its transmit and receive queues, and set the line parameters to a default state. It then sets a flag in the Uart data structure to mark a Virtual Serial Port as being open. An ERROR is returned if the serial board does not exist, if the channel number is invalid. or if an error occurs while opening the port. The QuadSerGetLineParmCmd is used to report the line parameter information from a quad serial board serial channel. This command extracts flags and variables from the Uart data structure, and writes a message to the VME. Embedded in the message is baud rate, data bits, stop bits, parity, handshake, and protocol information. An ERROR is returned if the serial board does not exist or if the channel number is invalid. The QuadSerSetLineParmCmd is used to set the line parameters for a quad serial board serial channel. This command first extracts the parameters from the command buffer. Then it set flags and variables in the Uart data structure, and writes to appropriate Uart control registers, to set up the Uart according to the line parameters specified. An ERROR is returned if the serial board does not exist or if the channel number is invalid. The QuadSerSetTermCharCmd is used to set the Termination Character for the quad serial board serial channel. This command extracts the Termination Character from the command buffer and writes it to a variable in the Uart data structure to setup the termination character. An ERROR is returned if the serial board does not exist or if the channel number is invalid.