home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / desklib / !DeskLib / h / Serial < prev    next >
Encoding:
Text File  |  1994-05-22  |  5.8 KB  |  177 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Serial.h
  12.     Author:  Copyright © 1993 Jason Howat
  13.     Version: 1.10 (12 Dec 1993)
  14.     Purpose: Serial-SWI interfaces.
  15. */
  16.  
  17.  
  18. #ifndef __dl_serial_h
  19. #define __dl_serial_h
  20.  
  21. #ifndef __dl_core_h
  22. #include "Core.h"
  23. #endif
  24.  
  25.  
  26. /* The serial_rate enumeration defines the values to be used when
  27.  * reading/setting baud rates with Serial_Get?xRate/Serial_Set?xRate.
  28.  */
  29. typedef enum
  30. {
  31.   serial_9600BAUD = 0,
  32.   serial_75BAUD,
  33.   serial_150BAUD,
  34.   serial_300BAUD,
  35.   serial_1200BAUD,
  36.   serial_2400BAUD,
  37.   serial_4800BAUD,
  38. /*serial_9600BAUD,*/
  39.   serial_19200BAUD = 8,
  40.   serial_50BAUD,
  41.   serial_110BAUD,
  42.   serial_134_5BAUD,
  43.   serial_600BAUD,
  44.   serial_1800BAUD,
  45.   serial_3600BAUD,
  46.   serial_7200BAUD
  47. } serial_rate;
  48.  
  49.  
  50. /* The following #defines describe the meaning of the bits in the word used
  51.  * by Serial_GetStatust/Serial_SetStatus.
  52.  */
  53. #define serial_USEXONXOFF               0x00000001   
  54. #define serial_IGNOREDCDBIT             0x00000002
  55. #define serial_IGNOREDSRBIT             0x00000004
  56. #define serial_DTROFF                   0x00000008
  57. #define serial_IGNORECTSBIT             0x00000010
  58. #define serial_DONTUSERTSFLOWCONTROL    0x00000020
  59. #define serial_SUPPRESSINPUT            0x00000040
  60. #define serial_RTSHIGH                  0x00000080
  61. #define serial_XOFFRECEIVED             0x00010000
  62. #define serial_XOFFSENT                 0x00020000
  63. #define serial_DCDHIGH                  0x00040000
  64. #define serial_NOCARRIER                0x00040000
  65. #define serial_DSRHIGH                  0x00080000
  66. #define serial_RIHIGH                   0x00100000
  67. #define serial_CTSHIGH                  0x00200000
  68. #define serial_XOFFSENTMANUALLY         0x00400000
  69. #define serial_SPACEINRECEIVEBUFFER     0x00800000
  70.  
  71.  
  72. /* The following #defines describe the meaning of the bits in the word used
  73.  * by Serial_GetFormat/Serial_SetFormat.
  74.  */
  75. #define serial_8BITWORD         0x00000000
  76. #define serial_7BITWORD         0x00000001    
  77. #define serial_6BITWORD         0x00000002
  78. #define serial_5BITWORD         0x00000003
  79. #define serial_1STOPBIT         0x00000000
  80. #define serial_2STOPBITS        0x00000004
  81. #define serial_NOPARITY         0x00000000
  82. #define serial_PARITY           0x00000008
  83. #define serial_ODDPARITY        0x00000000
  84. #define serial_EVENPARITY       0x00000010
  85. #define serial_MARKPARITY       0x00000020
  86. #define serial_SPACEPARITY      0x00000030
  87.  
  88.  
  89. /* Serial_Activate ---------------------------------------------------------
  90.  * This function simply does an OS_Byte 2,2 to enable the serial drivers.
  91.  */
  92. extern os_error *Serial_Activate(void);
  93.  
  94.  
  95. /* Serial_Deactivate -------------------------------------------------------
  96.  * This function simply does an OS_Byte 2,0 to disable the serial drivers.
  97.  */
  98. extern os_error *Serial_Deactivate(void);
  99.  
  100.  
  101. /* Serial_GetStatus --------------------------------------------------------
  102.  * This function returns the current status of the serial port as given by
  103.  * OS_SerialOp 0.
  104.  */
  105. extern int Serial_GetStatus(void);
  106.  
  107.  
  108. /* Serial_SetStatus --------------------------------------------------------
  109.  * This function sets the current state of the serial port as given by
  110.  * OS_SerialOp 0.
  111.  */
  112. extern os_error *Serial_SetStatus(int eor_mask, int and_mask);
  113.  
  114.  
  115. /* Serial_GetFormat --------------------------------------------------------
  116.  * This function returns the current format used for transmission/reception
  117.  * of characters on the serial line.
  118.  */
  119. extern int Serial_GetFormat(void);
  120.  
  121.  
  122. /* Serial_GetFormat --------------------------------------------------------
  123.  * This function sets the format to use for transmission/reception of
  124.  * characters on the serial line.
  125.  */
  126. extern os_error *Serial_SetFormat(int format);
  127.  
  128.  
  129. /* Serial_GetTxRate/Serial_GetRxRate ---------------------------------------
  130.  * This function returns the current speed used for transmission/reception
  131.  * of characters on the serial line.
  132.  */
  133. extern serial_rate Serial_GetTxRate(void);
  134. extern serial_rate Serial_GetRxRate(void);
  135.  
  136.  
  137. /* Serial_SetTxRate/Serial_SetRxRate ---------------------------------------
  138.  * This function sets the speed to use for transmission/reception of
  139.  * characters on the serial line.
  140.  */
  141. extern os_error *Serial_SetTxRate(serial_rate rate);
  142. extern os_error *Serial_SetRxRate(serial_rate rate);
  143.  
  144.  
  145. /* Serial_GetByte ----------------------------------------------------------
  146.  * Reads a byte from the serial input buffer if one is available, otherwise
  147.  * returns -1.
  148.  */
  149. extern int Serial_GetByte(void);
  150.  
  151.  
  152. /* Serial_PutByte ----------------------------------------------------------
  153.  * Inserts a byte to be transmitted into the serial output buffer if there
  154.  * is room.  Returns TRUE if unable to send byte.
  155.  */
  156. extern BOOL Serial_PutByte(int c);
  157.  
  158.  
  159. /* Serial_SendBreak --------------------------------------------------------
  160.  * Transmits a break of the specified length.
  161.  */
  162. extern os_error *Serial_SendBreak(int length);
  163.  
  164.  
  165. /* Serial_NonZeroPollWordOnReceive -----------------------------------------
  166.  * This function installs a piece of code on the InsV vector to monitor the
  167.  * insertion of characters into the serial input buffer.  It will modify the
  168.  * supplied pollword to the given value whenever an insertion occurs.  Also,
  169.  * an atexit function is registered to remove the vector claimant and the
  170.  * RMA based code.
  171.  */
  172. extern void Serial_NonZeroPollWordOnReceive(int pollword_value,
  173.                                             void *pollword);
  174.  
  175.   
  176. #endif
  177.