esp_coexist_internal.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. /**
  116. * @brief Clear coexistence status.
  117. *
  118. * @param type : Coexistence status type
  119. * @param status: Coexistence status
  120. */
  121. void coex_schm_status_bit_clear(uint32_t type, uint32_t status);
  122. /**
  123. * @brief Set coexistence status.
  124. *
  125. * @param type : Coexistence status type
  126. * @param status: Coexistence status
  127. */
  128. void coex_schm_status_bit_set(uint32_t type, uint32_t status);
  129. /**
  130. * @brief Set coexistence scheme interval.
  131. *
  132. * @param interval : Coexistence scheme interval
  133. * @return : 0 - success, other - failed
  134. */
  135. int coex_schm_interval_set(uint32_t interval);
  136. /**
  137. * @brief Get coexistence scheme interval.
  138. *
  139. * @return : Coexistence scheme interval
  140. */
  141. uint32_t coex_schm_interval_get(void);
  142. /**
  143. * @brief Get current coexistence scheme period.
  144. *
  145. * @return : Coexistence scheme period
  146. */
  147. uint8_t coex_schm_curr_period_get(void);
  148. /**
  149. * @brief Get current coexistence scheme phase.
  150. *
  151. * @return : Coexistence scheme phase
  152. */
  153. void * coex_schm_curr_phase_get(void);
  154. /**
  155. * @brief Set current coexistence scheme phase index.
  156. *
  157. * @param interval : Coexistence scheme phase index
  158. * @return : 0 - success, other - failed
  159. */
  160. int coex_schm_curr_phase_idx_set(int idx);
  161. /**
  162. * @brief Get current coexistence scheme phase index.
  163. *
  164. * @return : Coexistence scheme phase index
  165. */
  166. int coex_schm_curr_phase_idx_get(void);
  167. /**
  168. * @brief Register coexistence adapter functions.
  169. *
  170. * @param funcs : coexistence adapter functions
  171. * @return : ESP_OK - success, other - failed
  172. */
  173. esp_err_t esp_coex_adapter_register(coex_adapter_funcs_t *funcs);
  174. /**
  175. * @brief Check the MD5 values of the coexistence adapter header files in IDF and WiFi library
  176. *
  177. * @attention 1. It is used for internal CI version check
  178. *
  179. * @return
  180. * - ESP_OK : succeed
  181. * - ESP_WIFI_INVALID_ARG : MD5 check fail
  182. */
  183. esp_err_t esp_coex_adapter_funcs_md5_check(const char *md5);
  184. #ifdef __cplusplus
  185. }
  186. #endif
  187. #endif /* __ESP_COEXIST_INTERNAL_H__ */