2019-02-20 08:01:27 -05:00
|
|
|
// Copyright 2018-2018 Espressif Systems (Shanghai) PTE LTD
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
#ifndef __ESP_COEXIST_INTERNAL_H__
|
|
|
|
#define __ESP_COEXIST_INTERNAL_H__
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include "esp_coexist_adapter.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
COEX_PREFER_WIFI = 0,
|
|
|
|
COEX_PREFER_BT,
|
|
|
|
COEX_PREFER_BALANCE,
|
|
|
|
COEX_PREFER_NUM,
|
|
|
|
} coex_prefer_t;
|
|
|
|
|
|
|
|
typedef void (* coex_func_cb_t)(uint32_t event, int sched_cnt);
|
2022-08-10 23:07:31 -04:00
|
|
|
typedef esp_err_t (* coex_set_lpclk_source_callback_t)(void);
|
2019-02-20 08:01:27 -05:00
|
|
|
|
2019-11-27 10:32:54 -05:00
|
|
|
/**
|
|
|
|
* @brief Pre-Init software coexist
|
|
|
|
* extern function for internal use.
|
|
|
|
*
|
|
|
|
* @return Init ok or failed.
|
|
|
|
*/
|
|
|
|
esp_err_t coex_pre_init(void);
|
|
|
|
|
2019-02-20 08:01:27 -05:00
|
|
|
/**
|
|
|
|
* @brief Init software coexist
|
|
|
|
* extern function for internal use.
|
|
|
|
*
|
|
|
|
* @return Init ok or failed.
|
|
|
|
*/
|
|
|
|
esp_err_t coex_init(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief De-init software coexist
|
|
|
|
* extern function for internal use.
|
|
|
|
*/
|
|
|
|
void coex_deinit(void);
|
|
|
|
|
2020-08-26 05:51:13 -04:00
|
|
|
/**
|
|
|
|
* @brief Enable software coexist
|
|
|
|
* extern function for internal use.
|
|
|
|
*
|
|
|
|
* @return Enable ok or failed.
|
|
|
|
*/
|
|
|
|
esp_err_t coex_enable(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Disable software coexist
|
|
|
|
* extern function for internal use.
|
|
|
|
*/
|
|
|
|
void coex_disable(void);
|
|
|
|
|
2019-02-20 08:01:27 -05:00
|
|
|
/**
|
|
|
|
* @brief Get software coexist version string
|
|
|
|
* extern function for internal use.
|
|
|
|
* @return : version string
|
|
|
|
*/
|
|
|
|
const char *coex_version_get(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Coexist performance preference set from libbt.a
|
|
|
|
* extern function for internal use.
|
|
|
|
*
|
|
|
|
* @param prefer : the prefer enumeration value
|
|
|
|
* @return : ESP_OK - success, other - failed
|
|
|
|
*/
|
|
|
|
esp_err_t coex_preference_set(coex_prefer_t prefer);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get software coexist status.
|
|
|
|
* @return : software coexist status
|
|
|
|
*/
|
|
|
|
uint32_t coex_status_get(void);
|
|
|
|
|
2019-09-12 02:12:13 -04:00
|
|
|
/**
|
|
|
|
* @brief Set software coexist condition.
|
|
|
|
* @return : software coexist condition
|
|
|
|
*/
|
|
|
|
void coex_condition_set(uint32_t type, bool dissatisfy);
|
|
|
|
|
2019-02-20 08:01:27 -05:00
|
|
|
/**
|
|
|
|
* @brief WiFi requests coexistence.
|
|
|
|
*
|
|
|
|
* @param event : WiFi event
|
|
|
|
* @param latency : WiFi will request coexistence after latency
|
|
|
|
* @param duration : duration for WiFi to request coexistence
|
|
|
|
* @return : 0 - success, other - failed
|
|
|
|
*/
|
|
|
|
int coex_wifi_request(uint32_t event, uint32_t latency, uint32_t duration);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief WiFi release coexistence.
|
|
|
|
*
|
|
|
|
* @param event : WiFi event
|
|
|
|
* @return : 0 - success, other - failed
|
|
|
|
*/
|
|
|
|
int coex_wifi_release(uint32_t event);
|
|
|
|
|
|
|
|
/**
|
2020-08-26 05:51:13 -04:00
|
|
|
* @brief Set WiFi channel to coexistence module.
|
2019-02-20 08:01:27 -05:00
|
|
|
*
|
2020-08-26 05:51:13 -04:00
|
|
|
* @param primary : WiFi primary channel
|
|
|
|
* @param secondary : WiFi secondary channel
|
2019-02-20 08:01:27 -05:00
|
|
|
* @return : 0 - success, other - failed
|
|
|
|
*/
|
2020-08-26 05:51:13 -04:00
|
|
|
int coex_wifi_channel_set(uint8_t primary, uint8_t secondary);
|
2019-02-20 08:01:27 -05:00
|
|
|
|
2022-08-10 23:07:31 -04:00
|
|
|
/**
|
|
|
|
* @brief Register application callback function to Wi-Fi update low power clock module.
|
|
|
|
*
|
|
|
|
* @param callback : Wi-Fi update low power clock callback function
|
|
|
|
*/
|
|
|
|
void coex_wifi_register_update_lpclk_callback(coex_set_lpclk_source_callback_t callback);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Update low power clock interval
|
|
|
|
*/
|
|
|
|
void coex_update_lpclk_interval(void);
|
|
|
|
|
2019-02-20 08:01:27 -05:00
|
|
|
/**
|
2020-08-26 05:51:13 -04:00
|
|
|
* @brief Get coexistence event duration.
|
2019-02-20 08:01:27 -05:00
|
|
|
*
|
2020-08-26 05:51:13 -04:00
|
|
|
* @param event : Coexistence event
|
2020-11-10 02:40:01 -05:00
|
|
|
* @param duration: Coexistence event duration
|
2019-02-20 08:01:27 -05:00
|
|
|
* @return : 0 - success, other - failed
|
|
|
|
*/
|
2020-08-26 05:51:13 -04:00
|
|
|
int coex_event_duration_get(uint32_t event, uint32_t *duration);
|
|
|
|
|
2021-01-10 03:16:28 -05:00
|
|
|
#if SOC_COEX_HW_PTI
|
|
|
|
/**
|
|
|
|
* @brief Get coexistence event priority.
|
|
|
|
*
|
|
|
|
* @param event : Coexistence event
|
|
|
|
* @param pti: Coexistence event priority
|
|
|
|
* @return : 0 - success, other - failed
|
|
|
|
*/
|
|
|
|
int coex_pti_get(uint32_t event, uint8_t *pti);
|
|
|
|
#endif
|
|
|
|
|
2020-08-26 05:51:13 -04:00
|
|
|
/**
|
|
|
|
* @brief Clear coexistence status.
|
|
|
|
*
|
|
|
|
* @param type : Coexistence status type
|
|
|
|
* @param status: Coexistence status
|
|
|
|
*/
|
|
|
|
void coex_schm_status_bit_clear(uint32_t type, uint32_t status);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Set coexistence status.
|
|
|
|
*
|
|
|
|
* @param type : Coexistence status type
|
|
|
|
* @param status: Coexistence status
|
|
|
|
*/
|
|
|
|
void coex_schm_status_bit_set(uint32_t type, uint32_t status);
|
2019-02-20 08:01:27 -05:00
|
|
|
|
|
|
|
/**
|
2020-08-26 05:51:13 -04:00
|
|
|
* @brief Set coexistence scheme interval.
|
2019-02-20 08:01:27 -05:00
|
|
|
*
|
2020-11-10 02:40:01 -05:00
|
|
|
* @param interval : Coexistence scheme interval
|
2019-02-20 08:01:27 -05:00
|
|
|
* @return : 0 - success, other - failed
|
|
|
|
*/
|
2020-08-26 05:51:13 -04:00
|
|
|
int coex_schm_interval_set(uint32_t interval);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get coexistence scheme interval.
|
|
|
|
*
|
|
|
|
* @return : Coexistence scheme interval
|
|
|
|
*/
|
|
|
|
uint32_t coex_schm_interval_get(void);
|
2019-02-20 08:01:27 -05:00
|
|
|
|
|
|
|
/**
|
2020-08-26 05:51:13 -04:00
|
|
|
* @brief Get current coexistence scheme period.
|
2019-02-20 08:01:27 -05:00
|
|
|
*
|
2020-11-10 02:40:01 -05:00
|
|
|
* @return : Coexistence scheme period
|
2020-08-26 05:51:13 -04:00
|
|
|
*/
|
|
|
|
uint8_t coex_schm_curr_period_get(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get current coexistence scheme phase.
|
|
|
|
*
|
2020-11-10 02:40:01 -05:00
|
|
|
* @return : Coexistence scheme phase
|
2020-08-26 05:51:13 -04:00
|
|
|
*/
|
|
|
|
void * coex_schm_curr_phase_get(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Set current coexistence scheme phase index.
|
|
|
|
*
|
2020-11-10 02:40:01 -05:00
|
|
|
* @param interval : Coexistence scheme phase index
|
2020-08-26 05:51:13 -04:00
|
|
|
* @return : 0 - success, other - failed
|
2019-02-20 08:01:27 -05:00
|
|
|
*/
|
2020-08-26 05:51:13 -04:00
|
|
|
int coex_schm_curr_phase_idx_set(int idx);
|
2019-02-20 08:01:27 -05:00
|
|
|
|
|
|
|
/**
|
2020-08-26 05:51:13 -04:00
|
|
|
* @brief Get current coexistence scheme phase index.
|
2019-02-20 08:01:27 -05:00
|
|
|
*
|
2020-08-26 05:51:13 -04:00
|
|
|
* @return : Coexistence scheme phase index
|
2019-02-20 08:01:27 -05:00
|
|
|
*/
|
2020-08-26 05:51:13 -04:00
|
|
|
int coex_schm_curr_phase_idx_get(void);
|
2019-02-20 08:01:27 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Register coexistence adapter functions.
|
|
|
|
*
|
|
|
|
* @param funcs : coexistence adapter functions
|
|
|
|
* @return : ESP_OK - success, other - failed
|
|
|
|
*/
|
|
|
|
esp_err_t esp_coex_adapter_register(coex_adapter_funcs_t *funcs);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Check the MD5 values of the coexistence adapter header files in IDF and WiFi library
|
|
|
|
*
|
|
|
|
* @attention 1. It is used for internal CI version check
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* - ESP_OK : succeed
|
|
|
|
* - ESP_WIFI_INVALID_ARG : MD5 check fail
|
|
|
|
*/
|
|
|
|
esp_err_t esp_coex_adapter_funcs_md5_check(const char *md5);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* __ESP_COEXIST_INTERNAL_H__ */
|