/* Copyright (C) Magna Carta Software, Inc. 1990, 1991. All Rights Reserved. C COMMUNICATIONS TOOLKIT. DATAFORM.C -- Serial data format routines. Note: General purpose U(S)ART routines are in the source file for the chip to which they apply. */ #include #include short get_databits(COMM_PORT *p) { return((*p->get)(p, DATABITS)); } short get_loopback(COMM_PORT *p) { return((*p->get)(p, LOOPBACK)); } short get_parity(COMM_PORT *p) { return((*p->get)(p, PARITY)); } /* GET_SPEED -- Get the data rate (bps). */ long get_speed(COMM_PORT *p) { return((*p->get_speed)(p)); } short get_stopbits(COMM_PORT *p) { return((*p->get)(p, STOPBITS)); } short set_databits(COMM_PORT *p, short value) { p->rxdatabits = value; return((*p->set)(p, DATABITS, value)); } /* SET_LOOPBACK -- Set the state of U(S)ART loopback. Return values: 0 -- success; -1 -- failure; */ short set_loopback(COMM_PORT *p, short value) { return((*p->set)(p, LOOPBACK, value)); } /* SET_PARITY -- Set the parity for the designated serial port to the designated value. The type of UART is obtained from the COMM_PORT structure. Return values: Success: The value of the UART register that sets parity; -1 : Invalid UART type; -2 : Invalid parity value specified; */ short set_parity(COMM_PORT *p, short value) { p->parity = value; (*p->set)(p, PARITY, value); return (0); } /* SET_SPEED -- Set the data rate (bps). */ short set_speed(COMM_PORT *p, long value) { p->speed = value; return((*p->set_speed)(p, value)); } /* SET_STOPBITS -- Set the number of stopbits for the designated serial port to the designated value. The type of UART is obtained from the COMM_PORT structure. Return values: Success: The value of the UART register that sets stopbits; -1 : Invalid UART type; -2 : Invalid number of stopbits specified; */ short set_stopbits(COMM_PORT *p, short value) { p->stopbits = value; return((*p->set)(p, STOPBITS, value)); }