mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-02 12:14:32 +02:00
bt: lock APB frequency while BT controller is enabled
This commit is contained in:
@@ -33,6 +33,7 @@
|
|||||||
#include "bt.h"
|
#include "bt.h"
|
||||||
#include "esp_err.h"
|
#include "esp_err.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
#include "esp_pm.h"
|
||||||
|
|
||||||
#if CONFIG_BT_ENABLED
|
#if CONFIG_BT_ENABLED
|
||||||
|
|
||||||
@@ -147,6 +148,10 @@ static esp_bt_controller_status_t btdm_controller_status = ESP_BT_CONTROLLER_STA
|
|||||||
|
|
||||||
static portMUX_TYPE global_int_mux = portMUX_INITIALIZER_UNLOCKED;
|
static portMUX_TYPE global_int_mux = portMUX_INITIALIZER_UNLOCKED;
|
||||||
|
|
||||||
|
#ifdef CONFIG_PM_ENABLE
|
||||||
|
static esp_pm_lock_handle_t s_pm_lock;
|
||||||
|
#endif
|
||||||
|
|
||||||
static void IRAM_ATTR interrupt_disable(void)
|
static void IRAM_ATTR interrupt_disable(void)
|
||||||
{
|
{
|
||||||
portENTER_CRITICAL(&global_int_mux);
|
portENTER_CRITICAL(&global_int_mux);
|
||||||
@@ -442,6 +447,13 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
|||||||
return ESP_ERR_INVALID_ARG;
|
return ESP_ERR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_PM_ENABLE
|
||||||
|
esp_err_t err = esp_pm_lock_create(ESP_PM_APB_FREQ_MAX, 0, "bt", &s_pm_lock);
|
||||||
|
if (err != ESP_OK) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
btdm_osi_funcs_register(&osi_funcs);
|
btdm_osi_funcs_register(&osi_funcs);
|
||||||
|
|
||||||
btdm_controller_mem_init();
|
btdm_controller_mem_init();
|
||||||
@@ -450,6 +462,10 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
|||||||
|
|
||||||
ret = btdm_controller_init(btdm_cfg_mask, cfg);
|
ret = btdm_controller_init(btdm_cfg_mask, cfg);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
#ifdef CONFIG_PM_ENABLE
|
||||||
|
esp_pm_lock_delete(s_pm_lock);
|
||||||
|
s_pm_lock = NULL;
|
||||||
|
#endif
|
||||||
return ESP_ERR_NO_MEM;
|
return ESP_ERR_NO_MEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,6 +484,12 @@ esp_err_t esp_bt_controller_deinit(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE;
|
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE;
|
||||||
|
|
||||||
|
#ifdef CONFIG_PM_ENABLE
|
||||||
|
esp_pm_lock_delete(s_pm_lock);
|
||||||
|
s_pm_lock = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -484,6 +506,10 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
|||||||
return ESP_ERR_INVALID_ARG;
|
return ESP_ERR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_PM_ENABLE
|
||||||
|
esp_pm_lock_acquire(s_pm_lock);
|
||||||
|
#endif
|
||||||
|
|
||||||
esp_phy_load_cal_and_init();
|
esp_phy_load_cal_and_init();
|
||||||
|
|
||||||
if (btdm_bb_init_flag == false) {
|
if (btdm_bb_init_flag == false) {
|
||||||
@@ -519,6 +545,10 @@ esp_err_t esp_bt_controller_disable(void)
|
|||||||
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
|
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_PM_ENABLE
|
||||||
|
esp_pm_lock_release(s_pm_lock);
|
||||||
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user