home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / MODEM / UWPC201.ZIP / UW-SRC.ZIP / COMMS.H < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-31  |  5.5 KB  |  167 lines

  1. /*-----------------------------------------------------------------------------
  2.  
  3.    COMMS.H - Serial Communications Routines for Turbo C/C++
  4.  
  5.     NOTE: COM1 and COM3 cannot be used simultaneously and COM2 and COM4
  6.     cannot be used simultaneously.
  7.  
  8.     This file is part of UW/PC - a multi-window comms package for the PC.
  9.     Copyright (C) 1990-1991  Rhys Weatherley
  10.  
  11.     This program is free software; you can redistribute it and/or modify
  12.     it under the terms of the GNU General Public License as published by
  13.     the Free Software Foundation; either version 1, or (at your option)
  14.     any later version.
  15.  
  16.     This program is distributed in the hope that it will be useful,
  17.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  18.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19.     GNU General Public License for more details.
  20.  
  21.     You should have received a copy of the GNU General Public License
  22.     along with this program; if not, write to the Free Software
  23.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24.  
  25.    Revision History:
  26.    ================
  27.  
  28.     Version  DD/MM/YY  By  Description
  29.     -------  --------  --  ---------------------------------------------------
  30.       1.0    ??/09/90  RW  Original version of COMMS.H
  31.       1.1    10/11/90  RW  Added ability to call comcarrier before comenable,
  32.                      support for 57600 baud and automatic raising of
  33.                the DTR signal.
  34.       1.2    17/11/90  RW  Add 'leavedtr' parameter to "comrestore".
  35.       1.3    17/03/91  RW  Create 'comfix' to fix DOS shell-out bug.
  36.       1.4    21/03/91  RW  Fix minor problem with sign extension in comreceive.
  37.       1.5    22/03/91  RW  Fix COM port addressing & add COM3/COM4 support.
  38.       1.6    31/10/91  RW  Add some more stuff for Windows 3.0 support.
  39.  
  40.    Authors:
  41.    =======
  42.  
  43.     RW - Rhys Weatherley (e-mail: rhys@cs.uq.oz.au)
  44.          5 Horizon Drive
  45.      Jamboree Heights  QLD  4074
  46.      Australia
  47.  
  48. -----------------------------------------------------------------------------*/
  49.  
  50. #ifndef    __COMMS_H__
  51. #define    __COMMS_H__
  52.  
  53. /* Defines for various port parameters */
  54.  
  55. #define BAUD_RATE    0x0F        /* Mask to extract baud rate */
  56. #define    BAUD_110    0        /* Baud rates */
  57. #define    BAUD_150    1
  58. #define BAUD_300    2
  59. #define    BAUD_600    3
  60. #define    BAUD_1200    4
  61. #define BAUD_2400    5
  62. #define    BAUD_4800    6
  63. #define    BAUD_9600    7
  64. #define    BAUD_19200    8
  65. #define BAUD_38400    9
  66. #define BAUD_57600    10
  67. #define    BAUD_115200    11
  68.  
  69. #define    BITS_7        0x00        /* Data bits */
  70. #define    BITS_8        0x10
  71.  
  72. #define STOP_1        0x00        /* Stop bits */
  73. #define STOP_2        0x20
  74.  
  75. #define PARITY_GET    0xC0        /* Mask to extract parity */
  76. #define PARITY_NONE    0x00        /* Parity modes */
  77. #define    PARITY_ODD    0x40
  78. #define PARITY_EVEN    0x80
  79.  
  80. #ifdef    __STDC__
  81. #define    _Cdecl
  82. #else
  83. #define    _Cdecl    cdecl
  84. #endif
  85.  
  86. #ifdef    __cplusplus
  87. extern    "C" {
  88. #endif
  89.  
  90. /* Define the port addresses for the 4 serial ports. */
  91. /* These can be changed by the caller if necessary.  */
  92. extern    int    _Cdecl    comports[4];
  93.  
  94. /* Enable a COM port for Interrupt Driven I/O by this module */
  95. int    _Cdecl    comenable (int port);
  96.  
  97. /* Save the current setting of a COM port to be restored later */
  98. /* Call this function before calling 'comenable' on the port.  */
  99. void    _Cdecl    comsave (int port);
  100.  
  101. /* Set the communications parameters for a COM port */
  102. void    _Cdecl    comparams (int port,int params);
  103.  
  104. /* Disable the interrupt I/O for a COM port */
  105. /* If 'leavedtr' != 0, then leave DTR up    */
  106. void    _Cdecl    comdisable (int port,int leavedtr);
  107.  
  108. /* Restore the setting of a COM port - after 'comdisable'    */
  109. /* If 'leavedtr' is non-zero the keep DTR set no matter what */
  110. void    _Cdecl    comrestore (int port,int leavedtr);
  111.  
  112. /* Turn a COM port's test loop-back mode on or off */
  113. /* NOTE: comenable always turns the loop-mode off  */
  114. void    _Cdecl    comtest (int port,int on);
  115.  
  116. /* Return the number of available input chars on a COM port */
  117. /* Will raise the DTR signal if it is not already raised.   */
  118. int    _Cdecl    comavail (int port);
  119.  
  120. /* Flush all input from the COM port */
  121. void    _Cdecl    comflush (int port);
  122.  
  123. /* Receive a character from the COM port: -1 if not ready */
  124. /* Will raise the DTR signal if it is not already raised. */
  125. int    _Cdecl    comreceive (int port);
  126.  
  127. /* Test to see if the COM port is ready for a new */
  128. /* character to transmit.  Will raise the DTR     */
  129. /* signal if it is not already raised.          */
  130. int    _Cdecl    comready (int port);
  131.  
  132. /* Output a character to a COM port.  Will raise */
  133. /* the DTR signal if it is not already raised.   */
  134. void    _Cdecl    comsend (int port,int ch);
  135.  
  136. /* Test to see if a carrier is present - can be called before comenable */
  137. int    _Cdecl    comcarrier (int port);
  138.  
  139. /* Enable or disable the detection of carrier loss */
  140. void    _Cdecl    comloss    (int port,int enable);
  141.  
  142. /* Test if the last transmitted character could not be sent because */
  143. /* the carrier has been lost.  This is mainly for Windows 3.0.        */
  144. int    _Cdecl    comlost    (int port);
  145.  
  146. /* Test to see if the DSR (Data Set Ready) signal is present */
  147. int    _Cdecl    comdsr (int port);
  148.  
  149. /* Drop the DTR signal on a COM port */
  150. void    _Cdecl    comdropdtr (int port);
  151.  
  152. /* Raise the DTR signal on a COM port */
  153. void    _Cdecl    comraisedtr (int port);
  154.  
  155. /* Set the BREAK pulse on a COM port to 0 or 1 */
  156. void    _Cdecl    combreak (int port,int value);
  157.  
  158. /* Restore a COM port after a DOS shell-out, since */
  159. /* a program may have disabled interrupts, etc.    */
  160. void    _Cdecl    comfix (int port);
  161.  
  162. #ifdef    __cplusplus
  163. }
  164. #endif
  165.  
  166. #endif    /* __COMMS_H__ */
  167.