/**
 * @file hv_drv_I2c.c
 * @brief i2c driver  layer file.
 * @details This file provides the following functions: \n
 *          (1) i2c master tx/rx \n
 *          (2) i2c savle tx/rx \n
 *          (3) i2c init \n
 *
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2023-05-08
 * @copyright Copyright(c),2023-5, Hiview Software. All rights reserved.
 * @par History:
 * <table>
 * <tr><th>Author       <th>Date            <th>Change Description
 * <tr><td>HiView SoC Software Team     <td>2023-05-08      <td>init
 * </table>
 */
#include "Common/hv_comm_DataType.h"
#include "hv_comm_Define.h"
#include "hv_cal_I2c.h"
#include "hv_drv_I2c.h"
#include "hv_chip_Config.h"
#include "hv_vos_Comm.h"

/** Initialize i2c
 *  @param pstInitParam pointer to i2c configuration parameters
 *  @return i2c handler
 */
HvCalI2c*  Hv_Drv_I2C_Init(I2cInitParam *pstInitParam)
{
    return Hv_Cal_I2C_Init(pstInitParam);
}

/** Set i2c transfer speed
 *  @param pstSelf i2c handler
 *  @param enI2cSpeed i2c transfer speed
 */
void Hv_Drv_I2c_Setpeed(HvCalI2c *pstSelf, I2cSpeed enI2cSpeed)
{
    return Hv_Cal_I2C_Setpeed(pstSelf, enI2cSpeed);
}

/** De-initialize i2c
 *  @param pstSelf i2c handler
 *  @return result
 */
Status Hv_Drv_I2C_Cleanup(HvCalI2c *pstSelf)
{
    return Hv_Cal_I2C_Cleanup(pstSelf);
}

USHORT16 Hv_Drv_I2C_GetRxDataCount(HvCalI2c *pstSelf)
{
    return Hv_Cal_I2C_GetRxDataCount(pstSelf);
}

/** Transmits in master mode an amount of data in blocking mode.
 *  @param pstSelf i2c handler
 *  @param pstParam target device address
 *  pointer to command data buffer
 *  command length
 *  pointer to data buffer to be transmited
 *  amount of data to be sent
 *  @param uiTimeout uiTimeout duration
  * @retval Status
 */
Status Hv_Drv_I2C_MasterPollingTransmit(HvCalI2c *pstSelf, I2cFuncParam *pstParam, UINT32 uiTimeout)
{
    return Hv_Cal_I2C_MasterPollingTransmit(pstSelf, pstParam, uiTimeout);
}

/** Transmit in master mode an amount of data in non-blocking mode with interrupt
 *  @param pstSelf i2c handler
 *  @param pstParam target device address
 *  pointer to command data buffer
 *  command length
 *  pointer to data buffer to be transmited
 *  amount of data to be sent
  * @retval Status
 */
Status Hv_Drv_I2C_MasterIntTransmit(HvCalI2c  *pstSelf, I2cFuncParam *pstParam)
{
    return Hv_Cal_I2C_MasterIntTransmit(pstSelf, pstParam);
}

/** Receives in master mode an amount of data in blocking mode.
 *  @param pstSelf i2c handler
 *  @param pstParam target device address
 *  pointer to command data buffer
 *  command length
 *  pointer to data buffer to be receive
 *  amount of data to be receive
 *  @param uiTimeout uiTimeout duration
 *  @retval Status
*/
Status Hv_Drv_I2C_MasterPollingReceive(HvCalI2c *pstSelf, I2cFuncParam *pstParam, UINT32 uiTimeout)
{
    return Hv_Cal_I2C_MasterPollingReceive(pstSelf, pstParam, uiTimeout);
}

/** Receive in master mode an amount of data in non-blocking mode with interrupt
 *  @param pstSelf i2c handler
 *  @param pstParam target device address
 *  pointer to command data buffer
 *  command length
 *  pointer to data buffer to be receive
 *  amount of data to be receive
 *  @retval Status
*/
Status Hv_Drv_I2C_MasterIntReceive(HvCalI2c *pstSelf, I2cFuncParam *pstParam)
{
    return Hv_Cal_I2C_MasterIntReceive(pstSelf, pstParam);
}

/** Transmits in slave mode an amount of data in blocking mode.
 *  @param pstSelf i2c handler
 *  @param pucData pointer to data buffer
 *  @param usSize amount of data to be sent
 *  @param uiTimeout uiTimeout duration
 *  @retval Status
 */
Status Hv_Drv_I2C_SlavePollingTransmit(HvCalI2c *pstSelf, UCHAR8 *pucData, USHORT16 usSize, UINT32 uiTimeout)
{
    return Hv_Cal_I2C_SlavePollingTransmit(pstSelf, pucData, usSize, uiTimeout);
}

/** Transmit in slave mode an amount of data in non-blocking mode with interrupt
 *  @param pstSelf i2c handler
 *  @param pucData pointer to data buffer
 *  @param usSize amount of data to be sent
 *  @retval Status
 */
Status Hv_Drv_I2C_SlaveIntTransmit(HvCalI2c *pstSelf, UCHAR8 *pucData, USHORT16 usSize)
{
    return Hv_Cal_I2C_SlaveIntTransmit(pstSelf, pucData, usSize);
}

/** Receive in slave mode an amount of data in blocking mode
 *  @param pstSelf i2c handler
 *  @param pucData pointer to data buffer
 *  @param usSize amount of data to be sent
 *  @param uiTimeout uiTimeout duration
 *  @retval Status
 */
Status Hv_Drv_I2C_SlavePollingReceive(HvCalI2c *pstSelf, UCHAR8 *pucData, USHORT16 usSize, UINT32 uiTimeout)
{
    return Hv_Cal_I2C_SlavePollingReceive(pstSelf, pucData, usSize, uiTimeout);
}

/** Receive in slave mode an amount of data in non-blocking mode with interrupt
 *  @param pstSelf i2c handler
 *  @param pucData pointer to data buffer
 *  @param usSize amount of data to be sent
 *  @retval Status
 */
Status Hv_Drv_I2C_SlaveIntReceive(HvCalI2c *pstSelf, UCHAR8 *pucData)
{
    return Hv_Cal_I2C_SlaveIntReceive(pstSelf, pucData);
}


/** Receive in slave mode an amount of data in non-blocking mode with interrupt
 *  @param pstSelf i2c handler
 *  @retval is or not
 */
BOOL Hv_Drv_I2C_TransferIsComplete(HvCalI2c *pstSelf)
{
    return Hv_Cal_I2C_TransferIsComplete(pstSelf);
}