#ifndef __I2C_H__
#define __I2C_H__
/*_____ I N C L U D E S _________________________________*/
#include <SN8F5754.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_InitMaster(bit fTxRxSel, uint8_t *bptrDataBuf, uint16_t dbLength);
void I2C_InitSlave(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                         0
#define MASTER_SEL                        1

#define I2C_RX_SEL                        1
#define I2C_TX_SEL                        0

#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 |= 0xFF;	P0 &= 0x00;
#define	IO_PORT1_OUTPUT_LOW		P1M |= 0xFF;	P1 &= 0x00;
#define	IO_PORT2_OUTPUT_LOW		P2M |= 0xFF;	P2 &= 0x00;
#define	IO_PORT3_OUTPUT_LOW		P3M |= 0xFF;	P3 &= 0x00;

#define I2C_PIN_SET_INPUT_0					P1M &= (0x01U<<5);	P1M &= (0x01U<<6);
#define I2C_PIN_SET_INPUT_1					P1M &= (0x01U<<5);	P1M &= (0x01U<<6);


#endif  /*	__I2C_H__	*/