ax_channel_api.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. #ifndef _AX_CHANNEL_API_H_
  2. #define _AX_CHANNEL_API_H_
  3. #include "ax_base_type.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /* channel log level */
  8. typedef enum {
  9. AX_CHANNEL_LOG_LEVEL_NONE = 0,
  10. AX_CHANNEL_LOG_LEVEL_ERROR = 1,
  11. AX_CHANNEL_LOG_LEVEL_WARN = 2,
  12. AX_CHANNEL_LOG_LEVEL_INFO = 3,
  13. AX_CHANNEL_LOG_LEVEL_DEBUG = 4,
  14. AX_CHANNEL_LOG_LEVEL_VERBOSE = 5,
  15. AX_CHANNEL_LOG_LEVEL_DATA = 6,
  16. AX_CHANNEL_LOG_LEVEL_BUTT
  17. } AX_CHANNEL_LOG_LEVEL_E;
  18. /* startup info */
  19. #define AX_CH_MAX_PATH (256)
  20. typedef struct _ChannelStartupInfo {
  21. AX_CHAR szDevPath[AX_CH_MAX_PATH]; /* device path, e.g. /dev/xxxx */
  22. AX_U32 nDbgLv; /* see "AX_CHANNEL_LOG_LEVEL_E" */
  23. } AX_CHANNEL_STARTUP_INFO;
  24. /*
  25. [notify data callback for master]
  26. - nNotifyType: User defined enumeration type.
  27. - pData: Notify data buffer.
  28. - nSize: Notify data buffer size.
  29. - pContext: User context data.
  30. */
  31. typedef AX_VOID (*AX_ChannelNotifyCB)(AX_U32 nNotifyType, AX_U8* pData, AX_U32 nSize, AX_VOID* pContext);
  32. /*
  33. [incoming message data callback for slave]
  34. - nCmd: User defined command id, [1, 255].
  35. - nSubCmd: User defined subcommand id, [0, 255].
  36. - pData: Payload buffer from master, correspond to param "pSendData" in "AX_Channel_Master_SendAndRecv"
  37. - nSize: Payload buffer size, correspond to param "nSendSize" in "AX_Channel_Master_SendAndRecv"
  38. - pContext: User context data.
  39. */
  40. typedef AX_VOID (*AX_ChannelMessageCB)(AX_U8 nCmd, AX_U8 nSubCmd, AX_U8* pData, AX_U32 nSize, AX_VOID* pContext);
  41. //////////////////////////////////////////////////////////////////////////////////////
  42. /// AX_Channel_Master_Init
  43. ///
  44. /// @brief Initialize (sdio) master.
  45. ///
  46. /// @param pInfo Specifies the pointer of AX_CHANNEL_STARTUP_INFO structure.
  47. /// @param pCallback Pointer to a callback function to do with slave notify data report.
  48. /// @param pContext Pointer to a user context data.
  49. ///
  50. /// @return 0 if success, otherwise failure
  51. //////////////////////////////////////////////////////////////////////////////////////
  52. AX_S32 AX_Channel_Master_Init(const AX_CHANNEL_STARTUP_INFO *pInfo, AX_ChannelNotifyCB pCallback, AX_VOID* pContext);
  53. //////////////////////////////////////////////////////////////////////////////////////
  54. /// AX_Channel_Master_DeInit
  55. ///
  56. /// @brief Deinitialize (sdio) master.
  57. ///
  58. /// @return 0 if success, otherwise failure
  59. //////////////////////////////////////////////////////////////////////////////////////
  60. AX_S32 AX_Channel_Master_DeInit();
  61. //////////////////////////////////////////////////////////////////////////////////////
  62. /// AX_Channel_Master_SendAndRecv
  63. ///
  64. /// @brief Master send data to slave and receive response data, response data is optional.
  65. ///
  66. /// @param nCmd User defined command id, [1, 255]. 0 is for internal usage.
  67. /// @param nSubCmd User defined subcommand id, [0, 255].
  68. /// @param pSendData Send data buffer.
  69. /// @param nSendSize Send data buffer size.
  70. /// @param pRecvData Receive data buffer.
  71. /// @param nRecvSize Receive data buffer size.
  72. /// @param pReceived Actually received data size.
  73. /// @param nTimeOut communication timeout(reserved).
  74. ///
  75. /// @return 0 if success, otherwise failure
  76. //////////////////////////////////////////////////////////////////////////////////////
  77. AX_S32 AX_Channel_Master_SendAndRecv(AX_U8 nCmd, AX_U8 nSubCmd, AX_U8* pSendData, AX_U32 nSendSize, AX_U8* pRecvData, AX_U32 nRecvSize, AX_U32* pReceived, AX_S32 nTimeOut/*ms*/);
  78. //////////////////////////////////////////////////////////////////////////////////////
  79. /// AX_Channel_Slave_Init
  80. ///
  81. /// @brief Initialize (sdio) slave.
  82. ///
  83. /// @param pInfo Specifies the pointer of AX_CHANNEL_STARTUP_INFO structure.
  84. /// @param pCallback Pointer to a callback function to do with incoming message from master.
  85. /// @param pContext Pointer to a user context data.
  86. ///
  87. /// @return 0 if success, otherwise failure
  88. //////////////////////////////////////////////////////////////////////////////////////
  89. AX_S32 AX_Channel_Slave_Init(const AX_CHANNEL_STARTUP_INFO *pInfo, AX_ChannelMessageCB pCallback, AX_VOID* pContext);
  90. //////////////////////////////////////////////////////////////////////////////////////
  91. /// AX_Channel_Slave_DeInit
  92. ///
  93. /// @brief Deinitialize (sdio) slave.
  94. ///
  95. /// @return 0 if success, otherwise failure
  96. //////////////////////////////////////////////////////////////////////////////////////
  97. AX_S32 AX_Channel_Slave_DeInit();
  98. //////////////////////////////////////////////////////////////////////////////////////
  99. /// AX_Channel_Slave_WriteData
  100. ///
  101. /// @brief Slave write response data to master, response data is optional.
  102. /// This only can be invoked during "AX_ChannelMessageCB".
  103. ///
  104. /// @param nCmd User defined command id, [1, 255]. 0 is for internal usage.
  105. /// @param nSubCmd User defined subcommand id, [0, 255].
  106. /// @param pWriteData Response data buffer.
  107. /// @param nWriteSize Response data buffer size.
  108. ///
  109. /// @return 0 if success, otherwise failure
  110. //////////////////////////////////////////////////////////////////////////////////////
  111. AX_S32 AX_Channel_Slave_WriteData(AX_U8 nCmd, AX_U8 nSubCmd, AX_U8* pWriteData, AX_U32 nWriteSize);
  112. //////////////////////////////////////////////////////////////////////////////////////
  113. /// AX_Channel_Slave_Notify
  114. ///
  115. /// @brief Slave notify report data to master.
  116. ///
  117. /// @param nNotifyType User defined enumeration type.
  118. /// @param pNotifyData Notify data buffer.
  119. /// @param nNotifySize Notify data buffer size.
  120. ///
  121. /// @return 0 if success, otherwise failure
  122. //////////////////////////////////////////////////////////////////////////////////////
  123. AX_S32 AX_Channel_Slave_Notify(AX_U32 nNotifyType, AX_U8* pNotifyData, AX_U32 nNotifySize);
  124. #ifdef __cplusplus
  125. }
  126. #endif
  127. #endif /* _AX_CHANNEL_API_H_ */