/*
 * @file hv_cal_MI2c.h
 * @brief Header file of mi2c module.
 *
 * @verbatim
 * ==============================================================================
 *                        ##### How to use #####
 * ==============================================================================
 * (+) Use ()
 *
 * @endverbatim
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2023-06-26
 */

#ifndef _HV_CAL_MI2C_H
#define _HV_CAL_MI2C_H

/* I2C Timeout */
#define I2C_TIMEOUT_MAX     (0x0100)

#define I2C_EEPROM_DEFAULT_ID (0xA0 >> 1)
/*
* I2C speed div,12bit(0xFFF) max
* i2c_scl=osc_clk/(2*reg_speed)
* when apb clk = 198MHz, 0x3DE=100K, 0xF7=400K, 0x63=1M
* I2C speed div,12bit(0xFFF) max,0x340=100K
* when osc = 27MHz, 0x87=100K
*/
#define I2C_SPEED           (0x97)

/**
 * @brief I2C initialization.
 * @return None.
 */
void Hv_Cal_MI2C_Init(void);

/*
*@brief: this function read data from specified slave address.
*@param [in] ucSlvID         slave 7bit device ID want to read from
*@param [in] usAddr           subaddress want to read from
*@param [in] bSub2AddrEn   subaddress lenth ,0 - 1 byte, 1 - 2 byte
*@return None
*/
UCHAR8 Hv_Cal_MI2C_E2PReadByte(UCHAR8 ucSlvID,USHORT16 usAddr,BOOL bSub2AddrEn);

/*
*@brief: this function read data from specified slave address.
*@param [in] ucSlvID         slave 7bit device ID want to write out
*@param [in] usAddr           subaddress want to write out
*@param [in] bSub2AddrEn   subaddress lenth ,0 - 1 byte, 1 - 2 byte
*@param [in] ucTransData     data want to write
*@@return None.
*/
void Hv_Cal_MI2C_E2PWriteByte(UCHAR8 ucSlvID,USHORT16 usAddr,BOOL bSub2AddrEn, UCHAR8 ucTransData);
void Hv_Cal_MI2C_E2PWriteBytes(UCHAR8 ucSlvID,USHORT16 usAddr,BOOL bSub2AddrEn, UCHAR8 ucSize, UCHAR8 *pucTransData);
UCHAR8 Hv_Cal_MI2C_E2PReadBytes(UCHAR8 ucSlvID, USHORT16 usAddr, BOOL bSub2AddrEn, UCHAR8 ucSize, UCHAR8 *pucRevData);
#endif




