hv_drv_I2c.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * @file hv_drv_I2c.h
  3. * @brief Header file of misc module.
  4. *
  5. * @verbatim
  6. * ==============================================================================
  7. * ##### How to use #####
  8. * ==============================================================================
  9. * (+) Use ()
  10. *
  11. * @endverbatim
  12. * @author HiView SoC Software Team
  13. * @version 1.0.0
  14. * @date 2023-05-08
  15. */
  16. #ifndef _HV_DRV_I2C_H
  17. #define _HV_DRV_I2C_H
  18. /** @defgroup DRV_I2C DRV_I2C
  19. * drv i2c functions
  20. * @{
  21. */
  22. /** Initialize i2c
  23. * @param pstInitParam pointer to i2c configuration parameters
  24. * @return i2c handler
  25. */
  26. HvCalI2c* Hv_Drv_I2C_Init(I2cInitParam *pstInitParam);
  27. /** Set i2c transfer speed
  28. * @param pstSelf i2c handler
  29. * @param enI2cSpeed i2c transfer speed
  30. */
  31. void Hv_Drv_I2c_Setpeed(HvCalI2c *pstSelf, I2cSpeed enI2cSpeed );
  32. /** De-initialize i2c
  33. * @param pstSelf i2c handler
  34. * @return result
  35. */
  36. Status Hv_Drv_I2C_Cleanup(HvCalI2c *pstSelf);
  37. USHORT16 Hv_Drv_I2C_GetRxDataCount(HvCalI2c *pstSelf);
  38. /** Transmits in master mode an amount of data in blocking mode.
  39. * @param pstSelf i2c handler
  40. * @param pstParam target device address
  41. * pointer to command data buffer
  42. * command length
  43. * pointer to data buffer to be transmited
  44. * amount of data to be sent
  45. * @param uiTimeout uiTimeout duration
  46. * @retval Status
  47. */
  48. Status Hv_Drv_I2C_MasterPollingTransmit(HvCalI2c *pstSelf, I2cFuncParam *pstParam, UINT32 uiTimeout);
  49. /** Transmit in master mode an amount of data in non-blocking mode with interrupt
  50. * @param pstSelf i2c handler
  51. * @param pstParam target device address
  52. * pointer to command data buffer
  53. * command length
  54. * pointer to data buffer to be transmited
  55. * amount of data to be sent
  56. * @retval Status
  57. */
  58. Status Hv_Drv_I2C_MasterIntTransmit(HvCalI2c *pstSelf, I2cFuncParam *pstParam);
  59. /** Receives in master mode an amount of data in blocking mode.
  60. * @param pstSelf i2c handler
  61. * @param pstParam target device address
  62. * pointer to command data buffer
  63. * command length
  64. * pointer to data buffer to be receive
  65. * amount of data to be receive
  66. * @param uiTimeout uiTimeout duration
  67. * @retval Status
  68. */
  69. Status Hv_Drv_I2C_MasterPollingReceive(HvCalI2c *pstSelf, I2cFuncParam *pstParam, UINT32 uiTimeout);
  70. /** Receive in master mode an amount of data in non-blocking mode with interrupt
  71. * @param pstSelf i2c handler
  72. * @param pstParam target device address
  73. * pointer to command data buffer
  74. * command length
  75. * pointer to data buffer to be receive
  76. * amount of data to be receive
  77. * @retval Status
  78. */
  79. Status Hv_Drv_I2C_MasterIntReceive(HvCalI2c *pstSelf, I2cFuncParam *pstParam);
  80. /** Transmits in slave mode an amount of data in blocking mode.
  81. * @param pstSelf i2c handler
  82. * @param pucData pointer to data buffer
  83. * @param usSize amount of data to be sent
  84. * @param uiTimeout uiTimeout duration
  85. * @retval Status
  86. */
  87. Status Hv_Drv_I2C_SlavePollingTransmit(HvCalI2c *pstSelf, UCHAR8 *pucData, USHORT16 usSize, UINT32 uiTimeout);
  88. /** Transmit in slave mode an amount of data in non-blocking mode with interrupt
  89. * @param pstSelf i2c handler
  90. * @param pucData pointer to data buffer
  91. * @param usSize amount of data to be sent
  92. * @retval Status
  93. */
  94. Status Hv_Drv_I2C_SlaveIntTransmit(HvCalI2c *pstSelf, UCHAR8 *pucData, USHORT16 usSize);
  95. /** Receive in slave mode an amount of data in blocking mode
  96. * @param pstSelf i2c handler
  97. * @param pucData pointer to data buffer
  98. * @param usSize amount of data to be sent
  99. * @param uiTimeout uiTimeout duration
  100. * @retval Status
  101. */
  102. Status Hv_Drv_I2C_SlavePollingReceive(HvCalI2c *pstSelf, UCHAR8 *pucData, USHORT16 usSize, UINT32 uiTimeout);
  103. /** Receive in slave mode an amount of data in non-blocking mode with interrupt
  104. * @param pstSelf i2c handler
  105. * @param pucData pointer to data buffer
  106. * @param usSize amount of data to be sent
  107. * @retval Status
  108. */
  109. Status Hv_Drv_I2C_SlaveIntReceive(HvCalI2c *pstSelf, UCHAR8 *pucData);
  110. /** Receive in slave mode an amount of data in non-blocking mode with interrupt
  111. * @param pstSelf i2c handler
  112. * @retval is or not
  113. */
  114. BOOL Hv_Drv_I2C_TransferIsComplete(HvCalI2c *pstSelf);
  115. /** @} */
  116. #endif