#ifndef __I2C_H__
#define __I2C_H__
/*_____ I N C L U D E S _________________________________*/
#include <SN8F5762.h>

/*_____ F U N C T I O N S _______________________________*/
void GPIO_Initialization(void);
void I2C_ConfigureRegister(uint8_t bMuxNum, uint8_t bClockDiv, uint8_t bSelfAddress, uint8_t bMateAddress);
void I2C_InitSlaveTX(bit fTxRxSel, uint8_t *bptrDataBuf, uint16_t dbLength);
void I2C_InitSlaveRX(bit fTxRxSel, uint8_t *bptrDataBuf, uint16_t dbLength);
void I2C_RepeatMaster(void);
void I2C_RepeatSlave(void);

void I2C_ExecuteTransmission(void);
bit I2C_CheckTransDataDone(void);
bit I2C_CheckTransDataStop(void);
bit I2C_CheckReciDataDone(void);
bit I2C_CheckReciDataStop(void);

/*_____ D E F I N I T I O N S ___________________________*/
#define SLAVE_SEL                         1
#define MASTER_SEL                        0

#define I2C_RX_SEL                        1
#define I2C_TX_SEL                        1

#define	mskI2CCON_I2C_CLOCKDIV_40				(0x00U<<0)
#define	mskI2CCON_I2C_CLOCKDIV_80				(0x01U<<0)
#define	mskI2CCON_I2C_CLOCKDIV_160			(0x02U<<0)
#define	mskI2CCON_I2C_CLOCKDIV_320			(0x03U<<0)
#define	mskI2CCON_I2C_AA								(0x01U<<2)
#define	mskI2CCON_I2C_FLAG							(0x01U<<3)
#define	mskI2CCON_I2C_STO								(0x01U<<4)
#define	mskI2CCON_I2C_STA								(0x01U<<5)
#define	mskI2CCON_I2C_ENABLE						(0x01U<<6)
#define	mskI2CCON_I2C_CLOCKDIV_T1OV			(0x01U<<7)

#define	mskI2CADR_I2C_GENERALCALL				(0x01U<<0)

#define mskI2CDAT_I2C_MODE_TX						(0x00U<<0)
#define mskI2CDAT_I2C_MODE_RX						(0x01U<<0)

#define	mskIEN1_INT_I2C									(0x01U<<0)

/*_____ D E C L A R A T I O N S _________________________*/

/*_____ M A C R O S _____________________________________*/
#define	IO_PORT0_OUTPUT_LOW		P0M |= 0xFC;	P0 &= 0x03;
#define	IO_PORT1_OUTPUT_LOW		P1M |= 0xFE;	P1 &= 0x01;
#define	IO_PORT2_OUTPUT_LOW		P2M |= 0xFE;	P2 &= 0x01;


#define I2C_PIN_SET_INPUT_0					P0M &= (0x01U<<0);	P0M &= (0x01U<<1);
#define I2C_PIN_SET_INPUT_1					P2M &= (0x01U<<0);	P1M &= (0x01U<<0);



#endif  /*	__I2C_H__	*/