home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / alde_c / lattice / comring / comring1.doc next >
Encoding:
Text File  |  1985-02-10  |  3.5 KB  |  105 lines

  1. COMRING1 is a collection of Lattice "C" functions that set up COM1 to be
  2. completely interrupt driven. When you want to transmit something, it is
  3. placed in the transmit ring, and you immediately regain control to do 
  4. other processing. In the meantime, the interrupt routine is sending data
  5. from the transmit ring out the com port. Later on, you can check to see 
  6. if the operation is done, or add more data to the xmit ring before the
  7. previous xmit is finished. The receive function works similarily. When a
  8. character is received, it is put into a ring. When you ask for a byte,
  9. it is taken from the ring. This isn't quite true multi-tasking, but it's
  10. close.
  11.  
  12. This version is a test version. As soon as I am sure it is solid, it will
  13. be easy to do the same thing for COM2. Eventually I intend to write a
  14. multiple user BBS program that will not require any special software
  15. like Concurrent DOS or Topview.
  16.  
  17. Each function is described below. They were compiled using the small model.
  18. Support for the other models will come later.
  19.  
  20.  
  21. ************************************************************************
  22.  
  23. c1setup (rcvlen, xmtlen)
  24.     int    rcvlen, xmtlen
  25.  
  26. Allocates storage for transmit & receive ring. Enables all interrupts
  27. and sets new interrupt vector. Returns 0 if all ok, or 1 if insufficient
  28. storage for rings.
  29.  
  30. ************************************************************************
  31. c1bcnt(rbc, xbc)
  32.     int    *rbc, *xbc
  33.  
  34. Sends the current byte counts of the receive & transmit rings.
  35.  
  36. ************************************************************************
  37.  
  38. c1init (speed, parity, databits, stopbits)
  39.     int    speed, parity, databits, stopbits;
  40.  
  41. Initializes the communications port. Return codes are:
  42.   0 - all parameters valid
  43.   1 - invalid speed (110,150,300,600,1200,2400,4800,9600)
  44.   2 - invalid parity ('S','M','O','E','N')
  45.   3 - invalid data bits ('5', '6', '7', '8')
  46.   4 - invalid stop bits ('1', '2')
  47.  
  48. ************************************************************************
  49.  
  50. c1mstat()
  51.     int function that returns modem status. Refer to Technical
  52. Reference manual for bit meanings.
  53.  
  54. ************************************************************************
  55.  
  56. c1rbyte (rb, rstat)
  57.     char *rb, *rstat
  58.  
  59. int function that gets a received byte and status from the receive ring.
  60. Returns 0 if a character has been received, or 1 if the ring is empty.
  61.  
  62. ************************************************************************
  63.  
  64. c1smc(dsw)
  65.     int    dsw
  66.  
  67. Sets modem control (dtr, rts) on or off.
  68.  
  69. ************************************************************************
  70.  
  71. c1xmitb(xchar)
  72.     char    xchar
  73.  
  74. Inserts a character into the xmit ring.
  75.  
  76. ************************************************************************
  77.  
  78. c1xmits(string)
  79.     char     *string
  80.  
  81. Int function that puts a string into the xmit ring. Returns 0 if entire
  82. string was put in, or returns number of bytes that weren't put in because
  83. the ring was full.
  84.  
  85. ************************************************************************
  86.  
  87. c1xmitsw(string)
  88.     char    *string
  89.  
  90. Same as c1smits, but waits for the xmit operation to finish.
  91.  
  92. ************************************************************************
  93.  
  94. ckxfull()
  95.  
  96. Int function returns 0 if xmit ring is not full, returns 1 if it is full.
  97.  
  98. ************************************************************************
  99.  
  100.  
  101.  
  102. If you have any problems, comments, suggestions etc. leave me (John Cantlin)
  103. a message on the Consultants Exchange RBBS (714) 842-6348.
  104.  
  105.