From 103772df94be279fbedd3c6eba4f184cfc9b7074 Mon Sep 17 00:00:00 2001 From: liuning Date: Fri, 18 Nov 2022 17:26:31 +0800 Subject: [PATCH 01/10] esp_wifi: support adapter of all chips for new coex lib --- components/bt/controller/esp32/bt.c | 5 ++-- components/esp_rom/esp32c2/ld/esp32c2.rom.ld | 6 ++--- components/esp_wifi/esp32/esp_adapter.c | 18 ++++++------- components/esp_wifi/esp32c2/esp_adapter.c | 24 ++++++++++-------- components/esp_wifi/esp32c3/esp_adapter.c | 24 ++++++++++-------- components/esp_wifi/esp32s2/esp_adapter.c | 25 +++++++++++-------- components/esp_wifi/esp32s3/esp_adapter.c | 24 ++++++++++-------- .../esp_wifi/include/esp_coexist_adapter.h | 8 +++--- .../esp_wifi/include/esp_coexist_internal.h | 16 ++++++++++++ .../include/esp_private/wifi_os_adapter.h | 4 +-- 10 files changed, 93 insertions(+), 61 deletions(-) diff --git a/components/bt/controller/esp32/bt.c b/components/bt/controller/esp32/bt.c index 046f733b525..4cfda15174c 100644 --- a/components/bt/controller/esp32/bt.c +++ b/components/bt/controller/esp32/bt.c @@ -224,7 +224,7 @@ extern int coex_bt_release(uint32_t event); extern int coex_register_bt_cb(coex_func_cb_t cb); extern uint32_t coex_bb_reset_lock(void); extern void coex_bb_reset_unlock(uint32_t restore); -extern int coex_schm_register_btdm_callback(void *callback); +extern int coex_schm_register_callback(int type, void *callback); extern void coex_schm_status_bit_clear(uint32_t type, uint32_t status); extern void coex_schm_status_bit_set(uint32_t type, uint32_t status); extern uint32_t coex_schm_interval_get(void); @@ -1165,7 +1165,8 @@ static void IRAM_ATTR coex_bb_reset_unlock_wrapper(uint32_t restore) static int coex_schm_register_btdm_callback_wrapper(void *callback) { #if CONFIG_SW_COEXIST_ENABLE - return coex_schm_register_btdm_callback(callback); +#define COEX_SCHM_CALLBACK_TYPE_BT 0x1 + return coex_schm_register_callback(COEX_SCHM_CALLBACK_TYPE_BT, callback); #else return 0; #endif diff --git a/components/esp_rom/esp32c2/ld/esp32c2.rom.ld b/components/esp_rom/esp32c2/ld/esp32c2.rom.ld index 9ea94bb1624..91eda2dc40e 100644 --- a/components/esp_rom/esp32c2/ld/esp32c2.rom.ld +++ b/components/esp_rom/esp32c2/ld/esp32c2.rom.ld @@ -1768,7 +1768,7 @@ rcGetHighestRateIdx = 0x40001eac; pm_tx_null_data_done_process = 0x40001eb0; pm_tx_data_process = 0x40001eb4; pm_attach = 0x40001eb8; -pm_coex_schm_process = 0x40001ebc; +/* pm_coex_schm_process = 0x40001ebc; */ ppInitTxq = 0x40001ec0; pp_attach = 0x40001ec4; pp_deattach = 0x40001ec8; @@ -1948,12 +1948,12 @@ ieee80211_sta_is_connected = 0x40002080; current_task_is_wifi_task = 0x40002084; wifi_get_init_state = 0x40002088; ieee80211_timer_process = 0x4000208c; -cnx_coexist_timeout = 0x40002090; +/* cnx_coexist_timeout = 0x40002090; */ /* sta_recv_mgmt = 0x40002094;*/ ieee80211_send_setup = 0x40002098; ieee80211_send_probereq = 0x4000209c; sta_auth_shared = 0x400020a4; -cnx_coexist_timeout_process = 0x400020ac; +/* cnx_coexist_timeout_process = 0x400020ac; */ ieee80211_alloc_challenge = 0x400020b0; cnx_assoc_timeout = 0x400020b4; ieee80211_vnd_ie_set = 0x400020b8; diff --git a/components/esp_wifi/esp32/esp_adapter.c b/components/esp_wifi/esp32/esp_adapter.c index 3a99aeed04a..ce103cc1f6b 100644 --- a/components/esp_wifi/esp32/esp_adapter.c +++ b/components/esp_wifi/esp32/esp_adapter.c @@ -693,28 +693,28 @@ static void * coex_schm_curr_phase_get_wrapper(void) #endif } -static int coex_schm_curr_phase_idx_set_wrapper(int idx) +static int coex_register_start_cb_wrapper(int (* cb)(void)) { #if CONFIG_SW_COEXIST_ENABLE - return coex_schm_curr_phase_idx_set(idx); + return coex_register_start_cb(cb); #else return 0; #endif } -static int coex_schm_curr_phase_idx_get_wrapper(void) +static int coex_schm_process_restart_wrapper(void) { #if CONFIG_SW_COEXIST_ENABLE - return coex_schm_curr_phase_idx_get(); + return coex_schm_process_restart(); #else return 0; #endif } -static int coex_register_start_cb_wrapper(int (* cb)(void)) +static int coex_schm_register_cb_wrapper(int type, void(*cb)(int)) { #if CONFIG_SW_COEXIST_ENABLE - return coex_register_start_cb(cb); + return coex_schm_register_callback(type, cb); #else return 0; #endif @@ -845,9 +845,9 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._coex_schm_interval_get = coex_schm_interval_get_wrapper, ._coex_schm_curr_period_get = coex_schm_curr_period_get_wrapper, ._coex_schm_curr_phase_get = coex_schm_curr_phase_get_wrapper, - ._coex_schm_curr_phase_idx_set = coex_schm_curr_phase_idx_set_wrapper, - ._coex_schm_curr_phase_idx_get = coex_schm_curr_phase_idx_get_wrapper, ._coex_register_start_cb = coex_register_start_cb_wrapper, + ._coex_schm_process_restart = coex_schm_process_restart_wrapper, + ._coex_schm_register_cb = coex_schm_register_cb_wrapper, ._magic = ESP_WIFI_OS_ADAPTER_MAGIC, }; @@ -867,10 +867,10 @@ coex_adapter_funcs_t g_coex_adapter_funcs = { ._is_in_isr = coex_is_in_isr_wrapper, ._malloc_internal = malloc_internal_wrapper, ._free = free, + ._esp_timer_get_time = esp_timer_get_time, ._timer_disarm = timer_disarm_wrapper, ._timer_done = timer_done_wrapper, ._timer_setfn = timer_setfn_wrapper, ._timer_arm_us = timer_arm_us_wrapper, - ._esp_timer_get_time = esp_timer_get_time, ._magic = COEX_ADAPTER_MAGIC, }; diff --git a/components/esp_wifi/esp32c2/esp_adapter.c b/components/esp_wifi/esp32c2/esp_adapter.c index bec2a25ac1c..7d57949e302 100644 --- a/components/esp_wifi/esp32c2/esp_adapter.c +++ b/components/esp_wifi/esp32c2/esp_adapter.c @@ -619,28 +619,28 @@ static void * coex_schm_curr_phase_get_wrapper(void) #endif } -static int coex_schm_curr_phase_idx_set_wrapper(int idx) +static int coex_register_start_cb_wrapper(int (* cb)(void)) { #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE - return coex_schm_curr_phase_idx_set(idx); + return coex_register_start_cb(cb); #else return 0; #endif } -static int coex_schm_curr_phase_idx_get_wrapper(void) +static int coex_schm_process_restart_wrapper(void) { -#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE - return coex_schm_curr_phase_idx_get(); +#if CONFIG_SW_COEXIST_ENABLE + return coex_schm_process_restart(); #else return 0; #endif } -static int coex_register_start_cb_wrapper(int (* cb)(void)) +static int coex_schm_register_cb_wrapper(int type, void(*cb)(int)) { -#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE - return coex_register_start_cb(cb); +#if CONFIG_SW_COEXIST_ENABLE + return coex_schm_register_callback(type, cb); #else return 0; #endif @@ -765,9 +765,9 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._coex_schm_interval_get = coex_schm_interval_get_wrapper, ._coex_schm_curr_period_get = coex_schm_curr_period_get_wrapper, ._coex_schm_curr_phase_get = coex_schm_curr_phase_get_wrapper, - ._coex_schm_curr_phase_idx_set = coex_schm_curr_phase_idx_set_wrapper, - ._coex_schm_curr_phase_idx_get = coex_schm_curr_phase_idx_get_wrapper, ._coex_register_start_cb = coex_register_start_cb_wrapper, + ._coex_schm_process_restart = coex_schm_process_restart_wrapper, + ._coex_schm_register_cb = coex_schm_register_cb_wrapper, ._magic = ESP_WIFI_OS_ADAPTER_MAGIC, }; @@ -786,5 +786,9 @@ coex_adapter_funcs_t g_coex_adapter_funcs = { ._esp_timer_get_time = esp_timer_get_time, ._env_is_chip = env_is_chip_wrapper, ._slowclk_cal_get = esp_clk_slowclk_cal_get_wrapper, + ._timer_disarm = timer_disarm_wrapper, + ._timer_done = timer_done_wrapper, + ._timer_setfn = timer_setfn_wrapper, + ._timer_arm_us = timer_arm_us_wrapper, ._magic = COEX_ADAPTER_MAGIC, }; diff --git a/components/esp_wifi/esp32c3/esp_adapter.c b/components/esp_wifi/esp32c3/esp_adapter.c index 165f9e2fdfe..d6b87809aa6 100644 --- a/components/esp_wifi/esp32c3/esp_adapter.c +++ b/components/esp_wifi/esp32c3/esp_adapter.c @@ -627,28 +627,28 @@ static void * coex_schm_curr_phase_get_wrapper(void) #endif } -static int coex_schm_curr_phase_idx_set_wrapper(int idx) +static int coex_register_start_cb_wrapper(int (* cb)(void)) { -#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE - return coex_schm_curr_phase_idx_set(idx); +#if CONFIG_SW_COEXIST_ENABLE + return coex_register_start_cb(cb); #else return 0; #endif } -static int coex_schm_curr_phase_idx_get_wrapper(void) +static int coex_schm_process_restart_wrapper(void) { -#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE - return coex_schm_curr_phase_idx_get(); +#if CONFIG_SW_COEXIST_ENABLE + return coex_schm_process_restart(); #else return 0; #endif } -static int coex_register_start_cb_wrapper(int (* cb)(void)) +static int coex_schm_register_cb_wrapper(int type, void(*cb)(int)) { #if CONFIG_SW_COEXIST_ENABLE - return coex_register_start_cb(cb); + return coex_schm_register_callback(type, cb); #else return 0; #endif @@ -773,9 +773,9 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._coex_schm_interval_get = coex_schm_interval_get_wrapper, ._coex_schm_curr_period_get = coex_schm_curr_period_get_wrapper, ._coex_schm_curr_phase_get = coex_schm_curr_phase_get_wrapper, - ._coex_schm_curr_phase_idx_set = coex_schm_curr_phase_idx_set_wrapper, - ._coex_schm_curr_phase_idx_get = coex_schm_curr_phase_idx_get_wrapper, ._coex_register_start_cb = coex_register_start_cb_wrapper, + ._coex_schm_process_restart = coex_schm_process_restart_wrapper, + ._coex_schm_register_cb = coex_schm_register_cb_wrapper, ._magic = ESP_WIFI_OS_ADAPTER_MAGIC, }; @@ -792,5 +792,9 @@ coex_adapter_funcs_t g_coex_adapter_funcs = { ._malloc_internal = malloc_internal_wrapper, ._free = free, ._esp_timer_get_time = esp_timer_get_time, + ._timer_disarm = timer_disarm_wrapper, + ._timer_done = timer_done_wrapper, + ._timer_setfn = timer_setfn_wrapper, + ._timer_arm_us = timer_arm_us_wrapper, ._magic = COEX_ADAPTER_MAGIC, }; diff --git a/components/esp_wifi/esp32s2/esp_adapter.c b/components/esp_wifi/esp32s2/esp_adapter.c index 4a022638e1b..31654e12207 100644 --- a/components/esp_wifi/esp32s2/esp_adapter.c +++ b/components/esp_wifi/esp32s2/esp_adapter.c @@ -694,28 +694,28 @@ static void * coex_schm_curr_phase_get_wrapper(void) #endif } -static int coex_schm_curr_phase_idx_set_wrapper(int idx) +static int coex_register_start_cb_wrapper(int (* cb)(void)) { -#if CONFIG_EXTERNAL_COEX_ENABLE - return coex_schm_curr_phase_idx_set(idx); +#if CONFIG_SW_COEXIST_ENABLE + return coex_register_start_cb(cb); #else return 0; #endif } -static int coex_schm_curr_phase_idx_get_wrapper(void) +static int coex_schm_process_restart_wrapper(void) { -#if CONFIG_EXTERNAL_COEX_ENABLE - return coex_schm_curr_phase_idx_get(); +#if CONFIG_SW_COEXIST_ENABLE + return coex_schm_process_restart(); #else return 0; #endif } -static int coex_register_start_cb_wrapper(int (* cb)(void)) +static int coex_schm_register_cb_wrapper(int type, void(*cb)(int)) { #if CONFIG_SW_COEXIST_ENABLE - return coex_register_start_cb(cb); + return coex_schm_register_callback(type, cb); #else return 0; #endif @@ -847,9 +847,10 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._coex_schm_interval_get = coex_schm_interval_get_wrapper, ._coex_schm_curr_period_get = coex_schm_curr_period_get_wrapper, ._coex_schm_curr_phase_get = coex_schm_curr_phase_get_wrapper, - ._coex_schm_curr_phase_idx_set = coex_schm_curr_phase_idx_set_wrapper, - ._coex_schm_curr_phase_idx_get = coex_schm_curr_phase_idx_get_wrapper, ._coex_register_start_cb = coex_register_start_cb_wrapper, + ._coex_schm_process_restart = coex_schm_process_restart_wrapper, + ._coex_schm_register_cb = coex_schm_register_cb_wrapper, + ._magic = ESP_WIFI_OS_ADAPTER_MAGIC, }; @@ -866,5 +867,9 @@ coex_adapter_funcs_t g_coex_adapter_funcs = { ._malloc_internal = malloc_internal_wrapper, ._free = free, ._esp_timer_get_time = esp_timer_get_time, + ._timer_disarm = timer_disarm_wrapper, + ._timer_done = timer_done_wrapper, + ._timer_setfn = timer_setfn_wrapper, + ._timer_arm_us = timer_arm_us_wrapper, ._magic = COEX_ADAPTER_MAGIC, }; diff --git a/components/esp_wifi/esp32s3/esp_adapter.c b/components/esp_wifi/esp32s3/esp_adapter.c index dd67515fdad..0ecda198578 100644 --- a/components/esp_wifi/esp32s3/esp_adapter.c +++ b/components/esp_wifi/esp32s3/esp_adapter.c @@ -716,28 +716,28 @@ static void * coex_schm_curr_phase_get_wrapper(void) #endif } -static int coex_schm_curr_phase_idx_set_wrapper(int idx) +static int coex_register_start_cb_wrapper(int (* cb)(void)) { #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE - return coex_schm_curr_phase_idx_set(idx); + return coex_register_start_cb(cb); #else return 0; #endif } -static int coex_schm_curr_phase_idx_get_wrapper(void) +static int coex_schm_process_restart_wrapper(void) { -#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE - return coex_schm_curr_phase_idx_get(); +#if CONFIG_SW_COEXIST_ENABLE + return coex_schm_process_restart(); #else return 0; #endif } -static int coex_register_start_cb_wrapper(int (* cb)(void)) +static int coex_schm_register_cb_wrapper(int type, void(*cb)(int)) { -#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE - return coex_register_start_cb(cb); +#if CONFIG_SW_COEXIST_ENABLE + return coex_schm_register_callback(type, cb); #else return 0; #endif @@ -867,9 +867,9 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._coex_schm_interval_get = coex_schm_interval_get_wrapper, ._coex_schm_curr_period_get = coex_schm_curr_period_get_wrapper, ._coex_schm_curr_phase_get = coex_schm_curr_phase_get_wrapper, - ._coex_schm_curr_phase_idx_set = coex_schm_curr_phase_idx_set_wrapper, - ._coex_schm_curr_phase_idx_get = coex_schm_curr_phase_idx_get_wrapper, ._coex_register_start_cb = coex_register_start_cb_wrapper, + ._coex_schm_process_restart = coex_schm_process_restart_wrapper, + ._coex_schm_register_cb = coex_schm_register_cb_wrapper, ._magic = ESP_WIFI_OS_ADAPTER_MAGIC, }; @@ -886,5 +886,9 @@ coex_adapter_funcs_t g_coex_adapter_funcs = { ._malloc_internal = malloc_internal_wrapper, ._free = free, ._esp_timer_get_time = esp_timer_get_time, + ._timer_disarm = timer_disarm_wrapper, + ._timer_done = timer_done_wrapper, + ._timer_setfn = timer_setfn_wrapper, + ._timer_arm_us = timer_arm_us_wrapper, ._magic = COEX_ADAPTER_MAGIC, }; diff --git a/components/esp_wifi/include/esp_coexist_adapter.h b/components/esp_wifi/include/esp_coexist_adapter.h index d36a45ec875..11bf54d9b5e 100644 --- a/components/esp_wifi/include/esp_coexist_adapter.h +++ b/components/esp_wifi/include/esp_coexist_adapter.h @@ -36,15 +36,13 @@ typedef struct { int (* _is_in_isr)(void); void * (* _malloc_internal)(size_t size); void (* _free)(void *p); -#if CONFIG_IDF_TARGET_ESP32 + int64_t (* _esp_timer_get_time)(void); + bool (* _env_is_chip)(void); + uint32_t (* _slowclk_cal_get)(void); void (* _timer_disarm)(void *timer); void (* _timer_done)(void *ptimer); void (* _timer_setfn)(void *ptimer, void *pfunction, void *parg); void (* _timer_arm_us)(void *ptimer, uint32_t us, bool repeat); -#endif - int64_t (* _esp_timer_get_time)(void); - bool (* _env_is_chip)(void); - uint32_t (* _slowclk_cal_get)(void); int32_t _magic; } coex_adapter_funcs_t; diff --git a/components/esp_wifi/include/esp_coexist_internal.h b/components/esp_wifi/include/esp_coexist_internal.h index c9fbd2a15a5..fadb38c9398 100644 --- a/components/esp_wifi/include/esp_coexist_internal.h +++ b/components/esp_wifi/include/esp_coexist_internal.h @@ -216,6 +216,22 @@ int coex_schm_curr_phase_idx_get(void); */ int coex_register_start_cb(int (* cb)(void)); +/** + * @brief Restart current coexistence scheme. + * + * @return : 0 - success, other - failed + */ +int coex_schm_process_restart(void); + +/** + * @brief Register callback for coexistence scheme. + * + * @param type : callback type + * @param callback : callback + * @return : 0 - success, other - failed + */ +int coex_schm_register_callback(int type, void *callback); + /** * @brief Register coexistence adapter functions. * diff --git a/components/esp_wifi/include/esp_private/wifi_os_adapter.h b/components/esp_wifi/include/esp_private/wifi_os_adapter.h index d17b5fc47d2..da19d483210 100644 --- a/components/esp_wifi/include/esp_private/wifi_os_adapter.h +++ b/components/esp_wifi/include/esp_private/wifi_os_adapter.h @@ -142,8 +142,6 @@ typedef struct { uint32_t (* _coex_schm_interval_get)(void); uint8_t (* _coex_schm_curr_period_get)(void); void * (* _coex_schm_curr_phase_get)(void); - int (* _coex_schm_curr_phase_idx_set)(int idx); - int (* _coex_schm_curr_phase_idx_get)(void); int (* _coex_register_start_cb)(int (* cb)(void)); #if CONFIG_IDF_TARGET_ESP32C6 void (* _regdma_link_set_write_wait_content)(void *, uint32_t, uint32_t); @@ -151,6 +149,8 @@ typedef struct { int (* _sleep_retention_entries_create)(const void *, int, int, int); void (* _sleep_retention_entries_destroy)(int); #endif + int (* _coex_schm_process_restart)(void); + int (* _coex_schm_register_cb)(int, void (* cb)(int)); int32_t _magic; } wifi_osi_funcs_t; From 38316b38b5b37392efae6eb9cb3e1c11d13cd492 Mon Sep 17 00:00:00 2001 From: liuning Date: Wed, 14 Dec 2022 17:10:54 +0800 Subject: [PATCH 02/10] esp_wifi: move coex part from esp_wifi to esp_coex --- .gitlab/ci/pre_check.yml | 7 +- .gitlab/ci/rules.yml | 1 + .gitmodules | 4 + components/bt/CMakeLists.txt | 2 +- components/esp_coex/CMakeLists.txt | 46 ++++ components/esp_coex/Kconfig | 29 +++ components/esp_coex/esp32/esp_coex_adapter.c | 196 ++++++++++++++++++ .../esp_coex/esp32c2/esp_coex_adapter.c | 131 ++++++++++++ .../esp_coex/esp32c3/esp_coex_adapter.c | 110 ++++++++++ .../esp_coex/esp32s2/esp_coex_adapter.c | 160 ++++++++++++++ .../esp_coex/esp32s3/esp_coex_adapter.c | 160 ++++++++++++++ .../include/esp_coexist.h | 0 .../include/esp_coexist_adapter.h | 0 .../include/esp_coexist_internal.h | 0 .../esp_coex/include/esp_modem_wrapper.h | 78 +++++++ components/esp_coex/lib | 1 + components/esp_coex/linker.lf | 5 + .../{esp_wifi => esp_coex}/sdkconfig.rename | 0 .../{esp_wifi => esp_coex}/src/coexist.c | 0 components/esp_coex/test_md5/test_md5.sh | 66 ++++++ components/esp_phy/src/phy_init.c | 1 - components/esp_system/CMakeLists.txt | 2 +- components/esp_wifi/CMakeLists.txt | 7 +- components/esp_wifi/Kconfig | 24 --- components/esp_wifi/esp32/esp_adapter.c | 169 +-------------- components/esp_wifi/esp32c2/esp_adapter.c | 105 +--------- components/esp_wifi/esp32c3/esp_adapter.c | 86 +------- components/esp_wifi/esp32s2/esp_adapter.c | 131 +----------- components/esp_wifi/esp32s3/esp_adapter.c | 131 +----------- components/esp_wifi/linker.lf | 6 - components/esp_wifi/test_md5/test_md5.sh | 2 - tools/ci/check_public_headers_exceptions.txt | 4 +- tools/ci/executable-list.txt | 1 + 33 files changed, 1006 insertions(+), 659 deletions(-) create mode 100644 components/esp_coex/CMakeLists.txt create mode 100644 components/esp_coex/Kconfig create mode 100644 components/esp_coex/esp32/esp_coex_adapter.c create mode 100644 components/esp_coex/esp32c2/esp_coex_adapter.c create mode 100644 components/esp_coex/esp32c3/esp_coex_adapter.c create mode 100644 components/esp_coex/esp32s2/esp_coex_adapter.c create mode 100644 components/esp_coex/esp32s3/esp_coex_adapter.c rename components/{esp_wifi => esp_coex}/include/esp_coexist.h (100%) rename components/{esp_wifi => esp_coex}/include/esp_coexist_adapter.h (100%) rename components/{esp_wifi => esp_coex}/include/esp_coexist_internal.h (100%) create mode 100644 components/esp_coex/include/esp_modem_wrapper.h create mode 160000 components/esp_coex/lib create mode 100644 components/esp_coex/linker.lf rename components/{esp_wifi => esp_coex}/sdkconfig.rename (100%) rename components/{esp_wifi => esp_coex}/src/coexist.c (100%) create mode 100755 components/esp_coex/test_md5/test_md5.sh diff --git a/.gitlab/ci/pre_check.yml b/.gitlab/ci/pre_check.yml index 1df0ed62d09..df697a86996 100644 --- a/.gitlab/ci/pre_check.yml +++ b/.gitlab/ci/pre_check.yml @@ -77,13 +77,18 @@ test_check_kconfigs: check_blobs: extends: .pre_check_template variables: - SUBMODULES_TO_FETCH: "components/esp_wifi/lib;components/esp_phy/lib" + SUBMODULES_TO_FETCH: "components/esp_wifi/lib;components/esp_phy/lib;components/esp_coex/lib" script: # Check if Wi-Fi library header files match between IDF and the version used when compiling the libraries - IDF_TARGET=esp32 $IDF_PATH/components/esp_wifi/test_md5/test_md5.sh - IDF_TARGET=esp32s2 $IDF_PATH/components/esp_wifi/test_md5/test_md5.sh - IDF_TARGET=esp32s3 $IDF_PATH/components/esp_wifi/test_md5/test_md5.sh - IDF_TARGET=esp32c3 $IDF_PATH/components/esp_wifi/test_md5/test_md5.sh + # Check if Coexistence library header files match between IDF and the version used when compiling the libraries + - IDF_TARGET=esp32 $IDF_PATH/components/esp_coex/test_md5/test_md5.sh + - IDF_TARGET=esp32s2 $IDF_PATH/components/esp_coex/test_md5/test_md5.sh + - IDF_TARGET=esp32s3 $IDF_PATH/components/esp_coex/test_md5/test_md5.sh + - IDF_TARGET=esp32c3 $IDF_PATH/components/esp_coex/test_md5/test_md5.sh # Check if Wi-Fi, PHY, BT blobs contain references to specific symbols - bash $IDF_PATH/tools/ci/check_blobs.sh diff --git a/.gitlab/ci/rules.yml b/.gitlab/ci/rules.yml index 6c115428af6..f60d97973d7 100644 --- a/.gitlab/ci/rules.yml +++ b/.gitlab/ci/rules.yml @@ -183,6 +183,7 @@ - "components/cmock/CMock" - "components/esp_phy/lib" - "components/esp_wifi/lib" + - "components/esp_coex/lib" - "components/ieee802154/lib" - "components/json/cJSON" - "components/lwip/lwip" diff --git a/.gitmodules b/.gitmodules index d162ff483e1..b3b9edd1be4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -86,3 +86,7 @@ [submodule "components/heap/tlsf"] path = components/heap/tlsf url = ../../espressif/tlsf.git + +[submodule "components/esp_coex/lib"] + path = components/esp_coex/lib + url = ../../espressif/esp-coex-lib.git diff --git a/components/bt/CMakeLists.txt b/components/bt/CMakeLists.txt index a51b78b9514..e6f14e925a1 100644 --- a/components/bt/CMakeLists.txt +++ b/components/bt/CMakeLists.txt @@ -691,7 +691,7 @@ endif() idf_component_register(SRCS "${srcs}" INCLUDE_DIRS "${include_dirs}" PRIV_INCLUDE_DIRS "${priv_include_dirs}" - REQUIRES esp_timer esp_wifi + REQUIRES esp_timer esp_wifi esp_coex PRIV_REQUIRES nvs_flash soc esp_pm esp_phy mbedtls driver vfs LDFRAGMENTS "linker.lf") diff --git a/components/esp_coex/CMakeLists.txt b/components/esp_coex/CMakeLists.txt new file mode 100644 index 00000000000..053068b1b8e --- /dev/null +++ b/components/esp_coex/CMakeLists.txt @@ -0,0 +1,46 @@ +idf_build_get_property(idf_target IDF_TARGET) + +if(CONFIG_SW_COEXIST_ENABLE OR CONFIG_EXTERNAL_COEX_ENABLE) + if(CONFIG_APP_NO_BLOBS) + set(link_binary_libs 0) + set(ldfragments) + else() + set(link_binary_libs 1) + set(ldfragments "linker.lf") + endif() + + set(srcs + "src/coexist.c" + "${idf_target}/esp_coex_adapter.c") +endif() + +if(CONFIG_ESP32_WIFI_ENABLED) + list(APPEND srcs "${idf_target}/esp_coex_adapter.c") +endif() + +idf_component_register(SRCS "${srcs}" + INCLUDE_DIRS "include" + PRIV_REQUIRES esp_timer driver + LDFRAGMENTS "${ldfragments}") + +if(CONFIG_SW_COEXIST_ENABLE OR CONFIG_EXTERNAL_COEX_ENABLE) + idf_build_get_property(build_dir BUILD_DIR) + + set(target_name "${idf_target}") + target_link_directories(${COMPONENT_LIB} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/lib/${target_name}") + + if(link_binary_libs) + set(blobs coexist) + + foreach(blob ${blobs}) + add_prebuilt_library(${blob} "${CMAKE_CURRENT_SOURCE_DIR}/lib/${target_name}/lib${blob}.a" + REQUIRES ${COMPONENT_NAME}) + set(blob_reqs ${blobs}) + list(REMOVE_ITEM blob_reqs ${blob}) # remove itself from requirements + set_property(TARGET ${blob} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${blob_reqs}) + target_link_libraries(${COMPONENT_LIB} PUBLIC ${blob}) + endforeach() + endif() + + target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") +endif() diff --git a/components/esp_coex/Kconfig b/components/esp_coex/Kconfig new file mode 100644 index 00000000000..894a77df767 --- /dev/null +++ b/components/esp_coex/Kconfig @@ -0,0 +1,29 @@ + +menu "ESP-COEX" + visible if !IDF_TARGET_ESP32H4 + + config ESP_WIFI_SW_COEXIST_ENABLE + bool "Software controls WiFi/Bluetooth coexistence" + depends on ESP_WIFI_ENABLED && BT_ENABLED + default y + select ESP_WIFI_STA_DISCONNECTED_PM_ENABLE + help + If enabled, WiFi & Bluetooth coexistence is controlled by software rather than hardware. + Recommended for heavy traffic scenarios. Both coexistence configuration options are + automatically managed, no user intervention is required. + If only Bluetooth is used, it is recommended to disable this option to reduce binary file + size. + + config ESP_WIFI_EXTERNAL_COEXIST_ENABLE + bool "WiFi External Coexistence" + default n + depends on (!(BT_ENABLED||NIMBLE_ENABLED)&&(!IDF_TARGET_ESP32)) + help + If enabled, HW External coexistence arbitration is managed by GPIO pins. + It can support three types of wired combinations so far which are 1-wired/2-wired/3-wired. + User can select GPIO pins in application code with configure interfaces. + + This function depends on BT-off + because currently we do not support external coex and internal coex simultaneously. + +endmenu # Wi-Fi diff --git a/components/esp_coex/esp32/esp_coex_adapter.c b/components/esp_coex/esp32/esp_coex_adapter.c new file mode 100644 index 00000000000..4053565d78d --- /dev/null +++ b/components/esp_coex/esp32/esp_coex_adapter.c @@ -0,0 +1,196 @@ +/* + * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include +#include + +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "freertos/queue.h" +#include "freertos/semphr.h" +#include "freertos/portmacro.h" +#include "esp_heap_caps.h" +#include "esp_timer.h" +#include "esp_coexist_adapter.h" +#include "esp32/rom/ets_sys.h" + +#define TAG "esp_coex_adapter" + +#define OSI_FUNCS_TIME_BLOCKING 0xffffffff + +typedef struct { + QueueHandle_t handle; /**< FreeRTOS queue handler */ + void *storage; /**< storage for FreeRTOS queue */ +} modem_static_queue_t; + +void * spin_lock_create_wrapper(void) +{ + portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED; + void *mux = heap_caps_malloc(sizeof(portMUX_TYPE), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); + + if (mux) { + memcpy(mux,&tmp,sizeof(portMUX_TYPE)); + return mux; + } + return NULL; +} + +uint32_t IRAM_ATTR wifi_int_disable_wrapper(void *wifi_int_mux) +{ + if (xPortInIsrContext()) { + portENTER_CRITICAL_ISR(wifi_int_mux); + } else { + portENTER_CRITICAL(wifi_int_mux); + } + + return 0; +} + +void IRAM_ATTR wifi_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp) +{ + if (xPortInIsrContext()) { + portEXIT_CRITICAL_ISR(wifi_int_mux); + } else { + portEXIT_CRITICAL(wifi_int_mux); + } +} + +void IRAM_ATTR task_yield_from_isr_wrapper(void) +{ + portYIELD_FROM_ISR(); +} + +void *internal_semphr_create_wrapper(uint32_t max, uint32_t init) +{ + modem_static_queue_t *semphr = heap_caps_calloc(1, sizeof(modem_static_queue_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); + if (!semphr) { + return NULL; + } + +#ifdef CONFIG_SPIRAM_USE_MALLOC + semphr->storage = heap_caps_calloc(1, sizeof(StaticSemaphore_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); + if (!semphr->storage) { + goto _error; + } + + semphr->handle = xSemaphoreCreateCountingStatic(max, init, semphr->storage); + if (!semphr->handle) { + goto _error; + } + return (void *)semphr; + +_error: + if (semphr) { + if (semphr->storage) { + free(semphr->storage); + } + + free(semphr); + } + return NULL; +#else + semphr->handle = xSemaphoreCreateCounting(max, init); + return (void *)semphr; +#endif +} + +void internal_semphr_delete_wrapper(void *semphr) +{ + modem_static_queue_t *semphr_item = (modem_static_queue_t *)semphr; + if (semphr_item) { + if (semphr_item->handle) { + vSemaphoreDelete(semphr_item->handle); + } +#ifdef CONFIG_SPIRAM_USE_MALLOC + if (semphr_item->storage) { + free(semphr_item->storage); + } +#endif + free(semphr_item); + } +} + +int32_t IRAM_ATTR internal_semphr_take_from_isr_wrapper(void *semphr, void *hptw) +{ + return (int32_t)xSemaphoreTakeFromISR(((modem_static_queue_t *)semphr)->handle, hptw); +} + +int32_t IRAM_ATTR internal_semphr_give_from_isr_wrapper(void *semphr, void *hptw) +{ + return (int32_t)xSemaphoreGiveFromISR(((modem_static_queue_t *)semphr)->handle, hptw); +} + +int32_t internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick) +{ + if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) { + return (int32_t)xSemaphoreTake(((modem_static_queue_t *)semphr)->handle, portMAX_DELAY); + } else { + return (int32_t)xSemaphoreTake(((modem_static_queue_t *)semphr)->handle, block_time_tick); + } +} + +int32_t internal_semphr_give_wrapper(void *semphr) +{ + return (int32_t)xSemaphoreGive(((modem_static_queue_t *)semphr)->handle); +} + +void IRAM_ATTR timer_disarm_wrapper(void *timer) +{ + ets_timer_disarm(timer); +} + +void timer_done_wrapper(void *ptimer) +{ + ets_timer_done(ptimer); +} + +void timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg) +{ + ets_timer_setfn(ptimer, pfunction, parg); +} + +void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat) +{ + ets_timer_arm_us(ptimer, us, repeat); +} + +void * IRAM_ATTR malloc_internal_wrapper(size_t size) +{ + return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); +} + +int IRAM_ATTR coex_is_in_isr_wrapper(void) +{ + return !xPortCanYield(); +} + +coex_adapter_funcs_t g_coex_adapter_funcs = { + ._version = COEX_ADAPTER_VERSION, + ._spin_lock_create = spin_lock_create_wrapper, + ._spin_lock_delete = free, + ._int_disable = wifi_int_disable_wrapper, + ._int_enable = wifi_int_restore_wrapper, + ._task_yield_from_isr = task_yield_from_isr_wrapper, + ._semphr_create = internal_semphr_create_wrapper, + ._semphr_delete = internal_semphr_delete_wrapper, + ._semphr_take_from_isr = internal_semphr_take_from_isr_wrapper, + ._semphr_give_from_isr = internal_semphr_give_from_isr_wrapper, + ._semphr_take = internal_semphr_take_wrapper, + ._semphr_give = internal_semphr_give_wrapper, + ._is_in_isr = coex_is_in_isr_wrapper, + ._malloc_internal = malloc_internal_wrapper, + ._free = free, + ._esp_timer_get_time = esp_timer_get_time, + ._timer_disarm = timer_disarm_wrapper, + ._timer_done = timer_done_wrapper, + ._timer_setfn = timer_setfn_wrapper, + ._timer_arm_us = timer_arm_us_wrapper, + ._magic = COEX_ADAPTER_MAGIC, +}; diff --git a/components/esp_coex/esp32c2/esp_coex_adapter.c b/components/esp_coex/esp32c2/esp_coex_adapter.c new file mode 100644 index 00000000000..218f72cf07b --- /dev/null +++ b/components/esp_coex/esp32c2/esp_coex_adapter.c @@ -0,0 +1,131 @@ +/* + * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include +#include + +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "freertos/queue.h" +#include "freertos/semphr.h" +#include "freertos/portmacro.h" +#include "esp_heap_caps.h" +#include "esp_timer.h" +#include "soc/rtc.h" +#include "esp_private/esp_clk.h" +#include "esp_coexist_adapter.h" +#include "esp32c2/rom/ets_sys.h" + +#define TAG "esp_coex_adapter" + +#define OSI_FUNCS_TIME_BLOCKING 0xffffffff + +bool IRAM_ATTR env_is_chip_wrapper(void) +{ +#ifdef CONFIG_IDF_ENV_FPGA + return false; +#else + return true; +#endif +} + +void IRAM_ATTR task_yield_from_isr_wrapper(void) +{ + portYIELD_FROM_ISR(); +} + +void * semphr_create_wrapper(uint32_t max, uint32_t init) +{ + return (void *)xSemaphoreCreateCounting(max, init); +} + +void semphr_delete_wrapper(void *semphr) +{ + vSemaphoreDelete(semphr); +} + +int32_t IRAM_ATTR semphr_take_from_isr_wrapper(void *semphr, void *hptw) +{ + return (int32_t)xSemaphoreTakeFromISR(semphr, hptw); +} + +int32_t IRAM_ATTR semphr_give_from_isr_wrapper(void *semphr, void *hptw) +{ + return (int32_t)xSemaphoreGiveFromISR(semphr, hptw); +} + +int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick) +{ + if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) { + return (int32_t)xSemaphoreTake(semphr, portMAX_DELAY); + } else { + return (int32_t)xSemaphoreTake(semphr, block_time_tick); + } +} + +int32_t semphr_give_wrapper(void *semphr) +{ + return (int32_t)xSemaphoreGive(semphr); +} + +void IRAM_ATTR timer_disarm_wrapper(void *timer) +{ + ets_timer_disarm(timer); +} + +void timer_done_wrapper(void *ptimer) +{ + ets_timer_done(ptimer); +} + +void timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg) +{ + ets_timer_setfn(ptimer, pfunction, parg); +} + +void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat) +{ + ets_timer_arm_us(ptimer, us, repeat); +} + +uint32_t esp_clk_slowclk_cal_get_wrapper(void) +{ + /* The bit width of WiFi light sleep clock calibration is 12 while the one of + * system is 19. It should shift 19 - 12 = 7. + */ + return (esp_clk_slowclk_cal_get() >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH)); +} + +void * IRAM_ATTR malloc_internal_wrapper(size_t size) +{ + return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); +} + +coex_adapter_funcs_t g_coex_adapter_funcs = { + ._version = COEX_ADAPTER_VERSION, + ._task_yield_from_isr = task_yield_from_isr_wrapper, + ._semphr_create = semphr_create_wrapper, + ._semphr_delete = semphr_delete_wrapper, + ._semphr_take_from_isr = semphr_take_from_isr_wrapper, + ._semphr_give_from_isr = semphr_give_from_isr_wrapper, + ._semphr_take = semphr_take_wrapper, + ._semphr_give = semphr_give_wrapper, + ._is_in_isr = xPortInIsrContext, + ._malloc_internal = malloc_internal_wrapper, + ._free = free, + ._esp_timer_get_time = esp_timer_get_time, + ._env_is_chip = env_is_chip_wrapper, + ._slowclk_cal_get = esp_clk_slowclk_cal_get_wrapper, + ._timer_disarm = timer_disarm_wrapper, + ._timer_done = timer_done_wrapper, + ._timer_setfn = timer_setfn_wrapper, + ._timer_arm_us = timer_arm_us_wrapper, + ._magic = COEX_ADAPTER_MAGIC, +}; diff --git a/components/esp_coex/esp32c3/esp_coex_adapter.c b/components/esp_coex/esp32c3/esp_coex_adapter.c new file mode 100644 index 00000000000..a64ba30ab73 --- /dev/null +++ b/components/esp_coex/esp32c3/esp_coex_adapter.c @@ -0,0 +1,110 @@ +/* + * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include +#include + +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "freertos/queue.h" +#include "freertos/semphr.h" +#include "freertos/portmacro.h" +#include "esp_heap_caps.h" +#include "esp_timer.h" +#include "esp_coexist_adapter.h" +#include "esp32c3/rom/ets_sys.h" + +#define TAG "esp_coex_adapter" + +#define OSI_FUNCS_TIME_BLOCKING 0xffffffff + +void IRAM_ATTR task_yield_from_isr_wrapper(void) +{ + portYIELD_FROM_ISR(); +} + +void * semphr_create_wrapper(uint32_t max, uint32_t init) +{ + return (void *)xSemaphoreCreateCounting(max, init); +} + +void semphr_delete_wrapper(void *semphr) +{ + vSemaphoreDelete(semphr); +} + +int32_t IRAM_ATTR semphr_take_from_isr_wrapper(void *semphr, void *hptw) +{ + return (int32_t)xSemaphoreTakeFromISR(semphr, hptw); +} + +int32_t IRAM_ATTR semphr_give_from_isr_wrapper(void *semphr, void *hptw) +{ + return (int32_t)xSemaphoreGiveFromISR(semphr, hptw); +} + +int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick) +{ + if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) { + return (int32_t)xSemaphoreTake(semphr, portMAX_DELAY); + } else { + return (int32_t)xSemaphoreTake(semphr, block_time_tick); + } +} + +int32_t semphr_give_wrapper(void *semphr) +{ + return (int32_t)xSemaphoreGive(semphr); +} + +void IRAM_ATTR timer_disarm_wrapper(void *timer) +{ + ets_timer_disarm(timer); +} + +void timer_done_wrapper(void *ptimer) +{ + ets_timer_done(ptimer); +} + +void timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg) +{ + ets_timer_setfn(ptimer, pfunction, parg); +} + +void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat) +{ + ets_timer_arm_us(ptimer, us, repeat); +} + +void * IRAM_ATTR malloc_internal_wrapper(size_t size) +{ + return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); +} + +coex_adapter_funcs_t g_coex_adapter_funcs = { + ._version = COEX_ADAPTER_VERSION, + ._task_yield_from_isr = task_yield_from_isr_wrapper, + ._semphr_create = semphr_create_wrapper, + ._semphr_delete = semphr_delete_wrapper, + ._semphr_take_from_isr = semphr_take_from_isr_wrapper, + ._semphr_give_from_isr = semphr_give_from_isr_wrapper, + ._semphr_take = semphr_take_wrapper, + ._semphr_give = semphr_give_wrapper, + ._is_in_isr = xPortInIsrContext, + ._malloc_internal = malloc_internal_wrapper, + ._free = free, + ._esp_timer_get_time = esp_timer_get_time, + ._timer_disarm = timer_disarm_wrapper, + ._timer_done = timer_done_wrapper, + ._timer_setfn = timer_setfn_wrapper, + ._timer_arm_us = timer_arm_us_wrapper, + ._magic = COEX_ADAPTER_MAGIC, +}; diff --git a/components/esp_coex/esp32s2/esp_coex_adapter.c b/components/esp_coex/esp32s2/esp_coex_adapter.c new file mode 100644 index 00000000000..10e2176be69 --- /dev/null +++ b/components/esp_coex/esp32s2/esp_coex_adapter.c @@ -0,0 +1,160 @@ +/* + * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include +#include + +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "freertos/queue.h" +#include "freertos/semphr.h" +#include "freertos/portmacro.h" +#include "esp_heap_caps.h" +#include "esp_timer.h" +#include "esp_coexist_adapter.h" +#include "esp32s2/rom/ets_sys.h" + +#define TAG "esp_coex_adapter" + +#define OSI_FUNCS_TIME_BLOCKING 0xffffffff + +typedef struct { + QueueHandle_t handle; /**< FreeRTOS queue handler */ + void *storage; /**< storage for FreeRTOS queue */ +} modem_static_queue_t; + +void IRAM_ATTR task_yield_from_isr_wrapper(void) +{ + portYIELD_FROM_ISR(); +} + +void *internal_semphr_create_wrapper(uint32_t max, uint32_t init) +{ + modem_static_queue_t *semphr = heap_caps_calloc(1, sizeof(modem_static_queue_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); + if (!semphr) { + return NULL; + } + +#ifdef CONFIG_SPIRAM_USE_MALLOC + semphr->storage = heap_caps_calloc(1, sizeof(StaticSemaphore_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); + if (!semphr->storage) { + goto _error; + } + + semphr->handle = xSemaphoreCreateCountingStatic(max, init, semphr->storage); + if (!semphr->handle) { + goto _error; + } + return (void *)semphr; + +_error: + if (semphr) { + if (semphr->storage) { + free(semphr->storage); + } + + free(semphr); + } + return NULL; +#else + semphr->handle = xSemaphoreCreateCounting(max, init); + return (void *)semphr; +#endif +} + +void internal_semphr_delete_wrapper(void *semphr) +{ + modem_static_queue_t *semphr_item = (modem_static_queue_t *)semphr; + if (semphr_item) { + if (semphr_item->handle) { + vSemaphoreDelete(semphr_item->handle); + } +#ifdef CONFIG_SPIRAM_USE_MALLOC + if (semphr_item->storage) { + free(semphr_item->storage); + } +#endif + free(semphr_item); + } +} + +int32_t IRAM_ATTR internal_semphr_take_from_isr_wrapper(void *semphr, void *hptw) +{ + return (int32_t)xSemaphoreTakeFromISR(((modem_static_queue_t *)semphr)->handle, hptw); +} + +int32_t IRAM_ATTR internal_semphr_give_from_isr_wrapper(void *semphr, void *hptw) +{ + return (int32_t)xSemaphoreGiveFromISR(((modem_static_queue_t *)semphr)->handle, hptw); +} + +int32_t internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick) +{ + if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) { + return (int32_t)xSemaphoreTake(((modem_static_queue_t *)semphr)->handle, portMAX_DELAY); + } else { + return (int32_t)xSemaphoreTake(((modem_static_queue_t *)semphr)->handle, block_time_tick); + } +} + +int32_t internal_semphr_give_wrapper(void *semphr) +{ + return (int32_t)xSemaphoreGive(((modem_static_queue_t *)semphr)->handle); +} + +void IRAM_ATTR timer_disarm_wrapper(void *timer) +{ + ets_timer_disarm(timer); +} + +void timer_done_wrapper(void *ptimer) +{ + ets_timer_done(ptimer); +} + +void timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg) +{ + ets_timer_setfn(ptimer, pfunction, parg); +} + +void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat) +{ + ets_timer_arm_us(ptimer, us, repeat); +} + +void * IRAM_ATTR malloc_internal_wrapper(size_t size) +{ + return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); +} + +int IRAM_ATTR coex_is_in_isr_wrapper(void) +{ + return !xPortCanYield(); +} + +coex_adapter_funcs_t g_coex_adapter_funcs = { + ._version = COEX_ADAPTER_VERSION, + ._task_yield_from_isr = task_yield_from_isr_wrapper, + ._semphr_create = internal_semphr_create_wrapper, + ._semphr_delete = internal_semphr_delete_wrapper, + ._semphr_take_from_isr = internal_semphr_take_from_isr_wrapper, + ._semphr_give_from_isr = internal_semphr_give_from_isr_wrapper, + ._semphr_take = internal_semphr_take_wrapper, + ._semphr_give = internal_semphr_give_wrapper, + ._is_in_isr = coex_is_in_isr_wrapper, + ._malloc_internal = malloc_internal_wrapper, + ._free = free, + ._esp_timer_get_time = esp_timer_get_time, + ._timer_disarm = timer_disarm_wrapper, + ._timer_done = timer_done_wrapper, + ._timer_setfn = timer_setfn_wrapper, + ._timer_arm_us = timer_arm_us_wrapper, + ._magic = COEX_ADAPTER_MAGIC, +}; diff --git a/components/esp_coex/esp32s3/esp_coex_adapter.c b/components/esp_coex/esp32s3/esp_coex_adapter.c new file mode 100644 index 00000000000..7182d1f763a --- /dev/null +++ b/components/esp_coex/esp32s3/esp_coex_adapter.c @@ -0,0 +1,160 @@ +/* + * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include +#include + +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "freertos/queue.h" +#include "freertos/semphr.h" +#include "freertos/portmacro.h" +#include "esp_heap_caps.h" +#include "esp_timer.h" +#include "esp_coexist_adapter.h" +#include "esp32s3/rom/ets_sys.h" + +#define TAG "esp_coex_adapter" + +#define OSI_FUNCS_TIME_BLOCKING 0xffffffff + +typedef struct { + QueueHandle_t handle; /**< FreeRTOS queue handler */ + void *storage; /**< storage for FreeRTOS queue */ +} modem_static_queue_t; + +void IRAM_ATTR task_yield_from_isr_wrapper(void) +{ + portYIELD_FROM_ISR(); +} + +void *internal_semphr_create_wrapper(uint32_t max, uint32_t init) +{ + modem_static_queue_t *semphr = heap_caps_calloc(1, sizeof(modem_static_queue_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); + if (!semphr) { + return NULL; + } + +#ifdef CONFIG_SPIRAM_USE_MALLOC + semphr->storage = heap_caps_calloc(1, sizeof(StaticSemaphore_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); + if (!semphr->storage) { + goto _error; + } + + semphr->handle = xSemaphoreCreateCountingStatic(max, init, semphr->storage); + if (!semphr->handle) { + goto _error; + } + return (void *)semphr; + +_error: + if (semphr) { + if (semphr->storage) { + free(semphr->storage); + } + + free(semphr); + } + return NULL; +#else + semphr->handle = xSemaphoreCreateCounting(max, init); + return (void *)semphr; +#endif +} + +void internal_semphr_delete_wrapper(void *semphr) +{ + modem_static_queue_t *semphr_item = (modem_static_queue_t *)semphr; + if (semphr_item) { + if (semphr_item->handle) { + vSemaphoreDelete(semphr_item->handle); + } +#ifdef CONFIG_SPIRAM_USE_MALLOC + if (semphr_item->storage) { + free(semphr_item->storage); + } +#endif + free(semphr_item); + } +} + +int32_t IRAM_ATTR internal_semphr_take_from_isr_wrapper(void *semphr, void *hptw) +{ + return (int32_t)xSemaphoreTakeFromISR(((modem_static_queue_t *)semphr)->handle, hptw); +} + +int32_t IRAM_ATTR internal_semphr_give_from_isr_wrapper(void *semphr, void *hptw) +{ + return (int32_t)xSemaphoreGiveFromISR(((modem_static_queue_t *)semphr)->handle, hptw); +} + +int32_t internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick) +{ + if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) { + return (int32_t)xSemaphoreTake(((modem_static_queue_t *)semphr)->handle, portMAX_DELAY); + } else { + return (int32_t)xSemaphoreTake(((modem_static_queue_t *)semphr)->handle, block_time_tick); + } +} + +int32_t internal_semphr_give_wrapper(void *semphr) +{ + return (int32_t)xSemaphoreGive(((modem_static_queue_t *)semphr)->handle); +} + +void IRAM_ATTR timer_disarm_wrapper(void *timer) +{ + ets_timer_disarm(timer); +} + +void timer_done_wrapper(void *ptimer) +{ + ets_timer_done(ptimer); +} + +void timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg) +{ + ets_timer_setfn(ptimer, pfunction, parg); +} + +void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat) +{ + ets_timer_arm_us(ptimer, us, repeat); +} + +void * IRAM_ATTR malloc_internal_wrapper(size_t size) +{ + return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); +} + +int IRAM_ATTR coex_is_in_isr_wrapper(void) +{ + return !xPortCanYield(); +} + +coex_adapter_funcs_t g_coex_adapter_funcs = { + ._version = COEX_ADAPTER_VERSION, + ._task_yield_from_isr = task_yield_from_isr_wrapper, + ._semphr_create = internal_semphr_create_wrapper, + ._semphr_delete = internal_semphr_delete_wrapper, + ._semphr_take_from_isr = internal_semphr_take_from_isr_wrapper, + ._semphr_give_from_isr = internal_semphr_give_from_isr_wrapper, + ._semphr_take = internal_semphr_take_wrapper, + ._semphr_give = internal_semphr_give_wrapper, + ._is_in_isr = coex_is_in_isr_wrapper, + ._malloc_internal = malloc_internal_wrapper, + ._free = free, + ._esp_timer_get_time = esp_timer_get_time, + ._timer_disarm = timer_disarm_wrapper, + ._timer_done = timer_done_wrapper, + ._timer_setfn = timer_setfn_wrapper, + ._timer_arm_us = timer_arm_us_wrapper, + ._magic = COEX_ADAPTER_MAGIC, +}; diff --git a/components/esp_wifi/include/esp_coexist.h b/components/esp_coex/include/esp_coexist.h similarity index 100% rename from components/esp_wifi/include/esp_coexist.h rename to components/esp_coex/include/esp_coexist.h diff --git a/components/esp_wifi/include/esp_coexist_adapter.h b/components/esp_coex/include/esp_coexist_adapter.h similarity index 100% rename from components/esp_wifi/include/esp_coexist_adapter.h rename to components/esp_coex/include/esp_coexist_adapter.h diff --git a/components/esp_wifi/include/esp_coexist_internal.h b/components/esp_coex/include/esp_coexist_internal.h similarity index 100% rename from components/esp_wifi/include/esp_coexist_internal.h rename to components/esp_coex/include/esp_coexist_internal.h diff --git a/components/esp_coex/include/esp_modem_wrapper.h b/components/esp_coex/include/esp_modem_wrapper.h new file mode 100644 index 00000000000..c9277bdf9b6 --- /dev/null +++ b/components/esp_coex/include/esp_modem_wrapper.h @@ -0,0 +1,78 @@ +/* + * SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef __ESP_MODEM_WRAPPER_INTERNAL_H__ +#define __ESP_MODEM_WRAPPER_INTERNAL_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#ifdef CONFIG_IDF_TARGET_ESP32 +void * spin_lock_create_wrapper(void); + +uint32_t wifi_int_disable_wrapper(void *wifi_int_mux); + +void wifi_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp); +#endif + +void task_yield_from_isr_wrapper(void); + +#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 + +void *internal_semphr_create_wrapper(uint32_t max, uint32_t init); + +void internal_semphr_delete_wrapper(void *semphr); + +int32_t internal_semphr_take_from_isr_wrapper(void *semphr, void *hptw); + +int32_t internal_semphr_give_from_isr_wrapper(void *semphr, void *hptw); + +int32_t internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick); + +int32_t internal_semphr_give_wrapper(void *semphr); + +#else + +void * semphr_create_wrapper(uint32_t max, uint32_t init); + +void semphr_delete_wrapper(void *semphr); + +int32_t semphr_take_from_isr_wrapper(void *semphr, void *hptw); + +int32_t semphr_give_from_isr_wrapper(void *semphr, void *hptw); + +int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick); + +int32_t semphr_give_wrapper(void *semphr); + +#endif + +void timer_disarm_wrapper(void *timer); + +void timer_done_wrapper(void *ptimer); + +void timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg); + +void timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat); + +void * malloc_internal_wrapper(size_t size); + +#if CONFIG_IDF_TARGET_ESP32C2 +bool env_is_chip_wrapper(void); + +uint32_t esp_clk_slowclk_cal_get_wrapper(void); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/components/esp_coex/lib b/components/esp_coex/lib new file mode 160000 index 00000000000..22df5f00640 --- /dev/null +++ b/components/esp_coex/lib @@ -0,0 +1 @@ +Subproject commit 22df5f006409c215a6856c954eb3d32d19ec8fdc diff --git a/components/esp_coex/linker.lf b/components/esp_coex/linker.lf new file mode 100644 index 00000000000..89f1fd620db --- /dev/null +++ b/components/esp_coex/linker.lf @@ -0,0 +1,5 @@ +[mapping:coexist] +archive: libcoexist.a +entries: + if ESP_WIFI_SLP_IRAM_OPT = y: + * (wifi_slp_iram) diff --git a/components/esp_wifi/sdkconfig.rename b/components/esp_coex/sdkconfig.rename similarity index 100% rename from components/esp_wifi/sdkconfig.rename rename to components/esp_coex/sdkconfig.rename diff --git a/components/esp_wifi/src/coexist.c b/components/esp_coex/src/coexist.c similarity index 100% rename from components/esp_wifi/src/coexist.c rename to components/esp_coex/src/coexist.c diff --git a/components/esp_coex/test_md5/test_md5.sh b/components/esp_coex/test_md5/test_md5.sh new file mode 100755 index 00000000000..96874832d9a --- /dev/null +++ b/components/esp_coex/test_md5/test_md5.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env bash + +set -euo pipefail + +if [ -z "${IDF_PATH:-}" ]; then + echo "IDF_PATH must be set before running this script" + exit 1 +fi + +if [ -z "${IDF_TARGET:-}" ]; then + echo "IDF_TARGET must be set before running this script" + exit 1 +fi + +case $IDF_TARGET in + esp32) + PREFIX=xtensa-esp32-elf- + ;; + esp32s2) + PREFIX=xtensa-esp32s2-elf- + ;; + esp32s3) + PREFIX=xtensa-esp32s3-elf- + ;; + esp32c3) + PREFIX=riscv32-esp-elf- + ;; + *) + echo "Invalid IDF_TARGET value: \"${IDF_TARGET}\"" + exit 1 + ;; +esac +LIB_DIR=${IDF_TARGET} + +ELF_FILE=test.elf + +${PREFIX}ld --unresolved-symbols=ignore-all --entry 0 -o ${ELF_FILE} \ + -u g_coex_adapter_funcs_md5 \ + ${IDF_PATH}/components/esp_coex/lib/${LIB_DIR}/*.a + +FAILURES=0 + +function check_md5() +{ + FILENAME=$1 + SYMBOL=$2 + + GDB_COMMAND="printf \"%s\\n\", (const char*) ${SYMBOL}" + MD5_FROM_LIB=$(${PREFIX}gdb -n -batch ${ELF_FILE} -ex "${GDB_COMMAND}") + MD5_FROM_HEADER=$(md5sum ${FILENAME} | cut -c 1-7) + + echo "Checking ${FILENAME}:" + echo " ${MD5_FROM_HEADER} - from header file" + echo " ${MD5_FROM_LIB} - from library" + if [ "${MD5_FROM_LIB}" != "${MD5_FROM_HEADER}" ]; then + echo " error: MD5 mismatch!" + FAILURES=$(($FAILURES+1)) + fi +} + +echo "Checking libraries for target ${IDF_TARGET}..." +check_md5 ${IDF_PATH}/components/esp_coex/include/esp_coexist_adapter.h g_coex_adapter_funcs_md5 + +if [ $FAILURES -gt 0 ]; then + exit 1 +fi diff --git a/components/esp_phy/src/phy_init.c b/components/esp_phy/src/phy_init.c index b3cff57720c..371a13ffa6b 100644 --- a/components/esp_phy/src/phy_init.c +++ b/components/esp_phy/src/phy_init.c @@ -25,7 +25,6 @@ #include "endian.h" #include "esp_private/phy.h" #include "phy_init_data.h" -#include "esp_coexist_internal.h" #include "esp_private/periph_ctrl.h" #include "esp_private/wifi.h" #include "esp_rom_crc.h" diff --git a/components/esp_system/CMakeLists.txt b/components/esp_system/CMakeLists.txt index 14a2349548c..1fd108bdb3a 100644 --- a/components/esp_system/CMakeLists.txt +++ b/components/esp_system/CMakeLists.txt @@ -121,7 +121,7 @@ if(CONFIG_VFS_SUPPORT_IO) endif() if(CONFIG_SW_COEXIST_ENABLE OR CONFIG_EXTERNAL_COEX_ENABLE) - idf_component_optional_requires(PRIVATE esp_wifi) + idf_component_optional_requires(PRIVATE esp_coex) endif() if(NOT BOOTLOADER_BUILD) diff --git a/components/esp_wifi/CMakeLists.txt b/components/esp_wifi/CMakeLists.txt index 74291c9bf3e..a78c2739984 100644 --- a/components/esp_wifi/CMakeLists.txt +++ b/components/esp_wifi/CMakeLists.txt @@ -17,7 +17,6 @@ if(CONFIG_ESP_WIFI_ENABLED) endif() set(srcs - "src/coexist.c" "src/mesh_event.c" "src/smartconfig.c" "src/wifi_init.c" @@ -36,7 +35,7 @@ idf_component_register(SRCS "${srcs}" INCLUDE_DIRS "include" REQUIRES esp_event esp_phy esp_netif PRIV_REQUIRES driver esptool_py esp_pm esp_timer nvs_flash - wpa_supplicant hal lwip ${extra_priv_requires} + wpa_supplicant hal lwip esp_coex ${extra_priv_requires} LDFRAGMENTS "${ldfragments}") if(CONFIG_ESP_WIFI_ENABLED) @@ -47,9 +46,9 @@ if(CONFIG_ESP_WIFI_ENABLED) if(link_binary_libs) if(CONFIG_IDF_TARGET_ESP32C2) - set(blobs coexist core espnow net80211 pp smartconfig) + set(blobs core espnow net80211 pp smartconfig) else() - set(blobs coexist core espnow mesh net80211 pp smartconfig wapi) + set(blobs core espnow mesh net80211 pp smartconfig wapi) endif() foreach(blob ${blobs}) diff --git a/components/esp_wifi/Kconfig b/components/esp_wifi/Kconfig index 0c234bea7e6..cfa1d77aaa8 100644 --- a/components/esp_wifi/Kconfig +++ b/components/esp_wifi/Kconfig @@ -6,18 +6,6 @@ menu "Wi-Fi" bool default y if SOC_WIFI_SUPPORTED - config ESP_WIFI_SW_COEXIST_ENABLE - bool "Software controls WiFi/Bluetooth coexistence" - depends on ESP_WIFI_ENABLED && BT_ENABLED - default y - select ESP_WIFI_STA_DISCONNECTED_PM_ENABLE - help - If enabled, WiFi & Bluetooth coexistence is controlled by software rather than hardware. - Recommended for heavy traffic scenarios. Both coexistence configuration options are - automatically managed, no user intervention is required. - If only Bluetooth is used, it is recommended to disable this option to reduce binary file - size. - config ESP_WIFI_STATIC_RX_BUFFER_NUM int "Max number of WiFi static RX buffers" range 2 25 if !SOC_WIFI_HE_SUPPORT @@ -323,18 +311,6 @@ menu "Wi-Fi" Select this option to enable power_management for station when disconnected. Chip will do modem-sleep when rf module is not in use any more. - config ESP_WIFI_EXTERNAL_COEXIST_ENABLE - bool "WiFi External Coexistence" - default n - depends on (!(BT_ENABLED||NIMBLE_ENABLED)&&(!IDF_TARGET_ESP32)) - help - If enabled, HW External coexistence arbitration is managed by GPIO pins. - It can support three types of wired combinations so far which are 1-wired/2-wired/3-wired. - User can select GPIO pins in application code with configure interfaces. - - This function depends on BT-off - because currently we do not support external coex and internal coex simultaneously. - config ESP_WIFI_GCMP_SUPPORT bool "WiFi GCMP Support(GCMP128 and GCMP256)" default n diff --git a/components/esp_wifi/esp32/esp_adapter.c b/components/esp_wifi/esp32/esp_adapter.c index ce103cc1f6b..b2ab1f06748 100644 --- a/components/esp_wifi/esp32/esp_adapter.c +++ b/components/esp_wifi/esp32/esp_adapter.c @@ -40,10 +40,10 @@ #include "os.h" #include "esp_smartconfig.h" #include "esp_coexist_internal.h" -#include "esp_coexist_adapter.h" #include "dport_access.h" #include "esp_rom_sys.h" #include "esp32/rom/ets_sys.h" +#include "esp_modem_wrapper.h" #define TAG "esp_adapter" @@ -196,48 +196,11 @@ static void set_isr_wrapper(int32_t n, void *f, void *arg) xt_set_interrupt_handler(n, (xt_handler)f, arg); } -static void * spin_lock_create_wrapper(void) -{ - portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED; - void *mux = heap_caps_malloc(sizeof(portMUX_TYPE), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); - - if (mux) { - memcpy(mux,&tmp,sizeof(portMUX_TYPE)); - return mux; - } - return NULL; -} - -static uint32_t IRAM_ATTR wifi_int_disable_wrapper(void *wifi_int_mux) -{ - if (xPortInIsrContext()) { - portENTER_CRITICAL_ISR(wifi_int_mux); - } else { - portENTER_CRITICAL(wifi_int_mux); - } - - return 0; -} - -static void IRAM_ATTR wifi_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp) -{ - if (xPortInIsrContext()) { - portEXIT_CRITICAL_ISR(wifi_int_mux); - } else { - portEXIT_CRITICAL(wifi_int_mux); - } -} - static bool IRAM_ATTR is_from_isr_wrapper(void) { return !xPortCanYield(); } -static void IRAM_ATTR task_yield_from_isr_wrapper(void) -{ - portYIELD_FROM_ISR(); -} - static void * semphr_create_wrapper(uint32_t max, uint32_t init) { return (void *)xSemaphoreCreateCounting(max, init); @@ -297,82 +260,6 @@ static int32_t semphr_give_wrapper(void *semphr) return (int32_t)xSemaphoreGive(semphr); } - -static void *internal_semphr_create_wrapper(uint32_t max, uint32_t init) -{ - wifi_static_queue_t *semphr = heap_caps_calloc(1, sizeof(wifi_static_queue_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); - if (!semphr) { - return NULL; - } - -#ifdef CONFIG_SPIRAM_USE_MALLOC - semphr->storage = heap_caps_calloc(1, sizeof(StaticSemaphore_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); - if (!semphr->storage) { - goto _error; - } - - semphr->handle = xSemaphoreCreateCountingStatic(max, init, semphr->storage); - if (!semphr->handle) { - goto _error; - } - return (void *)semphr; - -_error: - if (semphr) { - if (semphr->storage) { - free(semphr->storage); - } - - free(semphr); - } - return NULL; -#else - semphr->handle = xSemaphoreCreateCounting(max, init); - return (void *)semphr; -#endif -} - -void internal_semphr_delete_wrapper(void *semphr) -{ - wifi_static_queue_t *semphr_item = (wifi_static_queue_t *)semphr; - if (semphr_item) { - if (semphr_item->handle) { - vSemaphoreDelete(semphr_item->handle); - } -#ifdef CONFIG_SPIRAM_USE_MALLOC - if (semphr_item->storage) { - free(semphr_item->storage); - } -#endif - free(semphr_item); - } -} - -static int32_t IRAM_ATTR internal_semphr_take_from_isr_wrapper(void *semphr, void *hptw) -{ - return (int32_t)xSemaphoreTakeFromISR(((wifi_static_queue_t *)semphr)->handle, hptw); -} - -static int32_t IRAM_ATTR internal_semphr_give_from_isr_wrapper(void *semphr, void *hptw) -{ - return (int32_t)xSemaphoreGiveFromISR(((wifi_static_queue_t *)semphr)->handle, hptw); -} - -static int32_t internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick) -{ - if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) { - return (int32_t)xSemaphoreTake(((wifi_static_queue_t *)semphr)->handle, portMAX_DELAY); - } else { - return (int32_t)xSemaphoreTake(((wifi_static_queue_t *)semphr)->handle, block_time_tick); - } -} - -static int32_t internal_semphr_give_wrapper(void *semphr) -{ - return (int32_t)xSemaphoreGive(((wifi_static_queue_t *)semphr)->handle); -} - - static void * recursive_mutex_create_wrapper(void) { return (void *)xSemaphoreCreateRecursiveMutex(); @@ -493,26 +380,6 @@ static void IRAM_ATTR timer_arm_wrapper(void *timer, uint32_t tmout, bool repeat ets_timer_arm(timer, tmout, repeat); } -static void IRAM_ATTR timer_disarm_wrapper(void *timer) -{ - ets_timer_disarm(timer); -} - -static void timer_done_wrapper(void *ptimer) -{ - ets_timer_done(ptimer); -} - -static void timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg) -{ - ets_timer_setfn(ptimer, pfunction, parg); -} - -static void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat) -{ - ets_timer_arm_us(ptimer, us, repeat); -} - static void wifi_reset_mac_wrapper(void) { periph_module_reset(PERIPH_WIFI_MODULE); @@ -533,11 +400,6 @@ static int get_time_wrapper(void *t) return os_get_time(t); } -static void * IRAM_ATTR malloc_internal_wrapper(size_t size) -{ - return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); -} - static void * IRAM_ATTR realloc_internal_wrapper(void *ptr, size_t size) { return heap_caps_realloc(ptr, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); @@ -725,11 +587,6 @@ static void IRAM_ATTR esp_empty_wrapper(void) } -int IRAM_ATTR coex_is_in_isr_wrapper(void) -{ - return !xPortCanYield(); -} - wifi_osi_funcs_t g_wifi_osi_funcs = { ._version = ESP_WIFI_OS_ADAPTER_VERSION, ._env_is_chip = env_is_chip_wrapper, @@ -850,27 +707,3 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._coex_schm_register_cb = coex_schm_register_cb_wrapper, ._magic = ESP_WIFI_OS_ADAPTER_MAGIC, }; - -coex_adapter_funcs_t g_coex_adapter_funcs = { - ._version = COEX_ADAPTER_VERSION, - ._spin_lock_create = spin_lock_create_wrapper, - ._spin_lock_delete = free, - ._int_disable = wifi_int_disable_wrapper, - ._int_enable = wifi_int_restore_wrapper, - ._task_yield_from_isr = task_yield_from_isr_wrapper, - ._semphr_create = internal_semphr_create_wrapper, - ._semphr_delete = internal_semphr_delete_wrapper, - ._semphr_take_from_isr = internal_semphr_take_from_isr_wrapper, - ._semphr_give_from_isr = internal_semphr_give_from_isr_wrapper, - ._semphr_take = internal_semphr_take_wrapper, - ._semphr_give = internal_semphr_give_wrapper, - ._is_in_isr = coex_is_in_isr_wrapper, - ._malloc_internal = malloc_internal_wrapper, - ._free = free, - ._esp_timer_get_time = esp_timer_get_time, - ._timer_disarm = timer_disarm_wrapper, - ._timer_done = timer_done_wrapper, - ._timer_setfn = timer_setfn_wrapper, - ._timer_arm_us = timer_arm_us_wrapper, - ._magic = COEX_ADAPTER_MAGIC, -}; diff --git a/components/esp_wifi/esp32c2/esp_adapter.c b/components/esp_wifi/esp32c2/esp_adapter.c index 7d57949e302..3906026e56e 100644 --- a/components/esp_wifi/esp32c2/esp_adapter.c +++ b/components/esp_wifi/esp32c2/esp_adapter.c @@ -41,8 +41,8 @@ #include "os.h" #include "esp_smartconfig.h" #include "esp_coexist_internal.h" -#include "esp_coexist_adapter.h" #include "esp32c2/rom/ets_sys.h" +#include "esp_modem_wrapper.h" #define TAG "esp_adapter" @@ -103,15 +103,6 @@ static void wifi_delete_queue_wrapper(void *queue) wifi_delete_queue(queue); } -static bool IRAM_ATTR env_is_chip_wrapper(void) -{ -#ifdef CONFIG_IDF_ENV_FPGA - return false; -#else - return true; -#endif -} - static void set_intr_wrapper(int32_t cpu_no, uint32_t intr_source, uint32_t intr_num, int32_t intr_prio) { intr_matrix_route(intr_source, intr_num); @@ -176,21 +167,6 @@ static bool IRAM_ATTR is_from_isr_wrapper(void) return !xPortCanYield(); } -static void IRAM_ATTR task_yield_from_isr_wrapper(void) -{ - portYIELD_FROM_ISR(); -} - -static void * semphr_create_wrapper(uint32_t max, uint32_t init) -{ - return (void *)xSemaphoreCreateCounting(max, init); -} - -static void semphr_delete_wrapper(void *semphr) -{ - vSemaphoreDelete(semphr); -} - static void wifi_thread_semphr_free(void* data) { SemaphoreHandle_t *sem = (SemaphoreHandle_t*)(data); @@ -226,30 +202,6 @@ static void * wifi_thread_semphr_get_wrapper(void) return (void*)sem; } -static int32_t IRAM_ATTR semphr_take_from_isr_wrapper(void *semphr, void *hptw) -{ - return (int32_t)xSemaphoreTakeFromISR(semphr, hptw); -} - -static int32_t IRAM_ATTR semphr_give_from_isr_wrapper(void *semphr, void *hptw) -{ - return (int32_t)xSemaphoreGiveFromISR(semphr, hptw); -} - -static int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick) -{ - if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) { - return (int32_t)xSemaphoreTake(semphr, portMAX_DELAY); - } else { - return (int32_t)xSemaphoreTake(semphr, block_time_tick); - } -} - -static int32_t semphr_give_wrapper(void *semphr) -{ - return (int32_t)xSemaphoreGive(semphr); -} - static void * recursive_mutex_create_wrapper(void) { return (void *)xSemaphoreCreateRecursiveMutex(); @@ -370,26 +322,6 @@ static void IRAM_ATTR timer_arm_wrapper(void *timer, uint32_t tmout, bool repeat ets_timer_arm(timer, tmout, repeat); } -static void IRAM_ATTR timer_disarm_wrapper(void *timer) -{ - ets_timer_disarm(timer); -} - -static void timer_done_wrapper(void *ptimer) -{ - ets_timer_done(ptimer); -} - -static void timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg) -{ - ets_timer_setfn(ptimer, pfunction, parg); -} - -static void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat) -{ - ets_timer_arm_us(ptimer, us, repeat); -} - static void wifi_reset_mac_wrapper(void) { periph_module_reset(PERIPH_WIFI_MODULE); @@ -424,19 +356,6 @@ static int get_time_wrapper(void *t) return os_get_time(t); } -static uint32_t esp_clk_slowclk_cal_get_wrapper(void) -{ - /* The bit width of WiFi light sleep clock calibration is 12 while the one of - * system is 19. It should shift 19 - 12 = 7. - */ - return (esp_clk_slowclk_cal_get() >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH)); -} - -static void * IRAM_ATTR malloc_internal_wrapper(size_t size) -{ - return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); -} - static void * IRAM_ATTR realloc_internal_wrapper(void *ptr, size_t size) { return heap_caps_realloc(ptr, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); @@ -770,25 +689,3 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._coex_schm_register_cb = coex_schm_register_cb_wrapper, ._magic = ESP_WIFI_OS_ADAPTER_MAGIC, }; - -coex_adapter_funcs_t g_coex_adapter_funcs = { - ._version = COEX_ADAPTER_VERSION, - ._task_yield_from_isr = task_yield_from_isr_wrapper, - ._semphr_create = semphr_create_wrapper, - ._semphr_delete = semphr_delete_wrapper, - ._semphr_take_from_isr = semphr_take_from_isr_wrapper, - ._semphr_give_from_isr = semphr_give_from_isr_wrapper, - ._semphr_take = semphr_take_wrapper, - ._semphr_give = semphr_give_wrapper, - ._is_in_isr = xPortInIsrContext, - ._malloc_internal = malloc_internal_wrapper, - ._free = free, - ._esp_timer_get_time = esp_timer_get_time, - ._env_is_chip = env_is_chip_wrapper, - ._slowclk_cal_get = esp_clk_slowclk_cal_get_wrapper, - ._timer_disarm = timer_disarm_wrapper, - ._timer_done = timer_done_wrapper, - ._timer_setfn = timer_setfn_wrapper, - ._timer_arm_us = timer_arm_us_wrapper, - ._magic = COEX_ADAPTER_MAGIC, -}; diff --git a/components/esp_wifi/esp32c3/esp_adapter.c b/components/esp_wifi/esp32c3/esp_adapter.c index d6b87809aa6..04e8b573598 100644 --- a/components/esp_wifi/esp32c3/esp_adapter.c +++ b/components/esp_wifi/esp32c3/esp_adapter.c @@ -42,8 +42,8 @@ #include "os.h" #include "esp_smartconfig.h" #include "esp_coexist_internal.h" -#include "esp_coexist_adapter.h" #include "esp32c3/rom/ets_sys.h" +#include "esp_modem_wrapper.h" #define TAG "esp_adapter" @@ -179,21 +179,6 @@ static bool IRAM_ATTR is_from_isr_wrapper(void) return !xPortCanYield(); } -static void IRAM_ATTR task_yield_from_isr_wrapper(void) -{ - portYIELD_FROM_ISR(); -} - -static void * semphr_create_wrapper(uint32_t max, uint32_t init) -{ - return (void *)xSemaphoreCreateCounting(max, init); -} - -static void semphr_delete_wrapper(void *semphr) -{ - vSemaphoreDelete(semphr); -} - static void wifi_thread_semphr_free(void* data) { SemaphoreHandle_t *sem = (SemaphoreHandle_t*)(data); @@ -229,30 +214,6 @@ static void * wifi_thread_semphr_get_wrapper(void) return (void*)sem; } -static int32_t IRAM_ATTR semphr_take_from_isr_wrapper(void *semphr, void *hptw) -{ - return (int32_t)xSemaphoreTakeFromISR(semphr, hptw); -} - -static int32_t IRAM_ATTR semphr_give_from_isr_wrapper(void *semphr, void *hptw) -{ - return (int32_t)xSemaphoreGiveFromISR(semphr, hptw); -} - -static int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick) -{ - if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) { - return (int32_t)xSemaphoreTake(semphr, portMAX_DELAY); - } else { - return (int32_t)xSemaphoreTake(semphr, block_time_tick); - } -} - -static int32_t semphr_give_wrapper(void *semphr) -{ - return (int32_t)xSemaphoreGive(semphr); -} - static void * recursive_mutex_create_wrapper(void) { return (void *)xSemaphoreCreateRecursiveMutex(); @@ -373,26 +334,6 @@ static void IRAM_ATTR timer_arm_wrapper(void *timer, uint32_t tmout, bool repeat ets_timer_arm(timer, tmout, repeat); } -static void IRAM_ATTR timer_disarm_wrapper(void *timer) -{ - ets_timer_disarm(timer); -} - -static void timer_done_wrapper(void *ptimer) -{ - ets_timer_done(ptimer); -} - -static void timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg) -{ - ets_timer_setfn(ptimer, pfunction, parg); -} - -static void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat) -{ - ets_timer_arm_us(ptimer, us, repeat); -} - static void wifi_reset_mac_wrapper(void) { periph_module_reset(PERIPH_WIFI_MODULE); @@ -440,11 +381,6 @@ static uint32_t esp_clk_slowclk_cal_get_wrapper(void) } } -static void * IRAM_ATTR malloc_internal_wrapper(size_t size) -{ - return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); -} - static void * IRAM_ATTR realloc_internal_wrapper(void *ptr, size_t size) { return heap_caps_realloc(ptr, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); @@ -778,23 +714,3 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._coex_schm_register_cb = coex_schm_register_cb_wrapper, ._magic = ESP_WIFI_OS_ADAPTER_MAGIC, }; - -coex_adapter_funcs_t g_coex_adapter_funcs = { - ._version = COEX_ADAPTER_VERSION, - ._task_yield_from_isr = task_yield_from_isr_wrapper, - ._semphr_create = semphr_create_wrapper, - ._semphr_delete = semphr_delete_wrapper, - ._semphr_take_from_isr = semphr_take_from_isr_wrapper, - ._semphr_give_from_isr = semphr_give_from_isr_wrapper, - ._semphr_take = semphr_take_wrapper, - ._semphr_give = semphr_give_wrapper, - ._is_in_isr = xPortInIsrContext, - ._malloc_internal = malloc_internal_wrapper, - ._free = free, - ._esp_timer_get_time = esp_timer_get_time, - ._timer_disarm = timer_disarm_wrapper, - ._timer_done = timer_done_wrapper, - ._timer_setfn = timer_setfn_wrapper, - ._timer_arm_us = timer_arm_us_wrapper, - ._magic = COEX_ADAPTER_MAGIC, -}; diff --git a/components/esp_wifi/esp32s2/esp_adapter.c b/components/esp_wifi/esp32s2/esp_adapter.c index 31654e12207..71bc9712401 100644 --- a/components/esp_wifi/esp32s2/esp_adapter.c +++ b/components/esp_wifi/esp32s2/esp_adapter.c @@ -42,9 +42,9 @@ #include "os.h" #include "esp_smartconfig.h" #include "esp_coexist_internal.h" -#include "esp_coexist_adapter.h" #include "esp_rom_sys.h" #include "esp32s2/rom/ets_sys.h" +#include "esp_modem_wrapper.h" #define TAG "esp_adapter" @@ -224,11 +224,6 @@ static bool IRAM_ATTR is_from_isr_wrapper(void) return !xPortCanYield(); } -static void IRAM_ATTR task_yield_from_isr_wrapper(void) -{ - portYIELD_FROM_ISR(); -} - static void * semphr_create_wrapper(uint32_t max, uint32_t init) { return (void *)xSemaphoreCreateCounting(max, init); @@ -288,80 +283,6 @@ static int32_t semphr_give_wrapper(void *semphr) return (int32_t)xSemaphoreGive(semphr); } -static void *internal_semphr_create_wrapper(uint32_t max, uint32_t init) -{ - wifi_static_queue_t *semphr = heap_caps_calloc(1, sizeof(wifi_static_queue_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); - if (!semphr) { - return NULL; - } - -#ifdef CONFIG_SPIRAM_USE_MALLOC - semphr->storage = heap_caps_calloc(1, sizeof(StaticSemaphore_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); - if (!semphr->storage) { - goto _error; - } - - semphr->handle = xSemaphoreCreateCountingStatic(max, init, semphr->storage); - if (!semphr->handle) { - goto _error; - } - return (void *)semphr; - -_error: - if (semphr) { - if (semphr->storage) { - free(semphr->storage); - } - - free(semphr); - } - return NULL; -#else - semphr->handle = xSemaphoreCreateCounting(max, init); - return (void *)semphr; -#endif -} - -void internal_semphr_delete_wrapper(void *semphr) -{ - wifi_static_queue_t *semphr_item = (wifi_static_queue_t *)semphr; - if (semphr_item) { - if (semphr_item->handle) { - vSemaphoreDelete(semphr_item->handle); - } -#ifdef CONFIG_SPIRAM_USE_MALLOC - if (semphr_item->storage) { - free(semphr_item->storage); - } -#endif - free(semphr_item); - } -} - -static int32_t IRAM_ATTR internal_semphr_take_from_isr_wrapper(void *semphr, void *hptw) -{ - return (int32_t)xSemaphoreTakeFromISR(((wifi_static_queue_t *)semphr)->handle, hptw); -} - -static int32_t IRAM_ATTR internal_semphr_give_from_isr_wrapper(void *semphr, void *hptw) -{ - return (int32_t)xSemaphoreGiveFromISR(((wifi_static_queue_t *)semphr)->handle, hptw); -} - -static int32_t internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick) -{ - if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) { - return (int32_t)xSemaphoreTake(((wifi_static_queue_t *)semphr)->handle, portMAX_DELAY); - } else { - return (int32_t)xSemaphoreTake(((wifi_static_queue_t *)semphr)->handle, block_time_tick); - } -} - -static int32_t internal_semphr_give_wrapper(void *semphr) -{ - return (int32_t)xSemaphoreGive(((wifi_static_queue_t *)semphr)->handle); -} - static void * recursive_mutex_create_wrapper(void) { return (void *)xSemaphoreCreateRecursiveMutex(); @@ -482,26 +403,6 @@ static void IRAM_ATTR timer_arm_wrapper(void *timer, uint32_t tmout, bool repeat ets_timer_arm(timer, tmout, repeat); } -static void IRAM_ATTR timer_disarm_wrapper(void *timer) -{ - ets_timer_disarm(timer); -} - -static void timer_done_wrapper(void *ptimer) -{ - ets_timer_done(ptimer); -} - -static void timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg) -{ - ets_timer_setfn(ptimer, pfunction, parg); -} - -static void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat) -{ - ets_timer_arm_us(ptimer, us, repeat); -} - static void wifi_reset_mac_wrapper(void) { periph_module_reset(PERIPH_WIFI_MODULE); @@ -530,11 +431,6 @@ static uint32_t esp_clk_slowclk_cal_get_wrapper(void) return (esp_clk_slowclk_cal_get() >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH)); } -static void * IRAM_ATTR malloc_internal_wrapper(size_t size) -{ - return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); -} - static void * IRAM_ATTR realloc_internal_wrapper(void *ptr, size_t size) { return heap_caps_realloc(ptr, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); @@ -726,11 +622,6 @@ static void IRAM_ATTR esp_empty_wrapper(void) } -int IRAM_ATTR coex_is_in_isr_wrapper(void) -{ - return !xPortCanYield(); -} - wifi_osi_funcs_t g_wifi_osi_funcs = { ._version = ESP_WIFI_OS_ADAPTER_VERSION, ._env_is_chip = env_is_chip_wrapper, @@ -853,23 +744,3 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._magic = ESP_WIFI_OS_ADAPTER_MAGIC, }; - -coex_adapter_funcs_t g_coex_adapter_funcs = { - ._version = COEX_ADAPTER_VERSION, - ._task_yield_from_isr = task_yield_from_isr_wrapper, - ._semphr_create = internal_semphr_create_wrapper, - ._semphr_delete = internal_semphr_delete_wrapper, - ._semphr_take_from_isr = internal_semphr_take_from_isr_wrapper, - ._semphr_give_from_isr = internal_semphr_give_from_isr_wrapper, - ._semphr_take = internal_semphr_take_wrapper, - ._semphr_give = internal_semphr_give_wrapper, - ._is_in_isr = coex_is_in_isr_wrapper, - ._malloc_internal = malloc_internal_wrapper, - ._free = free, - ._esp_timer_get_time = esp_timer_get_time, - ._timer_disarm = timer_disarm_wrapper, - ._timer_done = timer_done_wrapper, - ._timer_setfn = timer_setfn_wrapper, - ._timer_arm_us = timer_arm_us_wrapper, - ._magic = COEX_ADAPTER_MAGIC, -}; diff --git a/components/esp_wifi/esp32s3/esp_adapter.c b/components/esp_wifi/esp32s3/esp_adapter.c index 0ecda198578..0c7162a12d3 100644 --- a/components/esp_wifi/esp32s3/esp_adapter.c +++ b/components/esp_wifi/esp32s3/esp_adapter.c @@ -43,9 +43,9 @@ #include "os.h" #include "esp_smartconfig.h" #include "esp_coexist_internal.h" -#include "esp_coexist_adapter.h" #include "esp_rom_sys.h" #include "esp32s3/rom/ets_sys.h" +#include "esp_modem_wrapper.h" #define TAG "esp_adapter" @@ -227,11 +227,6 @@ static bool IRAM_ATTR is_from_isr_wrapper(void) return !xPortCanYield(); } -static void IRAM_ATTR task_yield_from_isr_wrapper(void) -{ - portYIELD_FROM_ISR(); -} - static void * semphr_create_wrapper(uint32_t max, uint32_t init) { return (void *)xSemaphoreCreateCounting(max, init); @@ -291,80 +286,6 @@ static int32_t semphr_give_wrapper(void *semphr) return (int32_t)xSemaphoreGive(semphr); } -static void *internal_semphr_create_wrapper(uint32_t max, uint32_t init) -{ - wifi_static_queue_t *semphr = heap_caps_calloc(1, sizeof(wifi_static_queue_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); - if (!semphr) { - return NULL; - } - -#ifdef CONFIG_SPIRAM_USE_MALLOC - semphr->storage = heap_caps_calloc(1, sizeof(StaticSemaphore_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); - if (!semphr->storage) { - goto _error; - } - - semphr->handle = xSemaphoreCreateCountingStatic(max, init, semphr->storage); - if (!semphr->handle) { - goto _error; - } - return (void *)semphr; - -_error: - if (semphr) { - if (semphr->storage) { - free(semphr->storage); - } - - free(semphr); - } - return NULL; -#else - semphr->handle = xSemaphoreCreateCounting(max, init); - return (void *)semphr; -#endif -} - -void internal_semphr_delete_wrapper(void *semphr) -{ - wifi_static_queue_t *semphr_item = (wifi_static_queue_t *)semphr; - if (semphr_item) { - if (semphr_item->handle) { - vSemaphoreDelete(semphr_item->handle); - } -#ifdef CONFIG_SPIRAM_USE_MALLOC - if (semphr_item->storage) { - free(semphr_item->storage); - } -#endif - free(semphr_item); - } -} - -static int32_t IRAM_ATTR internal_semphr_take_from_isr_wrapper(void *semphr, void *hptw) -{ - return (int32_t)xSemaphoreTakeFromISR(((wifi_static_queue_t *)semphr)->handle, hptw); -} - -static int32_t IRAM_ATTR internal_semphr_give_from_isr_wrapper(void *semphr, void *hptw) -{ - return (int32_t)xSemaphoreGiveFromISR(((wifi_static_queue_t *)semphr)->handle, hptw); -} - -static int32_t internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick) -{ - if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) { - return (int32_t)xSemaphoreTake(((wifi_static_queue_t *)semphr)->handle, portMAX_DELAY); - } else { - return (int32_t)xSemaphoreTake(((wifi_static_queue_t *)semphr)->handle, block_time_tick); - } -} - -static int32_t internal_semphr_give_wrapper(void *semphr) -{ - return (int32_t)xSemaphoreGive(((wifi_static_queue_t *)semphr)->handle); -} - static void * recursive_mutex_create_wrapper(void) { return (void *)xSemaphoreCreateRecursiveMutex(); @@ -485,26 +406,6 @@ static void IRAM_ATTR timer_arm_wrapper(void *timer, uint32_t tmout, bool repeat ets_timer_arm(timer, tmout, repeat); } -static void IRAM_ATTR timer_disarm_wrapper(void *timer) -{ - ets_timer_disarm(timer); -} - -static void timer_done_wrapper(void *ptimer) -{ - ets_timer_done(ptimer); -} - -static void timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg) -{ - ets_timer_setfn(ptimer, pfunction, parg); -} - -static void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat) -{ - ets_timer_arm_us(ptimer, us, repeat); -} - static void wifi_reset_mac_wrapper(void) { periph_module_reset(PERIPH_WIFI_MODULE); @@ -552,11 +453,6 @@ static uint32_t esp_clk_slowclk_cal_get_wrapper(void) } } -static void * IRAM_ATTR malloc_internal_wrapper(size_t size) -{ - return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); -} - static void * IRAM_ATTR realloc_internal_wrapper(void *ptr, size_t size) { return heap_caps_realloc(ptr, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); @@ -748,11 +644,6 @@ static void IRAM_ATTR esp_empty_wrapper(void) } -int IRAM_ATTR coex_is_in_isr_wrapper(void) -{ - return !xPortCanYield(); -} - wifi_osi_funcs_t g_wifi_osi_funcs = { ._version = ESP_WIFI_OS_ADAPTER_VERSION, ._env_is_chip = env_is_chip_wrapper, @@ -872,23 +763,3 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._coex_schm_register_cb = coex_schm_register_cb_wrapper, ._magic = ESP_WIFI_OS_ADAPTER_MAGIC, }; - -coex_adapter_funcs_t g_coex_adapter_funcs = { - ._version = COEX_ADAPTER_VERSION, - ._task_yield_from_isr = task_yield_from_isr_wrapper, - ._semphr_create = internal_semphr_create_wrapper, - ._semphr_delete = internal_semphr_delete_wrapper, - ._semphr_take_from_isr = internal_semphr_take_from_isr_wrapper, - ._semphr_give_from_isr = internal_semphr_give_from_isr_wrapper, - ._semphr_take = internal_semphr_take_wrapper, - ._semphr_give = internal_semphr_give_wrapper, - ._is_in_isr = coex_is_in_isr_wrapper, - ._malloc_internal = malloc_internal_wrapper, - ._free = free, - ._esp_timer_get_time = esp_timer_get_time, - ._timer_disarm = timer_disarm_wrapper, - ._timer_done = timer_done_wrapper, - ._timer_setfn = timer_setfn_wrapper, - ._timer_arm_us = timer_arm_us_wrapper, - ._magic = COEX_ADAPTER_MAGIC, -}; diff --git a/components/esp_wifi/linker.lf b/components/esp_wifi/linker.lf index 4e5c3403d59..99c7a0482ec 100644 --- a/components/esp_wifi/linker.lf +++ b/components/esp_wifi/linker.lf @@ -135,12 +135,6 @@ entries: if ESP_WIFI_RX_IRAM_OPT || ESP_WIFI_SLP_IRAM_OPT: * (wifi_slp_rx_iram) -[mapping:coexist] -archive: libcoexist.a -entries: - if ESP_WIFI_SLP_IRAM_OPT = y: - * (wifi_slp_iram) - [mapping:esp_wifi] archive: libesp_wifi.a entries: diff --git a/components/esp_wifi/test_md5/test_md5.sh b/components/esp_wifi/test_md5/test_md5.sh index aff6cbcf6fc..28e85b3a8fa 100755 --- a/components/esp_wifi/test_md5/test_md5.sh +++ b/components/esp_wifi/test_md5/test_md5.sh @@ -44,7 +44,6 @@ ${PREFIX}ld --unresolved-symbols=ignore-all --entry 0 -o ${ELF_FILE} \ -u g_wifi_type_md5 \ -u g_wifi_he_type_md5 \ -u g_wifi_osi_funcs_md5 \ - -u g_coex_adapter_funcs_md5 \ -u g_wifi_supplicant_funcs_md5 \ ${IDF_PATH}/components/esp_wifi/lib/${LIB_DIR}/*.a @@ -75,7 +74,6 @@ check_md5 ${IDF_PATH}/components/esp_wifi/include/esp_private/wifi_os_adapter.h check_md5 ${IDF_PATH}/components/esp_wifi/include/esp_wifi_crypto_types.h g_wifi_crypto_funcs_md5 check_md5 ${IDF_PATH}/components/esp_wifi/include/esp_wifi_types.h g_wifi_type_md5 check_md5 ${IDF_PATH}/components/esp_wifi/include/esp_wifi_he_types.h g_wifi_he_type_md5 -check_md5 ${IDF_PATH}/components/esp_wifi/include/esp_coexist_adapter.h g_coex_adapter_funcs_md5 check_md5 ${IDF_PATH}/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h g_wifi_supplicant_funcs_md5 if [ $FAILURES -gt 0 ]; then diff --git a/tools/ci/check_public_headers_exceptions.txt b/tools/ci/check_public_headers_exceptions.txt index 024e6b9eb61..3b68da343cb 100644 --- a/tools/ci/check_public_headers_exceptions.txt +++ b/tools/ci/check_public_headers_exceptions.txt @@ -118,11 +118,11 @@ components/esp_rom/include/esp32s2/rom/opi_flash.h components/esp_rom/include/esp32s2/rom/efuse.h components/esp_ringbuf/include/freertos/ringbuf.h components/esp_wifi/include/esp_wifi_crypto_types.h -components/esp_wifi/include/esp_coexist_internal.h +components/esp_coex/include/esp_coexist_internal.h components/esp_wifi/include/esp_wifi_netif.h components/esp_wifi/include/smartconfig_ack.h components/esp_wifi/include/esp_wifi_default.h -components/esp_wifi/include/esp_coexist_adapter.h +components/esp_coex/include/esp_coexist_adapter.h components/esp_event/include/esp_event_base.h components/esp_netif/include/esp_netif_sta_list.h components/esp_netif/include/esp_netif_defaults.h diff --git a/tools/ci/executable-list.txt b/tools/ci/executable-list.txt index 495a2122090..051f3b2138e 100644 --- a/tools/ci/executable-list.txt +++ b/tools/ci/executable-list.txt @@ -1,6 +1,7 @@ components/app_update/otatool.py components/efuse/efuse_table_gen.py components/efuse/test_efuse_host/efuse_tests.py +components/esp_coex/test_md5/test_md5.sh components/esp_wifi/test_md5/test_md5.sh components/espcoredump/espcoredump.py components/espcoredump/test/test_espcoredump.py From 5e59276ddffda04900ce60fd3ed06852da4e4ab3 Mon Sep 17 00:00:00 2001 From: liuning Date: Tue, 3 Jan 2023 20:57:29 +0800 Subject: [PATCH 03/10] esp_wifi: port coex adapter for esp32c6 --- components/esp_coex/CMakeLists.txt | 2 +- .../esp_coex/esp32c6/esp_coex_adapter.c | 131 ++++++++++++++++++ .../esp_coex/include/esp_modem_wrapper.h | 2 +- components/esp_wifi/esp32c6/esp_adapter.c | 121 ++-------------- 4 files changed, 144 insertions(+), 112 deletions(-) create mode 100644 components/esp_coex/esp32c6/esp_coex_adapter.c diff --git a/components/esp_coex/CMakeLists.txt b/components/esp_coex/CMakeLists.txt index 053068b1b8e..c6ec8dda9a4 100644 --- a/components/esp_coex/CMakeLists.txt +++ b/components/esp_coex/CMakeLists.txt @@ -20,7 +20,7 @@ endif() idf_component_register(SRCS "${srcs}" INCLUDE_DIRS "include" - PRIV_REQUIRES esp_timer driver + PRIV_REQUIRES esp_timer driver esp_event LDFRAGMENTS "${ldfragments}") if(CONFIG_SW_COEXIST_ENABLE OR CONFIG_EXTERNAL_COEX_ENABLE) diff --git a/components/esp_coex/esp32c6/esp_coex_adapter.c b/components/esp_coex/esp32c6/esp_coex_adapter.c new file mode 100644 index 00000000000..b3974dd32b2 --- /dev/null +++ b/components/esp_coex/esp32c6/esp_coex_adapter.c @@ -0,0 +1,131 @@ +/* + * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include +#include + +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "freertos/queue.h" +#include "freertos/semphr.h" +#include "freertos/portmacro.h" +#include "esp_heap_caps.h" +#include "esp_timer.h" +#include "soc/rtc.h" +#include "esp_private/esp_clk.h" +#include "esp_coexist_adapter.h" +#include "esp32c6/rom/ets_sys.h" + +#define TAG "esp_coex_adapter" + +#define OSI_FUNCS_TIME_BLOCKING 0xffffffff + +bool IRAM_ATTR env_is_chip_wrapper(void) +{ +#ifdef CONFIG_IDF_ENV_FPGA + return false; +#else + return true; +#endif +} + +void IRAM_ATTR task_yield_from_isr_wrapper(void) +{ + portYIELD_FROM_ISR(); +} + +void *semphr_create_wrapper(uint32_t max, uint32_t init) +{ + return (void *)xSemaphoreCreateCounting(max, init); +} + +void semphr_delete_wrapper(void *semphr) +{ + vSemaphoreDelete(semphr); +} + +int32_t IRAM_ATTR semphr_take_from_isr_wrapper(void *semphr, void *hptw) +{ + return (int32_t)xSemaphoreTakeFromISR(semphr, hptw); +} + +int32_t IRAM_ATTR semphr_give_from_isr_wrapper(void *semphr, void *hptw) +{ + return (int32_t)xSemaphoreGiveFromISR(semphr, hptw); +} + +int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick) +{ + if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) { + return (int32_t)xSemaphoreTake(semphr, portMAX_DELAY); + } else { + return (int32_t)xSemaphoreTake(semphr, block_time_tick); + } +} + +int32_t semphr_give_wrapper(void *semphr) +{ + return (int32_t)xSemaphoreGive(semphr); +} + +void IRAM_ATTR timer_disarm_wrapper(void *timer) +{ + ets_timer_disarm(timer); +} + +void timer_done_wrapper(void *ptimer) +{ + ets_timer_done(ptimer); +} + +void timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg) +{ + ets_timer_setfn(ptimer, pfunction, parg); +} + +void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat) +{ + ets_timer_arm_us(ptimer, us, repeat); +} + +uint32_t esp_clk_slowclk_cal_get_wrapper(void) +{ + /* The bit width of WiFi light sleep clock calibration is 12 while the one of + * system is 19. It should shift 19 - 12 = 7. + */ + return (esp_clk_slowclk_cal_get() >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH)); +} + +void *IRAM_ATTR malloc_internal_wrapper(size_t size) +{ + return heap_caps_malloc(size, MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL); +} + +coex_adapter_funcs_t g_coex_adapter_funcs = { + ._version = COEX_ADAPTER_VERSION, + ._task_yield_from_isr = task_yield_from_isr_wrapper, + ._semphr_create = semphr_create_wrapper, + ._semphr_delete = semphr_delete_wrapper, + ._semphr_take_from_isr = semphr_take_from_isr_wrapper, + ._semphr_give_from_isr = semphr_give_from_isr_wrapper, + ._semphr_take = semphr_take_wrapper, + ._semphr_give = semphr_give_wrapper, + ._is_in_isr = xPortInIsrContext, + ._malloc_internal = malloc_internal_wrapper, + ._free = free, + ._esp_timer_get_time = esp_timer_get_time, + ._env_is_chip = env_is_chip_wrapper, + ._slowclk_cal_get = esp_clk_slowclk_cal_get_wrapper, + ._timer_disarm = timer_disarm_wrapper, + ._timer_done = timer_done_wrapper, + ._timer_setfn = timer_setfn_wrapper, + ._timer_arm_us = timer_arm_us_wrapper, + ._magic = COEX_ADAPTER_MAGIC, +}; diff --git a/components/esp_coex/include/esp_modem_wrapper.h b/components/esp_coex/include/esp_modem_wrapper.h index c9277bdf9b6..606d6c42acc 100644 --- a/components/esp_coex/include/esp_modem_wrapper.h +++ b/components/esp_coex/include/esp_modem_wrapper.h @@ -65,7 +65,7 @@ void timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat); void * malloc_internal_wrapper(size_t size); -#if CONFIG_IDF_TARGET_ESP32C2 +#if CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C6 bool env_is_chip_wrapper(void); uint32_t esp_clk_slowclk_cal_get_wrapper(void); diff --git a/components/esp_wifi/esp32c6/esp_adapter.c b/components/esp_wifi/esp32c6/esp_adapter.c index 76eb31bd0b3..2b2da560f99 100644 --- a/components/esp_wifi/esp32c6/esp_adapter.c +++ b/components/esp_wifi/esp32c6/esp_adapter.c @@ -40,8 +40,8 @@ #include "os.h" #include "esp_smartconfig.h" #include "esp_coexist_internal.h" -#include "esp_coexist_adapter.h" #include "esp32c6/rom/ets_sys.h" +#include "esp_modem_wrapper.h" #define TAG "esp_adapter" @@ -102,15 +102,6 @@ static void wifi_delete_queue_wrapper(void *queue) wifi_delete_queue(queue); } -static bool IRAM_ATTR env_is_chip_wrapper(void) -{ -#ifdef CONFIG_IDF_ENV_FPGA - return false; -#else - return true; -#endif -} - static void set_intr_wrapper(int32_t cpu_no, uint32_t intr_source, uint32_t intr_num, int32_t intr_prio) { intr_matrix_route(intr_source, intr_num); @@ -175,21 +166,6 @@ static bool IRAM_ATTR is_from_isr_wrapper(void) return !xPortCanYield(); } -static void IRAM_ATTR task_yield_from_isr_wrapper(void) -{ - portYIELD_FROM_ISR(); -} - -static void *semphr_create_wrapper(uint32_t max, uint32_t init) -{ - return (void *)xSemaphoreCreateCounting(max, init); -} - -static void semphr_delete_wrapper(void *semphr) -{ - vSemaphoreDelete(semphr); -} - static void wifi_thread_semphr_free(void *data) { SemaphoreHandle_t *sem = (SemaphoreHandle_t *)(data); @@ -225,30 +201,6 @@ static void *wifi_thread_semphr_get_wrapper(void) return (void *)sem; } -static int32_t IRAM_ATTR semphr_take_from_isr_wrapper(void *semphr, void *hptw) -{ - return (int32_t)xSemaphoreTakeFromISR(semphr, hptw); -} - -static int32_t IRAM_ATTR semphr_give_from_isr_wrapper(void *semphr, void *hptw) -{ - return (int32_t)xSemaphoreGiveFromISR(semphr, hptw); -} - -static int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick) -{ - if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) { - return (int32_t)xSemaphoreTake(semphr, portMAX_DELAY); - } else { - return (int32_t)xSemaphoreTake(semphr, block_time_tick); - } -} - -static int32_t semphr_give_wrapper(void *semphr) -{ - return (int32_t)xSemaphoreGive(semphr); -} - static void *recursive_mutex_create_wrapper(void) { return (void *)xSemaphoreCreateRecursiveMutex(); @@ -369,26 +321,6 @@ static void IRAM_ATTR timer_arm_wrapper(void *timer, uint32_t tmout, bool repeat ets_timer_arm(timer, tmout, repeat); } -static void IRAM_ATTR timer_disarm_wrapper(void *timer) -{ - ets_timer_disarm(timer); -} - -static void timer_done_wrapper(void *ptimer) -{ - ets_timer_done(ptimer); -} - -static void timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg) -{ - ets_timer_setfn(ptimer, pfunction, parg); -} - -static void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat) -{ - ets_timer_arm_us(ptimer, us, repeat); -} - static void wifi_reset_mac_wrapper(void) { // TODO: IDF-5713 @@ -422,19 +354,6 @@ static int get_time_wrapper(void *t) return os_get_time(t); } -static uint32_t esp_clk_slowclk_cal_get_wrapper(void) -{ - /* The bit width of WiFi light sleep clock calibration is 12 while the one of - * system is 19. It should shift 19 - 12 = 7. - */ - return (esp_clk_slowclk_cal_get() >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH)); -} - -static void *IRAM_ATTR malloc_internal_wrapper(size_t size) -{ - return heap_caps_malloc(size, MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL); -} - static void *IRAM_ATTR realloc_internal_wrapper(void *ptr, size_t size) { return heap_caps_realloc(ptr, size, MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL); @@ -617,28 +536,28 @@ static void *coex_schm_curr_phase_get_wrapper(void) #endif } -static int coex_schm_curr_phase_idx_set_wrapper(int idx) +static int coex_register_start_cb_wrapper(int (* cb)(void)) { -#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE - return coex_schm_curr_phase_idx_set(idx); +#if CONFIG_SW_COEXIST_ENABLE + return coex_register_start_cb(cb); #else return 0; #endif } -static int coex_schm_curr_phase_idx_get_wrapper(void) +static int coex_schm_process_restart_wrapper(void) { -#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE - return coex_schm_curr_phase_idx_get(); +#if CONFIG_SW_COEXIST_ENABLE + return coex_schm_process_restart(); #else return 0; #endif } -static int coex_register_start_cb_wrapper(int (* cb)(void)) +static int coex_schm_register_cb_wrapper(int type, void(*cb)(int)) { #if CONFIG_SW_COEXIST_ENABLE - return coex_register_start_cb(cb); + return coex_schm_register_callback(type, cb); #else return 0; #endif @@ -763,8 +682,6 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._coex_schm_interval_get = coex_schm_interval_get_wrapper, ._coex_schm_curr_period_get = coex_schm_curr_period_get_wrapper, ._coex_schm_curr_phase_get = coex_schm_curr_phase_get_wrapper, - ._coex_schm_curr_phase_idx_set = coex_schm_curr_phase_idx_set_wrapper, - ._coex_schm_curr_phase_idx_get = coex_schm_curr_phase_idx_get_wrapper, ._coex_register_start_cb = coex_register_start_cb_wrapper, #if 0//CONFIG_IDF_TARGET_ESP32C6 // TODO: WIFI-5150 @@ -773,23 +690,7 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._sleep_retention_entries_create = (int (*)(const void *, int, int, int))sleep_retention_entries_create, ._sleep_retention_entries_destroy = sleep_retention_entries_destroy, #endif + ._coex_schm_process_restart = coex_schm_process_restart_wrapper, + ._coex_schm_register_cb = coex_schm_register_cb_wrapper, ._magic = ESP_WIFI_OS_ADAPTER_MAGIC, }; - -coex_adapter_funcs_t g_coex_adapter_funcs = { - ._version = COEX_ADAPTER_VERSION, - ._task_yield_from_isr = task_yield_from_isr_wrapper, - ._semphr_create = semphr_create_wrapper, - ._semphr_delete = semphr_delete_wrapper, - ._semphr_take_from_isr = semphr_take_from_isr_wrapper, - ._semphr_give_from_isr = semphr_give_from_isr_wrapper, - ._semphr_take = semphr_take_wrapper, - ._semphr_give = semphr_give_wrapper, - ._is_in_isr = xPortInIsrContext, - ._malloc_internal = malloc_internal_wrapper, - ._free = free, - ._esp_timer_get_time = esp_timer_get_time, - ._env_is_chip = env_is_chip_wrapper, - ._slowclk_cal_get = esp_clk_slowclk_cal_get_wrapper, - ._magic = COEX_ADAPTER_MAGIC, -}; From 4697d85944f9c0b0b2956d369a97e47222ddcfc3 Mon Sep 17 00:00:00 2001 From: zhangwenxu Date: Mon, 9 Jan 2023 21:29:41 +0800 Subject: [PATCH 04/10] esp_coex: support i154 set coex pti --- components/esp_coex/Kconfig | 3 ++- .../esp_coex/include/esp_coexist_i154.h | 23 +++++++++++++++++++ components/esp_coex/lib | 2 +- components/esp_coex/test_md5/test_md5.sh | 13 +++++++---- 4 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 components/esp_coex/include/esp_coexist_i154.h diff --git a/components/esp_coex/Kconfig b/components/esp_coex/Kconfig index 894a77df767..ffb4f6e7177 100644 --- a/components/esp_coex/Kconfig +++ b/components/esp_coex/Kconfig @@ -4,7 +4,8 @@ menu "ESP-COEX" config ESP_WIFI_SW_COEXIST_ENABLE bool "Software controls WiFi/Bluetooth coexistence" - depends on ESP_WIFI_ENABLED && BT_ENABLED + depends on (ESP_WIFI_ENABLED && BT_ENABLED) || \ + (ESP_WIFI_ENABLED && IEEE802154_ENABLED) default y select ESP_WIFI_STA_DISCONNECTED_PM_ENABLE help diff --git a/components/esp_coex/include/esp_coexist_i154.h b/components/esp_coex/include/esp_coexist_i154.h new file mode 100644 index 00000000000..4359b9b7035 --- /dev/null +++ b/components/esp_coex/include/esp_coexist_i154.h @@ -0,0 +1,23 @@ +/* + * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef __COEXIST_I154_H__ +#define __COEXIST_I154_H__ + +#ifdef SOC_IEEE802154_SUPPORTED +typedef enum { + IEEE802154_RISK_TX = 1, + IEEE802154_TX_AT, + IEEE802154_RX_AT, + IEEE802154_ACK, + IEEE802154_NORMAL, + IEEE802154_IDLE_RX, + IEEE802154_EVENT_MAX, +} ieee802154_coex_event_t; + +void esp_ieee802154_coex_pti_set(ieee802154_coex_event_t event); +#endif + +#endif diff --git a/components/esp_coex/lib b/components/esp_coex/lib index 22df5f00640..403b94e8e06 160000 --- a/components/esp_coex/lib +++ b/components/esp_coex/lib @@ -1 +1 @@ -Subproject commit 22df5f006409c215a6856c954eb3d32d19ec8fdc +Subproject commit 403b94e8e0691942ea0fb5ee54310d0089b15b3a diff --git a/components/esp_coex/test_md5/test_md5.sh b/components/esp_coex/test_md5/test_md5.sh index 96874832d9a..0ce478026f8 100755 --- a/components/esp_coex/test_md5/test_md5.sh +++ b/components/esp_coex/test_md5/test_md5.sh @@ -22,7 +22,7 @@ case $IDF_TARGET in esp32s3) PREFIX=xtensa-esp32s3-elf- ;; - esp32c3) + esp32c2|esp32c3|esp32c6) PREFIX=riscv32-esp-elf- ;; *) @@ -34,10 +34,6 @@ LIB_DIR=${IDF_TARGET} ELF_FILE=test.elf -${PREFIX}ld --unresolved-symbols=ignore-all --entry 0 -o ${ELF_FILE} \ - -u g_coex_adapter_funcs_md5 \ - ${IDF_PATH}/components/esp_coex/lib/${LIB_DIR}/*.a - FAILURES=0 function check_md5() @@ -45,6 +41,9 @@ function check_md5() FILENAME=$1 SYMBOL=$2 + ${PREFIX}ld --unresolved-symbols=ignore-all --entry 0 -o ${ELF_FILE} \ + -u ${SYMBOL} \ + ${IDF_PATH}/components/esp_coex/lib/${LIB_DIR}/*.a GDB_COMMAND="printf \"%s\\n\", (const char*) ${SYMBOL}" MD5_FROM_LIB=$(${PREFIX}gdb -n -batch ${ELF_FILE} -ex "${GDB_COMMAND}") MD5_FROM_HEADER=$(md5sum ${FILENAME} | cut -c 1-7) @@ -61,6 +60,10 @@ function check_md5() echo "Checking libraries for target ${IDF_TARGET}..." check_md5 ${IDF_PATH}/components/esp_coex/include/esp_coexist_adapter.h g_coex_adapter_funcs_md5 +if [ "${IDF_TARGET}" == "esp32c6" ]; then + check_md5 ${IDF_PATH}/components/esp_coex/include/esp_coexist_i154.h g_coex_i154_funcs_md5 +fi + if [ $FAILURES -gt 0 ]; then exit 1 fi From 7817c236233a2128eaf71ee4a31fee575d201af2 Mon Sep 17 00:00:00 2001 From: liuning Date: Tue, 14 Feb 2023 21:20:55 +0800 Subject: [PATCH 05/10] esp_coex: correct Kconfig name --- components/esp_coex/CMakeLists.txt | 21 +++----- components/esp_coex/Kconfig | 10 ++-- .../{esp_coexist_i154.h => esp_coex_i154.h} | 4 +- .../esp_coex/include/esp_modem_wrapper.h | 18 +------ components/esp_coex/sdkconfig.rename | 53 ++----------------- components/esp_coex/test_md5/test_md5.sh | 2 +- components/esp_wifi/sdkconfig.rename | 47 ++++++++++++++++ docs/en/api-guides/coexist.rst | 2 +- docs/zh_CN/api-guides/coexist.rst | 2 +- tools/ci/check_public_headers_exceptions.txt | 4 +- 10 files changed, 72 insertions(+), 91 deletions(-) rename components/esp_coex/include/{esp_coexist_i154.h => esp_coex_i154.h} (79%) create mode 100644 components/esp_wifi/sdkconfig.rename diff --git a/components/esp_coex/CMakeLists.txt b/components/esp_coex/CMakeLists.txt index c6ec8dda9a4..37f496a6321 100644 --- a/components/esp_coex/CMakeLists.txt +++ b/components/esp_coex/CMakeLists.txt @@ -1,6 +1,6 @@ idf_build_get_property(idf_target IDF_TARGET) -if(CONFIG_SW_COEXIST_ENABLE OR CONFIG_EXTERNAL_COEX_ENABLE) +if(CONFIG_ESP_COEX_SW_COEXIST_ENABLE OR CONFIG_ESP_COEX_EXTERNAL_COEXIST_ENABLE) if(CONFIG_APP_NO_BLOBS) set(link_binary_libs 0) set(ldfragments) @@ -14,7 +14,7 @@ if(CONFIG_SW_COEXIST_ENABLE OR CONFIG_EXTERNAL_COEX_ENABLE) "${idf_target}/esp_coex_adapter.c") endif() -if(CONFIG_ESP32_WIFI_ENABLED) +if(CONFIG_ESP_WIFI_ENABLED) list(APPEND srcs "${idf_target}/esp_coex_adapter.c") endif() @@ -23,23 +23,18 @@ idf_component_register(SRCS "${srcs}" PRIV_REQUIRES esp_timer driver esp_event LDFRAGMENTS "${ldfragments}") -if(CONFIG_SW_COEXIST_ENABLE OR CONFIG_EXTERNAL_COEX_ENABLE) +if(CONFIG_ESP_COEX_SW_COEXIST_ENABLE OR CONFIG_ESP_COEX_EXTERNAL_COEXIST_ENABLE) idf_build_get_property(build_dir BUILD_DIR) set(target_name "${idf_target}") target_link_directories(${COMPONENT_LIB} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/lib/${target_name}") if(link_binary_libs) - set(blobs coexist) - - foreach(blob ${blobs}) - add_prebuilt_library(${blob} "${CMAKE_CURRENT_SOURCE_DIR}/lib/${target_name}/lib${blob}.a" - REQUIRES ${COMPONENT_NAME}) - set(blob_reqs ${blobs}) - list(REMOVE_ITEM blob_reqs ${blob}) # remove itself from requirements - set_property(TARGET ${blob} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${blob_reqs}) - target_link_libraries(${COMPONENT_LIB} PUBLIC ${blob}) - endforeach() + set(blob coexist) + + add_prebuilt_library(${blob} "${CMAKE_CURRENT_SOURCE_DIR}/lib/${target_name}/lib${blob}.a" + REQUIRES ${COMPONENT_NAME}) + target_link_libraries(${COMPONENT_LIB} PUBLIC ${blob}) endif() target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/esp_coex/Kconfig b/components/esp_coex/Kconfig index ffb4f6e7177..909aef0c899 100644 --- a/components/esp_coex/Kconfig +++ b/components/esp_coex/Kconfig @@ -1,8 +1,6 @@ -menu "ESP-COEX" - visible if !IDF_TARGET_ESP32H4 - - config ESP_WIFI_SW_COEXIST_ENABLE +menu "Wireless Coexistence" + config ESP_COEX_SW_COEXIST_ENABLE bool "Software controls WiFi/Bluetooth coexistence" depends on (ESP_WIFI_ENABLED && BT_ENABLED) || \ (ESP_WIFI_ENABLED && IEEE802154_ENABLED) @@ -15,8 +13,8 @@ menu "ESP-COEX" If only Bluetooth is used, it is recommended to disable this option to reduce binary file size. - config ESP_WIFI_EXTERNAL_COEXIST_ENABLE - bool "WiFi External Coexistence" + config ESP_COEX_EXTERNAL_COEXIST_ENABLE + bool "External Coexistence" default n depends on (!(BT_ENABLED||NIMBLE_ENABLED)&&(!IDF_TARGET_ESP32)) help diff --git a/components/esp_coex/include/esp_coexist_i154.h b/components/esp_coex/include/esp_coex_i154.h similarity index 79% rename from components/esp_coex/include/esp_coexist_i154.h rename to components/esp_coex/include/esp_coex_i154.h index 4359b9b7035..9385a10c60a 100644 --- a/components/esp_coex/include/esp_coexist_i154.h +++ b/components/esp_coex/include/esp_coex_i154.h @@ -6,7 +6,7 @@ #ifndef __COEXIST_I154_H__ #define __COEXIST_I154_H__ -#ifdef SOC_IEEE802154_SUPPORTED +#ifdef CONFIG_SOC_IEEE802154_SUPPORTED typedef enum { IEEE802154_RISK_TX = 1, IEEE802154_TX_AT, @@ -17,7 +17,7 @@ typedef enum { IEEE802154_EVENT_MAX, } ieee802154_coex_event_t; -void esp_ieee802154_coex_pti_set(ieee802154_coex_event_t event); +void esp_coex_ieee802154_pti_set(ieee802154_coex_event_t event); #endif #endif diff --git a/components/esp_coex/include/esp_modem_wrapper.h b/components/esp_coex/include/esp_modem_wrapper.h index 606d6c42acc..464b05f60d0 100644 --- a/components/esp_coex/include/esp_modem_wrapper.h +++ b/components/esp_coex/include/esp_modem_wrapper.h @@ -25,22 +25,7 @@ void wifi_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp); void task_yield_from_isr_wrapper(void); -#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 - -void *internal_semphr_create_wrapper(uint32_t max, uint32_t init); - -void internal_semphr_delete_wrapper(void *semphr); - -int32_t internal_semphr_take_from_isr_wrapper(void *semphr, void *hptw); - -int32_t internal_semphr_give_from_isr_wrapper(void *semphr, void *hptw); - -int32_t internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick); - -int32_t internal_semphr_give_wrapper(void *semphr); - -#else - +#if !defined(CONFIG_IDF_TARGET_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32S3) void * semphr_create_wrapper(uint32_t max, uint32_t init); void semphr_delete_wrapper(void *semphr); @@ -52,7 +37,6 @@ int32_t semphr_give_from_isr_wrapper(void *semphr, void *hptw); int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick); int32_t semphr_give_wrapper(void *semphr); - #endif void timer_disarm_wrapper(void *timer); diff --git a/components/esp_coex/sdkconfig.rename b/components/esp_coex/sdkconfig.rename index 13c24f78efc..26d54404c68 100644 --- a/components/esp_coex/sdkconfig.rename +++ b/components/esp_coex/sdkconfig.rename @@ -1,52 +1,9 @@ # sdkconfig replacement configurations for deprecated options formatted as # CONFIG_DEPRECATED_OPTION CONFIG_NEW_OPTION -CONFIG_SW_COEXIST_ENABLE CONFIG_ESP_WIFI_SW_COEXIST_ENABLE -CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE CONFIG_ESP_WIFI_SW_COEXIST_ENABLE -CONFIG_EXTERNAL_COEX_ENABLE CONFIG_ESP_WIFI_EXTERNAL_COEXIST_ENABLE +CONFIG_SW_COEXIST_ENABLE CONFIG_ESP_COEX_SW_COEXIST_ENABLE +CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE CONFIG_ESP_COEX_SW_COEXIST_ENABLE +CONFIG_ESP_WIFI_SW_COEXIST_ENABLE CONFIG_ESP_COEX_SW_COEXIST_ENABLE -# renaming of esp_wifi kconfig options -CONFIG_ESP32_WIFI_ENABLED CONFIG_ESP_WIFI_ENABLED -CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE CONFIG_ESP_WIFI_SW_COEXIST_ENABLE -CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM -CONFIG_ESP32_WIFI_RX_BA_WIN CONFIG_ESP_WIFI_RX_BA_WIN -CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED CONFIG_ESP_WIFI_AMPDU_RX_ENABLED -CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM -CONFIG_ESP32_WIFI_TX_BUFFER CONFIG_ESP_WIFI_TX_BUFFER -CONFIG_ESP32_WIFI_STATIC_TX_BUFFER CONFIG_ESP_WIFI_STATIC_TX_BUFFER -CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER -CONFIG_ESP32_WIFI_TX_BUFFER_TYPE CONFIG_ESP_WIFI_TX_BUFFER_TYPE -CONFIG_ESP32_WIFI_STATIC_TX_BUFFER_NUM CONFIG_ESP_WIFI_STATIC_TX_BUFFER_NUM -CONFIG_ESP32_WIFI_CACHE_TX_BUFFER_NUM CONFIG_ESP_WIFI_CACHE_TX_BUFFER_NUM -CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM -CONFIG_ESP32_WIFI_CSI_ENABLED CONFIG_ESP_WIFI_CSI_ENABLED -CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED CONFIG_ESP_WIFI_AMPDU_TX_ENABLED -CONFIG_ESP32_WIFI_TX_BA_WIN CONFIG_ESP_WIFI_TX_BA_WIN -CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED CONFIG_ESP_WIFI_AMPDU_RX_ENABLED -CONFIG_ESP32_WIFI_RX_BA_WIN CONFIG_ESP_WIFI_RX_BA_WIN -CONFIG_ESP32_WIFI_AMSDU_TX_ENABLED CONFIG_ESP_WIFI_AMSDU_TX_ENABLED -CONFIG_ESP32_WIFI_NVS_ENABLED CONFIG_ESP_WIFI_NVS_ENABLED -CONFIG_ESP32_WIFI_TASK_CORE_ID CONFIG_ESP_WIFI_TASK_CORE_ID -CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0 CONFIG_ESP_WIFI_TASK_PINNED_TO_CORE_0 -CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1 CONFIG_ESP_WIFI_TASK_PINNED_TO_CORE_1 -CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN CONFIG_ESP_WIFI_SOFTAP_BEACON_MAX_LEN -CONFIG_ESP32_WIFI_MGMT_SBUF_NUM CONFIG_ESP_WIFI_MGMT_SBUF_NUM -CONFIG_ESP32_WIFI_IRAM_OPT CONFIG_ESP_WIFI_IRAM_OPT -CONFIG_ESP32_WIFI_RX_IRAM_OPT CONFIG_ESP_WIFI_RX_IRAM_OPT -CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE CONFIG_ESP_WIFI_ENABLE_WPA3_SAE -CONFIG_ESP32_WIFI_ENABLE_WPA3_OWE_STA CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA - -# renaming supplicant kconfig to esp_wifi kconfig -CONFIG_WPA_MBEDTLS_CRYPTO CONFIG_ESP_WIFI_MBEDTLS_CRYPTO -CONFIG_WPA_MBEDTLS_TLS_CLIENT CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT -CONFIG_WPA_WAPI_PSK CONFIG_ESP_WIFI_WAPI_PSK -CONFIG_WPA_SUITE_B_192 CONFIG_ESP_WIFI_SUITE_B_192 -CONFIG_WPA_DEBUG_PRINT CONFIG_ESP_WIFI_DEBUG_PRINT -CONFIG_WPA_TESTING_OPTIONS CONFIG_ESP_WIFI_TESTING_OPTIONS -CONFIG_WPA_WPS_STRICT CONFIG_ESP_WIFI_WPS_STRICT -CONFIG_WPA_11KV_SUPPORT CONFIG_ESP_WIFI_11KV_SUPPORT -CONFIG_WPA_SCAN_CACHE CONFIG_ESP_WIFI_SCAN_CACHE -CONFIG_WPA_MBO_SUPPORT CONFIG_ESP_WIFI_MBO_SUPPORT -CONFIG_WPA_DPP_SUPPORT CONFIG_ESP_WIFI_DPP_SUPPORT -CONFIG_WPA_11R_SUPPORT CONFIG_ESP_WIFI_11R_SUPPORT -CONFIG_WPA_WPS_SOFTAP_REGISTRAR CONFIG_ESP_WIFI_WPS_SOFTAP_REGISTRAR +CONFIG_EXTERNAL_COEX_ENABLE CONFIG_ESP_COEX_EXTERNAL_COEXIST_ENABLE +CONFIG_ESP_WIFI_EXTERNAL_COEXIST_ENABLE CONFIG_ESP_COEX_EXTERNAL_COEXIST_ENABLE diff --git a/components/esp_coex/test_md5/test_md5.sh b/components/esp_coex/test_md5/test_md5.sh index 0ce478026f8..f60c8783457 100755 --- a/components/esp_coex/test_md5/test_md5.sh +++ b/components/esp_coex/test_md5/test_md5.sh @@ -61,7 +61,7 @@ echo "Checking libraries for target ${IDF_TARGET}..." check_md5 ${IDF_PATH}/components/esp_coex/include/esp_coexist_adapter.h g_coex_adapter_funcs_md5 if [ "${IDF_TARGET}" == "esp32c6" ]; then - check_md5 ${IDF_PATH}/components/esp_coex/include/esp_coexist_i154.h g_coex_i154_funcs_md5 + check_md5 ${IDF_PATH}/components/esp_coex/include/esp_coex_i154.h g_coex_i154_funcs_md5 fi if [ $FAILURES -gt 0 ]; then diff --git a/components/esp_wifi/sdkconfig.rename b/components/esp_wifi/sdkconfig.rename new file mode 100644 index 00000000000..d6c1642ce21 --- /dev/null +++ b/components/esp_wifi/sdkconfig.rename @@ -0,0 +1,47 @@ +# sdkconfig replacement configurations for deprecated options formatted as +# CONFIG_DEPRECATED_OPTION CONFIG_NEW_OPTION + +# renaming of esp_wifi kconfig options +CONFIG_ESP32_WIFI_ENABLED CONFIG_ESP_WIFI_ENABLED +CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM +CONFIG_ESP32_WIFI_RX_BA_WIN CONFIG_ESP_WIFI_RX_BA_WIN +CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED CONFIG_ESP_WIFI_AMPDU_RX_ENABLED +CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM +CONFIG_ESP32_WIFI_TX_BUFFER CONFIG_ESP_WIFI_TX_BUFFER +CONFIG_ESP32_WIFI_STATIC_TX_BUFFER CONFIG_ESP_WIFI_STATIC_TX_BUFFER +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER +CONFIG_ESP32_WIFI_TX_BUFFER_TYPE CONFIG_ESP_WIFI_TX_BUFFER_TYPE +CONFIG_ESP32_WIFI_STATIC_TX_BUFFER_NUM CONFIG_ESP_WIFI_STATIC_TX_BUFFER_NUM +CONFIG_ESP32_WIFI_CACHE_TX_BUFFER_NUM CONFIG_ESP_WIFI_CACHE_TX_BUFFER_NUM +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM +CONFIG_ESP32_WIFI_CSI_ENABLED CONFIG_ESP_WIFI_CSI_ENABLED +CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED CONFIG_ESP_WIFI_AMPDU_TX_ENABLED +CONFIG_ESP32_WIFI_TX_BA_WIN CONFIG_ESP_WIFI_TX_BA_WIN +CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED CONFIG_ESP_WIFI_AMPDU_RX_ENABLED +CONFIG_ESP32_WIFI_RX_BA_WIN CONFIG_ESP_WIFI_RX_BA_WIN +CONFIG_ESP32_WIFI_AMSDU_TX_ENABLED CONFIG_ESP_WIFI_AMSDU_TX_ENABLED +CONFIG_ESP32_WIFI_NVS_ENABLED CONFIG_ESP_WIFI_NVS_ENABLED +CONFIG_ESP32_WIFI_TASK_CORE_ID CONFIG_ESP_WIFI_TASK_CORE_ID +CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0 CONFIG_ESP_WIFI_TASK_PINNED_TO_CORE_0 +CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1 CONFIG_ESP_WIFI_TASK_PINNED_TO_CORE_1 +CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN CONFIG_ESP_WIFI_SOFTAP_BEACON_MAX_LEN +CONFIG_ESP32_WIFI_MGMT_SBUF_NUM CONFIG_ESP_WIFI_MGMT_SBUF_NUM +CONFIG_ESP32_WIFI_IRAM_OPT CONFIG_ESP_WIFI_IRAM_OPT +CONFIG_ESP32_WIFI_RX_IRAM_OPT CONFIG_ESP_WIFI_RX_IRAM_OPT +CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE CONFIG_ESP_WIFI_ENABLE_WPA3_SAE +CONFIG_ESP32_WIFI_ENABLE_WPA3_OWE_STA CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA + +# renaming supplicant kconfig to esp_wifi kconfig +CONFIG_WPA_MBEDTLS_CRYPTO CONFIG_ESP_WIFI_MBEDTLS_CRYPTO +CONFIG_WPA_MBEDTLS_TLS_CLIENT CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT +CONFIG_WPA_WAPI_PSK CONFIG_ESP_WIFI_WAPI_PSK +CONFIG_WPA_SUITE_B_192 CONFIG_ESP_WIFI_SUITE_B_192 +CONFIG_WPA_DEBUG_PRINT CONFIG_ESP_WIFI_DEBUG_PRINT +CONFIG_WPA_TESTING_OPTIONS CONFIG_ESP_WIFI_TESTING_OPTIONS +CONFIG_WPA_WPS_STRICT CONFIG_ESP_WIFI_WPS_STRICT +CONFIG_WPA_11KV_SUPPORT CONFIG_ESP_WIFI_11KV_SUPPORT +CONFIG_WPA_SCAN_CACHE CONFIG_ESP_WIFI_SCAN_CACHE +CONFIG_WPA_MBO_SUPPORT CONFIG_ESP_WIFI_MBO_SUPPORT +CONFIG_WPA_DPP_SUPPORT CONFIG_ESP_WIFI_DPP_SUPPORT +CONFIG_WPA_11R_SUPPORT CONFIG_ESP_WIFI_11R_SUPPORT +CONFIG_WPA_WPS_SOFTAP_REGISTRAR CONFIG_ESP_WIFI_WPS_SOFTAP_REGISTRAR diff --git a/docs/en/api-guides/coexist.rst b/docs/en/api-guides/coexist.rst index 0f6bdb2e65a..e560f48e75a 100644 --- a/docs/en/api-guides/coexist.rst +++ b/docs/en/api-guides/coexist.rst @@ -194,7 +194,7 @@ Setting Coexistence Compile-time Options .. list:: - - After writing the coexistence program, you must check :ref:`CONFIG_ESP_WIFI_SW_COEXIST_ENABLE` option through menuconfig to open coexistence configuration on software, otherwise the coexistence function mentioned above cannot be used. + - After writing the coexistence program, you must check :ref:`CONFIG_ESP_COEX_SW_COEXIST_ENABLE` option through menuconfig to open coexistence configuration on software, otherwise the coexistence function mentioned above cannot be used. :esp32: - To ensure better communication performance of Wi-Fi and Bluetooth in the case of coexistence, run the task of the Wi-Fi protocol stack, the task of the Bluetooth Controller and Host protocol stack on different CPUs. You can use :ref:`CONFIG_BTDM_CTRL_PINNED_TO_CORE_CHOICE` and :ref:`CONFIG_BT_BLUEDROID_PINNED_TO_CORE_CHOICE` (or :ref:`CONFIG_BT_NIMBLE_PINNED_TO_CORE_CHOICE`) to put the tasks of the Bluetooth controller and the host protocol stack on the same CPU, and then use :ref:`CONFIG_ESP_WIFI_TASK_CORE_ID` to place the task of the Wi-Fi protocol stack on another CPU. diff --git a/docs/zh_CN/api-guides/coexist.rst b/docs/zh_CN/api-guides/coexist.rst index c3738054ac5..74e6fc88e7e 100644 --- a/docs/zh_CN/api-guides/coexist.rst +++ b/docs/zh_CN/api-guides/coexist.rst @@ -194,7 +194,7 @@ BLE MESH 共存状态描述 .. list:: - - 在完成共存程序编写的时候,您必须通过 menuconfig 选择 :ref:`CONFIG_ESP_WIFI_SW_COEXIST_ENABLE` 打开软件共存配置选项,否则就无法使用上文中提到的共存功能。 + - 在完成共存程序编写的时候,您必须通过 menuconfig 选择 :ref:`CONFIG_ESP_COEX_SW_COEXIST_ENABLE` 打开软件共存配置选项,否则就无法使用上文中提到的共存功能。 :esp32: - 为了在共存情况下获得更好的 Wi-Fi 和蓝牙的通信性能,建议将 Wi-Fi 协议栈的 task 和蓝牙 Controller 以及 Host 协议栈的 task 运行在不同的 CPU 上。您可以通过 :ref:`CONFIG_BTDM_CTRL_PINNED_TO_CORE_CHOICE` 和 :ref:`CONFIG_BT_BLUEDROID_PINNED_TO_CORE_CHOICE` (或者 :ref:`CONFIG_BT_NIMBLE_PINNED_TO_CORE_CHOICE` )选择将蓝牙 controller 以及 host 协议栈的 task 放在同一个 CPU 上,再通过 :ref:`CONFIG_ESP_WIFI_TASK_CORE_ID` 选择将 Wi-Fi 协议栈 task 放在另一个 CPU 上。 diff --git a/tools/ci/check_public_headers_exceptions.txt b/tools/ci/check_public_headers_exceptions.txt index 3b68da343cb..b2a06e8e5ae 100644 --- a/tools/ci/check_public_headers_exceptions.txt +++ b/tools/ci/check_public_headers_exceptions.txt @@ -98,6 +98,8 @@ components/esp_hw_support/include/esp_private/esp_memprot_internal.h ### Here are the files that use CONFIG_XXX values but don't include sdkconfig.h # components/esp_wifi/include/esp_private/wifi_os_adapter.h +components/esp_coex/include/esp_coexist_adapter.h +components/esp_coex/include/esp_coex_i154.h ### To be fixed: headers that rely on implicit inclusion # components/esp_rom/include/esp32/rom/rtc.h @@ -118,11 +120,9 @@ components/esp_rom/include/esp32s2/rom/opi_flash.h components/esp_rom/include/esp32s2/rom/efuse.h components/esp_ringbuf/include/freertos/ringbuf.h components/esp_wifi/include/esp_wifi_crypto_types.h -components/esp_coex/include/esp_coexist_internal.h components/esp_wifi/include/esp_wifi_netif.h components/esp_wifi/include/smartconfig_ack.h components/esp_wifi/include/esp_wifi_default.h -components/esp_coex/include/esp_coexist_adapter.h components/esp_event/include/esp_event_base.h components/esp_netif/include/esp_netif_sta_list.h components/esp_netif/include/esp_netif_defaults.h From 1661694e0bbf16fa6023a813e3edc58971925de4 Mon Sep 17 00:00:00 2001 From: wangmengyang Date: Fri, 17 Feb 2023 13:03:29 +0800 Subject: [PATCH 06/10] bt: added coex adapter operation to get version of coexist module to ESP32 Bluetooth Controller --- components/bt/controller/esp32/bt.c | 29 ++++++++++++++++++++++++++++- components/bt/controller/lib_esp32 | 2 +- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/components/bt/controller/esp32/bt.c b/components/bt/controller/esp32/bt.c index 4cfda15174c..c7dd4dbb128 100644 --- a/components/bt/controller/esp32/bt.c +++ b/components/bt/controller/esp32/bt.c @@ -89,7 +89,7 @@ do{\ } while(0) #define OSI_FUNCS_TIME_BLOCKING 0xffffffff -#define OSI_VERSION 0x00010003 +#define OSI_VERSION 0x00010004 #define OSI_MAGIC_VALUE 0xFADEBEAD /* Types definition @@ -176,6 +176,7 @@ struct osi_funcs_t { void (*_interrupt_l3_disable)(void); void (*_interrupt_l3_restore)(void); void *(* _customer_queue_create)(uint32_t queue_len, uint32_t item_size); + int (* _coex_version_get)(unsigned int *major, unsigned int *minor, unsigned int *patch); uint32_t _magic; }; @@ -320,6 +321,7 @@ static uint8_t coex_schm_curr_period_get_wrapper(void); static void * coex_schm_curr_phase_get_wrapper(void); static int coex_wifi_channel_get_wrapper(uint8_t *primary, uint8_t *secondary); static int coex_register_wifi_channel_change_callback_wrapper(void *cb); +static int coex_version_get_wrapper(unsigned int *major, unsigned int *minor, unsigned int *patch); #if CONFIG_BTDM_CTRL_HLI static void *customer_queue_create_hlevel_wrapper(uint32_t queue_len, uint32_t item_size); #endif /* CONFIG_BTDM_CTRL_HLI */ @@ -412,6 +414,7 @@ static const struct osi_funcs_t osi_funcs_ro = { #else ._customer_queue_create = NULL, #endif /* CONFIG_BTDM_CTRL_HLI */ + ._coex_version_get = coex_version_get_wrapper, ._magic = OSI_MAGIC_VALUE, }; @@ -1231,6 +1234,30 @@ static int coex_register_wifi_channel_change_callback_wrapper(void *cb) #endif } +static int coex_version_get_wrapper(unsigned int *major, unsigned int *minor, unsigned int *patch) +{ +#if CONFIG_SW_COEXIST_ENABLE + const char *ver_str = esp_coex_version_get(); + if (ver_str != NULL) { + unsigned int _major = 0, _minor = 0, _patch = 0; + if (sscanf(ver_str, "%u.%u.%u", &_major, &_minor, &_patch) != 3) { + return -1; + } + if (major != NULL) { + *major = _major; + } + if (minor != NULL) { + *minor = _minor; + } + if (patch != NULL) { + *patch = _patch; + } + return 0; + } +#endif + return -1; +} + bool esp_vhci_host_check_send_available(void) { return API_vhci_host_check_send_available(); diff --git a/components/bt/controller/lib_esp32 b/components/bt/controller/lib_esp32 index f18eabd48cb..b867411caf8 160000 --- a/components/bt/controller/lib_esp32 +++ b/components/bt/controller/lib_esp32 @@ -1 +1 @@ -Subproject commit f18eabd48cb91d779e56e985512bf210741aa700 +Subproject commit b867411caf88b485b2fa8b6d272692b6535a267a From b3a040aa981991e64e2a10346b723347bbf06727 Mon Sep 17 00:00:00 2001 From: liuning Date: Fri, 17 Feb 2023 16:20:46 +0800 Subject: [PATCH 07/10] coex: apply new coex_schm_callback --- components/bt/controller/esp32/bt.c | 3 +-- components/esp_coex/include/esp_coexist_internal.h | 8 +++++++- components/esp_wifi/esp32/esp_adapter.c | 2 +- components/esp_wifi/esp32c2/esp_adapter.c | 2 +- components/esp_wifi/esp32c3/esp_adapter.c | 2 +- components/esp_wifi/esp32c6/esp_adapter.c | 2 +- components/esp_wifi/esp32s2/esp_adapter.c | 2 +- components/esp_wifi/esp32s3/esp_adapter.c | 2 +- components/esp_wifi/include/esp_private/wifi_os_adapter.h | 2 +- 9 files changed, 15 insertions(+), 10 deletions(-) diff --git a/components/bt/controller/esp32/bt.c b/components/bt/controller/esp32/bt.c index c7dd4dbb128..ba6265378a5 100644 --- a/components/bt/controller/esp32/bt.c +++ b/components/bt/controller/esp32/bt.c @@ -225,7 +225,7 @@ extern int coex_bt_release(uint32_t event); extern int coex_register_bt_cb(coex_func_cb_t cb); extern uint32_t coex_bb_reset_lock(void); extern void coex_bb_reset_unlock(uint32_t restore); -extern int coex_schm_register_callback(int type, void *callback); +extern int coex_schm_register_callback(coex_schm_callback_type_t type, void *callback); extern void coex_schm_status_bit_clear(uint32_t type, uint32_t status); extern void coex_schm_status_bit_set(uint32_t type, uint32_t status); extern uint32_t coex_schm_interval_get(void); @@ -1168,7 +1168,6 @@ static void IRAM_ATTR coex_bb_reset_unlock_wrapper(uint32_t restore) static int coex_schm_register_btdm_callback_wrapper(void *callback) { #if CONFIG_SW_COEXIST_ENABLE -#define COEX_SCHM_CALLBACK_TYPE_BT 0x1 return coex_schm_register_callback(COEX_SCHM_CALLBACK_TYPE_BT, callback); #else return 0; diff --git a/components/esp_coex/include/esp_coexist_internal.h b/components/esp_coex/include/esp_coexist_internal.h index fadb38c9398..9de4f37a5c6 100644 --- a/components/esp_coex/include/esp_coexist_internal.h +++ b/components/esp_coex/include/esp_coexist_internal.h @@ -22,6 +22,12 @@ typedef enum { COEX_PREFER_NUM, } coex_prefer_t; +typedef enum { + COEX_SCHM_CALLBACK_TYPE_WIFI = 0, + COEX_SCHM_CALLBACK_TYPE_BT, + COEX_SCHM_CALLBACK_TYPE_I154, +} coex_schm_callback_type_t; + typedef void (* coex_func_cb_t)(uint32_t event, int sched_cnt); typedef esp_err_t (* coex_set_lpclk_source_callback_t)(void); @@ -230,7 +236,7 @@ int coex_schm_process_restart(void); * @param callback : callback * @return : 0 - success, other - failed */ -int coex_schm_register_callback(int type, void *callback); +int coex_schm_register_callback(coex_schm_callback_type_t type, void *callback); /** * @brief Register coexistence adapter functions. diff --git a/components/esp_wifi/esp32/esp_adapter.c b/components/esp_wifi/esp32/esp_adapter.c index b2ab1f06748..2e0cba008a8 100644 --- a/components/esp_wifi/esp32/esp_adapter.c +++ b/components/esp_wifi/esp32/esp_adapter.c @@ -573,7 +573,7 @@ static int coex_schm_process_restart_wrapper(void) #endif } -static int coex_schm_register_cb_wrapper(int type, void(*cb)(int)) +static int coex_schm_register_cb_wrapper(int type, int(*cb)(int)) { #if CONFIG_SW_COEXIST_ENABLE return coex_schm_register_callback(type, cb); diff --git a/components/esp_wifi/esp32c2/esp_adapter.c b/components/esp_wifi/esp32c2/esp_adapter.c index 3906026e56e..3bd74dcc575 100644 --- a/components/esp_wifi/esp32c2/esp_adapter.c +++ b/components/esp_wifi/esp32c2/esp_adapter.c @@ -556,7 +556,7 @@ static int coex_schm_process_restart_wrapper(void) #endif } -static int coex_schm_register_cb_wrapper(int type, void(*cb)(int)) +static int coex_schm_register_cb_wrapper(int type, int(*cb)(int)) { #if CONFIG_SW_COEXIST_ENABLE return coex_schm_register_callback(type, cb); diff --git a/components/esp_wifi/esp32c3/esp_adapter.c b/components/esp_wifi/esp32c3/esp_adapter.c index 04e8b573598..ff94d9c37d6 100644 --- a/components/esp_wifi/esp32c3/esp_adapter.c +++ b/components/esp_wifi/esp32c3/esp_adapter.c @@ -581,7 +581,7 @@ static int coex_schm_process_restart_wrapper(void) #endif } -static int coex_schm_register_cb_wrapper(int type, void(*cb)(int)) +static int coex_schm_register_cb_wrapper(int type, int(*cb)(int)) { #if CONFIG_SW_COEXIST_ENABLE return coex_schm_register_callback(type, cb); diff --git a/components/esp_wifi/esp32c6/esp_adapter.c b/components/esp_wifi/esp32c6/esp_adapter.c index 2b2da560f99..78c1e39574c 100644 --- a/components/esp_wifi/esp32c6/esp_adapter.c +++ b/components/esp_wifi/esp32c6/esp_adapter.c @@ -554,7 +554,7 @@ static int coex_schm_process_restart_wrapper(void) #endif } -static int coex_schm_register_cb_wrapper(int type, void(*cb)(int)) +static int coex_schm_register_cb_wrapper(int type, int(*cb)(int)) { #if CONFIG_SW_COEXIST_ENABLE return coex_schm_register_callback(type, cb); diff --git a/components/esp_wifi/esp32s2/esp_adapter.c b/components/esp_wifi/esp32s2/esp_adapter.c index 71bc9712401..698dd144f43 100644 --- a/components/esp_wifi/esp32s2/esp_adapter.c +++ b/components/esp_wifi/esp32s2/esp_adapter.c @@ -608,7 +608,7 @@ static int coex_schm_process_restart_wrapper(void) #endif } -static int coex_schm_register_cb_wrapper(int type, void(*cb)(int)) +static int coex_schm_register_cb_wrapper(int type, int(*cb)(int)) { #if CONFIG_SW_COEXIST_ENABLE return coex_schm_register_callback(type, cb); diff --git a/components/esp_wifi/esp32s3/esp_adapter.c b/components/esp_wifi/esp32s3/esp_adapter.c index 0c7162a12d3..95ab748163b 100644 --- a/components/esp_wifi/esp32s3/esp_adapter.c +++ b/components/esp_wifi/esp32s3/esp_adapter.c @@ -630,7 +630,7 @@ static int coex_schm_process_restart_wrapper(void) #endif } -static int coex_schm_register_cb_wrapper(int type, void(*cb)(int)) +static int coex_schm_register_cb_wrapper(int type, int(*cb)(int)) { #if CONFIG_SW_COEXIST_ENABLE return coex_schm_register_callback(type, cb); diff --git a/components/esp_wifi/include/esp_private/wifi_os_adapter.h b/components/esp_wifi/include/esp_private/wifi_os_adapter.h index da19d483210..d23cbdeacb3 100644 --- a/components/esp_wifi/include/esp_private/wifi_os_adapter.h +++ b/components/esp_wifi/include/esp_private/wifi_os_adapter.h @@ -150,7 +150,7 @@ typedef struct { void (* _sleep_retention_entries_destroy)(int); #endif int (* _coex_schm_process_restart)(void); - int (* _coex_schm_register_cb)(int, void (* cb)(int)); + int (* _coex_schm_register_cb)(int, int (* cb)(int)); int32_t _magic; } wifi_osi_funcs_t; From 2c4fc5d9eaf216c64b9bf246d29f565222e5b14a Mon Sep 17 00:00:00 2001 From: wangmengyang Date: Tue, 21 Feb 2023 16:30:54 +0800 Subject: [PATCH 08/10] bt: add coexistence internal API declarations and clean up some unused coexistence hooks --- components/bt/CMakeLists.txt | 4 +- components/bt/controller/esp32/bt.c | 14 ---- components/bt/controller/esp32c2/bt.c | 1 - components/bt/controller/esp32c3/bt.c | 3 +- components/bt/controller/esp32c6/bt.c | 1 - components/bt/controller/esp32h4/bt.c | 1 - components/bt/controller/esp32s3/bt.c | 3 +- .../esp_coex/include/esp_coexist_internal.h | 64 +++++++++++++++++++ 8 files changed, 68 insertions(+), 23 deletions(-) diff --git a/components/bt/CMakeLists.txt b/components/bt/CMakeLists.txt index e6f14e925a1..66bccab31aa 100644 --- a/components/bt/CMakeLists.txt +++ b/components/bt/CMakeLists.txt @@ -691,8 +691,8 @@ endif() idf_component_register(SRCS "${srcs}" INCLUDE_DIRS "${include_dirs}" PRIV_INCLUDE_DIRS "${priv_include_dirs}" - REQUIRES esp_timer esp_wifi esp_coex - PRIV_REQUIRES nvs_flash soc esp_pm esp_phy mbedtls driver vfs + REQUIRES esp_timer esp_wifi + PRIV_REQUIRES nvs_flash soc esp_pm esp_phy esp_coex mbedtls driver vfs LDFRAGMENTS "linker.lf") if(CONFIG_BT_ENABLED) diff --git a/components/bt/controller/esp32/bt.c b/components/bt/controller/esp32/bt.c index ba6265378a5..8e3420dedb7 100644 --- a/components/bt/controller/esp32/bt.c +++ b/components/bt/controller/esp32/bt.c @@ -219,20 +219,6 @@ extern int bredr_txpwr_set(int min_power_level, int max_power_level); extern int bredr_txpwr_get(int *min_power_level, int *max_power_level); extern void bredr_sco_datapath_set(uint8_t data_path); extern void btdm_controller_scan_duplicate_list_clear(void); -/* Coexistence */ -extern int coex_bt_request(uint32_t event, uint32_t latency, uint32_t duration); -extern int coex_bt_release(uint32_t event); -extern int coex_register_bt_cb(coex_func_cb_t cb); -extern uint32_t coex_bb_reset_lock(void); -extern void coex_bb_reset_unlock(uint32_t restore); -extern int coex_schm_register_callback(coex_schm_callback_type_t type, void *callback); -extern void coex_schm_status_bit_clear(uint32_t type, uint32_t status); -extern void coex_schm_status_bit_set(uint32_t type, uint32_t status); -extern uint32_t coex_schm_interval_get(void); -extern uint8_t coex_schm_curr_period_get(void); -extern void * coex_schm_curr_phase_get(void); -extern int coex_wifi_channel_get(uint8_t *primary, uint8_t *secondary); -extern int coex_register_wifi_channel_change_callback(void *cb); /* Shutdown */ extern void esp_bt_controller_shutdown(void); diff --git a/components/bt/controller/esp32c2/bt.c b/components/bt/controller/esp32c2/bt.c index add3a9cf20b..1ed40d5140d 100644 --- a/components/bt/controller/esp32c2/bt.c +++ b/components/bt/controller/esp32c2/bt.c @@ -114,7 +114,6 @@ struct ext_funcs_t { */ extern int ble_osi_coex_funcs_register(struct osi_coex_funcs_t *coex_funcs); -extern int coex_core_ble_conn_dyn_prio_get(bool *low, bool *high); extern int ble_controller_init(esp_bt_controller_config_t *cfg); extern int ble_controller_deinit(void); extern int ble_controller_enable(uint8_t mode); diff --git a/components/bt/controller/esp32c3/bt.c b/components/bt/controller/esp32c3/bt.c index 06acad6b17a..9414a18aefa 100644 --- a/components/bt/controller/esp32c3/bt.c +++ b/components/bt/controller/esp32c3/bt.c @@ -235,7 +235,6 @@ extern int ble_txpwr_set(int power_type, int power_level); extern int ble_txpwr_get(int power_type); extern uint16_t l2c_ble_link_get_tx_buf_num(void); -extern int coex_core_ble_conn_dyn_prio_get(bool *low, bool *high); extern void coex_pti_v2(void); extern bool btdm_deep_sleep_mem_init(void); @@ -365,7 +364,7 @@ static const struct osi_funcs_t osi_funcs_ro = { ._btdm_sleep_exit_phase2 = NULL, ._btdm_sleep_exit_phase3 = btdm_sleep_exit_phase3_wrapper, ._coex_wifi_sleep_set = coex_wifi_sleep_set_hook, - ._coex_core_ble_conn_dyn_prio_get = coex_core_ble_conn_dyn_prio_get, + ._coex_core_ble_conn_dyn_prio_get = NULL, ._coex_schm_status_bit_set = coex_schm_status_bit_set_wrapper, ._coex_schm_status_bit_clear = coex_schm_status_bit_clear_wrapper, ._interrupt_on = interrupt_on_wrapper, diff --git a/components/bt/controller/esp32c6/bt.c b/components/bt/controller/esp32c6/bt.c index 254c478f4b7..2a858c169bc 100644 --- a/components/bt/controller/esp32c6/bt.c +++ b/components/bt/controller/esp32c6/bt.c @@ -110,7 +110,6 @@ struct ext_funcs_t { ************************************************************************ */ extern int ble_osi_coex_funcs_register(struct osi_coex_funcs_t *coex_funcs); -extern int coex_core_ble_conn_dyn_prio_get(bool *low, bool *high); extern int ble_controller_init(esp_bt_controller_config_t *cfg); extern int ble_controller_deinit(void); extern int ble_controller_enable(uint8_t mode); diff --git a/components/bt/controller/esp32h4/bt.c b/components/bt/controller/esp32h4/bt.c index ca5343b2f80..665968fb28d 100644 --- a/components/bt/controller/esp32h4/bt.c +++ b/components/bt/controller/esp32h4/bt.c @@ -113,7 +113,6 @@ struct ext_funcs_t { extern int ble_plf_set_log_level(int level); extern int ble_osi_coex_funcs_register(struct osi_coex_funcs_t *coex_funcs); -extern int coex_core_ble_conn_dyn_prio_get(bool *low, bool *high); extern int ble_controller_init(esp_bt_controller_config_t *cfg); extern int ble_controller_deinit(void); extern int ble_controller_enable(uint8_t mode); diff --git a/components/bt/controller/esp32s3/bt.c b/components/bt/controller/esp32s3/bt.c index ab4c187bb6b..04f193e696f 100644 --- a/components/bt/controller/esp32s3/bt.c +++ b/components/bt/controller/esp32s3/bt.c @@ -240,7 +240,6 @@ extern int ble_txpwr_set(int power_type, int power_level); extern int ble_txpwr_get(int power_type); extern uint16_t l2c_ble_link_get_tx_buf_num(void); -extern int coex_core_ble_conn_dyn_prio_get(bool *low, bool *high); extern void coex_pti_v2(void); extern bool btdm_deep_sleep_mem_init(void); @@ -369,7 +368,7 @@ static const struct osi_funcs_t osi_funcs_ro = { ._btdm_sleep_exit_phase2 = NULL, ._btdm_sleep_exit_phase3 = btdm_sleep_exit_phase3_wrapper, ._coex_wifi_sleep_set = coex_wifi_sleep_set_hook, - ._coex_core_ble_conn_dyn_prio_get = coex_core_ble_conn_dyn_prio_get, + ._coex_core_ble_conn_dyn_prio_get = NULL, ._coex_schm_status_bit_set = coex_schm_status_bit_set_wrapper, ._coex_schm_status_bit_clear = coex_schm_status_bit_clear_wrapper, ._interrupt_on = interrupt_on_wrapper, diff --git a/components/esp_coex/include/esp_coexist_internal.h b/components/esp_coex/include/esp_coexist_internal.h index 9de4f37a5c6..7fc02dffedf 100644 --- a/components/esp_coex/include/esp_coexist_internal.h +++ b/components/esp_coex/include/esp_coexist_internal.h @@ -30,6 +30,7 @@ typedef enum { typedef void (* coex_func_cb_t)(uint32_t event, int sched_cnt); typedef esp_err_t (* coex_set_lpclk_source_callback_t)(void); +typedef void (* coex_wifi_channel_change_cb_t)(uint8_t primary, uint8_t secondary); /** * @brief Pre-Init software coexist @@ -122,6 +123,15 @@ int coex_wifi_release(uint32_t event); */ int coex_wifi_channel_set(uint8_t primary, uint8_t secondary); +/** + * @brief Get WiFi channel from coexistence module. + * + * @param primary : pointer to value of WiFi primary channel + * @param secondary : pointer to value of WiFi secondary channel + * @return : 0 - success, other - failed + */ +int coex_wifi_channel_get(uint8_t *primary, uint8_t *secondary); + /** * @brief Register application callback function to Wi-Fi update low power clock module. * @@ -129,6 +139,60 @@ int coex_wifi_channel_set(uint8_t primary, uint8_t secondary); */ void coex_wifi_register_update_lpclk_callback(coex_set_lpclk_source_callback_t callback); +/** + * @brief Bluetooth requests coexistence + * + * @param event : Bluetooth event + * @param latency : Bluetooth will request coexistence after latency + * @param duration : duration for Bluetooth to request coexistence + * @return : 0 - success, other - failed + */ +int coex_bt_request(uint32_t event, uint32_t latency, uint32_t duration); + +/** + * @brief Bluetooth release coexistence. + * + * @param event : Bluetooth event + * @return : 0 - success, other - failed + */ +int coex_bt_release(uint32_t event); + +#if CONFIG_IDF_TARGET_ESP32 +/** + * @brief Bluetooth registers callback function to coexistence module + * This function is only used on ESP32. + * + * @param callback: callback function registered to coexistence module + * @return : 0 - success, other - failed + */ +int coex_register_bt_cb(coex_func_cb_t callback); + +/** + * @brief To acquire the spin-lock used in resetting Bluetooth baseband. + * This function is only used to workaround ESP32 hardware issue. + * + * @param callback: callback function registered to coexistence module + * @return : value of the spinlock to be restored + */ +uint32_t coex_bb_reset_lock(void); + +/** + * @brief To release the spin-lock used in resetting Bluetooth baseband. + * This function is only used to workaround ESP32 hardware issue. + * + * @param restore: value of the spinlock returned from previous call of coex_bb_rest_lock + */ +void coex_bb_reset_unlock(uint32_t restore); +#endif /* CONFIG_IDF_TARGET_ESP32 */ + +/** + * @brief Bluetooth registers callback function to receive notification when Wi-Fi channel changes + * + * @param callback: callback function registered to coexistence module + * @return : 0 - success, other - failed + */ +int coex_register_wifi_channel_change_callback(coex_wifi_channel_change_cb_t callback); + /** * @brief Update low power clock interval */ From 31e340ee0dacfa2254e61afc3810372168cfaf23 Mon Sep 17 00:00:00 2001 From: liuning Date: Tue, 21 Feb 2023 16:18:15 +0800 Subject: [PATCH 09/10] esp_coex: correct wrapper names --- components/esp_coex/esp32/esp_coex_adapter.c | 147 ++++++++------ .../esp_coex/esp32c2/esp_coex_adapter.c | 102 ++++++---- .../esp_coex/esp32c3/esp_coex_adapter.c | 117 ++++++++--- .../esp_coex/esp32c6/esp_coex_adapter.c | 100 ++++++---- .../esp_coex/esp32s2/esp_coex_adapter.c | 177 ++++++++++++----- .../esp_coex/esp32s3/esp_coex_adapter.c | 183 +++++++++++++----- .../esp_coex/include/esp_modem_wrapper.h | 40 ++-- components/esp_wifi/esp32/esp_adapter.c | 61 ++---- components/esp_wifi/esp32c2/esp_adapter.c | 62 ++---- components/esp_wifi/esp32c3/esp_adapter.c | 84 ++------ components/esp_wifi/esp32c6/esp_adapter.c | 62 ++---- components/esp_wifi/esp32s2/esp_adapter.c | 103 ++-------- components/esp_wifi/esp32s3/esp_adapter.c | 108 ++--------- 13 files changed, 679 insertions(+), 667 deletions(-) diff --git a/components/esp_coex/esp32/esp_coex_adapter.c b/components/esp_coex/esp32/esp_coex_adapter.c index 4053565d78d..a120e11d538 100644 --- a/components/esp_coex/esp32/esp_coex_adapter.c +++ b/components/esp_coex/esp32/esp_coex_adapter.c @@ -30,7 +30,16 @@ typedef struct { void *storage; /**< storage for FreeRTOS queue */ } modem_static_queue_t; -void * spin_lock_create_wrapper(void) +bool IRAM_ATTR esp_coex_common_env_is_chip_wrapper(void) +{ +#ifdef CONFIG_IDF_ENV_FPGA + return false; +#else + return true; +#endif +} + +void * esp_coex_common_spin_lock_create_wrapper(void) { portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED; void *mux = heap_caps_malloc(sizeof(portMUX_TYPE), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); @@ -42,7 +51,7 @@ void * spin_lock_create_wrapper(void) return NULL; } -uint32_t IRAM_ATTR wifi_int_disable_wrapper(void *wifi_int_mux) +uint32_t IRAM_ATTR esp_coex_common_int_disable_wrapper(void *wifi_int_mux) { if (xPortInIsrContext()) { portENTER_CRITICAL_ISR(wifi_int_mux); @@ -53,7 +62,7 @@ uint32_t IRAM_ATTR wifi_int_disable_wrapper(void *wifi_int_mux) return 0; } -void IRAM_ATTR wifi_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp) +void IRAM_ATTR esp_coex_common_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp) { if (xPortInIsrContext()) { portEXIT_CRITICAL_ISR(wifi_int_mux); @@ -62,12 +71,68 @@ void IRAM_ATTR wifi_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp) } } -void IRAM_ATTR task_yield_from_isr_wrapper(void) +void IRAM_ATTR esp_coex_common_task_yield_from_isr_wrapper(void) { portYIELD_FROM_ISR(); } -void *internal_semphr_create_wrapper(uint32_t max, uint32_t init) +void * esp_coex_common_semphr_create_wrapper(uint32_t max, uint32_t init) +{ + return (void *)xSemaphoreCreateCounting(max, init); +} + +void esp_coex_common_semphr_delete_wrapper(void *semphr) +{ + vSemaphoreDelete(semphr); +} + +int32_t esp_coex_common_semphr_take_wrapper(void *semphr, uint32_t block_time_tick) +{ + if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) { + return (int32_t)xSemaphoreTake(semphr, portMAX_DELAY); + } else { + return (int32_t)xSemaphoreTake(semphr, block_time_tick); + } +} + +int32_t esp_coex_common_semphr_give_wrapper(void *semphr) +{ + return (int32_t)xSemaphoreGive(semphr); +} + +void IRAM_ATTR esp_coex_common_timer_disarm_wrapper(void *timer) +{ + ets_timer_disarm(timer); +} + +void esp_coex_common_timer_done_wrapper(void *ptimer) +{ + ets_timer_done(ptimer); +} + +void esp_coex_common_timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg) +{ + ets_timer_setfn(ptimer, pfunction, parg); +} + +void IRAM_ATTR esp_coex_common_timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat) +{ + ets_timer_arm_us(ptimer, us, repeat); +} + +void * IRAM_ATTR esp_coex_common_malloc_internal_wrapper(size_t size) +{ + return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); +} + +/* static wrapper */ + +static int IRAM_ATTR esp_coex_is_in_isr_wrapper(void) +{ + return !xPortCanYield(); +} + +static void *esp_coex_internal_semphr_create_wrapper(uint32_t max, uint32_t init) { modem_static_queue_t *semphr = heap_caps_calloc(1, sizeof(modem_static_queue_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); if (!semphr) { @@ -101,7 +166,7 @@ void *internal_semphr_create_wrapper(uint32_t max, uint32_t init) #endif } -void internal_semphr_delete_wrapper(void *semphr) +static void esp_coex_internal_semphr_delete_wrapper(void *semphr) { modem_static_queue_t *semphr_item = (modem_static_queue_t *)semphr; if (semphr_item) { @@ -117,17 +182,17 @@ void internal_semphr_delete_wrapper(void *semphr) } } -int32_t IRAM_ATTR internal_semphr_take_from_isr_wrapper(void *semphr, void *hptw) +static int32_t IRAM_ATTR esp_coex_internal_semphr_take_from_isr_wrapper(void *semphr, void *hptw) { return (int32_t)xSemaphoreTakeFromISR(((modem_static_queue_t *)semphr)->handle, hptw); } -int32_t IRAM_ATTR internal_semphr_give_from_isr_wrapper(void *semphr, void *hptw) +static int32_t IRAM_ATTR esp_coex_internal_semphr_give_from_isr_wrapper(void *semphr, void *hptw) { return (int32_t)xSemaphoreGiveFromISR(((modem_static_queue_t *)semphr)->handle, hptw); } -int32_t internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick) +static int32_t esp_coex_internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick) { if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) { return (int32_t)xSemaphoreTake(((modem_static_queue_t *)semphr)->handle, portMAX_DELAY); @@ -136,61 +201,31 @@ int32_t internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick) } } -int32_t internal_semphr_give_wrapper(void *semphr) +static int32_t esp_coex_internal_semphr_give_wrapper(void *semphr) { return (int32_t)xSemaphoreGive(((modem_static_queue_t *)semphr)->handle); } -void IRAM_ATTR timer_disarm_wrapper(void *timer) -{ - ets_timer_disarm(timer); -} - -void timer_done_wrapper(void *ptimer) -{ - ets_timer_done(ptimer); -} - -void timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg) -{ - ets_timer_setfn(ptimer, pfunction, parg); -} - -void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat) -{ - ets_timer_arm_us(ptimer, us, repeat); -} - -void * IRAM_ATTR malloc_internal_wrapper(size_t size) -{ - return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); -} - -int IRAM_ATTR coex_is_in_isr_wrapper(void) -{ - return !xPortCanYield(); -} - coex_adapter_funcs_t g_coex_adapter_funcs = { ._version = COEX_ADAPTER_VERSION, - ._spin_lock_create = spin_lock_create_wrapper, + ._spin_lock_create = esp_coex_common_spin_lock_create_wrapper, ._spin_lock_delete = free, - ._int_disable = wifi_int_disable_wrapper, - ._int_enable = wifi_int_restore_wrapper, - ._task_yield_from_isr = task_yield_from_isr_wrapper, - ._semphr_create = internal_semphr_create_wrapper, - ._semphr_delete = internal_semphr_delete_wrapper, - ._semphr_take_from_isr = internal_semphr_take_from_isr_wrapper, - ._semphr_give_from_isr = internal_semphr_give_from_isr_wrapper, - ._semphr_take = internal_semphr_take_wrapper, - ._semphr_give = internal_semphr_give_wrapper, - ._is_in_isr = coex_is_in_isr_wrapper, - ._malloc_internal = malloc_internal_wrapper, + ._int_disable = esp_coex_common_int_disable_wrapper, + ._int_enable = esp_coex_common_int_restore_wrapper, + ._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper, + ._semphr_create = esp_coex_internal_semphr_create_wrapper, + ._semphr_delete = esp_coex_internal_semphr_delete_wrapper, + ._semphr_take_from_isr = esp_coex_internal_semphr_take_from_isr_wrapper, + ._semphr_give_from_isr = esp_coex_internal_semphr_give_from_isr_wrapper, + ._semphr_take = esp_coex_internal_semphr_take_wrapper, + ._semphr_give = esp_coex_internal_semphr_give_wrapper, + ._is_in_isr = esp_coex_is_in_isr_wrapper, + ._malloc_internal = esp_coex_common_malloc_internal_wrapper, ._free = free, ._esp_timer_get_time = esp_timer_get_time, - ._timer_disarm = timer_disarm_wrapper, - ._timer_done = timer_done_wrapper, - ._timer_setfn = timer_setfn_wrapper, - ._timer_arm_us = timer_arm_us_wrapper, + ._timer_disarm = esp_coex_common_timer_disarm_wrapper, + ._timer_done = esp_coex_common_timer_done_wrapper, + ._timer_setfn = esp_coex_common_timer_setfn_wrapper, + ._timer_arm_us = esp_coex_common_timer_arm_us_wrapper, ._magic = COEX_ADAPTER_MAGIC, }; diff --git a/components/esp_coex/esp32c2/esp_coex_adapter.c b/components/esp_coex/esp32c2/esp_coex_adapter.c index 218f72cf07b..84adc6f088c 100644 --- a/components/esp_coex/esp32c2/esp_coex_adapter.c +++ b/components/esp_coex/esp32c2/esp_coex_adapter.c @@ -27,7 +27,7 @@ #define OSI_FUNCS_TIME_BLOCKING 0xffffffff -bool IRAM_ATTR env_is_chip_wrapper(void) +bool IRAM_ATTR esp_coex_common_env_is_chip_wrapper(void) { #ifdef CONFIG_IDF_ENV_FPGA return false; @@ -36,32 +36,54 @@ bool IRAM_ATTR env_is_chip_wrapper(void) #endif } -void IRAM_ATTR task_yield_from_isr_wrapper(void) +void * esp_coex_common_spin_lock_create_wrapper(void) { - portYIELD_FROM_ISR(); + portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED; + void *mux = malloc(sizeof(portMUX_TYPE)); + + if (mux) { + memcpy(mux,&tmp,sizeof(portMUX_TYPE)); + return mux; + } + return NULL; } -void * semphr_create_wrapper(uint32_t max, uint32_t init) +uint32_t IRAM_ATTR esp_coex_common_int_disable_wrapper(void *wifi_int_mux) { - return (void *)xSemaphoreCreateCounting(max, init); + if (xPortInIsrContext()) { + portENTER_CRITICAL_ISR(wifi_int_mux); + } else { + portENTER_CRITICAL(wifi_int_mux); + } + + return 0; } -void semphr_delete_wrapper(void *semphr) +void IRAM_ATTR esp_coex_common_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp) { - vSemaphoreDelete(semphr); + if (xPortInIsrContext()) { + portEXIT_CRITICAL_ISR(wifi_int_mux); + } else { + portEXIT_CRITICAL(wifi_int_mux); + } } -int32_t IRAM_ATTR semphr_take_from_isr_wrapper(void *semphr, void *hptw) +void IRAM_ATTR esp_coex_common_task_yield_from_isr_wrapper(void) { - return (int32_t)xSemaphoreTakeFromISR(semphr, hptw); + portYIELD_FROM_ISR(); } -int32_t IRAM_ATTR semphr_give_from_isr_wrapper(void *semphr, void *hptw) +void * esp_coex_common_semphr_create_wrapper(uint32_t max, uint32_t init) { - return (int32_t)xSemaphoreGiveFromISR(semphr, hptw); + return (void *)xSemaphoreCreateCounting(max, init); } -int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick) +void esp_coex_common_semphr_delete_wrapper(void *semphr) +{ + vSemaphoreDelete(semphr); +} + +int32_t esp_coex_common_semphr_take_wrapper(void *semphr, uint32_t block_time_tick) { if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) { return (int32_t)xSemaphoreTake(semphr, portMAX_DELAY); @@ -70,32 +92,37 @@ int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick) } } -int32_t semphr_give_wrapper(void *semphr) +int32_t esp_coex_common_semphr_give_wrapper(void *semphr) { return (int32_t)xSemaphoreGive(semphr); } -void IRAM_ATTR timer_disarm_wrapper(void *timer) +void IRAM_ATTR esp_coex_common_timer_disarm_wrapper(void *timer) { ets_timer_disarm(timer); } -void timer_done_wrapper(void *ptimer) +void esp_coex_common_timer_done_wrapper(void *ptimer) { ets_timer_done(ptimer); } -void timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg) +void esp_coex_common_timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg) { ets_timer_setfn(ptimer, pfunction, parg); } -void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat) +void IRAM_ATTR esp_coex_common_timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat) { ets_timer_arm_us(ptimer, us, repeat); } -uint32_t esp_clk_slowclk_cal_get_wrapper(void) +void * IRAM_ATTR esp_coex_common_malloc_internal_wrapper(size_t size) +{ + return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); +} + +uint32_t esp_coex_common_clk_slowclk_cal_get_wrapper(void) { /* The bit width of WiFi light sleep clock calibration is 12 while the one of * system is 19. It should shift 19 - 12 = 7. @@ -103,29 +130,36 @@ uint32_t esp_clk_slowclk_cal_get_wrapper(void) return (esp_clk_slowclk_cal_get() >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH)); } -void * IRAM_ATTR malloc_internal_wrapper(size_t size) +/* static wrapper */ + +static int32_t IRAM_ATTR esp_coex_semphr_take_from_isr_wrapper(void *semphr, void *hptw) { - return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); + return (int32_t)xSemaphoreTakeFromISR(semphr, hptw); +} + +static int32_t IRAM_ATTR esp_coex_semphr_give_from_isr_wrapper(void *semphr, void *hptw) +{ + return (int32_t)xSemaphoreGiveFromISR(semphr, hptw); } coex_adapter_funcs_t g_coex_adapter_funcs = { ._version = COEX_ADAPTER_VERSION, - ._task_yield_from_isr = task_yield_from_isr_wrapper, - ._semphr_create = semphr_create_wrapper, - ._semphr_delete = semphr_delete_wrapper, - ._semphr_take_from_isr = semphr_take_from_isr_wrapper, - ._semphr_give_from_isr = semphr_give_from_isr_wrapper, - ._semphr_take = semphr_take_wrapper, - ._semphr_give = semphr_give_wrapper, + ._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper, + ._semphr_create = esp_coex_common_semphr_create_wrapper, + ._semphr_delete = esp_coex_common_semphr_delete_wrapper, + ._semphr_take_from_isr = esp_coex_semphr_take_from_isr_wrapper, + ._semphr_give_from_isr = esp_coex_semphr_give_from_isr_wrapper, + ._semphr_take = esp_coex_common_semphr_take_wrapper, + ._semphr_give = esp_coex_common_semphr_give_wrapper, ._is_in_isr = xPortInIsrContext, - ._malloc_internal = malloc_internal_wrapper, + ._malloc_internal = esp_coex_common_malloc_internal_wrapper, ._free = free, ._esp_timer_get_time = esp_timer_get_time, - ._env_is_chip = env_is_chip_wrapper, - ._slowclk_cal_get = esp_clk_slowclk_cal_get_wrapper, - ._timer_disarm = timer_disarm_wrapper, - ._timer_done = timer_done_wrapper, - ._timer_setfn = timer_setfn_wrapper, - ._timer_arm_us = timer_arm_us_wrapper, + ._env_is_chip = esp_coex_common_env_is_chip_wrapper, + ._slowclk_cal_get = esp_coex_common_clk_slowclk_cal_get_wrapper, + ._timer_disarm = esp_coex_common_timer_disarm_wrapper, + ._timer_done = esp_coex_common_timer_done_wrapper, + ._timer_setfn = esp_coex_common_timer_setfn_wrapper, + ._timer_arm_us = esp_coex_common_timer_arm_us_wrapper, ._magic = COEX_ADAPTER_MAGIC, }; diff --git a/components/esp_coex/esp32c3/esp_coex_adapter.c b/components/esp_coex/esp32c3/esp_coex_adapter.c index a64ba30ab73..005b858f4b4 100644 --- a/components/esp_coex/esp32c3/esp_coex_adapter.c +++ b/components/esp_coex/esp32c3/esp_coex_adapter.c @@ -18,39 +18,73 @@ #include "freertos/portmacro.h" #include "esp_heap_caps.h" #include "esp_timer.h" +#include "soc/rtc.h" +#include "esp_private/esp_clk.h" #include "esp_coexist_adapter.h" #include "esp32c3/rom/ets_sys.h" +#include "soc/system_reg.h" #define TAG "esp_coex_adapter" #define OSI_FUNCS_TIME_BLOCKING 0xffffffff -void IRAM_ATTR task_yield_from_isr_wrapper(void) +bool IRAM_ATTR esp_coex_common_env_is_chip_wrapper(void) { - portYIELD_FROM_ISR(); +#ifdef CONFIG_IDF_ENV_FPGA + return false; +#else + return true; +#endif } -void * semphr_create_wrapper(uint32_t max, uint32_t init) +void * esp_coex_common_spin_lock_create_wrapper(void) { - return (void *)xSemaphoreCreateCounting(max, init); + portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED; + void *mux = malloc(sizeof(portMUX_TYPE)); + + if (mux) { + memcpy(mux,&tmp,sizeof(portMUX_TYPE)); + return mux; + } + return NULL; } -void semphr_delete_wrapper(void *semphr) +uint32_t IRAM_ATTR esp_coex_common_int_disable_wrapper(void *wifi_int_mux) { - vSemaphoreDelete(semphr); + if (xPortInIsrContext()) { + portENTER_CRITICAL_ISR(wifi_int_mux); + } else { + portENTER_CRITICAL(wifi_int_mux); + } + + return 0; } -int32_t IRAM_ATTR semphr_take_from_isr_wrapper(void *semphr, void *hptw) +void IRAM_ATTR esp_coex_common_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp) { - return (int32_t)xSemaphoreTakeFromISR(semphr, hptw); + if (xPortInIsrContext()) { + portEXIT_CRITICAL_ISR(wifi_int_mux); + } else { + portEXIT_CRITICAL(wifi_int_mux); + } } -int32_t IRAM_ATTR semphr_give_from_isr_wrapper(void *semphr, void *hptw) +void IRAM_ATTR esp_coex_common_task_yield_from_isr_wrapper(void) { - return (int32_t)xSemaphoreGiveFromISR(semphr, hptw); + portYIELD_FROM_ISR(); } -int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick) +void * esp_coex_common_semphr_create_wrapper(uint32_t max, uint32_t init) +{ + return (void *)xSemaphoreCreateCounting(max, init); +} + +void esp_coex_common_semphr_delete_wrapper(void *semphr) +{ + vSemaphoreDelete(semphr); +} + +int32_t esp_coex_common_semphr_take_wrapper(void *semphr, uint32_t block_time_tick) { if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) { return (int32_t)xSemaphoreTake(semphr, portMAX_DELAY); @@ -59,52 +93,77 @@ int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick) } } -int32_t semphr_give_wrapper(void *semphr) +int32_t esp_coex_common_semphr_give_wrapper(void *semphr) { return (int32_t)xSemaphoreGive(semphr); } -void IRAM_ATTR timer_disarm_wrapper(void *timer) +void IRAM_ATTR esp_coex_common_timer_disarm_wrapper(void *timer) { ets_timer_disarm(timer); } -void timer_done_wrapper(void *ptimer) +void esp_coex_common_timer_done_wrapper(void *ptimer) { ets_timer_done(ptimer); } -void timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg) +void esp_coex_common_timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg) { ets_timer_setfn(ptimer, pfunction, parg); } -void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat) +void IRAM_ATTR esp_coex_common_timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat) { ets_timer_arm_us(ptimer, us, repeat); } -void * IRAM_ATTR malloc_internal_wrapper(size_t size) +void * IRAM_ATTR esp_coex_common_malloc_internal_wrapper(size_t size) { return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); } +uint32_t esp_coex_common_clk_slowclk_cal_get_wrapper(void) +{ + /* The bit width of WiFi light sleep clock calibration is 12 while the one of + * system is 19. It should shift 19 - 12 = 7. + */ + if (GET_PERI_REG_MASK(SYSTEM_BT_LPCK_DIV_FRAC_REG, SYSTEM_LPCLK_SEL_XTAL)) { + uint64_t time_per_us = 1000000ULL; + return (((time_per_us << RTC_CLK_CAL_FRACT) / (MHZ)) >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH)); + } else { + return (esp_clk_slowclk_cal_get() >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH)); + } +} + +/* static wrapper */ + +static int32_t IRAM_ATTR esp_coex_semphr_take_from_isr_wrapper(void *semphr, void *hptw) +{ + return (int32_t)xSemaphoreTakeFromISR(semphr, hptw); +} + +static int32_t IRAM_ATTR esp_coex_semphr_give_from_isr_wrapper(void *semphr, void *hptw) +{ + return (int32_t)xSemaphoreGiveFromISR(semphr, hptw); +} + coex_adapter_funcs_t g_coex_adapter_funcs = { ._version = COEX_ADAPTER_VERSION, - ._task_yield_from_isr = task_yield_from_isr_wrapper, - ._semphr_create = semphr_create_wrapper, - ._semphr_delete = semphr_delete_wrapper, - ._semphr_take_from_isr = semphr_take_from_isr_wrapper, - ._semphr_give_from_isr = semphr_give_from_isr_wrapper, - ._semphr_take = semphr_take_wrapper, - ._semphr_give = semphr_give_wrapper, + ._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper, + ._semphr_create = esp_coex_common_semphr_create_wrapper, + ._semphr_delete = esp_coex_common_semphr_delete_wrapper, + ._semphr_take_from_isr = esp_coex_semphr_take_from_isr_wrapper, + ._semphr_give_from_isr = esp_coex_semphr_give_from_isr_wrapper, + ._semphr_take = esp_coex_common_semphr_take_wrapper, + ._semphr_give = esp_coex_common_semphr_give_wrapper, ._is_in_isr = xPortInIsrContext, - ._malloc_internal = malloc_internal_wrapper, + ._malloc_internal = esp_coex_common_malloc_internal_wrapper, ._free = free, ._esp_timer_get_time = esp_timer_get_time, - ._timer_disarm = timer_disarm_wrapper, - ._timer_done = timer_done_wrapper, - ._timer_setfn = timer_setfn_wrapper, - ._timer_arm_us = timer_arm_us_wrapper, + ._timer_disarm = esp_coex_common_timer_disarm_wrapper, + ._timer_done = esp_coex_common_timer_done_wrapper, + ._timer_setfn = esp_coex_common_timer_setfn_wrapper, + ._timer_arm_us = esp_coex_common_timer_arm_us_wrapper, ._magic = COEX_ADAPTER_MAGIC, }; diff --git a/components/esp_coex/esp32c6/esp_coex_adapter.c b/components/esp_coex/esp32c6/esp_coex_adapter.c index b3974dd32b2..51417fc912f 100644 --- a/components/esp_coex/esp32c6/esp_coex_adapter.c +++ b/components/esp_coex/esp32c6/esp_coex_adapter.c @@ -27,7 +27,7 @@ #define OSI_FUNCS_TIME_BLOCKING 0xffffffff -bool IRAM_ATTR env_is_chip_wrapper(void) +bool IRAM_ATTR esp_coex_common_env_is_chip_wrapper(void) { #ifdef CONFIG_IDF_ENV_FPGA return false; @@ -36,32 +36,54 @@ bool IRAM_ATTR env_is_chip_wrapper(void) #endif } -void IRAM_ATTR task_yield_from_isr_wrapper(void) +void *esp_coex_common_spin_lock_create_wrapper(void) { - portYIELD_FROM_ISR(); + portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED; + void *mux = malloc(sizeof(portMUX_TYPE)); + + if (mux) { + memcpy(mux, &tmp, sizeof(portMUX_TYPE)); + return mux; + } + return NULL; } -void *semphr_create_wrapper(uint32_t max, uint32_t init) +uint32_t IRAM_ATTR esp_coex_common_int_disable_wrapper(void *wifi_int_mux) { - return (void *)xSemaphoreCreateCounting(max, init); + if (xPortInIsrContext()) { + portENTER_CRITICAL_ISR(wifi_int_mux); + } else { + portENTER_CRITICAL(wifi_int_mux); + } + + return 0; } -void semphr_delete_wrapper(void *semphr) +void IRAM_ATTR esp_coex_common_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp) { - vSemaphoreDelete(semphr); + if (xPortInIsrContext()) { + portEXIT_CRITICAL_ISR(wifi_int_mux); + } else { + portEXIT_CRITICAL(wifi_int_mux); + } } -int32_t IRAM_ATTR semphr_take_from_isr_wrapper(void *semphr, void *hptw) +void IRAM_ATTR esp_coex_common_task_yield_from_isr_wrapper(void) { - return (int32_t)xSemaphoreTakeFromISR(semphr, hptw); + portYIELD_FROM_ISR(); } -int32_t IRAM_ATTR semphr_give_from_isr_wrapper(void *semphr, void *hptw) +void *esp_coex_common_semphr_create_wrapper(uint32_t max, uint32_t init) { - return (int32_t)xSemaphoreGiveFromISR(semphr, hptw); + return (void *)xSemaphoreCreateCounting(max, init); } -int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick) +void esp_coex_common_semphr_delete_wrapper(void *semphr) +{ + vSemaphoreDelete(semphr); +} + +int32_t esp_coex_common_semphr_take_wrapper(void *semphr, uint32_t block_time_tick) { if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) { return (int32_t)xSemaphoreTake(semphr, portMAX_DELAY); @@ -70,32 +92,32 @@ int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick) } } -int32_t semphr_give_wrapper(void *semphr) +int32_t esp_coex_common_semphr_give_wrapper(void *semphr) { return (int32_t)xSemaphoreGive(semphr); } -void IRAM_ATTR timer_disarm_wrapper(void *timer) +void IRAM_ATTR esp_coex_common_timer_disarm_wrapper(void *timer) { ets_timer_disarm(timer); } -void timer_done_wrapper(void *ptimer) +void esp_coex_common_timer_done_wrapper(void *ptimer) { ets_timer_done(ptimer); } -void timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg) +void esp_coex_common_timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg) { ets_timer_setfn(ptimer, pfunction, parg); } -void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat) +void IRAM_ATTR esp_coex_common_timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat) { ets_timer_arm_us(ptimer, us, repeat); } -uint32_t esp_clk_slowclk_cal_get_wrapper(void) +uint32_t esp_coex_common_clk_slowclk_cal_get_wrapper(void) { /* The bit width of WiFi light sleep clock calibration is 12 while the one of * system is 19. It should shift 19 - 12 = 7. @@ -103,29 +125,41 @@ uint32_t esp_clk_slowclk_cal_get_wrapper(void) return (esp_clk_slowclk_cal_get() >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH)); } -void *IRAM_ATTR malloc_internal_wrapper(size_t size) +void *IRAM_ATTR esp_coex_common_malloc_internal_wrapper(size_t size) { return heap_caps_malloc(size, MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL); } +/* static wrapper */ + +static int32_t IRAM_ATTR esp_coex_semphr_take_from_isr_wrapper(void *semphr, void *hptw) +{ + return (int32_t)xSemaphoreTakeFromISR(semphr, hptw); +} + +static int32_t IRAM_ATTR esp_coex_semphr_give_from_isr_wrapper(void *semphr, void *hptw) +{ + return (int32_t)xSemaphoreGiveFromISR(semphr, hptw); +} + coex_adapter_funcs_t g_coex_adapter_funcs = { ._version = COEX_ADAPTER_VERSION, - ._task_yield_from_isr = task_yield_from_isr_wrapper, - ._semphr_create = semphr_create_wrapper, - ._semphr_delete = semphr_delete_wrapper, - ._semphr_take_from_isr = semphr_take_from_isr_wrapper, - ._semphr_give_from_isr = semphr_give_from_isr_wrapper, - ._semphr_take = semphr_take_wrapper, - ._semphr_give = semphr_give_wrapper, + ._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper, + ._semphr_create = esp_coex_common_semphr_create_wrapper, + ._semphr_delete = esp_coex_common_semphr_delete_wrapper, + ._semphr_take_from_isr = esp_coex_semphr_take_from_isr_wrapper, + ._semphr_give_from_isr = esp_coex_semphr_give_from_isr_wrapper, + ._semphr_take = esp_coex_common_semphr_take_wrapper, + ._semphr_give = esp_coex_common_semphr_give_wrapper, ._is_in_isr = xPortInIsrContext, - ._malloc_internal = malloc_internal_wrapper, + ._malloc_internal = esp_coex_common_malloc_internal_wrapper, ._free = free, ._esp_timer_get_time = esp_timer_get_time, - ._env_is_chip = env_is_chip_wrapper, - ._slowclk_cal_get = esp_clk_slowclk_cal_get_wrapper, - ._timer_disarm = timer_disarm_wrapper, - ._timer_done = timer_done_wrapper, - ._timer_setfn = timer_setfn_wrapper, - ._timer_arm_us = timer_arm_us_wrapper, + ._env_is_chip = esp_coex_common_env_is_chip_wrapper, + ._slowclk_cal_get = esp_coex_common_clk_slowclk_cal_get_wrapper, + ._timer_disarm = esp_coex_common_timer_disarm_wrapper, + ._timer_done = esp_coex_common_timer_done_wrapper, + ._timer_setfn = esp_coex_common_timer_setfn_wrapper, + ._timer_arm_us = esp_coex_common_timer_arm_us_wrapper, ._magic = COEX_ADAPTER_MAGIC, }; diff --git a/components/esp_coex/esp32s2/esp_coex_adapter.c b/components/esp_coex/esp32s2/esp_coex_adapter.c index 10e2176be69..9100bfabe0e 100644 --- a/components/esp_coex/esp32s2/esp_coex_adapter.c +++ b/components/esp_coex/esp32s2/esp_coex_adapter.c @@ -18,6 +18,8 @@ #include "freertos/portmacro.h" #include "esp_heap_caps.h" #include "esp_timer.h" +#include "soc/rtc.h" +#include "esp_private/esp_clk.h" #include "esp_coexist_adapter.h" #include "esp32s2/rom/ets_sys.h" @@ -30,12 +32,117 @@ typedef struct { void *storage; /**< storage for FreeRTOS queue */ } modem_static_queue_t; -void IRAM_ATTR task_yield_from_isr_wrapper(void) +bool IRAM_ATTR esp_coex_common_env_is_chip_wrapper(void) +{ +#ifdef CONFIG_IDF_ENV_FPGA + return false; +#else + return true; +#endif +} + +void * esp_coex_common_spin_lock_create_wrapper(void) +{ + portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED; + void *mux = heap_caps_malloc(sizeof(portMUX_TYPE), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); + + if (mux) { + memcpy(mux,&tmp,sizeof(portMUX_TYPE)); + return mux; + } + return NULL; +} + +uint32_t IRAM_ATTR esp_coex_common_int_disable_wrapper(void *wifi_int_mux) +{ + if (xPortInIsrContext()) { + portENTER_CRITICAL_ISR(wifi_int_mux); + } else { + portENTER_CRITICAL(wifi_int_mux); + } + + return 0; +} + +void IRAM_ATTR esp_coex_common_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp) +{ + if (xPortInIsrContext()) { + portEXIT_CRITICAL_ISR(wifi_int_mux); + } else { + portEXIT_CRITICAL(wifi_int_mux); + } +} + +void IRAM_ATTR esp_coex_common_task_yield_from_isr_wrapper(void) { portYIELD_FROM_ISR(); } -void *internal_semphr_create_wrapper(uint32_t max, uint32_t init) +void * esp_coex_common_semphr_create_wrapper(uint32_t max, uint32_t init) +{ + return (void *)xSemaphoreCreateCounting(max, init); +} + +void esp_coex_common_semphr_delete_wrapper(void *semphr) +{ + vSemaphoreDelete(semphr); +} + +int32_t esp_coex_common_semphr_take_wrapper(void *semphr, uint32_t block_time_tick) +{ + if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) { + return (int32_t)xSemaphoreTake(semphr, portMAX_DELAY); + } else { + return (int32_t)xSemaphoreTake(semphr, block_time_tick); + } +} + +int32_t esp_coex_common_semphr_give_wrapper(void *semphr) +{ + return (int32_t)xSemaphoreGive(semphr); +} + +void IRAM_ATTR esp_coex_common_timer_disarm_wrapper(void *timer) +{ + ets_timer_disarm(timer); +} + +void esp_coex_common_timer_done_wrapper(void *ptimer) +{ + ets_timer_done(ptimer); +} + +void esp_coex_common_timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg) +{ + ets_timer_setfn(ptimer, pfunction, parg); +} + +void IRAM_ATTR esp_coex_common_timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat) +{ + ets_timer_arm_us(ptimer, us, repeat); +} + +void * IRAM_ATTR esp_coex_common_malloc_internal_wrapper(size_t size) +{ + return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); +} + +uint32_t esp_coex_common_clk_slowclk_cal_get_wrapper(void) +{ + /* The bit width of WiFi light sleep clock calibration is 12 while the one of + * system is 19. It should shift 19 - 12 = 7. + */ + return (esp_clk_slowclk_cal_get() >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH)); +} + +/* static wrapper */ + +static int IRAM_ATTR esp_coex_is_in_isr_wrapper(void) +{ + return !xPortCanYield(); +} + +static void *esp_coex_internal_semphr_create_wrapper(uint32_t max, uint32_t init) { modem_static_queue_t *semphr = heap_caps_calloc(1, sizeof(modem_static_queue_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); if (!semphr) { @@ -69,7 +176,7 @@ void *internal_semphr_create_wrapper(uint32_t max, uint32_t init) #endif } -void internal_semphr_delete_wrapper(void *semphr) +static void esp_coex_internal_semphr_delete_wrapper(void *semphr) { modem_static_queue_t *semphr_item = (modem_static_queue_t *)semphr; if (semphr_item) { @@ -85,17 +192,17 @@ void internal_semphr_delete_wrapper(void *semphr) } } -int32_t IRAM_ATTR internal_semphr_take_from_isr_wrapper(void *semphr, void *hptw) +static int32_t IRAM_ATTR esp_coex_internal_semphr_take_from_isr_wrapper(void *semphr, void *hptw) { return (int32_t)xSemaphoreTakeFromISR(((modem_static_queue_t *)semphr)->handle, hptw); } -int32_t IRAM_ATTR internal_semphr_give_from_isr_wrapper(void *semphr, void *hptw) +static int32_t IRAM_ATTR esp_coex_internal_semphr_give_from_isr_wrapper(void *semphr, void *hptw) { return (int32_t)xSemaphoreGiveFromISR(((modem_static_queue_t *)semphr)->handle, hptw); } -int32_t internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick) +static int32_t esp_coex_internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick) { if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) { return (int32_t)xSemaphoreTake(((modem_static_queue_t *)semphr)->handle, portMAX_DELAY); @@ -104,57 +211,27 @@ int32_t internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick) } } -int32_t internal_semphr_give_wrapper(void *semphr) +static int32_t esp_coex_internal_semphr_give_wrapper(void *semphr) { return (int32_t)xSemaphoreGive(((modem_static_queue_t *)semphr)->handle); } -void IRAM_ATTR timer_disarm_wrapper(void *timer) -{ - ets_timer_disarm(timer); -} - -void timer_done_wrapper(void *ptimer) -{ - ets_timer_done(ptimer); -} - -void timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg) -{ - ets_timer_setfn(ptimer, pfunction, parg); -} - -void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat) -{ - ets_timer_arm_us(ptimer, us, repeat); -} - -void * IRAM_ATTR malloc_internal_wrapper(size_t size) -{ - return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); -} - -int IRAM_ATTR coex_is_in_isr_wrapper(void) -{ - return !xPortCanYield(); -} - coex_adapter_funcs_t g_coex_adapter_funcs = { ._version = COEX_ADAPTER_VERSION, - ._task_yield_from_isr = task_yield_from_isr_wrapper, - ._semphr_create = internal_semphr_create_wrapper, - ._semphr_delete = internal_semphr_delete_wrapper, - ._semphr_take_from_isr = internal_semphr_take_from_isr_wrapper, - ._semphr_give_from_isr = internal_semphr_give_from_isr_wrapper, - ._semphr_take = internal_semphr_take_wrapper, - ._semphr_give = internal_semphr_give_wrapper, - ._is_in_isr = coex_is_in_isr_wrapper, - ._malloc_internal = malloc_internal_wrapper, + ._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper, + ._semphr_create = esp_coex_internal_semphr_create_wrapper, + ._semphr_delete = esp_coex_internal_semphr_delete_wrapper, + ._semphr_take_from_isr = esp_coex_internal_semphr_take_from_isr_wrapper, + ._semphr_give_from_isr = esp_coex_internal_semphr_give_from_isr_wrapper, + ._semphr_take = esp_coex_internal_semphr_take_wrapper, + ._semphr_give = esp_coex_internal_semphr_give_wrapper, + ._is_in_isr = esp_coex_is_in_isr_wrapper, + ._malloc_internal = esp_coex_common_malloc_internal_wrapper, ._free = free, ._esp_timer_get_time = esp_timer_get_time, - ._timer_disarm = timer_disarm_wrapper, - ._timer_done = timer_done_wrapper, - ._timer_setfn = timer_setfn_wrapper, - ._timer_arm_us = timer_arm_us_wrapper, + ._timer_disarm = esp_coex_common_timer_disarm_wrapper, + ._timer_done = esp_coex_common_timer_done_wrapper, + ._timer_setfn = esp_coex_common_timer_setfn_wrapper, + ._timer_arm_us = esp_coex_common_timer_arm_us_wrapper, ._magic = COEX_ADAPTER_MAGIC, }; diff --git a/components/esp_coex/esp32s3/esp_coex_adapter.c b/components/esp_coex/esp32s3/esp_coex_adapter.c index 7182d1f763a..bf277eb7898 100644 --- a/components/esp_coex/esp32s3/esp_coex_adapter.c +++ b/components/esp_coex/esp32s3/esp_coex_adapter.c @@ -18,8 +18,11 @@ #include "freertos/portmacro.h" #include "esp_heap_caps.h" #include "esp_timer.h" +#include "soc/rtc.h" +#include "esp_private/esp_clk.h" #include "esp_coexist_adapter.h" #include "esp32s3/rom/ets_sys.h" +#include "soc/system_reg.h" #define TAG "esp_coex_adapter" @@ -30,12 +33,122 @@ typedef struct { void *storage; /**< storage for FreeRTOS queue */ } modem_static_queue_t; -void IRAM_ATTR task_yield_from_isr_wrapper(void) +bool IRAM_ATTR esp_coex_common_env_is_chip_wrapper(void) +{ +#ifdef CONFIG_IDF_ENV_FPGA + return false; +#else + return true; +#endif +} + +void * esp_coex_common_spin_lock_create_wrapper(void) +{ + portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED; + void *mux = heap_caps_malloc(sizeof(portMUX_TYPE), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); + + if (mux) { + memcpy(mux,&tmp,sizeof(portMUX_TYPE)); + return mux; + } + return NULL; +} + +uint32_t IRAM_ATTR esp_coex_common_int_disable_wrapper(void *wifi_int_mux) +{ + if (xPortInIsrContext()) { + portENTER_CRITICAL_ISR(wifi_int_mux); + } else { + portENTER_CRITICAL(wifi_int_mux); + } + + return 0; +} + +void IRAM_ATTR esp_coex_common_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp) +{ + if (xPortInIsrContext()) { + portEXIT_CRITICAL_ISR(wifi_int_mux); + } else { + portEXIT_CRITICAL(wifi_int_mux); + } +} + +void IRAM_ATTR esp_coex_common_task_yield_from_isr_wrapper(void) { portYIELD_FROM_ISR(); } -void *internal_semphr_create_wrapper(uint32_t max, uint32_t init) +void * esp_coex_common_semphr_create_wrapper(uint32_t max, uint32_t init) +{ + return (void *)xSemaphoreCreateCounting(max, init); +} + +void esp_coex_common_semphr_delete_wrapper(void *semphr) +{ + vSemaphoreDelete(semphr); +} + +int32_t esp_coex_common_semphr_take_wrapper(void *semphr, uint32_t block_time_tick) +{ + if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) { + return (int32_t)xSemaphoreTake(semphr, portMAX_DELAY); + } else { + return (int32_t)xSemaphoreTake(semphr, block_time_tick); + } +} + +int32_t esp_coex_common_semphr_give_wrapper(void *semphr) +{ + return (int32_t)xSemaphoreGive(semphr); +} + +void IRAM_ATTR esp_coex_common_timer_disarm_wrapper(void *timer) +{ + ets_timer_disarm(timer); +} + +void esp_coex_common_timer_done_wrapper(void *ptimer) +{ + ets_timer_done(ptimer); +} + +void esp_coex_common_timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg) +{ + ets_timer_setfn(ptimer, pfunction, parg); +} + +void IRAM_ATTR esp_coex_common_timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat) +{ + ets_timer_arm_us(ptimer, us, repeat); +} + +void * IRAM_ATTR esp_coex_common_malloc_internal_wrapper(size_t size) +{ + return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); +} + +uint32_t esp_coex_common_clk_slowclk_cal_get_wrapper(void) +{ + /* The bit width of WiFi light sleep clock calibration is 12 while the one of + * system is 19. It should shift 19 - 12 = 7. + */ + if (GET_PERI_REG_MASK(SYSTEM_BT_LPCK_DIV_FRAC_REG, SYSTEM_LPCLK_SEL_XTAL)) { + uint64_t time_per_us = 1000000ULL; + return (((time_per_us << RTC_CLK_CAL_FRACT) / (MHZ)) >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH)); + } else { + return (esp_clk_slowclk_cal_get() >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH)); + } +} + +/* static wrapper */ + +static int IRAM_ATTR esp_coex_is_in_isr_wrapper(void) +{ + return !xPortCanYield(); +} + +static void *esp_coex_internal_semphr_create_wrapper(uint32_t max, uint32_t init) { modem_static_queue_t *semphr = heap_caps_calloc(1, sizeof(modem_static_queue_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); if (!semphr) { @@ -69,7 +182,7 @@ void *internal_semphr_create_wrapper(uint32_t max, uint32_t init) #endif } -void internal_semphr_delete_wrapper(void *semphr) +static void esp_coex_internal_semphr_delete_wrapper(void *semphr) { modem_static_queue_t *semphr_item = (modem_static_queue_t *)semphr; if (semphr_item) { @@ -85,17 +198,17 @@ void internal_semphr_delete_wrapper(void *semphr) } } -int32_t IRAM_ATTR internal_semphr_take_from_isr_wrapper(void *semphr, void *hptw) +static int32_t IRAM_ATTR esp_coex_internal_semphr_take_from_isr_wrapper(void *semphr, void *hptw) { return (int32_t)xSemaphoreTakeFromISR(((modem_static_queue_t *)semphr)->handle, hptw); } -int32_t IRAM_ATTR internal_semphr_give_from_isr_wrapper(void *semphr, void *hptw) +static int32_t IRAM_ATTR esp_coex_internal_semphr_give_from_isr_wrapper(void *semphr, void *hptw) { return (int32_t)xSemaphoreGiveFromISR(((modem_static_queue_t *)semphr)->handle, hptw); } -int32_t internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick) +static int32_t esp_coex_internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick) { if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) { return (int32_t)xSemaphoreTake(((modem_static_queue_t *)semphr)->handle, portMAX_DELAY); @@ -104,57 +217,27 @@ int32_t internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick) } } -int32_t internal_semphr_give_wrapper(void *semphr) +static int32_t esp_coex_internal_semphr_give_wrapper(void *semphr) { return (int32_t)xSemaphoreGive(((modem_static_queue_t *)semphr)->handle); } -void IRAM_ATTR timer_disarm_wrapper(void *timer) -{ - ets_timer_disarm(timer); -} - -void timer_done_wrapper(void *ptimer) -{ - ets_timer_done(ptimer); -} - -void timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg) -{ - ets_timer_setfn(ptimer, pfunction, parg); -} - -void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat) -{ - ets_timer_arm_us(ptimer, us, repeat); -} - -void * IRAM_ATTR malloc_internal_wrapper(size_t size) -{ - return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); -} - -int IRAM_ATTR coex_is_in_isr_wrapper(void) -{ - return !xPortCanYield(); -} - coex_adapter_funcs_t g_coex_adapter_funcs = { ._version = COEX_ADAPTER_VERSION, - ._task_yield_from_isr = task_yield_from_isr_wrapper, - ._semphr_create = internal_semphr_create_wrapper, - ._semphr_delete = internal_semphr_delete_wrapper, - ._semphr_take_from_isr = internal_semphr_take_from_isr_wrapper, - ._semphr_give_from_isr = internal_semphr_give_from_isr_wrapper, - ._semphr_take = internal_semphr_take_wrapper, - ._semphr_give = internal_semphr_give_wrapper, - ._is_in_isr = coex_is_in_isr_wrapper, - ._malloc_internal = malloc_internal_wrapper, + ._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper, + ._semphr_create = esp_coex_internal_semphr_create_wrapper, + ._semphr_delete = esp_coex_internal_semphr_delete_wrapper, + ._semphr_take_from_isr = esp_coex_internal_semphr_take_from_isr_wrapper, + ._semphr_give_from_isr = esp_coex_internal_semphr_give_from_isr_wrapper, + ._semphr_take = esp_coex_internal_semphr_take_wrapper, + ._semphr_give = esp_coex_internal_semphr_give_wrapper, + ._is_in_isr = esp_coex_is_in_isr_wrapper, + ._malloc_internal = esp_coex_common_malloc_internal_wrapper, ._free = free, ._esp_timer_get_time = esp_timer_get_time, - ._timer_disarm = timer_disarm_wrapper, - ._timer_done = timer_done_wrapper, - ._timer_setfn = timer_setfn_wrapper, - ._timer_arm_us = timer_arm_us_wrapper, + ._timer_disarm = esp_coex_common_timer_disarm_wrapper, + ._timer_done = esp_coex_common_timer_done_wrapper, + ._timer_setfn = esp_coex_common_timer_setfn_wrapper, + ._timer_arm_us = esp_coex_common_timer_arm_us_wrapper, ._magic = COEX_ADAPTER_MAGIC, }; diff --git a/components/esp_coex/include/esp_modem_wrapper.h b/components/esp_coex/include/esp_modem_wrapper.h index 464b05f60d0..8ce7a3a433f 100644 --- a/components/esp_coex/include/esp_modem_wrapper.h +++ b/components/esp_coex/include/esp_modem_wrapper.h @@ -15,44 +15,36 @@ extern "C" { #include #include -#ifdef CONFIG_IDF_TARGET_ESP32 -void * spin_lock_create_wrapper(void); +bool esp_coex_common_env_is_chip_wrapper(void); -uint32_t wifi_int_disable_wrapper(void *wifi_int_mux); +void * esp_coex_common_spin_lock_create_wrapper(void); -void wifi_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp); -#endif - -void task_yield_from_isr_wrapper(void); +uint32_t esp_coex_common_int_disable_wrapper(void *wifi_int_mux); -#if !defined(CONFIG_IDF_TARGET_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32S3) -void * semphr_create_wrapper(uint32_t max, uint32_t init); +void esp_coex_common_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp); -void semphr_delete_wrapper(void *semphr); +void esp_coex_common_task_yield_from_isr_wrapper(void); -int32_t semphr_take_from_isr_wrapper(void *semphr, void *hptw); +void * esp_coex_common_semphr_create_wrapper(uint32_t max, uint32_t init); -int32_t semphr_give_from_isr_wrapper(void *semphr, void *hptw); +void esp_coex_common_semphr_delete_wrapper(void *semphr); -int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick); - -int32_t semphr_give_wrapper(void *semphr); -#endif +int32_t esp_coex_common_semphr_take_wrapper(void *semphr, uint32_t block_time_tick); -void timer_disarm_wrapper(void *timer); +int32_t esp_coex_common_semphr_give_wrapper(void *semphr); -void timer_done_wrapper(void *ptimer); +void esp_coex_common_timer_disarm_wrapper(void *timer); -void timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg); +void esp_coex_common_timer_done_wrapper(void *ptimer); -void timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat); +void esp_coex_common_timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg); -void * malloc_internal_wrapper(size_t size); +void esp_coex_common_timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat); -#if CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C6 -bool env_is_chip_wrapper(void); +void * esp_coex_common_malloc_internal_wrapper(size_t size); -uint32_t esp_clk_slowclk_cal_get_wrapper(void); +#ifndef CONFIG_IDF_TARGET_ESP32 +uint32_t esp_coex_common_clk_slowclk_cal_get_wrapper(void); #endif #ifdef __cplusplus diff --git a/components/esp_wifi/esp32/esp_adapter.c b/components/esp_wifi/esp32/esp_adapter.c index 2e0cba008a8..20de25ec02c 100644 --- a/components/esp_wifi/esp32/esp_adapter.c +++ b/components/esp_wifi/esp32/esp_adapter.c @@ -172,15 +172,6 @@ static void wifi_delete_queue_wrapper(void *queue) wifi_delete_queue(queue); } -static bool IRAM_ATTR env_is_chip_wrapper(void) -{ -#ifdef CONFIG_IDF_ENV_FPGA - return false; -#else - return true; -#endif -} - static void set_intr_wrapper(int32_t cpu_no, uint32_t intr_source, uint32_t intr_num, int32_t intr_prio) { esp_rom_route_intr_matrix(cpu_no, intr_source, intr_num); @@ -201,16 +192,6 @@ static bool IRAM_ATTR is_from_isr_wrapper(void) return !xPortCanYield(); } -static void * semphr_create_wrapper(uint32_t max, uint32_t init) -{ - return (void *)xSemaphoreCreateCounting(max, init); -} - -static void semphr_delete_wrapper(void *semphr) -{ - vSemaphoreDelete(semphr); -} - static void wifi_thread_semphr_free(void* data) { SemaphoreHandle_t *sem = (SemaphoreHandle_t*)(data); @@ -246,20 +227,6 @@ static void * wifi_thread_semphr_get_wrapper(void) return (void*)sem; } -static int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick) -{ - if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) { - return (int32_t)xSemaphoreTake(semphr, portMAX_DELAY); - } else { - return (int32_t)xSemaphoreTake(semphr, block_time_tick); - } -} - -static int32_t semphr_give_wrapper(void *semphr) -{ - return (int32_t)xSemaphoreGive(semphr); -} - static void * recursive_mutex_create_wrapper(void) { return (void *)xSemaphoreCreateRecursiveMutex(); @@ -589,22 +556,22 @@ static void IRAM_ATTR esp_empty_wrapper(void) wifi_osi_funcs_t g_wifi_osi_funcs = { ._version = ESP_WIFI_OS_ADAPTER_VERSION, - ._env_is_chip = env_is_chip_wrapper, + ._env_is_chip = esp_coex_common_env_is_chip_wrapper, ._set_intr = set_intr_wrapper, ._clear_intr = clear_intr_wrapper, ._set_isr = set_isr_wrapper, ._ints_on = esp_cpu_intr_enable, ._ints_off = esp_cpu_intr_disable, ._is_from_isr = is_from_isr_wrapper, - ._spin_lock_create = spin_lock_create_wrapper, + ._spin_lock_create = esp_coex_common_spin_lock_create_wrapper, ._spin_lock_delete = free, - ._wifi_int_disable = wifi_int_disable_wrapper, - ._wifi_int_restore = wifi_int_restore_wrapper, - ._task_yield_from_isr = task_yield_from_isr_wrapper, - ._semphr_create = semphr_create_wrapper, - ._semphr_delete = semphr_delete_wrapper, - ._semphr_take = semphr_take_wrapper, - ._semphr_give = semphr_give_wrapper, + ._wifi_int_disable = esp_coex_common_int_disable_wrapper, + ._wifi_int_restore = esp_coex_common_int_restore_wrapper, + ._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper, + ._semphr_create = esp_coex_common_semphr_create_wrapper, + ._semphr_delete = esp_coex_common_semphr_delete_wrapper, + ._semphr_take = esp_coex_common_semphr_take_wrapper, + ._semphr_give = esp_coex_common_semphr_give_wrapper, ._wifi_thread_semphr_get = wifi_thread_semphr_get_wrapper, ._mutex_create = mutex_create_wrapper, ._recursive_mutex_create = recursive_mutex_create_wrapper, @@ -647,10 +614,10 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._phy_update_country_info = esp_phy_update_country_info, ._read_mac = esp_read_mac, ._timer_arm = timer_arm_wrapper, - ._timer_disarm = timer_disarm_wrapper, - ._timer_done = timer_done_wrapper, - ._timer_setfn = timer_setfn_wrapper, - ._timer_arm_us = timer_arm_us_wrapper, + ._timer_disarm = esp_coex_common_timer_disarm_wrapper, + ._timer_done = esp_coex_common_timer_done_wrapper, + ._timer_setfn = esp_coex_common_timer_setfn_wrapper, + ._timer_arm_us = esp_coex_common_timer_arm_us_wrapper, ._wifi_reset_mac = wifi_reset_mac_wrapper, ._wifi_clock_enable = wifi_clock_enable_wrapper, ._wifi_clock_disable = wifi_clock_disable_wrapper, @@ -675,7 +642,7 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._log_write = esp_log_write, ._log_writev = esp_log_writev, ._log_timestamp = esp_log_timestamp, - ._malloc_internal = malloc_internal_wrapper, + ._malloc_internal = esp_coex_common_malloc_internal_wrapper, ._realloc_internal = realloc_internal_wrapper, ._calloc_internal = calloc_internal_wrapper, ._zalloc_internal = zalloc_internal_wrapper, diff --git a/components/esp_wifi/esp32c2/esp_adapter.c b/components/esp_wifi/esp32c2/esp_adapter.c index 3bd74dcc575..a6dfd460596 100644 --- a/components/esp_wifi/esp32c2/esp_adapter.c +++ b/components/esp_wifi/esp32c2/esp_adapter.c @@ -130,38 +130,6 @@ static void disable_intr_wrapper(uint32_t intr_mask) esprv_intc_int_disable(intr_mask); } -static void * spin_lock_create_wrapper(void) -{ - portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED; - void *mux = malloc(sizeof(portMUX_TYPE)); - - if (mux) { - memcpy(mux,&tmp,sizeof(portMUX_TYPE)); - return mux; - } - return NULL; -} - -static uint32_t IRAM_ATTR wifi_int_disable_wrapper(void *wifi_int_mux) -{ - if (xPortInIsrContext()) { - portENTER_CRITICAL_ISR(wifi_int_mux); - } else { - portENTER_CRITICAL(wifi_int_mux); - } - - return 0; -} - -static void IRAM_ATTR wifi_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp) -{ - if (xPortInIsrContext()) { - portEXIT_CRITICAL_ISR(wifi_int_mux); - } else { - portEXIT_CRITICAL(wifi_int_mux); - } -} - static bool IRAM_ATTR is_from_isr_wrapper(void) { return !xPortCanYield(); @@ -572,22 +540,22 @@ static void IRAM_ATTR esp_empty_wrapper(void) wifi_osi_funcs_t g_wifi_osi_funcs = { ._version = ESP_WIFI_OS_ADAPTER_VERSION, - ._env_is_chip = env_is_chip_wrapper, + ._env_is_chip = esp_coex_common_env_is_chip_wrapper, ._set_intr = set_intr_wrapper, ._clear_intr = clear_intr_wrapper, ._set_isr = set_isr_wrapper, ._ints_on = enable_intr_wrapper, ._ints_off = disable_intr_wrapper, ._is_from_isr = is_from_isr_wrapper, - ._spin_lock_create = spin_lock_create_wrapper, + ._spin_lock_create = esp_coex_common_spin_lock_create_wrapper, ._spin_lock_delete = free, - ._wifi_int_disable = wifi_int_disable_wrapper, - ._wifi_int_restore = wifi_int_restore_wrapper, - ._task_yield_from_isr = task_yield_from_isr_wrapper, - ._semphr_create = semphr_create_wrapper, - ._semphr_delete = semphr_delete_wrapper, - ._semphr_take = semphr_take_wrapper, - ._semphr_give = semphr_give_wrapper, + ._wifi_int_disable = esp_coex_common_int_disable_wrapper, + ._wifi_int_restore = esp_coex_common_int_restore_wrapper, + ._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper, + ._semphr_create = esp_coex_common_semphr_create_wrapper, + ._semphr_delete = esp_coex_common_semphr_delete_wrapper, + ._semphr_take = esp_coex_common_semphr_take_wrapper, + ._semphr_give = esp_coex_common_semphr_give_wrapper, ._wifi_thread_semphr_get = wifi_thread_semphr_get_wrapper, ._mutex_create = mutex_create_wrapper, ._recursive_mutex_create = recursive_mutex_create_wrapper, @@ -628,10 +596,10 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._phy_update_country_info = esp_phy_update_country_info, ._read_mac = esp_read_mac_wrapper, ._timer_arm = timer_arm_wrapper, - ._timer_disarm = timer_disarm_wrapper, - ._timer_done = timer_done_wrapper, - ._timer_setfn = timer_setfn_wrapper, - ._timer_arm_us = timer_arm_us_wrapper, + ._timer_disarm = esp_coex_common_timer_disarm_wrapper, + ._timer_done = esp_coex_common_timer_done_wrapper, + ._timer_setfn = esp_coex_common_timer_setfn_wrapper, + ._timer_arm_us = esp_coex_common_timer_arm_us_wrapper, ._wifi_reset_mac = wifi_reset_mac_wrapper, ._wifi_clock_enable = wifi_clock_enable_wrapper, ._wifi_clock_disable = wifi_clock_disable_wrapper, @@ -653,11 +621,11 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._get_random = os_get_random, ._get_time = get_time_wrapper, ._random = os_random, - ._slowclk_cal_get = esp_clk_slowclk_cal_get_wrapper, + ._slowclk_cal_get = esp_coex_common_clk_slowclk_cal_get_wrapper, ._log_write = esp_log_write_wrapper, ._log_writev = esp_log_writev_wrapper, ._log_timestamp = esp_log_timestamp, - ._malloc_internal = malloc_internal_wrapper, + ._malloc_internal = esp_coex_common_malloc_internal_wrapper, ._realloc_internal = realloc_internal_wrapper, ._calloc_internal = calloc_internal_wrapper, ._zalloc_internal = zalloc_internal_wrapper, diff --git a/components/esp_wifi/esp32c3/esp_adapter.c b/components/esp_wifi/esp32c3/esp_adapter.c index ff94d9c37d6..13b619031b9 100644 --- a/components/esp_wifi/esp32c3/esp_adapter.c +++ b/components/esp_wifi/esp32c3/esp_adapter.c @@ -106,15 +106,6 @@ static void wifi_delete_queue_wrapper(void *queue) wifi_delete_queue(queue); } -static bool IRAM_ATTR env_is_chip_wrapper(void) -{ -#ifdef CONFIG_IDF_ENV_FPGA - return false; -#else - return true; -#endif -} - static void set_intr_wrapper(int32_t cpu_no, uint32_t intr_source, uint32_t intr_num, int32_t intr_prio) { intr_matrix_route(intr_source, intr_num); @@ -142,38 +133,6 @@ static void disable_intr_wrapper(uint32_t intr_mask) esprv_intc_int_disable(intr_mask); } -static void * spin_lock_create_wrapper(void) -{ - portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED; - void *mux = malloc(sizeof(portMUX_TYPE)); - - if (mux) { - memcpy(mux,&tmp,sizeof(portMUX_TYPE)); - return mux; - } - return NULL; -} - -static uint32_t IRAM_ATTR wifi_int_disable_wrapper(void *wifi_int_mux) -{ - if (xPortInIsrContext()) { - portENTER_CRITICAL_ISR(wifi_int_mux); - } else { - portENTER_CRITICAL(wifi_int_mux); - } - - return 0; -} - -static void IRAM_ATTR wifi_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp) -{ - if (xPortInIsrContext()) { - portEXIT_CRITICAL_ISR(wifi_int_mux); - } else { - portEXIT_CRITICAL(wifi_int_mux); - } -} - static bool IRAM_ATTR is_from_isr_wrapper(void) { return !xPortCanYield(); @@ -368,19 +327,6 @@ static int get_time_wrapper(void *t) return os_get_time(t); } -static uint32_t esp_clk_slowclk_cal_get_wrapper(void) -{ - /* The bit width of WiFi light sleep clock calibration is 12 while the one of - * system is 19. It should shift 19 - 12 = 7. - */ - if (GET_PERI_REG_MASK(SYSTEM_BT_LPCK_DIV_FRAC_REG, SYSTEM_LPCLK_SEL_XTAL)) { - uint64_t time_per_us = 1000000ULL; - return (((time_per_us << RTC_CLK_CAL_FRACT) / (MHZ)) >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH)); - } else { - return (esp_clk_slowclk_cal_get() >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH)); - } -} - static void * IRAM_ATTR realloc_internal_wrapper(void *ptr, size_t size) { return heap_caps_realloc(ptr, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); @@ -597,22 +543,22 @@ static void IRAM_ATTR esp_empty_wrapper(void) wifi_osi_funcs_t g_wifi_osi_funcs = { ._version = ESP_WIFI_OS_ADAPTER_VERSION, - ._env_is_chip = env_is_chip_wrapper, + ._env_is_chip = esp_coex_common_env_is_chip_wrapper, ._set_intr = set_intr_wrapper, ._clear_intr = clear_intr_wrapper, ._set_isr = set_isr_wrapper, ._ints_on = enable_intr_wrapper, ._ints_off = disable_intr_wrapper, ._is_from_isr = is_from_isr_wrapper, - ._spin_lock_create = spin_lock_create_wrapper, + ._spin_lock_create = esp_coex_common_spin_lock_create_wrapper, ._spin_lock_delete = free, - ._wifi_int_disable = wifi_int_disable_wrapper, - ._wifi_int_restore = wifi_int_restore_wrapper, - ._task_yield_from_isr = task_yield_from_isr_wrapper, - ._semphr_create = semphr_create_wrapper, - ._semphr_delete = semphr_delete_wrapper, - ._semphr_take = semphr_take_wrapper, - ._semphr_give = semphr_give_wrapper, + ._wifi_int_disable = esp_coex_common_int_disable_wrapper, + ._wifi_int_restore = esp_coex_common_int_restore_wrapper, + ._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper, + ._semphr_create = esp_coex_common_semphr_create_wrapper, + ._semphr_delete = esp_coex_common_semphr_delete_wrapper, + ._semphr_take = esp_coex_common_semphr_take_wrapper, + ._semphr_give = esp_coex_common_semphr_give_wrapper, ._wifi_thread_semphr_get = wifi_thread_semphr_get_wrapper, ._mutex_create = mutex_create_wrapper, ._recursive_mutex_create = recursive_mutex_create_wrapper, @@ -653,10 +599,10 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._phy_update_country_info = esp_phy_update_country_info, ._read_mac = esp_read_mac_wrapper, ._timer_arm = timer_arm_wrapper, - ._timer_disarm = timer_disarm_wrapper, - ._timer_done = timer_done_wrapper, - ._timer_setfn = timer_setfn_wrapper, - ._timer_arm_us = timer_arm_us_wrapper, + ._timer_disarm = esp_coex_common_timer_disarm_wrapper, + ._timer_done = esp_coex_common_timer_done_wrapper, + ._timer_setfn = esp_coex_common_timer_setfn_wrapper, + ._timer_arm_us = esp_coex_common_timer_arm_us_wrapper, ._wifi_reset_mac = wifi_reset_mac_wrapper, ._wifi_clock_enable = wifi_clock_enable_wrapper, ._wifi_clock_disable = wifi_clock_disable_wrapper, @@ -678,11 +624,11 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._get_random = os_get_random, ._get_time = get_time_wrapper, ._random = os_random, - ._slowclk_cal_get = esp_clk_slowclk_cal_get_wrapper, + ._slowclk_cal_get = esp_coex_common_clk_slowclk_cal_get_wrapper, ._log_write = esp_log_write_wrapper, ._log_writev = esp_log_writev_wrapper, ._log_timestamp = esp_log_timestamp, - ._malloc_internal = malloc_internal_wrapper, + ._malloc_internal = esp_coex_common_malloc_internal_wrapper, ._realloc_internal = realloc_internal_wrapper, ._calloc_internal = calloc_internal_wrapper, ._zalloc_internal = zalloc_internal_wrapper, diff --git a/components/esp_wifi/esp32c6/esp_adapter.c b/components/esp_wifi/esp32c6/esp_adapter.c index 78c1e39574c..86cc1b7005d 100644 --- a/components/esp_wifi/esp32c6/esp_adapter.c +++ b/components/esp_wifi/esp32c6/esp_adapter.c @@ -129,38 +129,6 @@ static void disable_intr_wrapper(uint32_t intr_mask) esprv_intc_int_disable(intr_mask); } -static void *spin_lock_create_wrapper(void) -{ - portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED; - void *mux = malloc(sizeof(portMUX_TYPE)); - - if (mux) { - memcpy(mux, &tmp, sizeof(portMUX_TYPE)); - return mux; - } - return NULL; -} - -static uint32_t IRAM_ATTR wifi_int_disable_wrapper(void *wifi_int_mux) -{ - if (xPortInIsrContext()) { - portENTER_CRITICAL_ISR(wifi_int_mux); - } else { - portENTER_CRITICAL(wifi_int_mux); - } - - return 0; -} - -static void IRAM_ATTR wifi_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp) -{ - if (xPortInIsrContext()) { - portEXIT_CRITICAL_ISR(wifi_int_mux); - } else { - portEXIT_CRITICAL(wifi_int_mux); - } -} - static bool IRAM_ATTR is_from_isr_wrapper(void) { return !xPortCanYield(); @@ -570,22 +538,22 @@ static void IRAM_ATTR esp_empty_wrapper(void) wifi_osi_funcs_t g_wifi_osi_funcs = { ._version = ESP_WIFI_OS_ADAPTER_VERSION, - ._env_is_chip = env_is_chip_wrapper, + ._env_is_chip = esp_coex_common_env_is_chip_wrapper, ._set_intr = set_intr_wrapper, ._clear_intr = clear_intr_wrapper, ._set_isr = set_isr_wrapper, ._ints_on = enable_intr_wrapper, ._ints_off = disable_intr_wrapper, ._is_from_isr = is_from_isr_wrapper, - ._spin_lock_create = spin_lock_create_wrapper, + ._spin_lock_create = esp_coex_common_spin_lock_create_wrapper, ._spin_lock_delete = free, - ._wifi_int_disable = wifi_int_disable_wrapper, - ._wifi_int_restore = wifi_int_restore_wrapper, - ._task_yield_from_isr = task_yield_from_isr_wrapper, - ._semphr_create = semphr_create_wrapper, - ._semphr_delete = semphr_delete_wrapper, - ._semphr_take = semphr_take_wrapper, - ._semphr_give = semphr_give_wrapper, + ._wifi_int_disable = esp_coex_common_int_disable_wrapper, + ._wifi_int_restore = esp_coex_common_int_restore_wrapper, + ._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper, + ._semphr_create = esp_coex_common_semphr_create_wrapper, + ._semphr_delete = esp_coex_common_semphr_delete_wrapper, + ._semphr_take = esp_coex_common_semphr_take_wrapper, + ._semphr_give = esp_coex_common_semphr_give_wrapper, ._wifi_thread_semphr_get = wifi_thread_semphr_get_wrapper, ._mutex_create = mutex_create_wrapper, ._recursive_mutex_create = recursive_mutex_create_wrapper, @@ -626,10 +594,10 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._phy_update_country_info = esp_phy_update_country_info, ._read_mac = esp_read_mac_wrapper, ._timer_arm = timer_arm_wrapper, - ._timer_disarm = timer_disarm_wrapper, - ._timer_done = timer_done_wrapper, - ._timer_setfn = timer_setfn_wrapper, - ._timer_arm_us = timer_arm_us_wrapper, + ._timer_disarm = esp_coex_common_timer_disarm_wrapper, + ._timer_done = esp_coex_common_timer_done_wrapper, + ._timer_setfn = esp_coex_common_timer_setfn_wrapper, + ._timer_arm_us = esp_coex_common_timer_arm_us_wrapper, ._wifi_reset_mac = wifi_reset_mac_wrapper, ._wifi_clock_enable = wifi_clock_enable_wrapper, ._wifi_clock_disable = wifi_clock_disable_wrapper, @@ -651,11 +619,11 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._get_random = os_get_random, ._get_time = get_time_wrapper, ._random = os_random, - ._slowclk_cal_get = esp_clk_slowclk_cal_get_wrapper, + ._slowclk_cal_get = esp_coex_common_clk_slowclk_cal_get_wrapper, ._log_write = esp_log_write_wrapper, ._log_writev = esp_log_writev_wrapper, ._log_timestamp = esp_log_timestamp, - ._malloc_internal = malloc_internal_wrapper, + ._malloc_internal = esp_coex_common_malloc_internal_wrapper, ._realloc_internal = realloc_internal_wrapper, ._calloc_internal = calloc_internal_wrapper, ._zalloc_internal = zalloc_internal_wrapper, diff --git a/components/esp_wifi/esp32s2/esp_adapter.c b/components/esp_wifi/esp32s2/esp_adapter.c index 698dd144f43..6468d800f75 100644 --- a/components/esp_wifi/esp32s2/esp_adapter.c +++ b/components/esp_wifi/esp32s2/esp_adapter.c @@ -163,15 +163,6 @@ static void wifi_delete_queue_wrapper(void *queue) wifi_delete_queue(queue); } -static bool IRAM_ATTR env_is_chip_wrapper(void) -{ -#ifdef CONFIG_IDF_ENV_FPGA - return false; -#else - return true; -#endif -} - static void set_intr_wrapper(int32_t cpu_no, uint32_t intr_source, uint32_t intr_num, int32_t intr_prio) { esp_rom_route_intr_matrix(cpu_no, intr_source, intr_num); @@ -187,53 +178,11 @@ static void set_isr_wrapper(int32_t n, void *f, void *arg) xt_set_interrupt_handler(n, (xt_handler)f, arg); } -static void * spin_lock_create_wrapper(void) -{ - portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED; - void *mux = heap_caps_malloc(sizeof(portMUX_TYPE), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); - - if (mux) { - memcpy(mux,&tmp,sizeof(portMUX_TYPE)); - return mux; - } - return NULL; -} - -static uint32_t IRAM_ATTR wifi_int_disable_wrapper(void *wifi_int_mux) -{ - if (xPortInIsrContext()) { - portENTER_CRITICAL_ISR(wifi_int_mux); - } else { - portENTER_CRITICAL(wifi_int_mux); - } - - return 0; -} - -static void IRAM_ATTR wifi_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp) -{ - if (xPortInIsrContext()) { - portEXIT_CRITICAL_ISR(wifi_int_mux); - } else { - portEXIT_CRITICAL(wifi_int_mux); - } -} - static bool IRAM_ATTR is_from_isr_wrapper(void) { return !xPortCanYield(); } -static void * semphr_create_wrapper(uint32_t max, uint32_t init) -{ - return (void *)xSemaphoreCreateCounting(max, init); -} - -static void semphr_delete_wrapper(void *semphr) -{ - vSemaphoreDelete(semphr); -} - static void wifi_thread_semphr_free(void* data) { SemaphoreHandle_t *sem = (SemaphoreHandle_t*)(data); @@ -269,20 +218,6 @@ static void * wifi_thread_semphr_get_wrapper(void) return (void*)sem; } -static int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick) -{ - if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) { - return (int32_t)xSemaphoreTake(semphr, portMAX_DELAY); - } else { - return (int32_t)xSemaphoreTake(semphr, block_time_tick); - } -} - -static int32_t semphr_give_wrapper(void *semphr) -{ - return (int32_t)xSemaphoreGive(semphr); -} - static void * recursive_mutex_create_wrapper(void) { return (void *)xSemaphoreCreateRecursiveMutex(); @@ -423,14 +358,6 @@ static int get_time_wrapper(void *t) return os_get_time(t); } -static uint32_t esp_clk_slowclk_cal_get_wrapper(void) -{ - /* The bit width of WiFi light sleep clock calibration is 12 while the one of - * system is 19. It should shift 19 - 12 = 7. - */ - return (esp_clk_slowclk_cal_get() >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH)); -} - static void * IRAM_ATTR realloc_internal_wrapper(void *ptr, size_t size) { return heap_caps_realloc(ptr, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); @@ -624,22 +551,22 @@ static void IRAM_ATTR esp_empty_wrapper(void) wifi_osi_funcs_t g_wifi_osi_funcs = { ._version = ESP_WIFI_OS_ADAPTER_VERSION, - ._env_is_chip = env_is_chip_wrapper, + ._env_is_chip = esp_coex_common_env_is_chip_wrapper, ._set_intr = set_intr_wrapper, ._clear_intr = clear_intr_wrapper, ._set_isr = set_isr_wrapper, ._ints_on = esp_cpu_intr_enable, ._ints_off = esp_cpu_intr_disable, ._is_from_isr = is_from_isr_wrapper, - ._spin_lock_create = spin_lock_create_wrapper, + ._spin_lock_create = esp_coex_common_spin_lock_create_wrapper, ._spin_lock_delete = free, - ._wifi_int_disable = wifi_int_disable_wrapper, - ._wifi_int_restore = wifi_int_restore_wrapper, - ._task_yield_from_isr = task_yield_from_isr_wrapper, - ._semphr_create = semphr_create_wrapper, - ._semphr_delete = semphr_delete_wrapper, - ._semphr_take = semphr_take_wrapper, - ._semphr_give = semphr_give_wrapper, + ._wifi_int_disable = esp_coex_common_int_disable_wrapper, + ._wifi_int_restore = esp_coex_common_int_restore_wrapper, + ._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper, + ._semphr_create = esp_coex_common_semphr_create_wrapper, + ._semphr_delete = esp_coex_common_semphr_delete_wrapper, + ._semphr_take = esp_coex_common_semphr_take_wrapper, + ._semphr_give = esp_coex_common_semphr_give_wrapper, ._wifi_thread_semphr_get = wifi_thread_semphr_get_wrapper, ._mutex_create = mutex_create_wrapper, ._recursive_mutex_create = recursive_mutex_create_wrapper, @@ -682,10 +609,10 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._phy_update_country_info = esp_phy_update_country_info, ._read_mac = esp_read_mac, ._timer_arm = timer_arm_wrapper, - ._timer_disarm = timer_disarm_wrapper, - ._timer_done = timer_done_wrapper, - ._timer_setfn = timer_setfn_wrapper, - ._timer_arm_us = timer_arm_us_wrapper, + ._timer_disarm = esp_coex_common_timer_disarm_wrapper, + ._timer_done = esp_coex_common_timer_done_wrapper, + ._timer_setfn = esp_coex_common_timer_setfn_wrapper, + ._timer_arm_us = esp_coex_common_timer_arm_us_wrapper, ._wifi_reset_mac = wifi_reset_mac_wrapper, ._wifi_clock_enable = wifi_clock_enable_wrapper, ._wifi_clock_disable = wifi_clock_disable_wrapper, @@ -707,11 +634,11 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._get_random = os_get_random, ._get_time = get_time_wrapper, ._random = os_random, - ._slowclk_cal_get = esp_clk_slowclk_cal_get_wrapper, + ._slowclk_cal_get = esp_coex_common_clk_slowclk_cal_get_wrapper, ._log_write = esp_log_write, ._log_writev = esp_log_writev, ._log_timestamp = esp_log_timestamp, - ._malloc_internal = malloc_internal_wrapper, + ._malloc_internal = esp_coex_common_malloc_internal_wrapper, ._realloc_internal = realloc_internal_wrapper, ._calloc_internal = calloc_internal_wrapper, ._zalloc_internal = zalloc_internal_wrapper, diff --git a/components/esp_wifi/esp32s3/esp_adapter.c b/components/esp_wifi/esp32s3/esp_adapter.c index 95ab748163b..9a76e612793 100644 --- a/components/esp_wifi/esp32s3/esp_adapter.c +++ b/components/esp_wifi/esp32s3/esp_adapter.c @@ -166,15 +166,6 @@ static void wifi_delete_queue_wrapper(void *queue) wifi_delete_queue(queue); } -static bool IRAM_ATTR env_is_chip_wrapper(void) -{ -#ifdef CONFIG_IDF_ENV_FPGA - return false; -#else - return true; -#endif -} - static void set_intr_wrapper(int32_t cpu_no, uint32_t intr_source, uint32_t intr_num, int32_t intr_prio) { esp_rom_route_intr_matrix(cpu_no, intr_source, intr_num); @@ -190,53 +181,11 @@ static void set_isr_wrapper(int32_t n, void *f, void *arg) xt_set_interrupt_handler(n, (xt_handler)f, arg); } -static void * spin_lock_create_wrapper(void) -{ - portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED; - void *mux = heap_caps_malloc(sizeof(portMUX_TYPE), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); - - if (mux) { - memcpy(mux,&tmp,sizeof(portMUX_TYPE)); - return mux; - } - return NULL; -} - -static uint32_t IRAM_ATTR wifi_int_disable_wrapper(void *wifi_int_mux) -{ - if (xPortInIsrContext()) { - portENTER_CRITICAL_ISR(wifi_int_mux); - } else { - portENTER_CRITICAL(wifi_int_mux); - } - - return 0; -} - -static void IRAM_ATTR wifi_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp) -{ - if (xPortInIsrContext()) { - portEXIT_CRITICAL_ISR(wifi_int_mux); - } else { - portEXIT_CRITICAL(wifi_int_mux); - } -} - static bool IRAM_ATTR is_from_isr_wrapper(void) { return !xPortCanYield(); } -static void * semphr_create_wrapper(uint32_t max, uint32_t init) -{ - return (void *)xSemaphoreCreateCounting(max, init); -} - -static void semphr_delete_wrapper(void *semphr) -{ - vSemaphoreDelete(semphr); -} - static void wifi_thread_semphr_free(void* data) { SemaphoreHandle_t *sem = (SemaphoreHandle_t*)(data); @@ -272,20 +221,6 @@ static void * wifi_thread_semphr_get_wrapper(void) return (void*)sem; } -static int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick) -{ - if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) { - return (int32_t)xSemaphoreTake(semphr, portMAX_DELAY); - } else { - return (int32_t)xSemaphoreTake(semphr, block_time_tick); - } -} - -static int32_t semphr_give_wrapper(void *semphr) -{ - return (int32_t)xSemaphoreGive(semphr); -} - static void * recursive_mutex_create_wrapper(void) { return (void *)xSemaphoreCreateRecursiveMutex(); @@ -440,19 +375,6 @@ static int get_time_wrapper(void *t) return os_get_time(t); } -static uint32_t esp_clk_slowclk_cal_get_wrapper(void) -{ - /* The bit width of WiFi light sleep clock calibration is 12 while the one of - * system is 19. It should shift 19 - 12 = 7. - */ - if (GET_PERI_REG_MASK(SYSTEM_BT_LPCK_DIV_FRAC_REG, SYSTEM_LPCLK_SEL_XTAL)) { - uint64_t time_per_us = 1000000ULL; - return (((time_per_us << RTC_CLK_CAL_FRACT) / (MHZ)) >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH)); - } else { - return (esp_clk_slowclk_cal_get() >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH)); - } -} - static void * IRAM_ATTR realloc_internal_wrapper(void *ptr, size_t size) { return heap_caps_realloc(ptr, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); @@ -646,22 +568,22 @@ static void IRAM_ATTR esp_empty_wrapper(void) wifi_osi_funcs_t g_wifi_osi_funcs = { ._version = ESP_WIFI_OS_ADAPTER_VERSION, - ._env_is_chip = env_is_chip_wrapper, + ._env_is_chip = esp_coex_common_env_is_chip_wrapper, ._set_intr = set_intr_wrapper, ._clear_intr = clear_intr_wrapper, ._set_isr = set_isr_wrapper, ._ints_on = esp_cpu_intr_enable, ._ints_off = esp_cpu_intr_disable, ._is_from_isr = is_from_isr_wrapper, - ._spin_lock_create = spin_lock_create_wrapper, + ._spin_lock_create = esp_coex_common_spin_lock_create_wrapper, ._spin_lock_delete = free, - ._wifi_int_disable = wifi_int_disable_wrapper, - ._wifi_int_restore = wifi_int_restore_wrapper, - ._task_yield_from_isr = task_yield_from_isr_wrapper, - ._semphr_create = semphr_create_wrapper, - ._semphr_delete = semphr_delete_wrapper, - ._semphr_take = semphr_take_wrapper, - ._semphr_give = semphr_give_wrapper, + ._wifi_int_disable = esp_coex_common_int_disable_wrapper, + ._wifi_int_restore = esp_coex_common_int_restore_wrapper, + ._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper, + ._semphr_create = esp_coex_common_semphr_create_wrapper, + ._semphr_delete = esp_coex_common_semphr_delete_wrapper, + ._semphr_take = esp_coex_common_semphr_take_wrapper, + ._semphr_give = esp_coex_common_semphr_give_wrapper, ._wifi_thread_semphr_get = wifi_thread_semphr_get_wrapper, ._mutex_create = mutex_create_wrapper, ._recursive_mutex_create = recursive_mutex_create_wrapper, @@ -702,10 +624,10 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._phy_update_country_info = esp_phy_update_country_info, ._read_mac = esp_read_mac, ._timer_arm = timer_arm_wrapper, - ._timer_disarm = timer_disarm_wrapper, - ._timer_done = timer_done_wrapper, - ._timer_setfn = timer_setfn_wrapper, - ._timer_arm_us = timer_arm_us_wrapper, + ._timer_disarm = esp_coex_common_timer_disarm_wrapper, + ._timer_done = esp_coex_common_timer_done_wrapper, + ._timer_setfn = esp_coex_common_timer_setfn_wrapper, + ._timer_arm_us = esp_coex_common_timer_arm_us_wrapper, ._wifi_reset_mac = wifi_reset_mac_wrapper, ._wifi_clock_enable = wifi_clock_enable_wrapper, ._wifi_clock_disable = wifi_clock_disable_wrapper, @@ -727,11 +649,11 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._get_random = os_get_random, ._get_time = get_time_wrapper, ._random = os_random, - ._slowclk_cal_get = esp_clk_slowclk_cal_get_wrapper, + ._slowclk_cal_get = esp_coex_common_clk_slowclk_cal_get_wrapper, ._log_write = esp_log_write, ._log_writev = esp_log_writev, ._log_timestamp = esp_log_timestamp, - ._malloc_internal = malloc_internal_wrapper, + ._malloc_internal = esp_coex_common_malloc_internal_wrapper, ._realloc_internal = realloc_internal_wrapper, ._calloc_internal = calloc_internal_wrapper, ._zalloc_internal = zalloc_internal_wrapper, From db11eaecdcbe7ca8430fa061e8785a7c09d939cb Mon Sep 17 00:00:00 2001 From: liuning Date: Thu, 16 Feb 2023 11:28:51 +0800 Subject: [PATCH 10/10] feature: separate coex lib from wifi lib, support esp32c6 internal coex update wifi, coex, phy libs --- .gitlab/CODEOWNERS | 1 + .gitlab/ci/rules.yml | 3 +++ components/esp_coex/lib | 2 +- components/esp_phy/lib | 2 +- components/esp_wifi/lib | 2 +- 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.gitlab/CODEOWNERS b/.gitlab/CODEOWNERS index e836f60e103..843c156be13 100644 --- a/.gitlab/CODEOWNERS +++ b/.gitlab/CODEOWNERS @@ -80,6 +80,7 @@ /components/efuse/ @esp-idf-codeowners/system /components/esp_adc/ @esp-idf-codeowners/peripherals /components/esp_app_format/ @esp-idf-codeowners/system @esp-idf-codeowners/app-utilities +/components/esp_coex/ @esp-idf-codeowners/wifi @esp-idf-codeowners/bluetooth @esp-idf-codeowners/ieee802154 /components/esp_common/ @esp-idf-codeowners/system /components/esp_eth/ @esp-idf-codeowners/network /components/esp_event/ @esp-idf-codeowners/system diff --git a/.gitlab/ci/rules.yml b/.gitlab/ci/rules.yml index f60d97973d7..05276471aab 100644 --- a/.gitlab/ci/rules.yml +++ b/.gitlab/ci/rules.yml @@ -86,6 +86,7 @@ .patterns-target_test-i154: &patterns-target_test-i154 - "components/esp_phy/**/*" - "components/ieee802154/**/*" + - "components/esp_coex/**/*" .patterns-example_test-i154: &patterns-example_test-i154 - "components/esp_netif/**/*" @@ -100,6 +101,7 @@ - "components/esp_wifi/**/*" - "components/esp_phy/**/*" - "components/wpa_supplicant/**/*" + - "components/esp_coex/**/*" .patterns-integration_test-ble: &patterns-integration_test-ble - "tools/ci/python_packages/gitlab_api.py" @@ -109,6 +111,7 @@ - "components/bt/controller/lib_esp32h2/esp32h2-bt-lib" - "components/bt/host/nimble/nimble" - "components/esp_phy/lib" + - "components/esp_coex/**/*" .patterns-integration_test-wifi: &patterns-integration_test-wifi - "tools/ci/python_packages/gitlab_api.py" diff --git a/components/esp_coex/lib b/components/esp_coex/lib index 403b94e8e06..cc8eae05caf 160000 --- a/components/esp_coex/lib +++ b/components/esp_coex/lib @@ -1 +1 @@ -Subproject commit 403b94e8e0691942ea0fb5ee54310d0089b15b3a +Subproject commit cc8eae05caf9b67ddbde40b057e32748c197b95b diff --git a/components/esp_phy/lib b/components/esp_phy/lib index b3e4adbe766..1ab8c85ff11 160000 --- a/components/esp_phy/lib +++ b/components/esp_phy/lib @@ -1 +1 @@ -Subproject commit b3e4adbe7663700ff6950d9d420e112a743f586f +Subproject commit 1ab8c85ff11a8e0f85d430726b2ff2d3c40dbf1b diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 7e1c6ef8bff..adf9880a99c 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 7e1c6ef8bff1d666b2a150110367abdf646ffafc +Subproject commit adf9880a99c6fba80a5f0d376f17de5c91151ff3