esp_coexist_internal.h 6.1 KB

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