• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
15 #ifndef __ESP_COEXIST_INTERNAL_H__
16 #define __ESP_COEXIST_INTERNAL_H__
17 
18 #include <stdbool.h>
19 #include "esp_coexist_adapter.h"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 typedef enum {
26     COEX_PREFER_WIFI = 0,
27     COEX_PREFER_BT,
28     COEX_PREFER_BALANCE,
29     COEX_PREFER_NUM,
30 } coex_prefer_t;
31 
32 typedef void (* coex_func_cb_t)(uint32_t event, int sched_cnt);
33 
34 /**
35  * @brief Pre-Init software coexist
36  *        extern function for internal use.
37  *
38  * @return Init ok or failed.
39  */
40 esp_err_t coex_pre_init(void);
41 
42 /**
43  * @brief Init software coexist
44  *        extern function for internal use.
45  *
46  * @return Init ok or failed.
47  */
48 esp_err_t coex_init(void);
49 
50 /**
51  * @brief De-init software coexist
52  *        extern function for internal use.
53  */
54 void coex_deinit(void);
55 
56 /**
57  * @brief Enable software coexist
58  *        extern function for internal use.
59  *
60  * @return Enable ok or failed.
61  */
62 esp_err_t coex_enable(void);
63 
64 /**
65  * @brief Disable software coexist
66  *        extern function for internal use.
67  */
68 void coex_disable(void);
69 
70 /**
71  * @brief Get software coexist version string
72  *        extern function for internal use.
73  * @return : version string
74  */
75 const char *coex_version_get(void);
76 
77 /**
78  * @brief Coexist performance preference set from libbt.a
79  *        extern function for internal use.
80  *
81  *  @param prefer : the prefer enumeration value
82  *  @return : ESP_OK - success, other - failed
83  */
84 esp_err_t coex_preference_set(coex_prefer_t prefer);
85 
86 /**
87  * @brief Get software coexist status.
88  * @return : software coexist status
89  */
90 uint32_t coex_status_get(void);
91 
92 /**
93  * @brief Set software coexist condition.
94  * @return : software coexist condition
95  */
96 void coex_condition_set(uint32_t type, bool dissatisfy);
97 
98 /**
99  * @brief WiFi requests coexistence.
100  *
101  *  @param event : WiFi event
102  *  @param latency : WiFi will request coexistence after latency
103  *  @param duration : duration for WiFi to request coexistence
104  *  @return : 0 - success, other - failed
105  */
106 int coex_wifi_request(uint32_t event, uint32_t latency, uint32_t duration);
107 
108 /**
109  * @brief WiFi release coexistence.
110  *
111  *  @param event : WiFi event
112  *  @return : 0 - success, other - failed
113  */
114 int coex_wifi_release(uint32_t event);
115 
116 /**
117  * @brief Set WiFi channel to coexistence module.
118  *
119  *  @param primary : WiFi primary channel
120  *  @param secondary : WiFi secondary channel
121  *  @return : 0 - success, other - failed
122  */
123 int coex_wifi_channel_set(uint8_t primary, uint8_t secondary);
124 
125 /**
126  * @brief Get coexistence event duration.
127  *
128  *  @param event : Coexistence event
129  *  @param duration: Coexistence event duration
130  *  @return : 0 - success, other - failed
131  */
132 int coex_event_duration_get(uint32_t event, uint32_t *duration);
133 
134 #if SOC_COEX_HW_PTI
135 /**
136  * @brief Get coexistence event priority.
137  *
138  *  @param event : Coexistence event
139  *  @param pti: Coexistence event priority
140  *  @return : 0 - success, other - failed
141  */
142 int coex_pti_get(uint32_t event, uint8_t *pti);
143 #endif
144 
145 /**
146  * @brief Clear coexistence status.
147  *
148  *  @param type : Coexistence status type
149  *  @param status: Coexistence status
150  */
151 void coex_schm_status_bit_clear(uint32_t type, uint32_t status);
152 
153 /**
154  * @brief Set coexistence status.
155  *
156  *  @param type : Coexistence status type
157  *  @param status: Coexistence status
158  */
159 void coex_schm_status_bit_set(uint32_t type, uint32_t status);
160 
161 /**
162  * @brief Set coexistence scheme interval.
163  *
164  *  @param interval : Coexistence scheme interval
165  *  @return : 0 - success, other - failed
166  */
167 int coex_schm_interval_set(uint32_t interval);
168 
169 /**
170  * @brief Get coexistence scheme interval.
171  *
172  *  @return : Coexistence scheme interval
173  */
174 uint32_t coex_schm_interval_get(void);
175 
176 /**
177  * @brief Get current coexistence scheme period.
178  *
179  *  @return : Coexistence scheme period
180  */
181 uint8_t coex_schm_curr_period_get(void);
182 
183 /**
184  * @brief Get current coexistence scheme phase.
185  *
186  *  @return : Coexistence scheme phase
187  */
188 void * coex_schm_curr_phase_get(void);
189 
190 /**
191  * @brief Set current coexistence scheme phase index.
192  *
193  *  @param interval : Coexistence scheme phase index
194  *  @return : 0 - success, other - failed
195  */
196 int coex_schm_curr_phase_idx_set(int idx);
197 
198 /**
199  * @brief Get current coexistence scheme phase index.
200  *
201  *  @return : Coexistence scheme phase index
202  */
203 int coex_schm_curr_phase_idx_get(void);
204 
205 /**
206  * @brief Register coexistence adapter functions.
207  *
208  *  @param funcs : coexistence adapter functions
209  *  @return : ESP_OK - success, other - failed
210  */
211 esp_err_t esp_coex_adapter_register(coex_adapter_funcs_t *funcs);
212 
213 /**
214   * @brief     Check the MD5 values of the coexistence adapter header files in IDF and WiFi library
215   *
216   * @attention 1. It is used for internal CI version check
217   *
218   * @return
219   *     - ESP_OK : succeed
220   *     - ESP_WIFI_INVALID_ARG : MD5 check fail
221   */
222 esp_err_t esp_coex_adapter_funcs_md5_check(const char *md5);
223 
224 #ifdef __cplusplus
225 }
226 #endif
227 
228 #endif /* __ESP_COEXIST_INTERNAL_H__ */
229