esp_coexist_internal.h 4.7 KB

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