esp_coexist.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef __ESP_COEXIST_H__
  7. #define __ESP_COEXIST_H__
  8. #include <stdbool.h>
  9. #include "esp_err.h"
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. /**
  14. * @brief coex prefer value
  15. */
  16. typedef enum {
  17. ESP_COEX_PREFER_WIFI = 0, /*!< Prefer to WiFi, WiFi will have more opportunity to use RF */
  18. ESP_COEX_PREFER_BT, /*!< Prefer to bluetooth, bluetooth will have more opportunity to use RF */
  19. ESP_COEX_PREFER_BALANCE, /*!< Do balance of WiFi and bluetooth */
  20. ESP_COEX_PREFER_NUM, /*!< Prefer value numbers */
  21. } esp_coex_prefer_t;
  22. typedef enum {
  23. EXTERN_COEX_WIRE_1 = 0,
  24. EXTERN_COEX_WIRE_2,
  25. EXTERN_COEX_WIRE_3,
  26. EXTERN_COEX_WIRE_NUM,
  27. } external_coex_wire_t;
  28. /**
  29. * @brief coex status type
  30. */
  31. typedef enum {
  32. ESP_COEX_ST_TYPE_WIFI = 0,
  33. ESP_COEX_ST_TYPE_BLE,
  34. ESP_COEX_ST_TYPE_BT,
  35. } esp_coex_status_type_t;
  36. /**
  37. * @brief external coex gpio pti
  38. */
  39. typedef struct {
  40. int32_t in_pin0;
  41. int32_t in_pin1;
  42. int32_t out_pin0;
  43. } esp_external_coex_gpio_set_t;
  44. /**
  45. * @brief external coex pti level
  46. */
  47. typedef enum {
  48. EXTERN_COEX_PTI_MID = 0,
  49. EXTERN_COEX_PTI_HIGH,
  50. EXTERN_COEX_PTI_NUM,
  51. } esp_coex_pti_level_t;
  52. /**
  53. * @brief external coex pti
  54. */
  55. typedef struct {
  56. uint32_t in_pti1;
  57. uint32_t in_pti2;
  58. uint32_t in_pti3;
  59. uint32_t out_pti1;
  60. uint32_t out_pti2;
  61. uint32_t out_pti3;
  62. } esp_external_coex_pti_set_t;
  63. #define ESP_COEX_BLE_ST_MESH_CONFIG 0x08
  64. #define ESP_COEX_BLE_ST_MESH_TRAFFIC 0x10
  65. #define ESP_COEX_BLE_ST_MESH_STANDBY 0x20
  66. #define ESP_COEX_BT_ST_A2DP_STREAMING 0x10
  67. #define ESP_COEX_BT_ST_A2DP_PAUSED 0x20
  68. /**
  69. * @brief Get software coexist version string
  70. *
  71. * @return : version string
  72. */
  73. const char *esp_coex_version_get(void);
  74. /**
  75. * @deprecated Use esp_coex_status_bit_set() and esp_coex_status_bit_clear() instead.
  76. * Set coexist preference of performance
  77. * For example, if prefer to bluetooth, then it will make A2DP(play audio via classic bt)
  78. * more smooth while wifi is runnning something.
  79. * If prefer to wifi, it will do similar things as prefer to bluetooth.
  80. * Default, it prefer to balance.
  81. *
  82. * @param prefer : the prefer enumeration value
  83. * @return : ESP_OK - success, other - failed
  84. */
  85. esp_err_t esp_coex_preference_set(esp_coex_prefer_t prefer);
  86. /**
  87. * @brief Set coex schm status
  88. * @param type : WIFI/BLE/BT
  89. * @param status : WIFI/BLE/BT STATUS
  90. * @return : ESP_OK - success, other - failed
  91. */
  92. esp_err_t esp_coex_status_bit_set(esp_coex_status_type_t type, uint32_t status);
  93. /**
  94. * @brief Clear coex schm status
  95. * @param type : WIFI/BLE/BT
  96. * @param status : WIFI/BLE/BT STATUS
  97. * @return : ESP_OK - success, other - failed
  98. */
  99. esp_err_t esp_coex_status_bit_clear(esp_coex_status_type_t type, uint32_t status);
  100. #if CONFIG_EXTERNAL_COEX_ENABLE
  101. /**
  102. * @brief Setup gpio pin and corresponding pti level, start external coex.
  103. * @param wire_type : to select the whole external coex gpio number.
  104. * @param gpio_pin : gpio pin number to choose.
  105. * @return : ESP_OK - success, other - failed
  106. */
  107. esp_err_t esp_enable_extern_coex_gpio_pin(external_coex_wire_t wire_type,
  108. esp_external_coex_gpio_set_t gpio_pin);
  109. esp_err_t esp_disable_extern_coex_gpio_pin();
  110. #endif
  111. #ifdef __cplusplus
  112. }
  113. #endif
  114. #endif /* __ESP_COEXIST_H__ */