/*
 * @file hv_drv_I2c.h
 * @brief Header file of misc module.
 *
 * @verbatim
 * ==============================================================================
 *                        ##### How to use #####
 * ==============================================================================
 * (+) Use ()
 *
 * @endverbatim
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2023-05-08
 */

#ifndef _HV_DRV_I2C_H
#define _HV_DRV_I2C_H

/** @defgroup DRV_I2C DRV_I2C
 *  drv i2c functions
 *  @{
 */

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

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


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


USHORT16 Hv_Drv_I2C_GetRxDataCount(HvCalI2c *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);

/** 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);

/** 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);

/** 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);

/** 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);

/** 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);


/** 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);

/** 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);


/** 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);


/** @} */


#endif




