esp_coexist_internal.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. /*
  2. * SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef __ESP_COEXIST_INTERNAL_H__
  7. #define __ESP_COEXIST_INTERNAL_H__
  8. #include <stdbool.h>
  9. #include "esp_coexist.h"
  10. #include "esp_coexist_adapter.h"
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. typedef enum {
  15. COEX_PREFER_WIFI = 0,
  16. COEX_PREFER_BT,
  17. COEX_PREFER_BALANCE,
  18. COEX_PREFER_NUM,
  19. } coex_prefer_t;
  20. typedef void (* coex_func_cb_t)(uint32_t event, int sched_cnt);
  21. /**
  22. * @brief Pre-Init software coexist
  23. * extern function for internal use.
  24. *
  25. * @return Init ok or failed.
  26. */
  27. esp_err_t coex_pre_init(void);
  28. /**
  29. * @brief Init software coexist
  30. * extern function for internal use.
  31. *
  32. * @return Init ok or failed.
  33. */
  34. esp_err_t coex_init(void);
  35. /**
  36. * @brief De-init software coexist
  37. * extern function for internal use.
  38. */
  39. void coex_deinit(void);
  40. /**
  41. * @brief Enable software coexist
  42. * extern function for internal use.
  43. *
  44. * @return Enable ok or failed.
  45. */
  46. esp_err_t coex_enable(void);
  47. /**
  48. * @brief Disable software coexist
  49. * extern function for internal use.
  50. */
  51. void coex_disable(void);
  52. /**
  53. * @brief Get software coexist version string
  54. * extern function for internal use.
  55. * @return : version string
  56. */
  57. const char *coex_version_get(void);
  58. /**
  59. * @brief Coexist performance preference set from libbt.a
  60. * extern function for internal use.
  61. *
  62. * @param prefer : the prefer enumeration value
  63. * @return : ESP_OK - success, other - failed
  64. */
  65. esp_err_t coex_preference_set(coex_prefer_t prefer);
  66. /**
  67. * @brief Get software coexist status.
  68. * @return : software coexist status
  69. */
  70. uint32_t coex_status_get(void);
  71. /**
  72. * @brief Set software coexist condition.
  73. * @return : software coexist condition
  74. */
  75. void coex_condition_set(uint32_t type, bool dissatisfy);
  76. /**
  77. * @brief WiFi requests coexistence.
  78. *
  79. * @param event : WiFi event
  80. * @param latency : WiFi will request coexistence after latency
  81. * @param duration : duration for WiFi to request coexistence
  82. * @return : 0 - success, other - failed
  83. */
  84. int coex_wifi_request(uint32_t event, uint32_t latency, uint32_t duration);
  85. /**
  86. * @brief WiFi release coexistence.
  87. *
  88. * @param event : WiFi event
  89. * @return : 0 - success, other - failed
  90. */
  91. int coex_wifi_release(uint32_t event);
  92. /**
  93. * @brief Set WiFi channel to coexistence module.
  94. *
  95. * @param primary : WiFi primary channel
  96. * @param secondary : WiFi secondary channel
  97. * @return : 0 - success, other - failed
  98. */
  99. int coex_wifi_channel_set(uint8_t primary, uint8_t secondary);
  100. /**
  101. * @brief Get coexistence event duration.
  102. *
  103. * @param event : Coexistence event
  104. * @param duration: Coexistence event duration
  105. * @return : 0 - success, other - failed
  106. */
  107. int coex_event_duration_get(uint32_t event, uint32_t *duration);
  108. #if SOC_COEX_HW_PTI
  109. /**
  110. * @brief Get coexistence event priority.
  111. *
  112. * @param event : Coexistence event
  113. * @param pti: Coexistence event priority
  114. * @return : 0 - success, other - failed
  115. */
  116. int coex_pti_get(uint32_t event, uint8_t *pti);
  117. #endif
  118. /**
  119. * @brief Clear coexistence status.
  120. *
  121. * @param type : Coexistence status type
  122. * @param status: Coexistence status
  123. */
  124. void coex_schm_status_bit_clear(uint32_t type, uint32_t status);
  125. /**
  126. * @brief Set coexistence status.
  127. *
  128. * @param type : Coexistence status type
  129. * @param status: Coexistence status
  130. */
  131. void coex_schm_status_bit_set(uint32_t type, uint32_t status);
  132. /**
  133. * @brief Set coexistence scheme interval.
  134. *
  135. * @param interval : Coexistence scheme interval
  136. * @return : 0 - success, other - failed
  137. */
  138. int coex_schm_interval_set(uint32_t interval);
  139. /**
  140. * @brief Get coexistence scheme interval.
  141. *
  142. * @return : Coexistence scheme interval
  143. */
  144. uint32_t coex_schm_interval_get(void);
  145. /**
  146. * @brief Get current coexistence scheme period.
  147. *
  148. * @return : Coexistence scheme period
  149. */
  150. uint8_t coex_schm_curr_period_get(void);
  151. /**
  152. * @brief Get current coexistence scheme phase.
  153. *
  154. * @return : Coexistence scheme phase
  155. */
  156. void * coex_schm_curr_phase_get(void);
  157. /**
  158. * @brief Set current coexistence scheme phase index.
  159. *
  160. * @param interval : Coexistence scheme phase index
  161. * @return : 0 - success, other - failed
  162. */
  163. int coex_schm_curr_phase_idx_set(int idx);
  164. /**
  165. * @brief Get current coexistence scheme phase index.
  166. *
  167. * @return : Coexistence scheme phase index
  168. */
  169. int coex_schm_curr_phase_idx_get(void);
  170. /**
  171. * @brief Register coexistence adapter functions.
  172. *
  173. * @param funcs : coexistence adapter functions
  174. * @return : ESP_OK - success, other - failed
  175. */
  176. esp_err_t esp_coex_adapter_register(coex_adapter_funcs_t *funcs);
  177. #if CONFIG_EXTERNAL_COEX_ENABLE
  178. /**
  179. * @brief Set external coexistence pti level and enable it.
  180. *
  181. * @param level1 external coex low pti
  182. * @param level2 external coex mid pti
  183. * @param level3 external coex high pti
  184. *
  185. * @return
  186. * - ESP_OK: succeed
  187. */
  188. esp_err_t esp_coex_external_set(esp_coex_pti_level_t level1,
  189. esp_coex_pti_level_t level2, esp_coex_pti_level_t level3);
  190. /**
  191. * @brief Disable external coexist
  192. *
  193. * @return
  194. * - ESP_OK: succeed
  195. */
  196. void esp_coex_external_stop(void);
  197. #endif /*External Coex*/
  198. /**
  199. * @brief Check the MD5 values of the coexistence adapter header files in IDF and WiFi library
  200. *
  201. * @attention 1. It is used for internal CI version check
  202. *
  203. * @return
  204. * - ESP_OK : succeed
  205. * - ESP_WIFI_INVALID_ARG : MD5 check fail
  206. */
  207. esp_err_t esp_coex_adapter_funcs_md5_check(const char *md5);
  208. #ifdef __cplusplus
  209. }
  210. #endif
  211. #endif /* __ESP_COEXIST_INTERNAL_H__ */