home *** CD-ROM | disk | FTP | other *** search
- /* asiopen.c
- *
- * The Greenleaf Comm Library
- *
- * Copyright (C) 1985-1990 Greenleaf Software Inc. All Rights Reserved.
- *
- * int asiopen( port, mode, rxlen, txlen, baud, parity, stopbits,
- * wordlength, dtr, rts)
- *
- * int port; - Port 0..MAX_PORT-1
- * unsigned mode; - Merged options for mode (see below)
- * int rxlen; - Length of Rx Buffer in bytes
- * int txlen; - Length of Tx Buffer in bytes
- * long baud; - Baud Rate (50L-9600L,19000L, 38400L, 57600L, 115200L)
- * int parity; - P_NONE,P_ODD,P_EVEN,P_S_STICK, P_M_STICK
- * int stopbits; - Number of stop bits: 1 or 2
- * int wordlength; - Number of Data Bits: 5,6,7, or 8
- * int dtr; - Initial State for DTR (ON or OFF)
- * int rts; - Initial State for RTS (ON or OFF)
- *
- * "mode" specifies five different kinds of operational parameters.
- * Choose one from each of the following five categories. See documentation
- * for further details:
- * 1. Direction (ASIN, ASOUT, ASINOUT)
- * 2. Data Type (BINARY, ASCII)
- * 3. Receive Buffer Width (NORMALRX, WIDETRACKRX)
- *
- * DESCRIPTION
- * This function performs all operations required to initialize a
- * port, including the following:
- * asifirst() - Setup the buffers for the port, allocation
- * asiinit() - Initialize UART
- * asdtr() - Setup DTR initial state
- * asrts() - Setup RTS initial state
- * asistart() - Start interrupts running
- *
- * The above functions are called internally in this "one-stop" combination
- * function.
- *
- * SIDE EFFECTS
- * None.
- *
- * RETURNS
- *
- * Value Meaning
- * ------- --------
- * ASSUCCESS port opened (no errors)
- * ASNOMEMORY Cannot allocate dynamic memory needed
- * ASINVPORT Requested logical port number too high or too low
- * ASINUSE port has already been setup with asifirst()
- * ASINVBUFSIZE Buffer size is out of range
- * ASNO8250 No 8250 installed at requested i/o address
- *
- * MODIFICATIONS
- * 10-29-85 ""
- * Modified for new structure members, also moved static
- * data items to this file.
- */
- #include <stdio.h>
- #include "gf.h"
- #include "asiports.h"
-
- int GF_CONV asiopen(port,mode,size_rx_buf,size_tx_buf,baud,parity,stopbits,
- wordlength,dtr,rts)
- int port;
- long baud;
- int parity,stopbits,wordlength,dtr,rts;
- unsigned size_tx_buf,size_rx_buf,mode;
- {
- int terror;
-
- if((terror=asifirst(port,mode,size_rx_buf,size_tx_buf))!=ASSUCCESS)
- return(terror);
- if((terror=asiinit(port,baud,parity,stopbits,wordlength))!=ASSUCCESS){
- (void)asiquit(port);
- return(terror);
- }
- if((terror=asistart(port,mode&(ASIN|ASOUT|ASINOUT)) )!=ASSUCCESS) {
- (void)asiquit(port);
- return(terror);
- }
- if((terror=asdtr(port,dtr)) < ASSUCCESS) {
- (void)asiquit(port);
- return(terror);
- }
- if((terror=asrts(port,rts)) < ASSUCCESS) {
- (void)asiquit(port);
- return(terror);
- }
- return(ASSUCCESS);
- }
-
-