1 
2 #include <stdint.h>
3 #include <stdbool.h>
4 #include <stddef.h>
5 #include "private/esp_coexist_internal.h"
6 
7 /**
8  * @brief Pre-Init software coexist
9  *
10  * @return ESP_OK on success.
11  */
coex_pre_init(void)12 esp_err_t coex_pre_init(void)
13 {
14     return ESP_OK;
15 }
16 
17 /**
18  * @brief Init software coexist
19  *
20  * @return ESP_OK on success.
21  */
coex_init(void)22 esp_err_t coex_init(void)
23 {
24     return ESP_OK;
25 }
26 
27 /**
28  * @brief De-init software coexist
29  */
coex_deinit(void)30 void coex_deinit(void)
31 {
32 }
33 
34 /**
35  * @brief Enable software coexist
36  *
37  * @return ESP_OK on success.
38  */
coex_enable(void)39 esp_err_t coex_enable(void)
40 {
41     return ESP_OK;
42 }
43 
44 /**
45  * @brief Disable software coexist
46  */
coex_disable(void)47 void coex_disable(void)
48 {
49 }
50 
51 /**
52  * @brief Get software coexist version string
53  *
54  * @return Pointer to version string.
55  */
coex_version_get(void)56 const char *coex_version_get(void)
57 {
58     return "stub";
59 }
60 
61 /**
62  * @brief Get software coexist version value.
63  *
64  * @param ptr_version Pointer to version structure.
65  * @return ESP_OK on success.
66  */
coex_version_get_value(coex_version_t * ptr_version)67 esp_err_t coex_version_get_value(coex_version_t* ptr_version)
68 {
69     (void)ptr_version;
70     return ESP_OK;
71 }
72 
73 /**
74  * @brief Set coexist performance preference.
75  *
76  * @param prefer Preference value.
77  * @return ESP_OK on success.
78  */
coex_preference_set(coex_prefer_t prefer)79 esp_err_t coex_preference_set(coex_prefer_t prefer)
80 {
81     (void)prefer;
82     return ESP_OK;
83 }
84 
85 /**
86  * @brief Get software coexist status.
87  *
88  * @param bitmap Bitmap of the module getting status.
89  * @return Status (stub returns 0).
90  */
coex_status_get(uint8_t bitmap)91 uint32_t coex_status_get(uint8_t bitmap)
92 {
93     (void)bitmap;
94     return 0;
95 }
96 
97 /**
98  * @brief WiFi requests coexistence.
99  *
100  * @param event WiFi event.
101  * @param latency Latency.
102  * @param duration Duration.
103  * @return 0 on success.
104  */
coex_wifi_request(uint32_t event,uint32_t latency,uint32_t duration)105 int coex_wifi_request(uint32_t event, uint32_t latency, uint32_t duration)
106 {
107     (void)event;
108     (void)latency;
109     (void)duration;
110     return 0;
111 }
112 
113 /**
114  * @brief WiFi release coexistence.
115  *
116  * @param event WiFi event.
117  * @return 0 on success.
118  */
coex_wifi_release(uint32_t event)119 int coex_wifi_release(uint32_t event)
120 {
121     (void)event;
122     return 0;
123 }
124 
125 /**
126  * @brief Set WiFi channel to coexistence module.
127  *
128  * @param primary WiFi primary channel.
129  * @param secondary WiFi secondary channel.
130  * @return 0 on success.
131  */
coex_wifi_channel_set(uint8_t primary,uint8_t secondary)132 int coex_wifi_channel_set(uint8_t primary, uint8_t secondary)
133 {
134     (void)primary;
135     (void)secondary;
136     return 0;
137 }
138 
139 /**
140  * @brief Get WiFi channel from coexistence module.
141  *
142  * @param primary Pointer to WiFi primary channel.
143  * @param secondary Pointer to WiFi secondary channel.
144  * @return 0 on success.
145  */
coex_wifi_channel_get(uint8_t * primary,uint8_t * secondary)146 int coex_wifi_channel_get(uint8_t *primary, uint8_t *secondary)
147 {
148     if (primary) {
149         *primary = 0;
150     }
151     if (secondary) {
152         *secondary = 0;
153     }
154     return 0;
155 }
156 
157 /**
158  * @brief Register application callback function to update low power clock.
159  *
160  * @param callback Callback function.
161  */
coex_wifi_register_update_lpclk_callback(coex_set_lpclk_source_callback_t callback)162 void coex_wifi_register_update_lpclk_callback(coex_set_lpclk_source_callback_t callback)
163 {
164     (void)callback;
165 }
166 
167 /**
168  * @brief Bluetooth requests coexistence.
169  *
170  * @param event Bluetooth event.
171  * @param latency Latency.
172  * @param duration Duration.
173  * @return 0 on success.
174  */
coex_bt_request(uint32_t event,uint32_t latency,uint32_t duration)175 int coex_bt_request(uint32_t event, uint32_t latency, uint32_t duration)
176 {
177     (void)event;
178     (void)latency;
179     (void)duration;
180     return 0;
181 }
182 
183 /**
184  * @brief Bluetooth release coexistence.
185  *
186  * @param event Bluetooth event.
187  * @return 0 on success.
188  */
coex_bt_release(uint32_t event)189 int coex_bt_release(uint32_t event)
190 {
191     (void)event;
192     return 0;
193 }
194 
195 #if defined(CONFIG_IDF_TARGET_ESP32)
196 /**
197  * @brief Bluetooth registers callback function.
198  *
199  * @param callback Callback function.
200  * @return 0 on success.
201  */
coex_register_bt_cb(coex_func_cb_t callback)202 int coex_register_bt_cb(coex_func_cb_t callback)
203 {
204     (void)callback;
205     return 0;
206 }
207 
208 /**
209  * @brief Acquire the spin-lock used in resetting Bluetooth baseband.
210  *
211  * @return Lock value (stub returns 0).
212  */
coex_bb_reset_lock(void)213 uint32_t coex_bb_reset_lock(void)
214 {
215     return 0;
216 }
217 
218 /**
219  * @brief Release the spin-lock used in resetting Bluetooth baseband.
220  *
221  * @param restore Value returned from coex_bb_reset_lock.
222  */
coex_bb_reset_unlock(uint32_t restore)223 void coex_bb_reset_unlock(uint32_t restore)
224 {
225     (void)restore;
226 }
227 #endif /* CONFIG_IDF_TARGET_ESP32 */
228 
229 /**
230  * @brief Bluetooth registers callback for Wi-Fi channel change notification.
231  *
232  * @param callback Callback function.
233  * @return 0 on success.
234  */
coex_register_wifi_channel_change_callback(coex_wifi_channel_change_cb_t callback)235 int coex_register_wifi_channel_change_callback(coex_wifi_channel_change_cb_t callback)
236 {
237     (void)callback;
238     return 0;
239 }
240 
241 /**
242  * @brief Update low power clock interval.
243  */
coex_update_lpclk_interval(void)244 void coex_update_lpclk_interval(void)
245 {
246 }
247 
248 /**
249  * @brief Get coexistence event duration.
250  *
251  * @param event Coexistence event.
252  * @param duration Pointer to store duration.
253  * @return 0 on success.
254  */
coex_event_duration_get(uint32_t event,uint32_t * duration)255 int coex_event_duration_get(uint32_t event, uint32_t *duration)
256 {
257     (void)event;
258     if (duration) {
259         *duration = 0;
260     }
261     return 0;
262 }
263 
264 #if defined(SOC_COEX_HW_PTI)
265 /**
266  * @brief Get coexistence event priority.
267  *
268  * @param event Coexistence event.
269  * @param pti Pointer to store priority.
270  * @return 0 on success.
271  */
coex_pti_get(uint32_t event,uint8_t * pti)272 int coex_pti_get(uint32_t event, uint8_t *pti)
273 {
274     (void)event;
275     if (pti) {
276         *pti = 0;
277     }
278     return 0;
279 }
280 #endif
281 
282 /**
283  * @brief Clear coexistence status.
284  *
285  * @param type Coexistence status type.
286  * @param status Coexistence status.
287  */
coex_schm_status_bit_clear(uint32_t type,uint32_t status)288 void coex_schm_status_bit_clear(uint32_t type, uint32_t status)
289 {
290     (void)type;
291     (void)status;
292 }
293 
294 /**
295  * @brief Set coexistence status.
296  *
297  * @param type Coexistence status type.
298  * @param status Coexistence status.
299  */
coex_schm_status_bit_set(uint32_t type,uint32_t status)300 void coex_schm_status_bit_set(uint32_t type, uint32_t status)
301 {
302     (void)type;
303     (void)status;
304 }
305 
306 /**
307  * @brief Set coexistence scheme interval.
308  *
309  * @param interval Coexistence scheme interval.
310  * @return 0 on success.
311  */
coex_schm_interval_set(uint32_t interval)312 int coex_schm_interval_set(uint32_t interval)
313 {
314     (void)interval;
315     return 0;
316 }
317 
318 /**
319  * @brief Get coexistence scheme interval.
320  *
321  * @return Coexistence scheme interval (stub returns 0).
322  */
coex_schm_interval_get(void)323 uint32_t coex_schm_interval_get(void)
324 {
325     return 0;
326 }
327 
328 /**
329  * @brief Get current coexistence scheme period.
330  *
331  * @return Coexistence scheme period (stub returns 0).
332  */
coex_schm_curr_period_get(void)333 uint8_t coex_schm_curr_period_get(void)
334 {
335     return 0;
336 }
337 
338 /**
339  * @brief Get current coexistence scheme phase.
340  *
341  * @return Pointer to current phase (stub returns NULL).
342  */
coex_schm_curr_phase_get(void)343 void * coex_schm_curr_phase_get(void)
344 {
345     return NULL;
346 }
347 
348 /**
349  * @brief Set current coexistence scheme phase index.
350  *
351  * @param idx Coexistence scheme phase index.
352  * @return 0 on success.
353  */
coex_schm_curr_phase_idx_set(int idx)354 int coex_schm_curr_phase_idx_set(int idx)
355 {
356     (void)idx;
357     return 0;
358 }
359 
360 /**
361  * @brief Get current coexistence scheme phase index.
362  *
363  * @return Coexistence scheme phase index (stub returns 0).
364  */
coex_schm_curr_phase_idx_get(void)365 int coex_schm_curr_phase_idx_get(void)
366 {
367     return 0;
368 }
369 
370 /**
371  * @brief Register WiFi callback for coexistence starts.
372  *
373  * @param cb Callback function.
374  * @return 0 on success.
375  */
coex_register_start_cb(int (* cb)(void))376 int coex_register_start_cb(int (* cb)(void))
377 {
378     (void)cb;
379     return 0;
380 }
381 
382 /**
383  * @brief Restart current coexistence scheme.
384  *
385  * @return 0 on success.
386  */
coex_schm_process_restart(void)387 int coex_schm_process_restart(void)
388 {
389     return 0;
390 }
391 
392 /**
393  * @brief Register callback for coexistence scheme.
394  *
395  * @param type Callback type.
396  * @param callback Callback pointer.
397  * @return 0 on success.
398  */
coex_schm_register_callback(coex_schm_callback_type_t type,void * callback)399 int coex_schm_register_callback(coex_schm_callback_type_t type, void *callback)
400 {
401     (void)type;
402     (void)callback;
403     return 0;
404 }
405 
406 /**
407  * @brief Register coexistence adapter functions.
408  *
409  * @param funcs Pointer to adapter functions.
410  * @return ESP_OK on success.
411  */
esp_coex_adapter_register(coex_adapter_funcs_t * funcs)412 esp_err_t esp_coex_adapter_register(coex_adapter_funcs_t *funcs)
413 {
414     (void)funcs;
415     return ESP_OK;
416 }
417 
418 #if defined(CONFIG_EXTERNAL_COEX_ENABLE)
419 /**
420  * @brief Set external coexistence advanced information.
421  *
422  * @param coex_info Advanced coexistence information.
423  * @param out_pti1 Deprecated parameter.
424  * @param out_pti2 Deprecated parameter.
425  * @return ESP_OK on success.
426  */
esp_coex_external_params(esp_external_coex_advance_t coex_info,uint32_t out_pti1,uint32_t out_pti2)427 esp_err_t esp_coex_external_params(esp_external_coex_advance_t coex_info, uint32_t out_pti1, uint32_t out_pti2)
428 {
429     (void)coex_info;
430     (void)out_pti1;
431     (void)out_pti2;
432     return ESP_OK;
433 }
434 
435 /**
436  * @brief Set external coexistence pti levels and enable it.
437  *
438  * @param level1 External coex low pti.
439  * @param level2 External coex mid pti.
440  * @param level3 External coex high pti.
441  * @return ESP_OK on success.
442  */
esp_coex_external_set(esp_coex_pti_level_t level1,esp_coex_pti_level_t level2,esp_coex_pti_level_t level3)443 esp_err_t esp_coex_external_set(esp_coex_pti_level_t level1,
444                                 esp_coex_pti_level_t level2,
445                                 esp_coex_pti_level_t level3)
446 {
447     (void)level1;
448     (void)level2;
449     (void)level3;
450     return ESP_OK;
451 }
452 
453 /**
454  * @brief Disable external coexist.
455  */
esp_coex_external_stop(void)456 void esp_coex_external_stop(void)
457 {
458 }
459 
460 /**
461  * @brief Set external coexistence wire type.
462  *
463  * @param wire_type Wire type.
464  */
esp_coex_external_set_wire_type(external_coex_wire_t wire_type)465 void esp_coex_external_set_wire_type(external_coex_wire_t wire_type)
466 {
467     (void)wire_type;
468 }
469 
470 #if defined(SOC_EXTERNAL_COEX_LEADER_TX_LINE)
471 /**
472  * @brief Enable external coexist TX line.
473  *
474  * @param en Enable flag.
475  */
esp_coex_external_set_txline(bool en)476 void esp_coex_external_set_txline(bool en)
477 {
478     (void)en;
479 }
480 #endif /* SOC_EXTERNAL_COEX_LEADER_TX_LINE */
481 #endif /* CONFIG_EXTERNAL_COEX_ENABLE */
482 
483 #if defined(CONFIG_ESP_COEX_POWER_MANAGEMENT)
484 /**
485  * @brief Set coexist scheme flexible period.
486  *
487  * @param period Flexible period.
488  * @return 0 on success.
489  */
coex_schm_flexible_period_set(uint8_t period)490 int coex_schm_flexible_period_set(uint8_t period)
491 {
492     (void)period;
493     return 0;
494 }
495 
496 /**
497  * @brief Get coexist scheme flexible period.
498  *
499  * @return Flexible period (stub returns 0).
500  */
coex_schm_flexible_period_get(void)501 uint8_t coex_schm_flexible_period_get(void)
502 {
503     return 0;
504 }
505 #endif /* CONFIG_ESP_COEX_POWER_MANAGEMENT */
506 
507 /**
508  * @brief Check the MD5 values of the coexistence adapter header files.
509  *
510  * @param md5 MD5 string.
511  * @return ESP_OK on success.
512  */
esp_coex_adapter_funcs_md5_check(const char * md5)513 esp_err_t esp_coex_adapter_funcs_md5_check(const char *md5)
514 {
515     (void)md5;
516     return ESP_OK;
517 }
518