mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
fix(ble): use apb max state for bt and enable should skip on ESP32-C6
(cherry picked from commit 73191cb5f9)
Co-authored-by: cjin <jinchen@espressif.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -48,6 +48,7 @@
|
|||||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||||
#include "esp_private/sleep_modem.h"
|
#include "esp_private/sleep_modem.h"
|
||||||
#include "esp_private/sleep_retention.h"
|
#include "esp_private/sleep_retention.h"
|
||||||
|
#include "esp_private/pm_impl.h"
|
||||||
#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||||
|
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
@@ -176,6 +177,7 @@ extern void esp_ble_controller_flash_only_param_config(void);
|
|||||||
#endif // CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
#endif // CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||||
extern sleep_retention_entries_config_t *r_esp_ble_mac_retention_link_get(uint8_t *size, uint8_t extra);
|
extern sleep_retention_entries_config_t *r_esp_ble_mac_retention_link_get(uint8_t *size, uint8_t extra);
|
||||||
|
extern bool r_ble_lll_sleep_should_skip_light_sleep_check(void);
|
||||||
extern void r_esp_ble_set_wakeup_overhead(uint32_t overhead);
|
extern void r_esp_ble_set_wakeup_overhead(uint32_t overhead);
|
||||||
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
|
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
|
||||||
#if CONFIG_BT_LE_LL_PEER_SCA_SET_ENABLE
|
#if CONFIG_BT_LE_LL_PEER_SCA_SET_ENABLE
|
||||||
@@ -862,7 +864,7 @@ esp_err_t controller_sleep_init(void)
|
|||||||
#endif // CONFIG_BT_LE_SLEEP_ENABLE
|
#endif // CONFIG_BT_LE_SLEEP_ENABLE
|
||||||
|
|
||||||
#ifdef CONFIG_PM_ENABLE
|
#ifdef CONFIG_PM_ENABLE
|
||||||
rc = esp_pm_lock_create(ESP_PM_CPU_FREQ_MAX, 0, "bt", &s_pm_lock);
|
rc = esp_pm_lock_create(ESP_PM_APB_FREQ_MAX, 0, "bt", &s_pm_lock);
|
||||||
if (rc != ESP_OK) {
|
if (rc != ESP_OK) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@@ -883,6 +885,12 @@ esp_err_t controller_sleep_init(void)
|
|||||||
esp_sleep_enable_bt_wakeup();
|
esp_sleep_enable_bt_wakeup();
|
||||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "Enable light sleep, the wake up source is BLE timer");
|
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "Enable light sleep, the wake up source is BLE timer");
|
||||||
|
|
||||||
|
rc = esp_pm_register_skip_light_sleep_callback(r_ble_lll_sleep_should_skip_light_sleep_check);
|
||||||
|
if (rc != ESP_OK) {
|
||||||
|
ESP_LOGE(NIMBLE_PORT_LOG_TAG, "Should skip cb register error");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
rc = esp_pm_register_inform_out_light_sleep_overhead_callback(sleep_modem_light_sleep_overhead_set);
|
rc = esp_pm_register_inform_out_light_sleep_overhead_callback(sleep_modem_light_sleep_overhead_set);
|
||||||
if (rc != ESP_OK) {
|
if (rc != ESP_OK) {
|
||||||
goto error;
|
goto error;
|
||||||
@@ -899,6 +907,7 @@ esp_err_t controller_sleep_init(void)
|
|||||||
error:
|
error:
|
||||||
#endif // CONFIG_PM_ENABLE
|
#endif // CONFIG_PM_ENABLE
|
||||||
#if CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
#if CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||||
|
esp_pm_unregister_skip_light_sleep_callback(r_ble_lll_sleep_should_skip_light_sleep_check);
|
||||||
#if SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD
|
#if SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD
|
||||||
sleep_modem_unregister_mac_bb_module_prepare_callback(sleep_modem_mac_bb_power_down_prepare,
|
sleep_modem_unregister_mac_bb_module_prepare_callback(sleep_modem_mac_bb_power_down_prepare,
|
||||||
sleep_modem_mac_bb_power_up_prepare);
|
sleep_modem_mac_bb_power_up_prepare);
|
||||||
@@ -920,6 +929,7 @@ error:
|
|||||||
void controller_sleep_deinit(void)
|
void controller_sleep_deinit(void)
|
||||||
{
|
{
|
||||||
#if CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
#if CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||||
|
esp_pm_unregister_skip_light_sleep_callback(r_ble_lll_sleep_should_skip_light_sleep_check);
|
||||||
#if SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD
|
#if SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD
|
||||||
sleep_modem_unregister_mac_bb_module_prepare_callback(sleep_modem_mac_bb_power_down_prepare,
|
sleep_modem_unregister_mac_bb_module_prepare_callback(sleep_modem_mac_bb_power_down_prepare,
|
||||||
sleep_modem_mac_bb_power_up_prepare);
|
sleep_modem_mac_bb_power_up_prepare);
|
||||||
|
|||||||
Reference in New Issue
Block a user