esp_coexist_internal.h 5.4 KB

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