mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 02:37:19 +02:00
1. Wi-Fi: update tsf tick interval when lpclk is modified
2. Move register_lpclk_callback to coexistence
This commit is contained in:
@ -395,8 +395,6 @@ static DRAM_ATTR uint8_t btdm_lpcycle_us_frac = 0;
|
||||
static DRAM_ATTR QueueHandle_t s_wakeup_req_sem = NULL;
|
||||
// wakeup timer
|
||||
static DRAM_ATTR esp_timer_handle_t s_btdm_slp_tmr;
|
||||
// set low power clock source callback
|
||||
static esp_set_lpclk_source_callback_t s_set_lpclk_source_cb = NULL;
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
static DRAM_ATTR esp_pm_lock_handle_t s_pm_lock;
|
||||
@ -927,11 +925,6 @@ static void IRAM_ATTR btdm_mac_bb_power_up_cb(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
void esp_wifi_set_lpclk_register_callback(esp_set_lpclk_source_callback_t callback)
|
||||
{
|
||||
s_set_lpclk_source_cb = callback;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
{
|
||||
esp_err_t err = ESP_FAIL;
|
||||
@ -1113,10 +1106,9 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
err = ESP_ERR_INVALID_ARG;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (s_set_lpclk_source_cb) {
|
||||
s_set_lpclk_source_cb();
|
||||
}
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_update_lpclk_interval();
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (s_lp_cntl.no_light_sleep) {
|
||||
@ -1205,13 +1197,12 @@ error:
|
||||
#endif
|
||||
btdm_lpclk_select_src(BTDM_LPCLK_SEL_RTC_SLOW);
|
||||
btdm_lpclk_set_div(0);
|
||||
if (s_set_lpclk_source_cb) {
|
||||
s_set_lpclk_source_cb();
|
||||
}
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_update_lpclk_interval();
|
||||
#endif
|
||||
}
|
||||
|
||||
btdm_lpcycle_us = 0;
|
||||
s_set_lpclk_source_cb = NULL;
|
||||
} while (0);
|
||||
|
||||
#if CONFIG_MAC_BB_PD
|
||||
@ -1283,13 +1274,12 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
#endif
|
||||
btdm_lpclk_select_src(BTDM_LPCLK_SEL_RTC_SLOW);
|
||||
btdm_lpclk_set_div(0);
|
||||
if (s_set_lpclk_source_cb) {
|
||||
s_set_lpclk_source_cb();
|
||||
}
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_update_lpclk_interval();
|
||||
#endif
|
||||
}
|
||||
|
||||
btdm_lpcycle_us = 0;
|
||||
s_set_lpclk_source_cb = NULL;
|
||||
} while (0);
|
||||
|
||||
#if CONFIG_MAC_BB_PD
|
||||
|
@ -399,8 +399,6 @@ static DRAM_ATTR uint8_t btdm_lpcycle_us_frac = 0;
|
||||
static DRAM_ATTR QueueHandle_t s_wakeup_req_sem = NULL;
|
||||
// wakeup timer
|
||||
static DRAM_ATTR esp_timer_handle_t s_btdm_slp_tmr;
|
||||
// set low power clock source callback
|
||||
static esp_set_lpclk_source_callback_t s_set_lpclk_source_cb = NULL;
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
static DRAM_ATTR esp_pm_lock_handle_t s_pm_lock;
|
||||
@ -959,11 +957,6 @@ static void IRAM_ATTR btdm_mac_bb_power_up_cb(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
void esp_wifi_set_lpclk_register_callback(esp_set_lpclk_source_callback_t callback)
|
||||
{
|
||||
s_set_lpclk_source_cb = callback;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
{
|
||||
esp_err_t err = ESP_FAIL;
|
||||
@ -1145,10 +1138,9 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
err = ESP_ERR_INVALID_ARG;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (s_set_lpclk_source_cb) {
|
||||
s_set_lpclk_source_cb();
|
||||
}
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_update_lpclk_interval();
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (s_lp_cntl.no_light_sleep) {
|
||||
@ -1237,13 +1229,12 @@ error:
|
||||
#endif
|
||||
btdm_lpclk_select_src(BTDM_LPCLK_SEL_RTC_SLOW);
|
||||
btdm_lpclk_set_div(0);
|
||||
if (s_set_lpclk_source_cb) {
|
||||
s_set_lpclk_source_cb();
|
||||
}
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_update_lpclk_interval();
|
||||
#endif
|
||||
}
|
||||
|
||||
btdm_lpcycle_us = 0;
|
||||
s_set_lpclk_source_cb = NULL;
|
||||
} while (0);
|
||||
|
||||
#if CONFIG_MAC_BB_PD
|
||||
@ -1316,13 +1307,12 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
#endif
|
||||
btdm_lpclk_select_src(BTDM_LPCLK_SEL_RTC_SLOW);
|
||||
btdm_lpclk_set_div(0);
|
||||
if (s_set_lpclk_source_cb) {
|
||||
s_set_lpclk_source_cb();
|
||||
}
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_update_lpclk_interval();
|
||||
#endif
|
||||
}
|
||||
|
||||
btdm_lpcycle_us = 0;
|
||||
s_set_lpclk_source_cb = NULL;
|
||||
} while (0);
|
||||
|
||||
#if CONFIG_MAC_BB_PD
|
||||
|
@ -92,11 +92,6 @@ enum {
|
||||
*/
|
||||
typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status);
|
||||
|
||||
/**
|
||||
* @brief callback function for Wi-Fi low power clock operations
|
||||
*/
|
||||
typedef void (* esp_set_lpclk_source_callback_t)(void);
|
||||
|
||||
#ifdef CONFIG_BT_ENABLED
|
||||
|
||||
#define BT_CTRL_BLE_MAX_ACT_LIMIT 10 //Maximum BLE activity limitation
|
||||
@ -540,13 +535,6 @@ void esp_wifi_bt_power_domain_on(void);
|
||||
*/
|
||||
void esp_wifi_bt_power_domain_off(void);
|
||||
|
||||
/**
|
||||
* @brief Register application callback function to Wi-Fi low power clock module.
|
||||
*
|
||||
* @param callback : Wi-Fi set low power clock callback function
|
||||
*/
|
||||
void esp_wifi_set_lpclk_register_callback(esp_set_lpclk_source_callback_t callback);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -92,11 +92,6 @@ enum {
|
||||
*/
|
||||
typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status);
|
||||
|
||||
/**
|
||||
* @brief callback function for Wi-Fi low power clock operations
|
||||
*/
|
||||
typedef void (* esp_set_lpclk_source_callback_t)(void);
|
||||
|
||||
#ifdef CONFIG_BT_ENABLED
|
||||
|
||||
#define BT_CTRL_BLE_MAX_ACT_LIMIT 10 //Maximum BLE activity limitation
|
||||
@ -539,13 +534,6 @@ void esp_wifi_bt_power_domain_on(void);
|
||||
*/
|
||||
void esp_wifi_bt_power_domain_off(void);
|
||||
|
||||
/**
|
||||
* @brief Register application callback function to Wi-Fi low power clock module.
|
||||
*
|
||||
* @param callback : Wi-Fi set low power clock callback function
|
||||
*/
|
||||
void esp_wifi_set_lpclk_register_callback(esp_set_lpclk_source_callback_t callback);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/syscon_reg.h"
|
||||
#include "soc/system_reg.h"
|
||||
#include "phy_init_data.h"
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
#include "esp_private/esp_clk.h"
|
||||
@ -47,6 +48,8 @@
|
||||
|
||||
#define TAG "esp_adapter"
|
||||
|
||||
#define MHZ (1000000)
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
extern void wifi_apb80m_request(void);
|
||||
extern void wifi_apb80m_release(void);
|
||||
@ -434,7 +437,12 @@ 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));
|
||||
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 malloc_internal_wrapper(size_t size)
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/syscon_reg.h"
|
||||
#include "soc/system_reg.h"
|
||||
#include "phy_init_data.h"
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
#include "esp_private/esp_clk.h"
|
||||
@ -48,6 +49,8 @@
|
||||
|
||||
#define TAG "esp_adapter"
|
||||
|
||||
#define MHZ (1000000)
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
extern void wifi_apb80m_request(void);
|
||||
extern void wifi_apb80m_release(void);
|
||||
@ -545,7 +548,12 @@ 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));
|
||||
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 malloc_internal_wrapper(size_t size)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -23,6 +23,7 @@ typedef enum {
|
||||
} coex_prefer_t;
|
||||
|
||||
typedef void (* coex_func_cb_t)(uint32_t event, int sched_cnt);
|
||||
typedef esp_err_t (* coex_set_lpclk_source_callback_t)(void);
|
||||
|
||||
/**
|
||||
* @brief Pre-Init software coexist
|
||||
@ -115,6 +116,18 @@ int coex_wifi_release(uint32_t event);
|
||||
*/
|
||||
int coex_wifi_channel_set(uint8_t primary, uint8_t secondary);
|
||||
|
||||
/**
|
||||
* @brief Register application callback function to Wi-Fi update low power clock module.
|
||||
*
|
||||
* @param callback : Wi-Fi update low power clock callback function
|
||||
*/
|
||||
void coex_wifi_register_update_lpclk_callback(coex_set_lpclk_source_callback_t callback);
|
||||
|
||||
/**
|
||||
* @brief Update low power clock interval
|
||||
*/
|
||||
void coex_update_lpclk_interval(void);
|
||||
|
||||
/**
|
||||
* @brief Get coexistence event duration.
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -496,6 +496,15 @@ bool esp_wifi_internal_is_tsf_active(void);
|
||||
*
|
||||
*/
|
||||
void esp_wifi_internal_update_light_sleep_wake_ahead_time(uint32_t);
|
||||
|
||||
/**
|
||||
* @brief Update WiFi TSF tick interval
|
||||
*
|
||||
* @return
|
||||
* - true: Active
|
||||
* - false: Not active
|
||||
*/
|
||||
esp_err_t esp_wifi_update_tsf_tick_interval(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
Submodule components/esp_wifi/lib updated: 3a69afcd41...767ec0f081
@ -234,6 +234,9 @@ esp_err_t esp_wifi_init(const wifi_init_config_t *config)
|
||||
return ret;
|
||||
}
|
||||
esp_sleep_enable_wifi_wakeup();
|
||||
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
|
||||
coex_wifi_register_update_lpclk_callback(esp_wifi_update_tsf_tick_interval);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user