#ifndef SERVICE_I2C_I2C_H_
#define SERVICE_I2C_I2C_H_


/********************************************************************************************
Debug Switch Definition Section
********************************************************************************************/

/********************************************************************************************
Include File Section
********************************************************************************************/
#include "Lpi2c_Ip_Callbacks.h"
#include "Lpi2c_Ip.h"
#include "Flexio_I2c_Ip.h"
#include "Flexio_I2c_Ip_Callbacks.h"
#include "Flexio_I2c_Ip_Features.h"
/********************************************************************************************
Macro Definition Section
********************************************************************************************/
/**
@brief I2c return info
*/
typedef enum
{
   I2C_NULL                              = 0x01U,
   I2C_NACK                              = 0x02U,
   I2C_ARBITRATION_LOST                  = 0x03U,
   I2C_ERROR_FIFO                        = 0x04U,
   I2C_END_TRANSFER                      = 0x05U,
   I2C_PIN_LOW_TIMEOUT                   = 0x06U,
   I2C_TRAN_OK                           = 0x07U,
}i2c_ReturnType;
typedef void (*i2c_Ip_MasterCallbackType)(i2c_ReturnType Event);
/********************************************************************************************
Structure Type Declaration Section
********************************************************************************************/
/**
@brief Write data struct info
*/
typedef struct 
{	
	uint8 channelID;						/**<  channel */
	uint16_t Address;						/**<  device address */
	boolean Is10bitAddr;					/**<  device address 7bit or 10bit*/
	uint8_t* TxBuff;						/**<  send write data buffer*/
	uint32_t TxSize;						/**<  send data length */
	uint32_t Timerout;						/**<  Timerout time */
	i2c_Ip_MasterCallbackType Callback;		/**<  Callback */
}I2c_WriteInfo_t;

/**
@brief Read data struct info
*/
typedef struct 
{	
	uint8 channelID;						/**<  channel */
	uint16_t Address;						/**<  device address */
	boolean Is10bitAddr;					/**<  device address 7bit or 10bit*/
	uint8* Reg_Addr;							/**<  register address*/
	uint32 Reg_AddrSize;					/**<  register address length*/
	uint8_t* RxBuff;						/**<  send write data buffer*/
	uint32_t RxSize;						/**<  send data length */
	uint32_t Timerout;						/**<  Timerout time */
	i2c_Ip_MasterCallbackType Callback;		/**<  Callback */
}I2c_ReadInfo_t;

/********************************************************************************************
Prototype Declaration Section
********************************************************************************************/
void Lpi2c_MasterInit(uint8 channelID,const Lpi2c_Ip_MasterConfigType * ConfigPtr);

void Lpi2c_MasterDeinit(uint8 channelID);

void Lpi2c_SlaveInit(uint8 channelID,const Lpi2c_Ip_SlaveConfigType * ConfigPtr);

void Lpi2c_SlaveDeInit(uint8 channelID);

void Lpi2c_StartListening(uint8 channelID);

void LPI2C_Synchronization_Write(I2c_WriteInfo_t* writeData);

void LPI2C_Synchronization_Read(I2c_ReadInfo_t* readData);

void LPI2C_Asynchronous_Write(I2c_WriteInfo_t* writeData);

void LPI2C_Asynchronous_Read(I2c_ReadInfo_t* readData);

void Flexio_I2c_MasterInit( uint8 Channel,const Flexio_I2c_Ip_MasterConfigType * ConfigPtr);

void Flexio_I2c_MasterDeInit( uint8 Channel);

void FlexioI2C_Synchronization_WriteData(I2c_WriteInfo_t* writeData);

void FlexioI2C_Synchronization_ReadData(I2c_ReadInfo_t* readData);

void FlexioI2C_Asynchronous_WriteData(I2c_WriteInfo_t* writeData);

void FlexioI2C_Asynchronous_ReadData(I2c_ReadInfo_t* readData);




/****************************************************************************************************
 * End of the file
****************************************************************************************************/
#endif /* SERVICE_I2C_I2C_H_ */
