esp_coexist_internal.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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 Pause software coexist
  49. * extern function for internal use.
  50. */
  51. void coex_pause(void);
  52. /**
  53. * @brief Resume software coexist
  54. * extern function for internal use.
  55. */
  56. void coex_resume(void);
  57. /**
  58. * @brief Get software coexist version string
  59. * extern function for internal use.
  60. * @return : version string
  61. */
  62. const char *coex_version_get(void);
  63. /**
  64. * @brief Coexist performance preference set from libbt.a
  65. * extern function for internal use.
  66. *
  67. * @param prefer : the prefer enumeration value
  68. * @return : ESP_OK - success, other - failed
  69. */
  70. esp_err_t coex_preference_set(coex_prefer_t prefer);
  71. /**
  72. * @brief Get software coexist status.
  73. * @return : software coexist status
  74. */
  75. uint32_t coex_status_get(void);
  76. /**
  77. * @brief Set software coexist condition.
  78. * @return : software coexist condition
  79. */
  80. void coex_condition_set(uint32_t type, bool dissatisfy);
  81. /**
  82. * @brief WiFi requests coexistence.
  83. *
  84. * @param event : WiFi event
  85. * @param latency : WiFi will request coexistence after latency
  86. * @param duration : duration for WiFi to request coexistence
  87. * @return : 0 - success, other - failed
  88. */
  89. int coex_wifi_request(uint32_t event, uint32_t latency, uint32_t duration);
  90. /**
  91. * @brief WiFi release coexistence.
  92. *
  93. * @param event : WiFi event
  94. * @return : 0 - success, other - failed
  95. */
  96. int coex_wifi_release(uint32_t event);
  97. /**
  98. * @brief Set WiFi channel to coexistence module.
  99. *
  100. * @param primary : WiFi primary channel
  101. * @param secondary : WiFi secondary channel
  102. * @return : 0 - success, other - failed
  103. */
  104. int coex_wifi_channel_set(uint8_t primary, uint8_t secondary);
  105. /**
  106. * @brief Clear coexistence status.
  107. *
  108. * @param type : Coexistence status type
  109. * @param status: Coexistence status
  110. */
  111. void coex_schm_status_bit_clear(uint32_t type, uint32_t status);
  112. /**
  113. * @brief Set coexistence status.
  114. *
  115. * @param type : Coexistence status type
  116. * @param status: Coexistence status
  117. */
  118. void coex_schm_status_bit_set(uint32_t type, uint32_t status);
  119. /**
  120. * @brief Set coexistence scheme interval.
  121. *
  122. * @param interval : Coexistence scheme interval
  123. * @return : 0 - success, other - failed
  124. */
  125. int coex_schm_interval_set(uint32_t interval);
  126. /**
  127. * @brief Get coexistence scheme interval.
  128. *
  129. * @return : Coexistence scheme interval
  130. */
  131. uint32_t coex_schm_interval_get(void);
  132. /**
  133. * @brief Get current coexistence scheme period.
  134. *
  135. * @return : Coexistence scheme period
  136. */
  137. uint8_t coex_schm_curr_period_get(void);
  138. /**
  139. * @brief Get current coexistence scheme phase.
  140. *
  141. * @return : Coexistence scheme phase
  142. */
  143. void * coex_schm_curr_phase_get(void);
  144. /**
  145. * @brief Set current coexistence scheme phase index.
  146. *
  147. * @param interval : Coexistence scheme phase index
  148. * @return : 0 - success, other - failed
  149. */
  150. int coex_schm_curr_phase_idx_set(int idx);
  151. /**
  152. * @brief Get current coexistence scheme phase index.
  153. *
  154. * @return : Coexistence scheme phase index
  155. */
  156. int coex_schm_curr_phase_idx_get(void);
  157. /**
  158. * @brief Register coexistence adapter functions.
  159. *
  160. * @param funcs : coexistence adapter functions
  161. * @return : ESP_OK - success, other - failed
  162. */
  163. esp_err_t esp_coex_adapter_register(coex_adapter_funcs_t *funcs);
  164. /**
  165. * @brief Check the MD5 values of the coexistence adapter header files in IDF and WiFi library
  166. *
  167. * @attention 1. It is used for internal CI version check
  168. *
  169. * @return
  170. * - ESP_OK : succeed
  171. * - ESP_WIFI_INVALID_ARG : MD5 check fail
  172. */
  173. esp_err_t esp_coex_adapter_funcs_md5_check(const char *md5);
  174. #ifdef __cplusplus
  175. }
  176. #endif
  177. #endif /* __ESP_COEXIST_INTERNAL_H__ */