Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

244 linhas
8.2 KiB

  1. /*******************************************************************************
  2. File Name:
  3. m2m_hif.h
  4. Summary:
  5. This module contains M2M host interface API definitions.
  6. Description:
  7. This module contains M2M host interface API definitions.
  8. *******************************************************************************/
  9. //DOM-IGNORE-BEGIN
  10. /*******************************************************************************
  11. * Copyright (C) 2021 Microchip Technology Inc. and its subsidiaries.
  12. *
  13. * Subject to your compliance with these terms, you may use Microchip software
  14. * and any derivatives exclusively with Microchip products. It is your
  15. * responsibility to comply with third party license terms applicable to your
  16. * use of third party software (including open source software) that may
  17. * accompany Microchip software.
  18. *
  19. * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
  20. * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
  21. * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
  22. * PARTICULAR PURPOSE.
  23. *
  24. * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
  25. * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
  26. * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
  27. * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
  28. * FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
  29. * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
  30. * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
  31. *******************************************************************************/
  32. // DOM-IGNORE-END
  33. #ifndef _M2M_HIF_
  34. #define _M2M_HIF_
  35. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
  36. INCLUDES
  37. *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
  38. #include "nm_common.h"
  39. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
  40. MACROS
  41. *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
  42. #define M2M_HIF_MAX_PACKET_SIZE (1600 - 4)
  43. /*!< Maximum size of the buffer could be transferred between Host and Firmware.
  44. */
  45. #define M2M_HIF_HDR_OFFSET (sizeof(tstrHifHdr) + 4)
  46. /**
  47. * @struct tstrHifHdr
  48. * @brief Structure to hold HIF header
  49. */
  50. typedef struct
  51. {
  52. uint8_t u8Gid; /*!< Group ID */
  53. uint8_t u8Opcode; /*!< OP code */
  54. uint16_t u16Length; /*!< Payload length */
  55. } tstrHifHdr;
  56. #ifdef __cplusplus
  57. extern "C" {
  58. #endif
  59. /*!
  60. @typedef typedef void (*tpfHifCallBack)(uint8_t u8OpCode, uint16_t u16DataSize, uint32_t u32Addr);
  61. @brief used to point to Wi-Fi call back function depend on Arduino project or other projects.
  62. @param [in] u8OpCode
  63. HIF Opcode type.
  64. @param [in] u16DataSize
  65. HIF data length.
  66. @param [in] u32Addr
  67. HIF address.
  68. @param [in] grp
  69. HIF group type.
  70. */
  71. typedef void (*tpfHifCallBack)(uint8_t u8OpCode, uint16_t u16DataSize, uint32_t u32Addr);
  72. /**
  73. * @fn int8_t hif_init(void *arg);
  74. * @brief
  75. To initialize HIF layer.
  76. * @param [in] arg
  77. * Pointer to the arguments.
  78. * @return
  79. The function shall return ZERO for successful operation and a negative value otherwise.
  80. */
  81. int8_t hif_init(void *arg);
  82. /**
  83. * @fn int8_t hif_deinit(void *arg);
  84. * @brief
  85. To Deinitialize HIF layer.
  86. * @param [in] arg
  87. * Pointer to the arguments.
  88. * @return
  89. The function shall return ZERO for successful operation and a negative value otherwise.
  90. */
  91. int8_t hif_deinit(void *arg);
  92. /**
  93. * @fn int8_t hif_check_compatibility(uint16_t u16HifInfo);
  94. * @brief
  95. * To check the compatibility of an image with the current driver.
  96. * @param [in] u16HifInfo
  97. * HIF info of image to be checked.
  98. * @return The function shall return ZERO for compatible image and a negative value otherwise.
  99. */
  100. int8_t hif_check_compatibility(uint16_t u16HifInfo);
  101. /**
  102. * @fn int8_t hif_enable_access(void);
  103. * @brief
  104. * To enable access to HIF layer, based on HIF level of Firmware.
  105. * This function reads HIF level directly from a register written by Firmware.
  106. * @return The function shall return ZERO for full match operation and a negative value if operation is restricted.
  107. */
  108. int8_t hif_enable_access(void);
  109. /**
  110. * @fn int8_t hif_check_code(uint8_t u8Gid, uint8_t u8OpCode);
  111. * @brief
  112. * To check that a particular hif message is supported with the current driver/firmware pair.
  113. * @param [in] u8Gid
  114. * Group ID.
  115. * @param [in] u8Opcode
  116. * Operation ID.
  117. * @return The function shall return ZERO for support and a negative value otherwise.
  118. */
  119. int8_t hif_check_code(uint8_t u8Gid, uint8_t u8OpCode);
  120. /**
  121. * @fn int8_t hif_send(uint8_t u8Gid, uint8_t u8Opcode, uint8_t *pu8CtrlBuf, uint16_t u16CtrlBufSize,
  122. uint8_t *pu8DataBuf, uint16_t u16DataSize, uint16_t u16DataOffset)
  123. * @brief Send packet using host interface.
  124. * @param [in] u8Gid
  125. * Group ID.
  126. * @param [in] u8Opcode
  127. * Operation ID.
  128. * @param [in] pu8CtrlBuf
  129. * Pointer to the Control buffer.
  130. * @param [in] u16CtrlBufSize
  131. Control buffer size.
  132. * @param [in] u16DataOffset
  133. Packet Data offset.
  134. * @param [in] pu8DataBuf
  135. * Packet buffer Allocated by the caller.
  136. * @param [in] u16DataSize
  137. Packet buffer size (including the HIF header).
  138. * @return The function shall return ZERO for successful operation and a negative value otherwise.
  139. */
  140. int8_t hif_send(uint8_t u8Gid, uint8_t u8Opcode, uint8_t *pu8CtrlBuf, uint16_t u16CtrlBufSize,
  141. uint8_t *pu8DataBuf, uint16_t u16DataSize, uint16_t u16DataOffset);
  142. /**
  143. * @fn hif_receive
  144. * @brief Host interface interrupt service routine
  145. * @param [in] u32Addr
  146. * Receive start address
  147. * @param [out] pu8Buf
  148. * Pointer to receive buffer. Allocated by the caller
  149. * @param [in] u16Sz
  150. * Receive buffer size
  151. * @param [in] isDone
  152. * If you don't need any more packets send True otherwise send false
  153. * @return
  154. The function shall return ZERO for successful operation and a negative value otherwise.
  155. */
  156. int8_t hif_receive(uint32_t u32Addr, uint8_t *pu8Buf, uint16_t u16Sz, uint8_t isDone);
  157. /**
  158. * @fn hif_register_cb
  159. * @brief
  160. To set Callback function for every Component.
  161. * @param [in] u8Grp
  162. * Group to which the Callback function should be set.
  163. * @param [in] fn
  164. * function to be set to the specified group.
  165. * @return
  166. The function shall return ZERO for successful operation and a negative value otherwise.
  167. */
  168. int8_t hif_register_cb(uint8_t u8Grp, tpfHifCallBack fn);
  169. /**
  170. * @fn int8_t hif_chip_sleep(void);
  171. * @brief
  172. To make the chip sleep.
  173. * @return
  174. The function shall return ZERO for successful operation and a negative value otherwise.
  175. */
  176. int8_t hif_chip_sleep(void);
  177. /**
  178. * @fn int8_t hif_chip_wake(void);
  179. * @brief
  180. To Wakeup the chip.
  181. * @return
  182. The function shall return ZERO for successful operation and a negative value otherwise.
  183. */
  184. int8_t hif_chip_wake(void);
  185. /*!
  186. @fn \
  187. void hif_set_sleep_mode(uint8_t u8Pstype);
  188. @brief
  189. Set the sleep mode of the HIF layer.
  190. @param [in] u8Pstype
  191. Sleep mode.
  192. @return
  193. The function SHALL return 0 for success and a negative value otherwise.
  194. */
  195. void hif_set_sleep_mode(uint8_t u8Pstype);
  196. /*!
  197. @fn \
  198. uint8_t hif_get_sleep_mode(void);
  199. @brief
  200. Get the sleep mode of the HIF layer.
  201. @return
  202. The function SHALL return the sleep mode of the HIF layer.
  203. */
  204. uint8_t hif_get_sleep_mode(void);
  205. /**
  206. * @fn hif_handle_isr(void)
  207. * @brief
  208. Handle interrupt received from WINC3400 firmware.
  209. * @return
  210. The function SHALL return 0 for success and a negative value otherwise.
  211. */
  212. int8_t hif_handle_isr(void);
  213. #ifdef __cplusplus
  214. }
  215. #endif
  216. #endif