mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
fix(bt): update btdm init/deinit and enable/disable process
This commit is contained in:
@@ -32,19 +32,27 @@
|
||||
#if UC_BT_CTRL_HCI_INTERFACE_USE_RAM
|
||||
#define BT_HCI_TRANSPORT_MODE HCI_TRANSPORT_VHCI
|
||||
#elif UC_BT_CTRL_HCI_INTERFACE_USE_UART
|
||||
#define BT_HCI_TRANSPORT_MODE HCI_TRANSPORT_UART_NO_DMA
|
||||
#if UC_BT_CTRL_UART_HCI_DMA_MODE
|
||||
#define BT_HCI_TRANSPORT_MODE HCI_TRANSPORT_UART_UHCI
|
||||
#else
|
||||
#define BT_HCI_TRANSPORT_MODE HCI_TRANSPORT_UART_NO_DMA
|
||||
#endif // UC_BT_CTRL_UART_HCI_DMA_MODE
|
||||
#else
|
||||
#error "Unknown HCI transport mode!!"
|
||||
#endif // UC_BT_CTRL_HCI_INTERFACE_USE_RAM
|
||||
|
||||
#if defined(UNUSED)
|
||||
#undef UNUSED
|
||||
#endif
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
/*
|
||||
***************************************************************************************************
|
||||
* External Functions
|
||||
***************************************************************************************************
|
||||
*/
|
||||
extern const char *r_btdm_get_compile_version(void);
|
||||
extern int r_btdm_hci_fc_env_init();
|
||||
extern int r_btdm_hci_fc_env_init(void);
|
||||
extern void r_btdm_hci_fc_env_deinit(void);
|
||||
extern int r_btdm_hci_fc_enable(void);
|
||||
extern void r_btdm_hci_fc_disable(void);
|
||||
@@ -74,10 +82,68 @@ bt_shutdown(void)
|
||||
return;
|
||||
}
|
||||
|
||||
s_btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
|
||||
r_btdm_task_shutdown();
|
||||
btdm_lp_shutdown();
|
||||
}
|
||||
|
||||
static esp_err_t
|
||||
bt_controller_deinit(void)
|
||||
{
|
||||
s_btdm_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE;
|
||||
|
||||
hci_transport_deinit();
|
||||
|
||||
#if UC_BT_CTRL_BR_EDR_IS_ENABLE
|
||||
bredr_stack_deinit();
|
||||
#endif // UC_BT_CTRL_BR_EDR_IS_ENABLE
|
||||
|
||||
#if UC_BT_CTRL_BLE_IS_ENABLE
|
||||
ble_stack_deinit();
|
||||
#endif // UC_BT_CTRL_BLE_IS_ENABLE
|
||||
|
||||
#if UC_BT_CTRL_CONN_FC_ENABLE
|
||||
r_btdm_hci_fc_env_deinit();
|
||||
#endif // UC_BT_CTRL_CONN_FC_ENABLE
|
||||
|
||||
btdm_lp_deinit();
|
||||
r_btdm_task_deinit();
|
||||
btdm_lp_disable_clock();
|
||||
btdm_coex_deinit();
|
||||
btdm_external_deinit();
|
||||
btdm_log_deinit();
|
||||
btdm_osal_elem_mempool_deinit();
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t
|
||||
bt_controller_disable(void)
|
||||
{
|
||||
s_btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
|
||||
|
||||
esp_unregister_shutdown_handler(bt_shutdown);
|
||||
|
||||
r_btdm_task_disable();
|
||||
|
||||
#if UC_BT_CTRL_CONN_FC_ENABLE
|
||||
r_btdm_hci_fc_disable();
|
||||
#endif // UC_BT_CTRL_CONN_FC_ENABLE
|
||||
|
||||
#if UC_BT_CTRL_BR_EDR_IS_ENABLE
|
||||
bredr_stack_disable();
|
||||
#endif // UC_BT_CTRL_BR_EDR_IS_ENABLE
|
||||
|
||||
#if UC_BT_CTRL_BLE_IS_ENABLE
|
||||
ble_stack_disable();
|
||||
#endif // UC_BT_CTRL_BLE_IS_ENABLE
|
||||
|
||||
btdm_coex_disable();
|
||||
btdm_lp_reset(false);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
***************************************************************************************************
|
||||
* Public Function Definitions
|
||||
@@ -86,6 +152,7 @@ bt_shutdown(void)
|
||||
esp_err_t
|
||||
esp_bt_mem_release(esp_bt_mode_t mode)
|
||||
{
|
||||
// TODO: Support bluetooth stack memory release
|
||||
ESP_LOGW(BTDM_LOG_TAG, "esp_bt_mem_release not implement yet!");
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -93,7 +160,7 @@ esp_bt_mem_release(esp_bt_mode_t mode)
|
||||
esp_err_t
|
||||
esp_bt_controller_mem_release(esp_bt_mode_t mode)
|
||||
{
|
||||
|
||||
// TODO: Support bt controller memory release
|
||||
ESP_LOGW(BTDM_LOG_TAG, "esp_bt_controller_mem_release not implement yet!");
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -111,6 +178,10 @@ esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
.mutex_count = 1,
|
||||
};
|
||||
|
||||
if (cfg == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_LOGI(BTDM_LOG_TAG, "BTDM version [%s]", r_btdm_get_compile_version());
|
||||
|
||||
if (cfg->btdm.bluetooth_mode == ESP_BT_MODE_IDLE) {
|
||||
@@ -121,9 +192,6 @@ esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
if (s_btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
s_btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
|
||||
|
||||
ret = ESP_FAIL;
|
||||
|
||||
#if UC_BT_CTRL_BLE_IS_ENABLE
|
||||
ble_osal_elem_calc(cfg, &elem);
|
||||
@@ -202,11 +270,12 @@ esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
}
|
||||
|
||||
ESP_LOGI(BTDM_LOG_TAG, "BTDM controller init OK");
|
||||
s_btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
|
||||
|
||||
return ESP_OK;
|
||||
|
||||
init_failed:
|
||||
esp_bt_controller_deinit();
|
||||
bt_controller_deinit();
|
||||
|
||||
return ESP_FAIL;
|
||||
}
|
||||
@@ -217,31 +286,7 @@ esp_bt_controller_deinit(void)
|
||||
if (s_btdm_controller_status != ESP_BT_CONTROLLER_STATUS_INITED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
s_btdm_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE;
|
||||
|
||||
hci_transport_deinit();
|
||||
|
||||
#if UC_BT_CTRL_BR_EDR_IS_ENABLE
|
||||
bredr_stack_deinit();
|
||||
#endif // UC_BT_CTRL_BR_EDR_IS_ENABLE
|
||||
|
||||
#if UC_BT_CTRL_BLE_IS_ENABLE
|
||||
ble_stack_deinit();
|
||||
#endif // UC_BT_CTRL_BLE_IS_ENABLE
|
||||
|
||||
#if UC_BT_CTRL_CONN_FC_ENABLE
|
||||
r_btdm_hci_fc_env_deinit();
|
||||
#endif // UC_BT_CTRL_CONN_FC_ENABLE
|
||||
|
||||
btdm_lp_deinit();
|
||||
r_btdm_task_deinit();
|
||||
btdm_lp_disable_clock();
|
||||
btdm_coex_deinit();
|
||||
btdm_log_deinit();
|
||||
btdm_external_deinit();
|
||||
btdm_osal_elem_mempool_deinit();
|
||||
|
||||
return ESP_OK;
|
||||
return bt_controller_deinit();
|
||||
}
|
||||
|
||||
esp_err_t
|
||||
@@ -249,10 +294,10 @@ esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
{
|
||||
int ret;
|
||||
|
||||
UNUSED(mode);
|
||||
if (s_btdm_controller_status != ESP_BT_CONTROLLER_STATUS_INITED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
s_btdm_controller_status = ESP_BT_CONTROLLER_STATUS_ENABLED;
|
||||
|
||||
btdm_lp_reset(true);
|
||||
|
||||
@@ -297,10 +342,11 @@ esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
ESP_LOGW(BTDM_LOG_TAG, "Register shutdown handler failed, ret = 0x%x", ret);
|
||||
}
|
||||
|
||||
s_btdm_controller_status = ESP_BT_CONTROLLER_STATUS_ENABLED;
|
||||
return ESP_OK;
|
||||
|
||||
enable_failed:
|
||||
esp_bt_controller_disable();
|
||||
bt_controller_disable();
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
@@ -310,26 +356,8 @@ esp_bt_controller_disable(void)
|
||||
if (s_btdm_controller_status != ESP_BT_CONTROLLER_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
s_btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
|
||||
|
||||
esp_unregister_shutdown_handler(bt_shutdown);
|
||||
|
||||
r_btdm_task_disable();
|
||||
|
||||
#if UC_BT_CTRL_CONN_FC_ENABLE
|
||||
r_btdm_hci_fc_disable();
|
||||
#endif // UC_BT_CTRL_CONN_FC_ENABLE
|
||||
|
||||
#if UC_BT_CTRL_BR_EDR_IS_ENABLE
|
||||
bredr_stack_disable();
|
||||
#endif // UC_BT_CTRL_BR_EDR_IS_ENABLE
|
||||
|
||||
#if UC_BT_CTRL_BLE_IS_ENABLE
|
||||
ble_stack_disable();
|
||||
#endif // UC_BT_CTRL_BLE_IS_ENABLE
|
||||
|
||||
btdm_coex_disable();
|
||||
btdm_lp_reset(false);
|
||||
bt_controller_disable();
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@@ -32,21 +32,27 @@
|
||||
#if UC_BT_CTRL_HCI_INTERFACE_USE_RAM
|
||||
#define BT_HCI_TRANSPORT_MODE HCI_TRANSPORT_VHCI
|
||||
#elif UC_BT_CTRL_HCI_INTERFACE_USE_UART
|
||||
#define BT_HCI_TRANSPORT_MODE HCI_TRANSPORT_UART_NO_DMA
|
||||
#if UC_BT_CTRL_UART_HCI_DMA_MODE
|
||||
#define BT_HCI_TRANSPORT_MODE HCI_TRANSPORT_UART_UHCI
|
||||
#else
|
||||
#define BT_HCI_TRANSPORT_MODE HCI_TRANSPORT_UART_NO_DMA
|
||||
#endif // UC_BT_CTRL_UART_HCI_DMA_MODE
|
||||
#else
|
||||
#error "Unknown HCI transport mode!!"
|
||||
#endif // UC_BT_CTRL_HCI_INTERFACE_USE_RAM
|
||||
|
||||
#if defined(UNUSED)
|
||||
#undef UNUSED
|
||||
#endif
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
/*
|
||||
***************************************************************************************************
|
||||
* External Functions
|
||||
***************************************************************************************************
|
||||
*/
|
||||
extern const char *r_btdm_get_compile_version(void);
|
||||
extern int r_btdm_hci_fc_env_init();
|
||||
extern int r_btdm_hci_fc_env_init(void);
|
||||
extern void r_btdm_hci_fc_env_deinit(void);
|
||||
extern int r_btdm_hci_fc_enable(void);
|
||||
extern void r_btdm_hci_fc_disable(void);
|
||||
@@ -76,10 +82,68 @@ bt_shutdown(void)
|
||||
return;
|
||||
}
|
||||
|
||||
s_btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
|
||||
r_btdm_task_shutdown();
|
||||
btdm_lp_shutdown();
|
||||
}
|
||||
|
||||
static esp_err_t
|
||||
bt_controller_deinit(void)
|
||||
{
|
||||
s_btdm_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE;
|
||||
|
||||
hci_transport_deinit();
|
||||
|
||||
#if UC_BT_CTRL_BR_EDR_IS_ENABLE
|
||||
bredr_stack_deinit();
|
||||
#endif // UC_BT_CTRL_BR_EDR_IS_ENABLE
|
||||
|
||||
#if UC_BT_CTRL_BLE_IS_ENABLE
|
||||
ble_stack_deinit();
|
||||
#endif // UC_BT_CTRL_BLE_IS_ENABLE
|
||||
|
||||
#if UC_BT_CTRL_CONN_FC_ENABLE
|
||||
r_btdm_hci_fc_env_deinit();
|
||||
#endif // UC_BT_CTRL_CONN_FC_ENABLE
|
||||
|
||||
btdm_lp_deinit();
|
||||
r_btdm_task_deinit();
|
||||
btdm_lp_disable_clock();
|
||||
btdm_coex_deinit();
|
||||
btdm_external_deinit();
|
||||
btdm_log_deinit();
|
||||
btdm_osal_elem_mempool_deinit();
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t
|
||||
bt_controller_disable(void)
|
||||
{
|
||||
s_btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
|
||||
|
||||
esp_unregister_shutdown_handler(bt_shutdown);
|
||||
|
||||
r_btdm_task_disable();
|
||||
|
||||
#if UC_BT_CTRL_CONN_FC_ENABLE
|
||||
r_btdm_hci_fc_disable();
|
||||
#endif // UC_BT_CTRL_CONN_FC_ENABLE
|
||||
|
||||
#if UC_BT_CTRL_BR_EDR_IS_ENABLE
|
||||
bredr_stack_disable();
|
||||
#endif // UC_BT_CTRL_BR_EDR_IS_ENABLE
|
||||
|
||||
#if UC_BT_CTRL_BLE_IS_ENABLE
|
||||
ble_stack_disable();
|
||||
#endif // UC_BT_CTRL_BLE_IS_ENABLE
|
||||
|
||||
btdm_coex_disable();
|
||||
btdm_lp_reset(false);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
***************************************************************************************************
|
||||
* Public Function Definitions
|
||||
@@ -88,6 +152,7 @@ bt_shutdown(void)
|
||||
esp_err_t
|
||||
esp_bt_mem_release(esp_bt_mode_t mode)
|
||||
{
|
||||
// TODO: Support bluetooth stack memory release
|
||||
ESP_LOGW(BTDM_LOG_TAG, "esp_bt_mem_release not implement yet!");
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -95,7 +160,7 @@ esp_bt_mem_release(esp_bt_mode_t mode)
|
||||
esp_err_t
|
||||
esp_bt_controller_mem_release(esp_bt_mode_t mode)
|
||||
{
|
||||
|
||||
// TODO: Support bt controller memory release
|
||||
ESP_LOGW(BTDM_LOG_TAG, "esp_bt_controller_mem_release not implement yet!");
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -113,6 +178,10 @@ esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
.mutex_count = 1,
|
||||
};
|
||||
|
||||
if (cfg == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_LOGI(BTDM_LOG_TAG, "BTDM version [%s]", r_btdm_get_compile_version());
|
||||
|
||||
if (cfg->btdm.bluetooth_mode == ESP_BT_MODE_IDLE) {
|
||||
@@ -123,9 +192,6 @@ esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
if (s_btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
s_btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
|
||||
|
||||
ret = ESP_FAIL;
|
||||
|
||||
#if UC_BT_CTRL_BLE_IS_ENABLE
|
||||
ble_osal_elem_calc(cfg, &elem);
|
||||
@@ -138,25 +204,25 @@ esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
ret = btdm_osal_elem_mempool_init(&elem);
|
||||
if (ret) {
|
||||
ESP_LOGE(BTDM_LOG_TAG, "btdm_osal_elem_mempool_init failed: %d", ret);
|
||||
goto destroy_btdm_osal_mempool;
|
||||
goto init_failed;
|
||||
}
|
||||
|
||||
ret = btdm_log_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(BTDM_LOG_TAG, "btdm_log_init failed: %d", ret);
|
||||
goto destroy_btdm_log;
|
||||
goto init_failed;
|
||||
}
|
||||
|
||||
ret = btdm_external_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(BTDM_LOG_TAG, "btdm_external_init failed: %d", ret);
|
||||
goto destroy_btdm_external;
|
||||
goto init_failed;
|
||||
}
|
||||
|
||||
ret = btdm_coex_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(BTDM_LOG_TAG, "btdm_coex_init failed: %d", ret);
|
||||
goto destroy_btdm_coex;
|
||||
goto init_failed;
|
||||
}
|
||||
|
||||
btdm_lp_enable_clock(&cfg->btdm);
|
||||
@@ -164,20 +230,20 @@ esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
ret = r_btdm_task_init(&cfg->btdm);
|
||||
if (ret) {
|
||||
ESP_LOGE(BTDM_LOG_TAG, "r_btdm_task_init failed: %d", ret);
|
||||
goto destroy_btdm_task;
|
||||
goto init_failed;
|
||||
}
|
||||
|
||||
ret = btdm_lp_init();
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(BTDM_LOG_TAG, "btdm_lp_init failed %d", ret);
|
||||
goto destroy_btdm_lp;
|
||||
goto init_failed;
|
||||
}
|
||||
|
||||
#if UC_BT_CTRL_CONN_FC_ENABLE
|
||||
ret = r_btdm_hci_fc_env_init();
|
||||
if (ret) {
|
||||
ESP_LOGE(BTDM_LOG_TAG, "r_btdm_hci_fc_env_init failed: %d", ret);
|
||||
goto destroy_hci_fc_env;
|
||||
goto init_failed;
|
||||
}
|
||||
#endif // UC_BT_CTRL_CONN_FC_ENABLE
|
||||
|
||||
@@ -185,7 +251,7 @@ esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
ret = ble_stack_init(cfg);
|
||||
if (ret) {
|
||||
ESP_LOGE(BTDM_LOG_TAG, "ble_stack_init failed: %d", ret);
|
||||
goto destroy_ble_stack;
|
||||
goto init_failed;
|
||||
}
|
||||
#endif // UC_BT_CTRL_BLE_IS_ENABLE
|
||||
|
||||
@@ -193,52 +259,24 @@ esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
ret = bredr_stack_init(cfg);
|
||||
if (ret) {
|
||||
ESP_LOGE(BTDM_LOG_TAG, "bredr_stack_init failed: %d", ret);
|
||||
goto destroy_bredr_stack;
|
||||
goto init_failed;
|
||||
}
|
||||
#endif // UC_BT_CTRL_BR_EDR_IS_ENABLE
|
||||
|
||||
ret = hci_transport_init(BT_HCI_TRANSPORT_MODE);
|
||||
if (ret) {
|
||||
ESP_LOGE(BTDM_LOG_TAG, "hci_transport_init failed %d", ret);
|
||||
goto destroy_hci_transport;
|
||||
goto init_failed;
|
||||
}
|
||||
|
||||
ESP_LOGI(BTDM_LOG_TAG, "BTDM controller init OK");
|
||||
s_btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
|
||||
|
||||
return ESP_OK;
|
||||
|
||||
destroy_hci_transport:
|
||||
hci_transport_deinit();
|
||||
init_failed:
|
||||
bt_controller_deinit();
|
||||
|
||||
#if UC_BT_CTRL_BR_EDR_IS_ENABLE
|
||||
destroy_bredr_stack:
|
||||
bredr_stack_deinit();
|
||||
#endif // UC_BT_CTRL_BR_EDR_IS_ENABLE
|
||||
|
||||
#if UC_BT_CTRL_BLE_IS_ENABLE
|
||||
destroy_ble_stack:
|
||||
ble_stack_deinit();
|
||||
#endif // UC_BT_CTRL_BLE_IS_ENABLE
|
||||
|
||||
#if UC_BT_CTRL_CONN_FC_ENABLE
|
||||
destroy_hci_fc_env:
|
||||
r_btdm_hci_fc_env_deinit();
|
||||
#endif // UC_BT_CTRL_CONN_FC_ENABLE
|
||||
|
||||
destroy_btdm_lp:
|
||||
btdm_lp_deinit();
|
||||
destroy_btdm_task:
|
||||
r_btdm_task_deinit();
|
||||
btdm_lp_disable_clock();
|
||||
destroy_btdm_coex:
|
||||
btdm_coex_deinit();
|
||||
destroy_btdm_external:
|
||||
btdm_external_deinit();
|
||||
destroy_btdm_log:
|
||||
btdm_log_deinit();
|
||||
destroy_btdm_osal_mempool:
|
||||
btdm_osal_elem_mempool_deinit();
|
||||
s_btdm_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE;
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
@@ -248,31 +286,7 @@ esp_bt_controller_deinit(void)
|
||||
if (s_btdm_controller_status != ESP_BT_CONTROLLER_STATUS_INITED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
s_btdm_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE;
|
||||
|
||||
hci_transport_deinit();
|
||||
|
||||
#if UC_BT_CTRL_BR_EDR_IS_ENABLE
|
||||
bredr_stack_deinit();
|
||||
#endif // UC_BT_CTRL_BR_EDR_IS_ENABLE
|
||||
|
||||
#if UC_BT_CTRL_BLE_IS_ENABLE
|
||||
ble_stack_deinit();
|
||||
#endif // UC_BT_CTRL_BLE_IS_ENABLE
|
||||
|
||||
#if UC_BT_CTRL_CONN_FC_ENABLE
|
||||
r_btdm_hci_fc_env_deinit();
|
||||
#endif // UC_BT_CTRL_CONN_FC_ENABLE
|
||||
|
||||
btdm_lp_deinit();
|
||||
r_btdm_task_deinit();
|
||||
btdm_lp_disable_clock();
|
||||
btdm_coex_deinit();
|
||||
btdm_log_deinit();
|
||||
btdm_external_deinit();
|
||||
btdm_osal_elem_mempool_deinit();
|
||||
|
||||
return ESP_OK;
|
||||
return bt_controller_deinit();
|
||||
}
|
||||
|
||||
esp_err_t
|
||||
@@ -280,10 +294,10 @@ esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
{
|
||||
int ret;
|
||||
|
||||
UNUSED(mode);
|
||||
if (s_btdm_controller_status != ESP_BT_CONTROLLER_STATUS_INITED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
s_btdm_controller_status = ESP_BT_CONTROLLER_STATUS_ENABLED;
|
||||
|
||||
btdm_lp_reset(true);
|
||||
|
||||
@@ -328,10 +342,11 @@ esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
ESP_LOGW(BTDM_LOG_TAG, "Register shutdown handler failed, ret = 0x%x", ret);
|
||||
}
|
||||
|
||||
s_btdm_controller_status = ESP_BT_CONTROLLER_STATUS_ENABLED;
|
||||
return ESP_OK;
|
||||
|
||||
enable_failed:
|
||||
esp_bt_controller_disable();
|
||||
bt_controller_disable();
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
@@ -341,26 +356,8 @@ esp_bt_controller_disable(void)
|
||||
if (s_btdm_controller_status != ESP_BT_CONTROLLER_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
s_btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
|
||||
|
||||
esp_unregister_shutdown_handler(bt_shutdown);
|
||||
|
||||
r_btdm_task_disable();
|
||||
|
||||
#if UC_BT_CTRL_CONN_FC_ENABLE
|
||||
r_btdm_hci_fc_disable();
|
||||
#endif // UC_BT_CTRL_CONN_FC_ENABLE
|
||||
|
||||
#if UC_BT_CTRL_BR_EDR_IS_ENABLE
|
||||
bredr_stack_disable();
|
||||
#endif // UC_BT_CTRL_BR_EDR_IS_ENABLE
|
||||
|
||||
#if UC_BT_CTRL_BLE_IS_ENABLE
|
||||
ble_stack_disable();
|
||||
#endif // UC_BT_CTRL_BLE_IS_ENABLE
|
||||
|
||||
btdm_coex_disable();
|
||||
btdm_lp_reset(false);
|
||||
bt_controller_disable();
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user