/****************************************************************************/
/* Copyright 2010 MBARI.                                                    */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
#ifndef DIG_IO_H
#define DIG_IO_H

/*********** Output Bits ****************/
#define GF_48V_01	LATBbits.LATB2
#define GF_48V_01_RET	LATBbits.LATB3
#define GF_48V_02	LATBbits.LATB4
#define GF_48V_02_RET	LATBbits.LATB5
#define TEST_GF		LATBbits.LATB6
#define TEST_RET_GF	LATBbits.LATB7

#define SPARE_01	LATBbits.LATB8
#define SPARE_02	LATBbits.LATB9
#define SPARE_03	LATBbits.LATB10
#define SPARE_04	LATBbits.LATB11
#define SPARE_05	LATBbits.LATB12
#define SPARE_06	LATBbits.LATB13
#define SPARE_07	LATBbits.LATB14
#define SPARE_08	LATBbits.LATB15

#define ADC_01_CS	LATDbits.LATD6
#define ADC_02_CS	LATDbits.LATD7
#define ADC_48V_01_CS	LATDbits.LATD9
#define ADC_48V_02_CS	LATDbits.LATD10
#define XPORT_INT	LATDbits.LATD11

#define FAN_01		LATFbits.LATF0
#define FAN_02		LATFbits.LATF1
#define VICOR_01	LATFbits.LATF2
#define VICOR_02	LATFbits.LATF3
#define RELAY_01	LATFbits.LATF4
#define RELAY_02	LATFbits.LATF5

#define LED_BIT		LATGbits.LATG6

/******** Input Bits in Port E **********/
#define FAN_01_BIT	1
#define FAN_02_BIT	2
#define VICOR_01_BIT	4
#define VICOR_02_BIT	8
#define RELAY_01_BIT	0x10
#define RELAY_02_BIT	0x20

/*********Port G Input Bits *************/
#define H2O_SENSE_01	PORTGbits.RG2
#define H2O_SENSE_02	PORTGbits.RG3

/***** Bits in Sys Status *****/
#define FAN_01_STAT	1
#define FAN_02_STAT	2
#define VICOR_01_STAT	4
#define VICOR_02_STAT	8
#define RELAY_01_STAT	0x10
#define RELAY_02_STAT	0x20

/* init registers */
void digInit(); 

void digSetBlinky(int state);
int  digGetBlinky();
void digSetFan(int fan, int state);
int  digGetFanState(void);
void digSetVicor(int vicor, int state);
int  digGetVicorState(void);
void digSetRelay(int relay, int state);
int  digGetRelayState(void);
void digSet48VAct(int state);
int  digGet48VRdy(void);
int  digGet375VRdy(void);
int  digGetSysStatus(void);
int  digGetH2OSense(void);

#endif

