home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_02_02 / 2n02038a < prev    next >
Text File  |  1990-12-27  |  3KB  |  88 lines

  1. /*  ---------------------------------------------
  2.  *  File:       I8255GEN.H
  3.  *  Creator:    Blake Miller
  4.  *  Version:    01.00.00            September 1990
  5.  *  Language:   Microsoft Quick C   Version 2.0
  6.  *  Purpose:    Intel 8255 Digital IO Functions
  7.  *              Generic Header File
  8.  *  ---------------------------------------------
  9.  */
  10.  
  11. #define     I8255GEN_H_DEFINED   1
  12.  
  13. /*  The address definitions are set up for the 8255.
  14.  *  The base address should be passed to
  15.  *  the I8255_init() function.
  16.  */
  17. #define I8255_PORTA(X)  (X + 0) /* PORT A   */
  18. #define I8255_PORTB(X)  (X + 1) /* PORT B   */
  19. #define I8255_PORTC(X)  (X + 2) /* PORT C   */
  20. #define I8255_CNTRL(X)  (X + 3) /* CONTROL  */
  21.  
  22. #define I8255_MAXCH 0x03    /* three IO ports   */
  23.  
  24. #define I8255_SET   0x80    /* configure set bit    */
  25.  
  26. #define I8255_PA_M0 0x20    /* A Mode 0 : Basic     */
  27. #define I8255_PA_M1 0x40    /* A Mode 1 : Strobed   */
  28. #define I8255_PA_M2 0x60    /* A Mode 2 : Bidir     */
  29. #define I8255_PB_M0 0x00    /* B Mode 0 : Basic     */
  30. #define I8255_PB_M1 0x04    /* B Mode 1 : Strobed   */
  31.  
  32. /*  The bit masks for the port input configurations.
  33.  *  Corresponding bits are 0 if the port is configured
  34.  *  for output.
  35.  */
  36. #define I8255_CL_IN 0x01    /* C Low  Input */
  37. #define I8255_PB_IN 0x02    /* B      Input */
  38. #define I8255_CH_IN 0x08    /* C High Input */
  39. #define I8255_PA_IN 0x10    /* A      Input */
  40.  
  41. /*  8255 Digital select mode:
  42.  *  PA 0-7 output, PB 0-7 output, PC 0-3 output,
  43.  *  PC 4-7 output
  44.  *  ALL ports in Mode 0
  45.  */
  46. #define I8255_ALL_OP I8255_SET
  47.  
  48. /*  8255 Digital select mode:
  49.  *  PA 0-7 input, PB 0-7 input, PC 0-3 input,
  50.  *  PC 4-7 input
  51.  *  ALL ports in Mode 0
  52.  */
  53. #define I8255_ALL_IP ( I8255_SET | I8255_CL_IN | \
  54.                        I8255_PB_IN | I8255_CH_IN | \
  55.                        I8255_PA_IN )
  56.  
  57. /*  Error Definitions ------------------------*/
  58. #define I8255_ST_OK  0x0000  /* OK               */
  59. #define I8255_ST_BB  0x0001  /* Bad Bit number   */
  60. #define I8255_ST_BP  0x0001  /* Bad Port number  */
  61.  
  62. /*  Data Structure ---------------------------*/
  63. #if !defined ( I8255DAT_STRUCT_DEFINED )
  64. typedef struct I8255dat_struct {
  65.     int             base;   /* 8255 address */
  66.     int             stat;   /* status flag  */
  67.     unsigned char   mode;   /* current mode */
  68.     unsigned char   adat;   /* port A data  */
  69.     unsigned char   bdat;   /* port B data  */
  70.     unsigned char   cdat;   /* port C data  */
  71.     } I8255DAT;
  72. #define I8255DAT_STRUCT_DEFINED
  73. #endif
  74.  
  75. /*  Function Prototypes ----------------------*/
  76. /*  These are the INP and OUTP functions used to
  77.  *  write and read from an 80X86 IO Port.
  78.  */
  79. extern  void chp_portwt (int d_port,
  80.                          unsigned char d_byte);
  81. extern  void chp_portrd (int d_port,
  82.                          unsigned char *d_byte);
  83.  
  84. /*  ---------------------------------------------
  85.  *  END I8255GEN.H Header File
  86.  *  ---------------------------------------------
  87.  */
  88.