/*********************************i******************************************/
/* Copyright 1992, 1993 MBARI                                               */
/****************************************************************************/
/* Summary  : IBC Parallel Input/Output Interface Board definitions         */
/* Filename : pio.h                                                         */
/* Author   : Andrew Pearce                                                 */
/* Project  : New ROV Data Concentrator                                     */
/* Version  : 1.0                                                           */
/* Created  : 10/08/92                                                      */
/* Modified : 04/01/93                                                      */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/* $Header: /usr/tiburon/.cvsroot/micro/h/pio.h,v 1.1.1.1 1997/05/02 17:15:40 pean Exp $
 * $Log: pio.h,v $
 * Revision 1.1.1.1  1997/05/02 17:15:40  pean
 * Initial release of the microcontroller software after Tiburon
 * Moolpool Dive to test IView, Lapboxes, modified Power can
 * GF/5V using bus capacitance mode.
 *
 * Revision 1.1  93/07/02  09:37:44  09:37:44  pean (Andrew Pearce)
 * Initial revision
 *
*/
/****************************************************************************/

                                        /* Parallel IO Board Register Offset*/
#define PIO_PORTA_REG      0            /* Address of Port A Data register  */
#define PIO_PORTB_REG      1            /* Address of Port B Data register  */
#define PIO_PORTC_REG      2            /* Address of Port C Data register  */
#define PIO_CMD_REG        3            /* Address of PIC control word reg  */
#define PIO_NUM_PORTS      3            /* Number of IO Ports Per Board     */

                                        /*   82C55 Mode Configuration Bits  */
#define PIO_PORTC_LOWER_IN    0x01      /* Configure Port C Lower for Input */
#define PIO_PORTC_LOWER_OUT   0x00      /* Configure Port C Lower for Output*/
#define PIO_PORTB_IN          0x02      /* Configure Port B for Input       */
#define PIO_PORTB_OUT         0x00      /* Configure Port B for Output      */
#define PIO_PORTB_BASIC_IO    0x00      /* Port B is Basic Input/Output     */
#define PIO_PORTB_STROBED_IO  0x04      /* Port B is Strobed Input/Output   */

#define PIO_PORTC_UPPER_IN    0x08      /* Configure Port C Upper for Input */
#define PIO_PORTC_UPPER_OUT   0x00      /* Configure Port C Upper for Output*/
#define PIO_PORTA_IN          0x10      /* Configure Port A for Input       */
#define PIO_PORTA_OUT         0x00      /* Configure Port A for Output      */
#define PIO_PORTA_BASIC_IO    0x00      /* Port A is Basic Input/Output     */
#define PIO_PORTA_STROBED_IO  0x20      /* Port A is Strobed Input/Output   */
#define PIO_PORTA_BI_DIR_IO   0x40      /* Port A is Bi-directional I/O     */

#define PIO_BIT_MANIP_SELECT  0x00      /* Select Bit Manipulation register */
#define PIO_MODE_REG_SELECT   0x80      /* Select Mode Command register     */

#define PIO_BIT_SET           0x01      /* Set PIO Bit                      */
#define PIO_BIT_CLEAR         0x00      /* Clear PIO Bit                    */

typedef struct                          /* Parallel IO Data Structure       */
{
    IBC_BoardEntry IBC_Board;           /* IBC Board Entry structure        */
    Byte ioportCopy[PIO_NUM_PORTS];     /* Copy of ioport value             */
} PIO_BoardEntry;

#ifdef __STDC__

Int16 PIO_BoardSearch( IBC_BoardEntry *IBC_Boards[], Int16 maxCards );

PIO_BoardEntry* PIO_BoardInit( Byte *boardBaseAddr );

Void PIO_BoardInterruptOn( PIO_BoardEntry *PIO_Board );
Void PIO_BoardInterruptOff( PIO_BoardEntry *PIO_Board );
Void PIO_BoardIsr( PIO_BoardEntry *PIO_Board );
Int16 PIO_readPort( PIO_BoardEntry *PIO_Board, Byte portAddr );
Int16 PIO_readPortCopy( PIO_BoardEntry *PIO_Board, Byte port );

Int16 PIO_writePort( PIO_BoardEntry *PIO_Board, Byte portAddr, Byte value,
     Word action );

Int16 PIO_writePortBit( PIO_BoardEntry *PIO_Board, Byte port, Byte bit,
     Boolean state );

Void PIO_ReadPortCmd( IBC_BoardEntry* IBC_CardTable[], Int16 IBC_CardCount,
         Byte *commandBuf );

Void PIO_WritePortCmd( IBC_BoardEntry* IBC_CardTable[], Int16 IBC_CardCount,
         Byte *commandBuf );

#endif
