home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_01_01 / 1n01054a < prev    next >
Text File  |  1990-05-17  |  2KB  |  70 lines

  1. *****Listing 1*****
  2.  
  3. /*
  4.  *  COM.H
  5.  *
  6.  *  Copyright (C) Mark R. Nelson 1990
  7.  *
  8.  * This file contains the structure definitions, constants,
  9.  * and function prototypes needed to use the RS-232
  10.  * interface code supplied in COM.C.  It should be included
  11.  * by any routine using COM.C procedures.
  12.  */
  13.  
  14. /*
  15.  * This structure defines the 256 byte buffer used for
  16.  * I/O buffers by the COM routines.  By using a buffer
  17.  * size of 256 bytes, updating the indices is simplified.
  18.  */
  19. typedef struct {
  20.                  char buffer[256];
  21.                  unsigned char write_index;
  22.                  unsigned char read_index;
  23.                } BUFFER;
  24. /*
  25.  * This structure defines a COM port.  It is initialized
  26.  * when the port is opened with port_open().
  27.  */
  28. typedef struct {
  29.                  void (interrupt far * old_vector)();
  30.                  int                   uart_base;
  31.                  int                   irq_mask;
  32.                  int                   interrupt_number;
  33.                  BUFFER                in;
  34.                  BUFFER                out;
  35. } PORT ;
  36. /*
  37.  * the ifdef M_186 is checking for Microsoft C/QuickC.
  38.  * Borland and Microsoft differ slightly on the names of
  39.  * some of the DOS specific procedure names, and the
  40.  * fixing up is done here.
  41.  */
  42. #ifdef M_I86
  43. #define inportb inp
  44. #define outportb outp
  45. #define getvect _dos_getvect
  46. #define setvect _dos_setvect
  47. #define enable _enable
  48. #endif
  49. /*
  50.  * The fully qualified function prototypes.  All of these
  51.  * routines actually reside in COM.C
  52.  */
  53. PORT *port_open( int address, int interrupt_number );
  54. void port_set( PORT *port,
  55.                long speed,
  56.                char parity,
  57.                int data,
  58.                int stopbits );
  59. void port_close( PORT *port );
  60. int port_putc( unsigned char c, PORT *port );
  61. int port_getc( PORT *port );
  62. /*
  63.  * These are the standard UART addresses and interrupt
  64.  * numbers for the two IBM compatible COM ports.
  65.  */
  66. #define COM1_UART         0x3f8
  67. #define COM1_INTERRUPT    12
  68. #define COM2_UART         0x2f8
  69. #define COM2_INTERRUPT    11
  70.