#ifndef TCA6424_INC
#define TCA6424_INC				1

#include	<msc_config.h>

extern ushort WrRegVal;


// TCA6424 ADDRESS BYTES
#define TCA6424_ADDR_WR         0x44
#define TCA6424_ADDR_RD         0x45

// TCA6424 COMMAND BYTE REGISTER ADDRESSES
#define TCA6424_INPUT_AUTOI     0x80
#define TCA6424_INPUT_PORT0     0x00
#define TCA6424_INPUT_PORT1     0x01
#define TCA6424_INPUT_PORT2     0x02

#define TCA6424_OUTPUT_AUTOI    0x84
#define TCA6424_OUTPUT_PORT0    0x04
#define TCA6424_OUTPUT_PORT1    0x05
#define TCA6424_OUTPUT_PORT2    0x06

#define TCA6424_INVERT_AUTOI    0x88
#define TCA6424_INVERT_REG0     0x08
#define TCA6424_INVERT_REG1     0x09
#define TCA6424_INVERT_REG2     0x0A

#define TCA6424_CONFIG_AUTOI    0x8C
#define TCA6424_CONFIG_REG0     0x0C
#define TCA6424_CONFIG_REG1     0x0D
#define TCA6424_CONFIG_REG2     0x0E

// TCA6424 DEFAULT OUTPUT PORT DATA VALUES
#define TCA6424_OUTPUT_VAL0     0x90
#define TCA6424_OUTPUT_VAL1     0x00
#define TCA6424_OUTPUT_VAL2     0x80

// TCA6424 PORT INVERT PORT BYTE VALUES
#define TCA6424_INVERT_VAL0     0x00
#define TCA6424_INVERT_VAL1     0x00
#define TCA6424_INVERT_VAL2     0x00

// TCA6424 PORT CONFIG PORT BYTE VALUES  (PIN DATA DIRECTION)
#define TCA6424_CONFIG_VAL0     0x08
#define TCA6424_CONFIG_VAL1     0x00
#define TCA6424_CONFIG_VAL2     0x01

// TCA6424 READ REGISTER OFFSET FROM ASSOCIATED WRITE REGISTER
#define TCA6424_RD_OFFSET       0x04

// TCA6424 DURAFET FUNCTION SPECIFC BIT ASSIGNMENTS
// IO_PORT_0
#define ADC_A0                  0x01
#define ADC_A1                  0x02
#define ADC_CONV                0x04
#define ADC_DRDY                0x08
#define ADC_CS                  0x10
#define ADC_CAL                 0x20
#define ADC_POL                 0x40
#define ADC_SHDN                0x80
// IO_PORT_1
#define ANSW_A0                 0x01
#define ANSW_A1                 0x02
#define ANSW_EN                 0x04
#define IAMP_D0                 0x08
#define IAMP_D1                 0x10
#define IAMP_D2                 0x20
#define IAMP_D3                 0x40
#define IAMP_LATCH              0x80
// IO_PORT_2
#define A_SUPPLY_RDY            0x01
#define A_SUPPLY_SHDN           0x02
#define VRS_BUFF_SHDN           0x04
#define IAMP_SHDN               0x08
#define TEMP_BUFF_SHDN          0x10
#define VK_BUFF_SHDN            0x20
#define VBAT_MONITOR            0x40
#define STATUS_LED              0x80


// TCA6424 PROTOTYPES
int   TCA6424_Init(void);
int   TCA6424_WritePortDefaults(void);
int   TCA6424_ReadPort(uchar Port, uchar *Data);
int   TCA6424_ReadPorts(uchar *Data0, uchar *Data1, uchar *Data2);
int   TCA6424_WritePort(uchar Port, uchar Data);
int   TCA6424_WritePortBit(uchar Port, uchar Bitval, uchar State);
void  TCA6424_ArmINT(void);
int   TCA6424_MonINT(void);


#endif

