/*
 * @file hv_pm51_driver_I2C.h
 * @brief Header file of I2C driver.
 *
 * @verbatim
 * ==============================================================================
 *                        ##### How to use #####
 * ==============================================================================
 * (+) Use ()
 *
 * @endverbatim
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2023-03-01
 */

#ifndef __HV_PM51_DRIVER_I2C_H__
#define __HV_PM51_DRIVER_I2C_H__

#include "hv_pm51_Base.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
*/

#define I2C_SPEED           (0x87)  /* 100K */

/**
 * @brief I2C initialization.
 * @return None.
 */
void Hv_PM51_I2C_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_PM51_I2C_E2PReadByte(UCHAR8 ucSlvID,USHORT16 usAddr,iBOOL 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_PM51_I2C_E2PWriteByte(UCHAR8 ucSlvID,USHORT16 usAddr,iBOOL bSub2AddrEn, UCHAR8 ucTransData);

#endif
