diff --git a/components/esp_wifi/esp32/esp_adapter.c b/components/esp_wifi/esp32/esp_adapter.c index 87e8863ec9..ec684c088b 100644 --- a/components/esp_wifi/esp32/esp_adapter.c +++ b/components/esp_wifi/esp32/esp_adapter.c @@ -211,6 +211,11 @@ static void IRAM_ATTR wifi_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp) } } +static bool IRAM_ATTR is_from_isr_wrapper(void) +{ + return xPortInIsrContext(); +} + static void IRAM_ATTR task_yield_from_isr_wrapper(void) { portYIELD_FROM_ISR(); @@ -636,6 +641,7 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._coex_condition_set = coex_condition_set_wrapper, ._coex_wifi_request = coex_wifi_request_wrapper, ._coex_wifi_release = coex_wifi_release_wrapper, + ._is_from_isr = is_from_isr_wrapper, ._magic = ESP_WIFI_OS_ADAPTER_MAGIC, }; diff --git a/components/esp_wifi/esp32s2/esp_adapter.c b/components/esp_wifi/esp32s2/esp_adapter.c index d7ff25b3c8..23ef893f97 100644 --- a/components/esp_wifi/esp32s2/esp_adapter.c +++ b/components/esp_wifi/esp32s2/esp_adapter.c @@ -201,6 +201,11 @@ static void IRAM_ATTR wifi_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp) } } +static bool IRAM_ATTR is_from_isr_wrapper(void) +{ + return xPortInIsrContext(); +} + static void IRAM_ATTR task_yield_from_isr_wrapper(void) { portYIELD_FROM_ISR(); @@ -635,6 +640,7 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._coex_condition_set = coex_condition_set_wrapper, ._coex_wifi_request = coex_wifi_request_wrapper, ._coex_wifi_release = coex_wifi_release_wrapper, + ._is_from_isr = is_from_isr_wrapper, ._magic = ESP_WIFI_OS_ADAPTER_MAGIC, }; 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 f005b315bc..ad4245b705 100644 --- a/components/esp_wifi/include/esp_private/wifi_os_adapter.h +++ b/components/esp_wifi/include/esp_private/wifi_os_adapter.h @@ -21,7 +21,7 @@ extern "C" { #endif -#define ESP_WIFI_OS_ADAPTER_VERSION 0x00000006 +#define ESP_WIFI_OS_ADAPTER_VERSION 0x00000007 #define ESP_WIFI_OS_ADAPTER_MAGIC 0xDEADBEAF #define OSI_FUNCS_TIME_BLOCKING 0xffffffff @@ -133,6 +133,7 @@ typedef struct { void (* _coex_condition_set)(uint32_t type, bool dissatisfy); int32_t (* _coex_wifi_request)(uint32_t event, uint32_t latency, uint32_t duration); int32_t (* _coex_wifi_release)(uint32_t event); + bool (* _is_from_isr)(void); int32_t _magic; } wifi_osi_funcs_t; diff --git a/components/esp_wifi/include/esp_wifi.h b/components/esp_wifi/include/esp_wifi.h index 891a8de6ab..2f3f77bf5c 100644 --- a/components/esp_wifi/include/esp_wifi.h +++ b/components/esp_wifi/include/esp_wifi.h @@ -1093,6 +1093,19 @@ esp_err_t esp_wifi_set_ant(const wifi_ant_config_t *config); */ esp_err_t esp_wifi_get_ant(wifi_ant_config_t *config); +/** + * @brief Get the TSF time + * In Station mode or SoftAP+Station mode if station is not connected or station doesn't receive at least + * one beacon after connected, will return 0 + * + * @attention Enabling power save may cause the return value inaccurate, except WiFi modem sleep + * + * @param interface The interface whose tsf_time is to be retrieved. + * + * @return 0 or the TSF time + */ +int64_t esp_wifi_get_tsf_time(wifi_interface_t interface); + #ifdef __cplusplus } #endif diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index fad0f87b2c..3258b4cd30 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit fad0f87b2c31d0ff2779bbf834ad0edc6e2a99a7 +Subproject commit 3258b4cd3044326ce2d75062f0944ea5cfc41bd6