From b09488d35abc2b47d727b44756a471883db68bd6 Mon Sep 17 00:00:00 2001 From: liuning Date: Mon, 23 Sep 2024 20:18:43 +0800 Subject: [PATCH] fix(coex): fix some coexist debug issues --- components/esp_coex/Kconfig | 4 +- .../include/private/esp_coexist_debug.h | 11 +++- components/esp_coex/src/coexist_debug.c | 50 ++++++++++--------- 3 files changed, 37 insertions(+), 28 deletions(-) diff --git a/components/esp_coex/Kconfig b/components/esp_coex/Kconfig index 5fb0eac973..bc37b3820b 100644 --- a/components/esp_coex/Kconfig +++ b/components/esp_coex/Kconfig @@ -217,7 +217,7 @@ menu "Wireless Coexistence" default 12 if IDF_TARGET_ESP32S3 default 3 if IDF_TARGET_ESP32C2 default 22 if IDF_TARGET_ESP32C6 - default 16 if IDF_TARGET_ESP32C5 + default 10 if IDF_TARGET_ESP32C5 default 13 if IDF_TARGET_ESP32C61 default 11 @@ -231,7 +231,7 @@ menu "Wireless Coexistence" default 13 if IDF_TARGET_ESP32S3 default 2 if IDF_TARGET_ESP32C2 default 21 if IDF_TARGET_ESP32C6 - default 0 if IDF_TARGET_ESP32C5 + default 9 if IDF_TARGET_ESP32C5 default 12 if IDF_TARGET_ESP32C61 default 12 diff --git a/components/esp_coex/include/private/esp_coexist_debug.h b/components/esp_coex/include/private/esp_coexist_debug.h index 26147262c7..80bfbbd5aa 100644 --- a/components/esp_coex/include/private/esp_coexist_debug.h +++ b/components/esp_coex/include/private/esp_coexist_debug.h @@ -108,7 +108,7 @@ typedef enum { #endif /* wifi callback -> debug */ -void wifi_set_gpio_debug_cb(void (* cb)(int, int)); +void wifi_set_gpio_debug_cb(void (* cb)(int, coex_gpio_debug_sig_t)); int wifi_gpio_debug_max_event_get(void); /* functions to check if in ROM */ @@ -128,9 +128,10 @@ void pm_check_state(void); void pm_tx_null_data_done_process(void); void pm_start(void); void pm_stop(void); +void pm_disconnected_wake(void); /* coex callback -> debug */ -void coex_set_gpio_debug_cb(void (*cb)(int, int)); +void coex_set_gpio_debug_cb(void (*cb)(int, coex_gpio_debug_sig_t)); int coex_gpio_debug_max_event_get(void); esp_err_t coex_gpio_debug_matrix_init(void); @@ -142,4 +143,10 @@ void wifi_bind_io_to_evt(uint8_t io_idx, uint8_t evt); void coex_bind_io_to_evt(uint8_t io_idx, uint8_t evt); void diagram_bind_io_to_evt(void); +/* coex -> debug + * configure single gpio debug event */ +esp_err_t coex_gpio_debug_matrix_config(int event); +/* debug -> internal use */ +esp_err_t esp_coexist_gpio_debug_matrix_config(int event); + #endif diff --git a/components/esp_coex/src/coexist_debug.c b/components/esp_coex/src/coexist_debug.c index 7c38eea8e5..b0cc341313 100644 --- a/components/esp_coex/src/coexist_debug.c +++ b/components/esp_coex/src/coexist_debug.c @@ -13,37 +13,19 @@ #include "esp_attr.h" #include "esp_log.h" -#if CONFIG_IDF_TARGET_ESP32 -#include "esp32/rom/gpio.h" -#include "esp32/rom/ets_sys.h" -#elif defined(CONFIG_IDF_TARGET_ESP32S2) -#include "esp32s2/rom/gpio.h" -#include "esp32s2/rom/ets_sys.h" -#elif defined(CONFIG_IDF_TARGET_ESP32C3) -#include "esp32c3/rom/gpio.h" -#include "esp32c3/rom/ets_sys.h" -#elif defined(CONFIG_IDF_TARGET_ESP32C2) -#include "esp32c2/rom/gpio.h" -#include "esp32c2/rom/ets_sys.h" -#elif defined(CONFIG_IDF_TARGET_ESP32C6) -#include "esp32c6/rom/gpio.h" -#include "esp32c6/rom/ets_sys.h" -#elif defined(CONFIG_IDF_TARGET_ESP32C5) -#include "esp32c5/rom/gpio.h" -#include "esp32c5/rom/ets_sys.h" -#elif defined(CONFIG_IDF_TARGET_ESP32C61) -#include "esp32c61/rom/gpio.h" -#include "esp32c61/rom/ets_sys.h" -#endif +#include "rom/ets_sys.h" #include "driver/gpio.h" #include "soc/gpio_sig_map.h" #include "esp_rom_gpio.h" #include "soc/soc.h" +#if SOC_MODEM_CLOCK_IS_INDEPENDENT +#include "esp_private/esp_modem_clock.h" +#endif #if CONFIG_ESP_COEX_GPIO_DEBUG static char* TAG = "coexist debug"; -__attribute__((weak)) void wifi_set_gpio_debug_cb(void (* cb)(int, int)) +__attribute__((weak)) void wifi_set_gpio_debug_cb(void (* cb)(int, coex_gpio_debug_sig_t)) { ESP_LOGW(TAG, "Not support: %s", __FUNCTION__); } @@ -53,7 +35,7 @@ __attribute__((weak)) int wifi_gpio_debug_max_event_get(void) return 0; } -__attribute__((weak)) void coex_set_gpio_debug_cb(void (*cb)(int, int)) +__attribute__((weak)) void coex_set_gpio_debug_cb(void (*cb)(int, coex_gpio_debug_sig_t)) { ESP_LOGW(TAG, "Not support: %s", __FUNCTION__); } @@ -89,6 +71,7 @@ static const void* rom_funcs[] = { pm_tx_null_data_done_process, pm_start, pm_stop, + pm_disconnected_wake, #endif }; static const char* rom_funcs_name[] = { @@ -109,6 +92,7 @@ static const char* rom_funcs_name[] = { "pm_tx_null_data_done_process", "pm_start", "pm_stop", + "pm_disconnected_wake", #endif }; @@ -205,6 +189,18 @@ esp_err_t esp_coexist_debug_matrix_init(int evt, int sig, bool rev) return ESP_OK; } +esp_err_t esp_coexist_gpio_debug_matrix_config(int event) +{ +#if SOC_MODEM_CLOCK_IS_INDEPENDENT + modem_clock_module_enable(PERIPH_COEX_MODULE); +#endif + esp_err_t ret = coex_gpio_debug_matrix_config(event); +#if SOC_MODEM_CLOCK_IS_INDEPENDENT + modem_clock_module_disable(PERIPH_COEX_MODULE); +#endif + return ret; +} + esp_err_t esp_coexist_debug_init(void) { if (check_funcs_in_rom()) { @@ -268,8 +264,14 @@ esp_err_t esp_coexist_debug_init(void) gpio_set_level(s_io_nums[i], false); } +#if SOC_MODEM_CLOCK_IS_INDEPENDENT + modem_clock_module_enable(PERIPH_COEX_MODULE); +#endif /* Init coexist hardware signal */ ESP_ERROR_CHECK(coex_gpio_debug_matrix_init()); +#if SOC_MODEM_CLOCK_IS_INDEPENDENT + modem_clock_module_disable(PERIPH_COEX_MODULE); +#endif return ESP_OK; }