esp_coexist_internal.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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 Blue tooth requests coexistence.
  99. *
  100. * @param event : blue tooth event
  101. * @param latency : blue tooth will request coexistence after latency
  102. * @param duration : duration for blue tooth to request coexistence
  103. * @return : 0 - success, other - failed
  104. */
  105. int coex_bt_request(uint32_t event, uint32_t latency, uint32_t duration);
  106. /**
  107. * @brief Blue tooth release coexistence.
  108. *
  109. * @param event : blue tooth event
  110. * @return : 0 - success, other - failed
  111. */
  112. int coex_bt_release(uint32_t event);
  113. /**
  114. * @brief Register callback function for blue tooth.
  115. *
  116. * @param cb : callback function
  117. * @return : 0 - success, other - failed
  118. */
  119. int coex_register_bt_cb(coex_func_cb_t cb);
  120. /**
  121. * @brief Lock before reset base band.
  122. *
  123. * @return : lock value
  124. */
  125. uint32_t coex_bb_reset_lock(void);
  126. /**
  127. * @brief Unlock after reset base band.
  128. *
  129. * @param restore : lock value
  130. */
  131. void coex_bb_reset_unlock(uint32_t restore);
  132. /**
  133. * @brief Register coexistence adapter functions.
  134. *
  135. * @param funcs : coexistence adapter functions
  136. * @return : ESP_OK - success, other - failed
  137. */
  138. esp_err_t esp_coex_adapter_register(coex_adapter_funcs_t *funcs);
  139. /**
  140. * @brief Check the MD5 values of the coexistence adapter header files in IDF and WiFi library
  141. *
  142. * @attention 1. It is used for internal CI version check
  143. *
  144. * @return
  145. * - ESP_OK : succeed
  146. * - ESP_WIFI_INVALID_ARG : MD5 check fail
  147. */
  148. esp_err_t esp_coex_adapter_funcs_md5_check(const char *md5);
  149. #ifdef __cplusplus
  150. }
  151. #endif
  152. #endif /* __ESP_COEXIST_INTERNAL_H__ */