Skip to content

Commit

Permalink
Merge branch 'bugfix/fix_mac_bb_pd_iwdt_timeout_v5.0' into 'release/v…
Browse files Browse the repository at this point in the history
…5.0'

fix(ble): fixed interrupt timeout in MAC_BB_PD callback (v5.0)

See merge request espressif/esp-idf!28466
  • Loading branch information
jack0c committed Jan 18, 2024
2 parents 2398c20 + 50ef9e3 commit 463514a
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions components/bt/controller/esp32c3/bt.c
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -1182,18 +1182,6 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)

btdm_controller_mem_init();

#if CONFIG_MAC_BB_PD
if (esp_register_mac_bb_pd_callback(btdm_mac_bb_power_down_cb) != 0) {
err = ESP_ERR_INVALID_ARG;
goto error;
}

if (esp_register_mac_bb_pu_callback(btdm_mac_bb_power_up_cb) != 0) {
err = ESP_ERR_INVALID_ARG;
goto error;
}
#endif

osi_funcs_p = (struct osi_funcs_t *)malloc_internal_wrapper(sizeof(struct osi_funcs_t));
if (osi_funcs_p == NULL) {
return ESP_ERR_NO_MEM;
Expand Down Expand Up @@ -1434,11 +1422,6 @@ static void bt_controller_deinit_internal(void)
btdm_lpcycle_us = 0;
} while (0);

#if CONFIG_MAC_BB_PD
esp_unregister_mac_bb_pd_callback(btdm_mac_bb_power_down_cb);
esp_unregister_mac_bb_pu_callback(btdm_mac_bb_power_up_cb);
#endif

esp_bt_power_domain_off();
#if CONFIG_MAC_BB_PD
esp_mac_bb_pd_mem_deinit();
Expand Down Expand Up @@ -1487,6 +1470,18 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
s_lp_stat.pm_lock_released = 0;
#endif

#if CONFIG_MAC_BB_PD
if (esp_register_mac_bb_pd_callback(btdm_mac_bb_power_down_cb) != 0) {
ret = ESP_ERR_INVALID_ARG;
goto error;
}

if (esp_register_mac_bb_pu_callback(btdm_mac_bb_power_up_cb) != 0) {
ret = ESP_ERR_INVALID_ARG;
goto error;
}
#endif

if (s_lp_cntl.enable) {
btdm_controller_enable_sleep(true);
}
Expand All @@ -1506,6 +1501,11 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
error:
// disable low power mode
do {
#if CONFIG_MAC_BB_PD
esp_unregister_mac_bb_pd_callback(btdm_mac_bb_power_down_cb);
esp_unregister_mac_bb_pu_callback(btdm_mac_bb_power_up_cb);
#endif

btdm_controller_enable_sleep(false);
#ifdef CONFIG_PM_ENABLE
if (s_lp_cntl.no_light_sleep) {
Expand Down Expand Up @@ -1552,6 +1552,11 @@ esp_err_t esp_bt_controller_disable(void)

// disable low power mode
do {
#if CONFIG_MAC_BB_PD
esp_unregister_mac_bb_pd_callback(btdm_mac_bb_power_down_cb);
esp_unregister_mac_bb_pu_callback(btdm_mac_bb_power_up_cb);
#endif

#ifdef CONFIG_PM_ENABLE
if (s_lp_cntl.no_light_sleep) {
esp_pm_lock_release(s_light_sleep_pm_lock);
Expand Down

0 comments on commit 463514a

Please sign in to comment.