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

VxWorks

开发平台:

C/C++

  1. /* lptDrv.h - IBM-PC LPT */
  2. /* Copyright 1984-2000 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01g,23mar01,sru  add register spacing field to LPT_RESOURCE SPR# 65937
  7. 01f,23aug00,jgn  move _ASMLANGUAGE guard to prevent header file problems with
  8.                  assembler builds
  9. 01e,04jan00,dat  SPR 29875, chg'd SEMAPHOREs to SEM_IDs
  10. 01d,22nov99,stv  added missing header files (SPR #24014).
  11. 01c,10dec97,ms   added lptResources import
  12. 01b,18oct96,hdn  re-written.
  13. 01a,13oct94,hdn  written.
  14. */
  15. #ifndef __INClptDrvh
  16. #define __INClptDrvh
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #ifndef _ASMLANGUAGE
  21. /* includes */
  22. #include "iosLib.h"
  23. #include "semLib.h"
  24. typedef struct lptDev /* LPT_DEV */
  25.     {
  26.     DEV_HDR devHdr;
  27.     BOOL created; /* TRUE if this device has been created */
  28.     BOOL autofeed; /* TRUE if enable autofeed */
  29.     BOOL inservice; /* TRUE if interrupt in service */
  30.     ULONG data; /* data register */
  31.     ULONG stat; /* status register */
  32.     ULONG ctrl; /* control register */
  33.     int  intCnt; /* interrupt count */
  34.     int  retryCnt; /* retry count */
  35.     int busyWait; /* loop count for BUSY wait */
  36.     int  strobeWait; /* loop count for STROBE wait */
  37.     int  timeout; /* timeout second for syncSem */
  38.     int  intLevel; /* interrupt level */
  39.     SEM_ID muteSem; /* mutex semaphore */
  40.     SEM_ID syncSem; /* sync semaphore */
  41.     } LPT_DEV;
  42. typedef struct lptResource /* LPT_RESOURCE */
  43.     {
  44.     int ioBase; /* IO base address */
  45.     int intVector; /* interrupt vector */
  46.     int intLevel; /* interrupt level */
  47.     BOOL autofeed;       /* TRUE if enable autofeed */
  48.     int busyWait;       /* loop count for BUSY wait */
  49.     int strobeWait;     /* loop count for STROBE wait */
  50.     int retryCnt;       /* retry count */
  51.     int timeout;        /* timeout second for syncSem */
  52.     int regDelta; /* register address spacing */
  53.     } LPT_RESOURCE;
  54. /* IO address (LPT) */
  55. #define N_LPT_CHANNELS 3 /* max LPT channels */
  56. /* register definitions */
  57. #define CAST
  58. #define LPT_REG_ADDR_INTERVAL   1       /* address diff of adjacent regs. */
  59. #define LPT_ADRS(base,reg)   (CAST (base+(reg*LPT_REG_ADDR_INTERVAL)))
  60. /* register spacing based on header file definition */
  61. #define LPT_DATA(base) LPT_ADRS(base,0x00) /* data reg. */
  62. #define LPT_STAT(base) LPT_ADRS(base,0x01) /* status reg. */
  63. #define LPT_CTRL(base) LPT_ADRS(base,0x02) /* control reg. */
  64. /* register spacing based on resource structure */
  65. #define LPT_DATA_RES(resource)  (resource->ioBase + (0 * resource->regDelta))
  66. #define LPT_STAT_RES(resource)  (resource->ioBase + (1 * resource->regDelta))
  67. #define LPT_CTRL_RES(resource)  (resource->ioBase + (2 * resource->regDelta))
  68. /* control register */
  69. #define C_STROBE 0x01 /* STROBE signal */
  70. #define C_AUTOFEED 0x02 /* AUTOFEED signal */
  71. #define C_NOINIT 0x04 /* INITIALIZE signal */
  72. #define C_SELECT 0x08 /* SELECT INPUT signal */
  73. #define C_ENABLE 0x10 /* ENABLE interrupt */
  74. #define C_INPUT 0x20 /* DATA DIRECTION control bit */
  75. /* status register */
  76. #define S_NODERR 0x08 /* Device error */
  77. #define S_SELECT 0x10 /* Device selected */
  78. #define S_PERR 0x20 /* Device out of paper */
  79. #define S_NOACK 0x40 /* Printer ready */
  80. #define S_NOBUSY 0x80 /* Device busy */
  81. #define S_MASK 0xb8 /* mask bits */
  82. /* ioctl functions */
  83. #define LPT_SETCONTROL 0
  84. #define LPT_GETSTATUS 1
  85. IMPORT LPT_RESOURCE lptResources[];
  86. /* function declarations */
  87. #if defined(__STDC__) || defined(__cplusplus)
  88. STATUS lptDrv (int channels, LPT_RESOURCE *pResource);
  89. STATUS lptDevCreate (char *name, int channel);
  90. #else
  91. STATUS lptDrv ();
  92. STATUS lptDevCreate ();
  93. #endif  /* __STDC__ */
  94. #endif /* _ASMLANGUAGE */
  95. #ifdef __cplusplus
  96. }
  97. #endif
  98. #endif /* __INClptDrvh */