sioLib.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:7k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* sioLib.h - header file for binary interface serial drivers */
  2. /* Copyright 1984-2002 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01i,09may02,wef adding keyboard led set and get ioctls.
  7. 01h,29sep01,dat added SIO_ERRROR_NONE, new MODEM ctrl values.
  8. 01g,26apr00,dat added error callback
  9. 01f,04feb00,db  added support for handling modem control signals and 
  10. multiple keyboard modes(SPR #29348).
  11. 01e,14jan97,db  added SIO_OPEN and SIO_HUP for modem control(SPR #7637).
  12. 01d,24oct95,ms  removed "static __inline__" (SPR #4500)
  13. 01c,15jun95,ms  Added SIO_MODE_SET, SIO_MODE_GET, SIO_AVAIL_MODES_GET iotcl's
  14. Renamed SIO_CHAN to SIO_CHAN
  15. Changed prototype and name of callbackInstall()
  16. Added documentation.
  17. 01b,22may95,ms  removed unneeded include file.
  18. 01a,21feb95,ms  written.
  19. */
  20. #ifndef __INCsioLibh
  21. #define __INCsioLibh
  22. #include "types/vxTypes.h"
  23. #include "types/vxTypesOld.h"
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. /* serial device I/O controls */
  28. #define SIO_BAUD_SET 0x1003
  29. #define SIO_BAUD_GET 0x1004
  30. #define SIO_HW_OPTS_SET 0x1005
  31. #define SIO_HW_OPTS_GET 0x1006
  32. #define SIO_MODE_SET 0x1007
  33. #define SIO_MODE_GET 0x1008
  34. #define SIO_AVAIL_MODES_GET 0x1009
  35. /* These are used to communicate open/close between layers */
  36. #define SIO_OPEN 0x100A 
  37. #define SIO_HUP 0x100B
  38. /*
  39.  * The ioctl commands listed below provide a way for reading and
  40.  * setting the modem lines. 
  41.  * 
  42.  * SIO_MSTAT_GET: returns status of all input and output modem signals.
  43.  * SIO_MCTRL_BITS_SET: sets modem signals specified in argument.
  44.  * SIO_MCTRL_BITS_CLR: clears modem signal(s) specified in argument.
  45.  * SIO_MCTRL_ISIG_MASK: returns mask of all input modem signals.
  46.  * SIO_MCTRL_OSIG_MASK: returns mask of all output(writable) modem signals.
  47.  */
  48. #define SIO_MSTAT_GET           0x100C  /* get modem status lines */
  49. #define SIO_MCTRL_BITS_SET      0x100D  /* set selected modem lines */
  50. #define SIO_MCTRL_BITS_CLR      0x100E  /* clear selected modem lines  */
  51. #define SIO_MCTRL_ISIG_MASK     0x100F  /* mask of lines that can be read */
  52. #define SIO_MCTRL_OSIG_MASK     0x1010  /* mask of lines that can be set */
  53. /* Ioctl cmds for reading/setting keyboard mode */
  54. #define SIO_KYBD_MODE_SET       0x1011
  55. #define SIO_KYBD_MODE_GET       0x1012
  56. /* Ioctl cmds for reading/setting keyboard led state */
  57. #define SIO_KYBD_LED_SET       0x1013
  58. #define SIO_KYBD_LED_GET       0x1014
  59. /* callback type codes */
  60. #define SIO_CALLBACK_GET_TX_CHAR 1
  61. #define SIO_CALLBACK_PUT_RCV_CHAR 2
  62. #define SIO_CALLBACK_ERROR 3
  63. /* Get Tx Chara callback (getTxCallbk) (callbkArg, pChar) */
  64. /* Put Rx Chara callback (putRxCallbk) (callbkArg, char) */
  65. /* Error callback codes: (errorCallbk) (callbkArg, code, pData, size) */
  66. #define SIO_ERROR_NONE (-1)
  67. #define SIO_ERROR_FRAMING 0
  68. #define SIO_ERROR_PARITY 1
  69. #define SIO_ERROR_OFLOW 2
  70. #define SIO_ERROR_UFLOW 3
  71. #define SIO_ERROR_CONNECT 4
  72. #define SIO_ERROR_DISCONNECT 5
  73. #define SIO_ERROR_NO_CLK 6
  74. #define SIO_ERROR_UNKNWN 7
  75. /* options to SIO_MODE_SET */
  76. #define SIO_MODE_POLL 1
  77. #define SIO_MODE_INT 2
  78. /* options to SIOBAUDSET */
  79. /* use the number, not a macro */
  80. /* options to SIO_HW_OPTS_SET (ala POSIX), bitwise or'ed together */
  81. #define CLOCAL 0x1 /* ignore modem status lines */
  82. #define CREAD 0x2 /* enable device reciever */
  83. #define CSIZE 0xc /* bits 3 and 4 encode the character size */
  84. #define CS5 0x0 /* 5 bits */
  85. #define CS6 0x4 /* 6 bits */
  86. #define CS7 0x8 /* 7 bits */
  87. #define CS8 0xc /* 8 bits */
  88. #define HUPCL 0x10 /* hang up on last close */
  89. #define STOPB 0x20 /* send two stop bits (else one) */
  90. #define PARENB 0x40 /* parity detection enabled (else disabled) */
  91. #define PARODD 0x80 /* odd parity  (else even) */
  92. /* 
  93.  * Modem signals definitions 
  94.  *
  95.  * The following six macros define the different modem signals. They
  96.  * are used as arguments to the modem ioctls commands to specify 
  97.  * the signals to read(set) and also to parse the returned value. They
  98.  * provide hardware independence, as modem signals bits vary from one 
  99.  * chip to another.      
  100.  */
  101. #define SIO_MODEM_DTR   0x01    /* data terminal ready */
  102. #define SIO_MODEM_RTS   0x02    /* request to send */
  103. #define SIO_MODEM_CTS   0x04    /* clear to send */
  104. #define SIO_MODEM_CD    0x08    /* carrier detect */
  105. #define SIO_MODEM_RI    0x10    /* ring */
  106. #define SIO_MODEM_DSR   0x20    /* data set ready */
  107. /*
  108.  * options to SIO_KYBD_MODE_SET 
  109.  *
  110.  * These macros are used as arguments by the keyboard ioctl comands.
  111.  * When used with SIO_KYBD_MODE_SET they mean the following:
  112.  * 
  113.  * SIO_KYBD_MODE_RAW:
  114.  *    Requests the keyboard driver to return raw key values as read
  115.  *    by the keyboard controller.
  116.  * 
  117.  * SIO_KYBD_MODE_ASCII:
  118.  *    Requests the keyboard driver to return ASCII codes read from a
  119.  *    known table that maps raw key values to ASCII.
  120.  *
  121.  * SIO_KYBD_MODE_UNICODE:
  122.  *    Requests the keyboard driver to return 16 bit UNICODE values for
  123.  *    multiple languages support.
  124.  */
  125. #define SIO_KYBD_MODE_RAW     1
  126. #define SIO_KYBD_MODE_ASCII   2
  127. #define SIO_KYBD_MODE_UNICODE 3
  128. /*
  129.  * options to SIO_KYBD_LED_SET 
  130.  *
  131.  * These macros are used as arguments by the keyboard ioctl comands.
  132.  * When used with SIO_KYBD_LED_SET they mean the following:
  133.  * 
  134.  * SIO_KYBD_LED_NUM:
  135.  *    Sets the Num Lock LED on the keyboard - bit 1
  136.  * 
  137.  * SIO_KYBD_LED_CAP:
  138.  *    Sets the Caps Lock LED on the keyboard - bit 2
  139.  *
  140.  * SIO_KYBD_LED_SRC:
  141.  *    Sets the Scroll Lock LED on the keyboard - bit 4
  142.  */
  143. #define SIO_KYBD_LED_NUM 1
  144. #define SIO_KYBD_LED_CAP 2
  145. #define SIO_KYBD_LED_SCR 4
  146. /* serial device data structures */
  147. typedef struct sio_drv_funcs SIO_DRV_FUNCS;
  148. typedef struct sio_chan /* a serial channel */
  149.     {
  150.     SIO_DRV_FUNCS * pDrvFuncs;
  151.     /* device data */
  152.     } SIO_CHAN;
  153. struct sio_drv_funcs /* driver functions */
  154.     {
  155.     int (*ioctl)
  156. (
  157. SIO_CHAN * pSioChan,
  158. int cmd,
  159. void * arg
  160. );
  161.     int (*txStartup)
  162. (
  163. SIO_CHAN * pSioChan
  164. );
  165.     int (*callbackInstall)
  166. (
  167. SIO_CHAN * pSioChan,
  168. int callbackType,
  169. STATUS (*callback)(void *, ...),
  170. void * callbackArg
  171. );
  172.     int (*pollInput)
  173. (
  174. SIO_CHAN * pSioChan,
  175. char * inChar
  176. );
  177.     int (*pollOutput)
  178. (
  179. SIO_CHAN * pSioChan,
  180. char  outChar
  181. );
  182.     };
  183. /* in-line macros */
  184. #define sioIoctl(pSioChan, cmd, arg) 
  185.         ((pSioChan)->pDrvFuncs->ioctl (pSioChan, cmd, arg))
  186. #define sioTxStartup(pSioChan) 
  187.         ((pSioChan)->pDrvFuncs->txStartup (pSioChan))
  188. #define sioCallbackInstall(pSioChan, callbackType, callback, callbackArg) 
  189. ((pSioChan)->pDrvFuncs->callbackInstall (pSioChan, callbackType, 
  190. callback, callbackArg))
  191. #define sioPollInput(pSioChan, inChar) 
  192.         ((pSioChan)->pDrvFuncs->pollInput (pSioChan, inChar))
  193. #define sioPollOutput(pSioChan, thisChar) 
  194.         ((pSioChan)->pDrvFuncs->pollOutput (pSioChan, thisChar))
  195. #ifdef __cplusplus
  196. }
  197. #endif
  198. #endif  /* __INCsioLibh */