feat(bt): refactor bt sdk with broker for esp32h4 and esp32s31

This commit is contained in:
ShenWeilong
2026-05-12 13:41:06 +08:00
parent 5967653bdd
commit 18534fb1cd
42 changed files with 7362 additions and 3927 deletions

View File

@@ -87,7 +87,15 @@ if(CONFIG_IDF_DOC_BUILD AND CONFIG_SOC_BT_SUPPORTED)
"${CMAKE_CURRENT_LIST_DIR}/../include/${TARGET_SRC_NAME}/include"
ABSOLUTE
)
set(bt_ctrl_include_dirs "${_bt_ctrl_absolute_include_dir}" PARENT_SCOPE)
get_filename_component(
_bt_ctrl_common_absolute_include_dir
"${CMAKE_CURRENT_LIST_DIR}/../include/common"
ABSOLUTE
)
set(bt_ctrl_include_dirs
"${_bt_ctrl_absolute_include_dir}"
"${_bt_ctrl_common_absolute_include_dir}"
PARENT_SCOPE)
return()
endif()

View File

@@ -57,12 +57,15 @@ 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);
extern int r_btdm_task_init(esp_btdm_controller_config_t *cfg);
extern int r_btdm_task_init(esp_bt_ctrl_btdm_config_t *cfg);
extern void r_btdm_task_deinit(void);
extern int r_btdm_task_enable(void);
extern void r_btdm_task_disable(void);
extern void r_btdm_task_shutdown(void);
extern int btdm_broker_init(void);
extern void btdm_broker_deinit(void);
/*
***************************************************************************************************
* Local Variables
@@ -114,6 +117,8 @@ bt_controller_deinit(void)
btdm_log_deinit();
btdm_osal_elem_mempool_deinit();
btdm_broker_deinit();
return ESP_OK;
}
@@ -169,11 +174,11 @@ esp_err_t
esp_bt_controller_init(esp_bt_controller_config_t *cfg)
{
int ret;
// TODO: Delete workaround
btdm_osal_elem_num_t elem = {
.evt_count = 3 + 100,
.evtq_count = 1 + 2,
.co_count = 0 + 10,
.evt_count = 3,
.evtq_count = 1,
.co_count = 0,
.sem_count = 0,
.mutex_count = 1,
};
@@ -193,6 +198,12 @@ esp_bt_controller_init(esp_bt_controller_config_t *cfg)
return ESP_ERR_INVALID_STATE;
}
ret = btdm_broker_init();
if (ret) {
ESP_LOGE(BTDM_LOG_TAG, "btdm_broker_init failed: %d", ret);
goto init_failed;
}
#if UC_BT_CTRL_BLE_IS_ENABLE
ble_osal_elem_calc(cfg, &elem);
#endif // UC_BT_CTRL_BLE_IS_ENABLE

View File

@@ -0,0 +1,797 @@
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*
* !!! DO NOT MODIFY ANYTHING IN THIS FILE !!!
*/
#include <stdint.h>
#include <stdbool.h>
#include "btdm_user_cfg.h"
#if UC_BT_CTRL_BLE_IS_ENABLE
#include "ble_user_cfg.h"
#endif
#if UC_BT_CTRL_BR_EDR_IS_ENABLE
#include "bredr_user_cfg.h"
#endif
#define BTDM_BROKER_MAGIC (0xc55c0000UL)
#define __BTDM_BROKER_ARRAY_SIZE(storage, ...) \
((sizeof((storage void *storage[]){0, __VA_ARGS__}) / sizeof(void *)) - 1)
#define __BTDM_BROKER_ENTRY(storage, ...) \
((storage void *storage[]){ \
(void *)(BTDM_BROKER_MAGIC | (__BTDM_BROKER_ARRAY_SIZE(storage, __VA_ARGS__) & 0xFFFFU)), \
__VA_ARGS__})
#define BTDM_BROKER_ENTRY_DEF_FLASH(...) __BTDM_BROKER_ENTRY(const, __VA_ARGS__)
#define BTDM_BROKER_ENTRY_DEF_RAM(...) __BTDM_BROKER_ENTRY(, __VA_ARGS__)
#define BTDM_BROKER_NODE_DEF_FLASH(...) \
{(const void *const)(__BTDM_BROKER_ARRAY_SIZE(const, __VA_ARGS__)), __VA_ARGS__}
#define BTDM_BROKER_NODE_DEF_RAM(...) \
{(void *)(__BTDM_BROKER_ARRAY_SIZE(, __VA_ARGS__)), __VA_ARGS__}
/*
********************************************************************************
* External Functions Declaration
********************************************************************************
*/
extern int r_btdm_broker_linear_selfcheck(const void *broker, bool is_ram);
extern int r_btdm_broker_indexed_selfcheck(const void *broker, bool is_ram);
extern int r_sym_bt_8fMePSgKBxkeyUSGQQcU(void *param);
#if UC_BT_CTRL_BLE_IS_ENABLE
extern int sym_acceptList_E2sQw1uVsjxxiP0PJWNT(void *param);
extern int sym_acceptList_vvIIdyHCcpNAdAdzZrPN(void *param);
extern int sym_acceptList_yfAo03VLjZhjCR2fnGvX(void *param);
extern int sym_adv_S1K3QvkLgRcH2We9Z3KD(void *param);
extern int sym_adv_k0eZcDthWb1sk0Kloemu(void *param);
extern int sym_adv_xfHX4YH2Zb9de4JlBztj(void *param);
extern int sym_arr_CG7zWaZkh7QOTatTjs2v(void *param);
extern int sym_arr_SH7I2IviDsjnpqawpi0F(void *param);
extern int sym_base_CdIdlqttqbZqCmaW9GAc(void *param);
extern int sym_base_IdP4ncGWlpNArj2oW20N(void *param);
extern int sym_base_NVN4AbeIskmtcV2PX3N1(void *param);
extern int sym_base_QIE6fqExGJrsGUIGYNSf(void *param);
extern int sym_base_uevmRkB8BjrlJh1c3VnZ(void *param);
extern int sym_base_uuBMFaiuN71hyzVcBBth(void *param);
extern int sym_coexStack_hzrw4DdhxAw5xAlGFEwI(void *param);
extern int sym_coexStack_sMPrrpveO5HOIb2qa5I8(void *param);
extern int sym_extAdv_65JKSxhAHiLFV63DSxJk(void *param);
extern int sym_extAdv_cxB4HBdDRajzTQg8DqKC(void *param);
extern int sym_extAdv_j9EFs8yTWikhycyNL2tu(void *param);
extern int sym_memMgmt_7tLw3T7RgI6l7DQc4dMI(void *param);
extern int sym_memMgmt_PpI7zFiJWyV56U0OIURt(void *param);
extern int sym_rand_6102wQhjz4grvtu5s8T3(void *param);
extern int sym_rand_TnYdBCetsq1sndnhcROz(void *param);
extern int sym_resolv_GWz7Tb1ymxsyLQ1208Jj(void *param);
extern int sym_resolv_YX00BNf3Z2oJaizN1uK8(void *param);
extern int sym_resolv_hQFDtxZqj5AP1IMR8s59(void *param);
extern int sym_scan_0gIKmjMRFT37raN6hnDo(void *param);
extern int sym_scan_1G8QO0lWyTS0nKOqvZOE(void *param);
extern int sym_scan_Tfvee56pMZTiTxWnEWgP(void *param);
extern int sym_scan_b8ogEC3hTjGmqL5oRuyw(void *param);
extern int sym_scan_cgn6c03k4ZQqi2dJOtfm(void *param);
extern int sym_scan_fd4yzdFac8vdFTlQ4BPA(void *param);
extern int sym_scan_l1avG2cwTzJAlle4KLdU(void *param);
extern int sym_scan_tdX6OLWyRKYxelkB8vZ1(void *param);
extern int sym_scan_zmw2OczvfXFB4aIFaWkc(void *param);
extern int sym_sched_PNMeumLUZPcz8o4UrTLi(void *param);
extern int sym_sync_NOAs4m6LAUpamsUYHfqm(void *param);
extern int sym_sync_dVvFbZ7ZwsleTM2nkzdV(void *param);
extern int sym_sync_uoa5Xd4XcSSCUjyNsVGo(void *param);
#if UC_BLE_CTRL_CONN_ENABLED
extern int sym_conn_Sw7sI0dtf78paJdn9Uhg(void *param);
extern int sym_conn_eZ0plXo8e56VyJXdcbNn(void *param);
extern int sym_conn_k5hEt7krj8McRSctLS7X(void *param);
extern int sym_conn_nW2gyrsrYX980SM1JXUT(void *param);
extern int sym_conn_sIcAPw7j0toiOGWivJ0e(void *param);
#endif /* UC_BLE_CTRL_CONN_ENABLED */
#if UC_BLE_CTRL_CONN_ENABLED && CONFIG_BT_LE_ERROR_SIM_ENABLED
extern int sym_connSim_2RFEzu4Evi68Nnt4YowZ(void *param);
extern int sym_connSim_3guOkwBVGmSgwrEIVUvL(void *param);
extern int sym_connSim_EIv22SNth3fM1SPgJ9hO(void *param);
extern int sym_connSim_SoaIlItcCgS4km7f1141(void *param);
extern int sym_connSim_dytLpHTAgMtQWf4K3pGc(void *param);
extern int sym_connSim_rsrSBeH3W8LE1yGVrtBc(void *param);
#endif /* UC_BLE_CTRL_CONN_ENABLED && CONFIG_BT_LE_ERROR_SIM_ENABLED */
#if UC_BLE_CTRL_PAWR_BCAST_SUPPORTED
extern int sym_pawrBcast_02YCihGkfXcpLt0zh1uM(void *param);
extern int sym_pawrBcast_0PNup0d8oI1288mfULNW(void *param);
extern int sym_pawrBcast_0Wq1DOQE0eOWEGV2grxM(void *param);
extern int sym_pawrBcast_1y9l4P0a3qWUSydU3cDY(void *param);
extern int sym_pawrBcast_7jK56jlcfafMtoQgLg6t(void *param);
extern int sym_pawrBcast_7qGF1F9weQ363Ml7Gj0n(void *param);
extern int sym_pawrBcast_JHmbFJCpV155hIYyDVQ8(void *param);
extern int sym_pawrBcast_JPGtn7AltqyvIRT8iPtF(void *param);
extern int sym_pawrBcast_Jrj3qAmZkOoWxL1jFdmP(void *param);
extern int sym_pawrBcast_KBuKVEBVXwxouWjaJUva(void *param);
extern int sym_pawrBcast_OEzQrCBnW7rhUIi6H6gM(void *param);
extern int sym_pawrBcast_SB1LBCzybPoDd0XYyLM8(void *param);
extern int sym_pawrBcast_WNd7Y6n56cZrTlhBjFRU(void *param);
extern int sym_pawrBcast_eBH7HrPT8y2Fj9382el3(void *param);
extern int sym_pawrBcast_g6t1IjxRbcv5GUq1uXIA(void *param);
extern int sym_pawrBcast_lk2Wpy4u04ukjtC7Ijcb(void *param);
extern int sym_pawrBcast_on08yxBjym4I0iV3tlPo(void *param);
extern int sym_pawrBcast_sSbQFGKMJszbA895ddLO(void *param);
extern int sym_pawrBcast_w9Kcjl02BFd1e11Ic3A0(void *param);
#endif /* UC_BLE_CTRL_PAWR_BCAST_SUPPORTED */
#if UC_BLE_CTRL_PAWR_SYNC_SUPPORTED
extern int sym_pawrSync_1cW8RtQRnVveTqFg9OSR(void *param);
extern int sym_pawrSync_2gh2xSEYHokuhQ7UohkM(void *param);
extern int sym_pawrSync_7bchpvHsUM8DXHyaXC7f(void *param);
extern int sym_pawrSync_9XvRcZs9CUOgHNbMhe5G(void *param);
extern int sym_pawrSync_LO7YyFM93srewqVpETY2(void *param);
extern int sym_pawrSync_Qifv1iec7w57n2pBwucX(void *param);
extern int sym_pawrSync_bbizSGqM6wZUOT0fQF1M(void *param);
extern int sym_pawrSync_fn4PoAB0qFmYpbwqTO2H(void *param);
extern int sym_pawrSync_k4txvaSWHJBXXqtE62MG(void *param);
extern int sym_pawrSync_oBwpWArFlWxUJNCnHvsJ(void *param);
extern int sym_pawrSync_pbTRKlIHoevVfNidtKZb(void *param);
extern int sym_pawrSync_vAN2YoeCsSKafv2NdPVC(void *param);
extern int sym_pawrSync_vBce2UGY5s0PhM3gRF8p(void *param);
extern int sym_pawrSync_zuG0pqdRWK2zt5S09fTS(void *param);
#endif /* UC_BLE_CTRL_PAWR_SYNC_SUPPORTED */
#if UC_BT_CTRL_LE_BIS_BCAST_ENABLED
extern int sym_bisBcast_2a3kgxHeabxbnBIsRh4s(void *param);
extern int sym_bisBcast_2dWM4hoGuoEwy8loUGlI(void *param);
extern int sym_bisBcast_2uiisGIdoGa6SNUZCE2m(void *param);
extern int sym_bisBcast_BcOOZfvM58VUQK6uC2ew(void *param);
extern int sym_bisBcast_EtJ8xQ5EIWS6IjqpsD1U(void *param);
extern int sym_bisBcast_Pe7M3vC0UOSbZWC7Bm8D(void *param);
extern int sym_bisBcast_vATQ5EU18M2xnmNZ84fY(void *param);
extern int sym_bisBcast_vKPkmtQzLc0ZU4R3Mpa1(void *param);
extern int sym_bisBcast_zlcnIBGOIfWlPC3WJ66f(void *param);
#endif /* UC_BT_CTRL_LE_BIS_BCAST_ENABLED */
#if UC_BT_CTRL_LE_BIS_SYNC_ENABLED
extern int sym_bisSync_0xkTwhqVWK4bwJa6dDH6(void *param);
extern int sym_bisSync_3FCcFQdSowAGd7aAejeg(void *param);
extern int sym_bisSync_BO46u3KvbiXYsPrQplUT(void *param);
extern int sym_bisSync_DuQGVcBNN6l6ggZp4Y8J(void *param);
extern int sym_bisSync_EaKbiRZI30mvH3KWkMY5(void *param);
extern int sym_bisSync_cB4uyzKmrYjduUbWqXdb(void *param);
extern int sym_bisSync_qLbiM85U90F0BvzUDhgt(void *param);
#endif /* UC_BT_CTRL_LE_BIS_SYNC_ENABLED */
#if UC_BT_CTRL_LE_CIS_CENT_ENABLED
extern int sym_cisCent_9P0KC1xZQpumJC2psVXO(void *param);
extern int sym_cisCent_GSToGcnDAoUIQsFaBPr7(void *param);
extern int sym_cisCent_JUzUk54A9UNHtsUAHT8F(void *param);
extern int sym_cisCent_f2xo5SuAzLb4iRlhLPhf(void *param);
extern int sym_cisCent_jfaA90JGHwEKv1YkKIUO(void *param);
extern int sym_cisCent_wt1P0oioDDyNz026HxsK(void *param);
#endif /* UC_BT_CTRL_LE_CIS_CENT_ENABLED */
#if UC_BT_CTRL_LE_CIS_ENABLED
extern int sym_cis_3DmpJ8V6gGsnSNopbei0(void *param);
extern int sym_cis_5PzTPmH8LVt7wMSC7YnP(void *param);
extern int sym_cis_Bmj5ai8K8ZKFKqWA8X8B(void *param);
extern int sym_cis_Guzdzme9CFLxrbjG6HEJ(void *param);
extern int sym_cis_QxmCCIxcxCfrWCKZmT3X(void *param);
extern int sym_cis_UBu7crU2pIczpNc5cEcP(void *param);
extern int sym_cis_WICEvILg2pK6JZvhry3j(void *param);
extern int sym_cis_coXGBkWhDUZWHDFo80gN(void *param);
extern int sym_cis_eeNELMi6IB5X3UF8MMvQ(void *param);
extern int sym_cis_f2SkEM3LCeOCgMzDRq24(void *param);
extern int sym_cis_i4bfG8waTBMteoJaWD40(void *param);
extern int sym_cis_j0GHq32oPR9AN7YHYxEI(void *param);
extern int sym_cis_mcjvVuw8ttAldZnobGxJ(void *param);
extern int sym_cis_vY92iDVk3ph4SrNh5ccy(void *param);
extern int sym_cis_wQtv7EbxMlyUdVE0TQ9T(void *param);
extern int sym_cis_zGkqwv9urnJ8DbX0JZAr(void *param);
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
#if UC_BT_CTRL_LE_CIS_PRPH_ENABLED
extern int sym_cisPrph_6ORekVL63tenTy0sCT2O(void *param);
extern int sym_cisPrph_Dw8FBGfBWm2LptzYq46z(void *param);
extern int sym_cisPrph_Kb3o0Y7oUCdHJ1SXcoqj(void *param);
extern int sym_cisPrph_xR7NheKHstTWkDAuZROL(void *param);
extern int sym_cisPrph_zr8KQ3aEASRV2ZptTSnX(void *param);
#endif /* UC_BT_CTRL_LE_CIS_PRPH_ENABLED */
#if UC_BT_CTRL_LE_CTE_CAL_ENABLED
extern int sym_cteCal_Lxc6TR3r9tNnhSe66bmE(void *param);
extern int sym_cteCal_NKbWd6AypEyH2B338dAx(void *param);
extern int sym_cteCal_ixMlNDshScz4WVTbiOKl(void *param);
extern int sym_cteCal_j700khui6oomGLu22Rgb(void *param);
extern int sym_cteCal_uWSKv9wSYw0nIY0GhuZF(void *param);
#endif /* UC_BT_CTRL_LE_CTE_CAL_ENABLED */
#if UC_BT_CTRL_LE_CTE_ENABLED
extern int sym_cte_NjXx2EHiiDoBXhq2trhx(void *param);
extern int sym_cte_P7A06WogxnY1JlnvQaGe(void *param);
extern int sym_cte_aMtk23FR89BNAXNthzRu(void *param);
extern int sym_cte_onkmOjIkv3QCPJVJQuUB(void *param);
extern int sym_cte_vx3COozMkhCXFbq2ZjHK(void *param);
#endif /* UC_BT_CTRL_LE_CTE_ENABLED */
#if UC_BT_CTRL_LE_DTM_ENABLED
extern int sym_dtm_8YKzWpU1Xe3NGGMtUeY6(void *param);
extern int sym_dtm_Er3Vd8hhSABNIkl9x3At(void *param);
extern int sym_dtm_wW4wnzkRa1kpb5NfwZVi(void *param);
#endif /* UC_BT_CTRL_LE_DTM_ENABLED */
#if UC_BT_CTRL_LE_ISO_ENABLED
extern int sym_coexIsoHal_RVw8jrRQybFIlwvrONo9(void *param);
extern int sym_iso_6SFIpEwXw1SsCdgfyN88(void *param);
extern int sym_iso_8HHndXTSYyYcW1EhDzAN(void *param);
extern int sym_iso_WJJo4fn6Hkvt9xXAvziZ(void *param);
extern int sym_iso_Ywq26gNcDI3MQQVQbDEF(void *param);
extern int sym_iso_gk1uwrtqhb5WsUZoPUJq(void *param);
extern int sym_iso_qYKZbEBVIsH27HGf5VCS(void *param);
extern int sym_iso_xew5NrC4aBwCavwqySPp(void *param);
#endif /* UC_BT_CTRL_LE_ISO_ENABLED */
#if UC_BT_CTRL_LE_VS_CMD_EVT_ENABLED && CONFIG_BT_CTRL_SLEEP_ENABLE
extern int sym_sleep_Ayr8PrlSNd7F6hhsmt13(void *param);
#endif /* UC_BT_CTRL_LE_VS_CMD_EVT_ENABLED && CONFIG_BT_CTRL_SLEEP_ENABLE */
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
/*
********************************************************************************
* Linear Broker Definitions
********************************************************************************
*/
#if UC_BT_CTRL_BLE_IS_ENABLE
const void * const _adv_linear_broker_flash[] = BTDM_BROKER_NODE_DEF_FLASH(
#if UC_BLE_CTRL_PAWR_BCAST_SUPPORTED
[1] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_0PNup0d8oI1288mfULNW,
),
[2] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_02YCihGkfXcpLt0zh1uM,
),
[3] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_g6t1IjxRbcv5GUq1uXIA,
),
[4] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_7jK56jlcfafMtoQgLg6t,
),
[5] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_w9Kcjl02BFd1e11Ic3A0,
),
[6] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_0Wq1DOQE0eOWEGV2grxM,
),
[7] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_JPGtn7AltqyvIRT8iPtF,
),
[8] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_1y9l4P0a3qWUSydU3cDY,
),
[9] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_lk2Wpy4u04ukjtC7Ijcb,
),
[10] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_OEzQrCBnW7rhUIi6H6gM,
),
[11] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_KBuKVEBVXwxouWjaJUva,
),
[12] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_sSbQFGKMJszbA895ddLO,
),
[13] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_WNd7Y6n56cZrTlhBjFRU,
),
#endif /* UC_BLE_CTRL_PAWR_BCAST_SUPPORTED */
);
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
#if UC_BT_CTRL_BLE_IS_ENABLE
const void * const _base_linear_broker_flash[] = BTDM_BROKER_NODE_DEF_FLASH(
[1] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_acceptList_E2sQw1uVsjxxiP0PJWNT,
sym_adv_k0eZcDthWb1sk0Kloemu,
#if UC_BT_CTRL_LE_BIS_BCAST_ENABLED
sym_bisBcast_Pe7M3vC0UOSbZWC7Bm8D,
#endif /* UC_BT_CTRL_LE_BIS_BCAST_ENABLED */
#if UC_BT_CTRL_LE_BIS_SYNC_ENABLED
sym_bisSync_BO46u3KvbiXYsPrQplUT,
#endif /* UC_BT_CTRL_LE_BIS_SYNC_ENABLED */
#if UC_BT_CTRL_LE_CIS_ENABLED
sym_cis_5PzTPmH8LVt7wMSC7YnP,
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
sym_coexStack_hzrw4DdhxAw5xAlGFEwI,
#if UC_BLE_CTRL_CONN_ENABLED && CONFIG_BT_LE_ERROR_SIM_ENABLED
sym_connSim_dytLpHTAgMtQWf4K3pGc,
#endif /* UC_BLE_CTRL_CONN_ENABLED && CONFIG_BT_LE_ERROR_SIM_ENABLED */
#if UC_BLE_CTRL_CONN_ENABLED
sym_conn_k5hEt7krj8McRSctLS7X,
#endif /* UC_BLE_CTRL_CONN_ENABLED */
#if UC_BT_CTRL_LE_CTE_CAL_ENABLED
sym_cteCal_j700khui6oomGLu22Rgb,
#endif /* UC_BT_CTRL_LE_CTE_CAL_ENABLED */
#if UC_BT_CTRL_LE_CTE_ENABLED
sym_cte_aMtk23FR89BNAXNthzRu,
#endif /* UC_BT_CTRL_LE_CTE_ENABLED */
#if UC_BT_CTRL_LE_DTM_ENABLED
sym_dtm_Er3Vd8hhSABNIkl9x3At,
#endif /* UC_BT_CTRL_LE_DTM_ENABLED */
sym_extAdv_65JKSxhAHiLFV63DSxJk,
#if UC_BT_CTRL_LE_ISO_ENABLED
sym_iso_gk1uwrtqhb5WsUZoPUJq,
#endif /* UC_BT_CTRL_LE_ISO_ENABLED */
#if UC_BLE_CTRL_PAWR_BCAST_SUPPORTED
sym_pawrBcast_7qGF1F9weQ363Ml7Gj0n,
#endif /* UC_BLE_CTRL_PAWR_BCAST_SUPPORTED */
#if UC_BLE_CTRL_PAWR_SYNC_SUPPORTED
sym_pawrSync_vBce2UGY5s0PhM3gRF8p,
#endif /* UC_BLE_CTRL_PAWR_SYNC_SUPPORTED */
sym_rand_TnYdBCetsq1sndnhcROz,
sym_resolv_YX00BNf3Z2oJaizN1uK8,
sym_scan_Tfvee56pMZTiTxWnEWgP,
sym_sync_uoa5Xd4XcSSCUjyNsVGo,
),
[2] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_acceptList_yfAo03VLjZhjCR2fnGvX,
sym_adv_S1K3QvkLgRcH2We9Z3KD,
#if UC_BT_CTRL_LE_BIS_BCAST_ENABLED
sym_bisBcast_vKPkmtQzLc0ZU4R3Mpa1,
#endif /* UC_BT_CTRL_LE_BIS_BCAST_ENABLED */
#if UC_BT_CTRL_LE_BIS_SYNC_ENABLED
sym_bisSync_qLbiM85U90F0BvzUDhgt,
#endif /* UC_BT_CTRL_LE_BIS_SYNC_ENABLED */
#if UC_BT_CTRL_LE_CIS_ENABLED
sym_cis_j0GHq32oPR9AN7YHYxEI,
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
sym_coexStack_sMPrrpveO5HOIb2qa5I8,
#if UC_BLE_CTRL_CONN_ENABLED && CONFIG_BT_LE_ERROR_SIM_ENABLED
sym_connSim_rsrSBeH3W8LE1yGVrtBc,
#endif /* UC_BLE_CTRL_CONN_ENABLED && CONFIG_BT_LE_ERROR_SIM_ENABLED */
#if UC_BLE_CTRL_CONN_ENABLED
sym_conn_nW2gyrsrYX980SM1JXUT,
#endif /* UC_BLE_CTRL_CONN_ENABLED */
#if UC_BT_CTRL_LE_CTE_CAL_ENABLED
sym_cteCal_Lxc6TR3r9tNnhSe66bmE,
#endif /* UC_BT_CTRL_LE_CTE_CAL_ENABLED */
#if UC_BT_CTRL_LE_CTE_ENABLED
sym_cte_onkmOjIkv3QCPJVJQuUB,
#endif /* UC_BT_CTRL_LE_CTE_ENABLED */
#if UC_BT_CTRL_LE_DTM_ENABLED
sym_dtm_8YKzWpU1Xe3NGGMtUeY6,
#endif /* UC_BT_CTRL_LE_DTM_ENABLED */
sym_extAdv_cxB4HBdDRajzTQg8DqKC,
#if UC_BT_CTRL_LE_ISO_ENABLED
sym_iso_xew5NrC4aBwCavwqySPp,
#endif /* UC_BT_CTRL_LE_ISO_ENABLED */
#if UC_BLE_CTRL_PAWR_BCAST_SUPPORTED
sym_pawrBcast_SB1LBCzybPoDd0XYyLM8,
#endif /* UC_BLE_CTRL_PAWR_BCAST_SUPPORTED */
#if UC_BLE_CTRL_PAWR_SYNC_SUPPORTED
sym_pawrSync_1cW8RtQRnVveTqFg9OSR,
#endif /* UC_BLE_CTRL_PAWR_SYNC_SUPPORTED */
sym_rand_6102wQhjz4grvtu5s8T3,
sym_resolv_hQFDtxZqj5AP1IMR8s59,
sym_scan_cgn6c03k4ZQqi2dJOtfm,
sym_sync_dVvFbZ7ZwsleTM2nkzdV,
),
#if UC_BT_CTRL_LE_CIS_ENABLED
[3] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_cis_vY92iDVk3ph4SrNh5ccy,
),
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
#if UC_BT_CTRL_LE_BIS_BCAST_ENABLED
[4] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_bisBcast_BcOOZfvM58VUQK6uC2ew,
),
#endif /* UC_BT_CTRL_LE_BIS_BCAST_ENABLED */
);
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
void * _btdm_hal_linear_broker_ram[] = BTDM_BROKER_NODE_DEF_RAM(
#if UC_BT_CTRL_BLE_IS_ENABLE
[1] = BTDM_BROKER_ENTRY_DEF_RAM(
sym_base_QIE6fqExGJrsGUIGYNSf,
#if UC_BT_CTRL_LE_ISO_ENABLED
sym_coexIsoHal_RVw8jrRQybFIlwvrONo9,
sym_iso_6SFIpEwXw1SsCdgfyN88,
#endif /* UC_BT_CTRL_LE_ISO_ENABLED */
),
[2] = BTDM_BROKER_ENTRY_DEF_RAM(
sym_base_NVN4AbeIskmtcV2PX3N1,
),
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
);
const void * const _btdm_hci_linear_broker_flash[] = BTDM_BROKER_NODE_DEF_FLASH(
#if UC_BT_CTRL_BLE_IS_ENABLE
#if UC_BLE_CTRL_CONN_ENABLED
[1] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_conn_eZ0plXo8e56VyJXdcbNn,
),
[3] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_conn_Sw7sI0dtf78paJdn9Uhg,
),
#endif /* UC_BLE_CTRL_CONN_ENABLED */
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
);
const void * const _btdm_sched_linear_broker_flash[] = BTDM_BROKER_NODE_DEF_FLASH(
#if UC_BT_CTRL_BLE_IS_ENABLE
[1] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_memMgmt_7tLw3T7RgI6l7DQc4dMI,
),
[2] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_memMgmt_PpI7zFiJWyV56U0OIURt,
),
[3] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_scan_0gIKmjMRFT37raN6hnDo,
),
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
);
void * _btdm_sched_linear_broker_ram[] = BTDM_BROKER_NODE_DEF_RAM(
#if UC_BT_CTRL_BLE_IS_ENABLE
[1] = BTDM_BROKER_ENTRY_DEF_RAM(
#if UC_BT_CTRL_LE_ISO_ENABLED
sym_iso_qYKZbEBVIsH27HGf5VCS,
#endif /* UC_BT_CTRL_LE_ISO_ENABLED */
sym_sched_PNMeumLUZPcz8o4UrTLi,
),
[2] = BTDM_BROKER_ENTRY_DEF_RAM(
sym_scan_b8ogEC3hTjGmqL5oRuyw,
),
[3] = BTDM_BROKER_ENTRY_DEF_RAM(
sym_scan_fd4yzdFac8vdFTlQ4BPA,
),
[4] = BTDM_BROKER_ENTRY_DEF_RAM(
sym_scan_tdX6OLWyRKYxelkB8vZ1,
),
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
);
const void * const _btdm_sleep_linear_broker_flash[] = BTDM_BROKER_NODE_DEF_FLASH(
#if UC_BT_CTRL_BLE_IS_ENABLE
#if UC_BT_CTRL_LE_VS_CMD_EVT_ENABLED && CONFIG_BT_CTRL_SLEEP_ENABLE
[1] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_sleep_Ayr8PrlSNd7F6hhsmt13,
),
#endif /* UC_BT_CTRL_LE_VS_CMD_EVT_ENABLED && CONFIG_BT_CTRL_SLEEP_ENABLE */
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
);
const void * const _btdm_task_linear_broker_flash[] = BTDM_BROKER_NODE_DEF_FLASH(
#if UC_BT_CTRL_BLE_IS_ENABLE
[1] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_arr_CG7zWaZkh7QOTatTjs2v,
sym_base_uevmRkB8BjrlJh1c3VnZ,
#if UC_BT_CTRL_LE_BIS_BCAST_ENABLED
sym_bisBcast_2dWM4hoGuoEwy8loUGlI,
#endif /* UC_BT_CTRL_LE_BIS_BCAST_ENABLED */
#if UC_BT_CTRL_LE_BIS_SYNC_ENABLED
sym_bisSync_cB4uyzKmrYjduUbWqXdb,
#endif /* UC_BT_CTRL_LE_BIS_SYNC_ENABLED */
#if UC_BT_CTRL_LE_CIS_ENABLED
sym_cis_f2SkEM3LCeOCgMzDRq24,
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
#if UC_BLE_CTRL_CONN_ENABLED && CONFIG_BT_LE_ERROR_SIM_ENABLED
sym_connSim_EIv22SNth3fM1SPgJ9hO,
#endif /* UC_BLE_CTRL_CONN_ENABLED && CONFIG_BT_LE_ERROR_SIM_ENABLED */
#if UC_BT_CTRL_LE_CTE_CAL_ENABLED
sym_cteCal_NKbWd6AypEyH2B338dAx,
#endif /* UC_BT_CTRL_LE_CTE_CAL_ENABLED */
#if UC_BT_CTRL_LE_CTE_ENABLED
sym_cte_NjXx2EHiiDoBXhq2trhx,
#endif /* UC_BT_CTRL_LE_CTE_ENABLED */
sym_extAdv_j9EFs8yTWikhycyNL2tu,
#if UC_BT_CTRL_LE_ISO_ENABLED
sym_iso_8HHndXTSYyYcW1EhDzAN,
#endif /* UC_BT_CTRL_LE_ISO_ENABLED */
#if UC_BLE_CTRL_PAWR_BCAST_SUPPORTED
sym_pawrBcast_Jrj3qAmZkOoWxL1jFdmP,
#endif /* UC_BLE_CTRL_PAWR_BCAST_SUPPORTED */
#if UC_BLE_CTRL_PAWR_SYNC_SUPPORTED
sym_pawrSync_k4txvaSWHJBXXqtE62MG,
#endif /* UC_BLE_CTRL_PAWR_SYNC_SUPPORTED */
sym_scan_1G8QO0lWyTS0nKOqvZOE,
),
[2] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_arr_SH7I2IviDsjnpqawpi0F,
sym_base_uuBMFaiuN71hyzVcBBth,
#if UC_BT_CTRL_LE_BIS_BCAST_ENABLED
sym_bisBcast_vATQ5EU18M2xnmNZ84fY,
#endif /* UC_BT_CTRL_LE_BIS_BCAST_ENABLED */
#if UC_BT_CTRL_LE_BIS_SYNC_ENABLED
sym_bisSync_DuQGVcBNN6l6ggZp4Y8J,
#endif /* UC_BT_CTRL_LE_BIS_SYNC_ENABLED */
#if UC_BT_CTRL_LE_CIS_ENABLED
sym_cis_UBu7crU2pIczpNc5cEcP,
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
#if UC_BT_CTRL_LE_CTE_CAL_ENABLED
sym_cteCal_uWSKv9wSYw0nIY0GhuZF,
#endif /* UC_BT_CTRL_LE_CTE_CAL_ENABLED */
#if UC_BT_CTRL_LE_CTE_ENABLED
sym_cte_vx3COozMkhCXFbq2ZjHK,
#endif /* UC_BT_CTRL_LE_CTE_ENABLED */
#if UC_BT_CTRL_LE_ISO_ENABLED
sym_iso_Ywq26gNcDI3MQQVQbDEF,
#endif /* UC_BT_CTRL_LE_ISO_ENABLED */
#if UC_BLE_CTRL_PAWR_BCAST_SUPPORTED
sym_pawrBcast_JHmbFJCpV155hIYyDVQ8,
#endif /* UC_BLE_CTRL_PAWR_BCAST_SUPPORTED */
#if UC_BLE_CTRL_PAWR_SYNC_SUPPORTED
sym_pawrSync_2gh2xSEYHokuhQ7UohkM,
#endif /* UC_BLE_CTRL_PAWR_SYNC_SUPPORTED */
sym_scan_zmw2OczvfXFB4aIFaWkc,
),
[3] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_base_IdP4ncGWlpNArj2oW20N,
),
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
[4] = BTDM_BROKER_ENTRY_DEF_FLASH(
r_sym_bt_8fMePSgKBxkeyUSGQQcU,
#if UC_BT_CTRL_BLE_IS_ENABLE
sym_acceptList_vvIIdyHCcpNAdAdzZrPN,
sym_adv_xfHX4YH2Zb9de4JlBztj,
sym_base_CdIdlqttqbZqCmaW9GAc,
#if UC_BT_CTRL_LE_BIS_BCAST_ENABLED
sym_bisBcast_zlcnIBGOIfWlPC3WJ66f,
#endif /* UC_BT_CTRL_LE_BIS_BCAST_ENABLED */
#if UC_BT_CTRL_LE_BIS_SYNC_ENABLED
sym_bisSync_EaKbiRZI30mvH3KWkMY5,
#endif /* UC_BT_CTRL_LE_BIS_SYNC_ENABLED */
#if UC_BT_CTRL_LE_CIS_ENABLED
sym_cis_QxmCCIxcxCfrWCKZmT3X,
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
#if UC_BLE_CTRL_CONN_ENABLED && CONFIG_BT_LE_ERROR_SIM_ENABLED
sym_connSim_3guOkwBVGmSgwrEIVUvL,
#endif /* UC_BLE_CTRL_CONN_ENABLED && CONFIG_BT_LE_ERROR_SIM_ENABLED */
#if UC_BLE_CTRL_CONN_ENABLED
sym_conn_sIcAPw7j0toiOGWivJ0e,
#endif /* UC_BLE_CTRL_CONN_ENABLED */
#if UC_BT_CTRL_LE_CTE_CAL_ENABLED
sym_cteCal_ixMlNDshScz4WVTbiOKl,
#endif /* UC_BT_CTRL_LE_CTE_CAL_ENABLED */
#if UC_BT_CTRL_LE_CTE_ENABLED
sym_cte_P7A06WogxnY1JlnvQaGe,
#endif /* UC_BT_CTRL_LE_CTE_ENABLED */
#if UC_BT_CTRL_LE_DTM_ENABLED
sym_dtm_wW4wnzkRa1kpb5NfwZVi,
#endif /* UC_BT_CTRL_LE_DTM_ENABLED */
#if UC_BT_CTRL_LE_ISO_ENABLED
sym_iso_WJJo4fn6Hkvt9xXAvziZ,
#endif /* UC_BT_CTRL_LE_ISO_ENABLED */
#if UC_BLE_CTRL_PAWR_BCAST_SUPPORTED
sym_pawrBcast_eBH7HrPT8y2Fj9382el3,
#endif /* UC_BLE_CTRL_PAWR_BCAST_SUPPORTED */
sym_resolv_GWz7Tb1ymxsyLQ1208Jj,
sym_scan_l1avG2cwTzJAlle4KLdU,
sym_sync_NOAs4m6LAUpamsUYHfqm,
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
),
);
#if UC_BT_CTRL_BLE_IS_ENABLE && UC_BLE_CTRL_CONN_ENABLED
const void * const _conn_linear_broker_flash[] = BTDM_BROKER_NODE_DEF_FLASH(
#if UC_BLE_CTRL_CONN_ENABLED && CONFIG_BT_LE_ERROR_SIM_ENABLED
[1] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_connSim_2RFEzu4Evi68Nnt4YowZ,
),
[2] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_connSim_SoaIlItcCgS4km7f1141,
),
#endif /* UC_BLE_CTRL_CONN_ENABLED && CONFIG_BT_LE_ERROR_SIM_ENABLED */
#if UC_BLE_CTRL_PAWR_SYNC_SUPPORTED
[3] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrSync_pbTRKlIHoevVfNidtKZb,
),
[4] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrSync_fn4PoAB0qFmYpbwqTO2H,
),
#endif /* UC_BLE_CTRL_PAWR_SYNC_SUPPORTED */
#if UC_BLE_CTRL_PAWR_BCAST_SUPPORTED
[5] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_on08yxBjym4I0iV3tlPo,
),
#endif /* UC_BLE_CTRL_PAWR_BCAST_SUPPORTED */
[6] = BTDM_BROKER_ENTRY_DEF_FLASH(
#if UC_BT_CTRL_LE_CIS_CENT_ENABLED
sym_cisCent_9P0KC1xZQpumJC2psVXO,
#endif /* UC_BT_CTRL_LE_CIS_CENT_ENABLED */
#if UC_BT_CTRL_LE_CIS_PRPH_ENABLED
sym_cisPrph_6ORekVL63tenTy0sCT2O,
#endif /* UC_BT_CTRL_LE_CIS_PRPH_ENABLED */
#if UC_BT_CTRL_LE_CIS_ENABLED
sym_cis_wQtv7EbxMlyUdVE0TQ9T,
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
),
[7] = BTDM_BROKER_ENTRY_DEF_FLASH(
#if UC_BT_CTRL_LE_CIS_CENT_ENABLED
sym_cisCent_GSToGcnDAoUIQsFaBPr7,
#endif /* UC_BT_CTRL_LE_CIS_CENT_ENABLED */
#if UC_BT_CTRL_LE_CIS_PRPH_ENABLED
sym_cisPrph_zr8KQ3aEASRV2ZptTSnX,
#endif /* UC_BT_CTRL_LE_CIS_PRPH_ENABLED */
),
[8] = BTDM_BROKER_ENTRY_DEF_FLASH(
#if UC_BT_CTRL_LE_CIS_CENT_ENABLED
sym_cisCent_JUzUk54A9UNHtsUAHT8F,
#endif /* UC_BT_CTRL_LE_CIS_CENT_ENABLED */
#if UC_BT_CTRL_LE_CIS_PRPH_ENABLED
sym_cisPrph_xR7NheKHstTWkDAuZROL,
#endif /* UC_BT_CTRL_LE_CIS_PRPH_ENABLED */
),
#if UC_BT_CTRL_LE_CIS_ENABLED
[9] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_cis_eeNELMi6IB5X3UF8MMvQ,
),
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
[10] = BTDM_BROKER_ENTRY_DEF_FLASH(
#if UC_BT_CTRL_LE_CIS_CENT_ENABLED
sym_cisCent_wt1P0oioDDyNz026HxsK,
#endif /* UC_BT_CTRL_LE_CIS_CENT_ENABLED */
#if UC_BT_CTRL_LE_CIS_PRPH_ENABLED
sym_cisPrph_Kb3o0Y7oUCdHJ1SXcoqj,
#endif /* UC_BT_CTRL_LE_CIS_PRPH_ENABLED */
#if UC_BT_CTRL_LE_CIS_ENABLED
sym_cis_i4bfG8waTBMteoJaWD40,
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
),
[12] = BTDM_BROKER_ENTRY_DEF_FLASH(
#if UC_BT_CTRL_LE_CIS_CENT_ENABLED
sym_cisCent_f2xo5SuAzLb4iRlhLPhf,
#endif /* UC_BT_CTRL_LE_CIS_CENT_ENABLED */
#if UC_BT_CTRL_LE_CIS_PRPH_ENABLED
sym_cisPrph_Dw8FBGfBWm2LptzYq46z,
#endif /* UC_BT_CTRL_LE_CIS_PRPH_ENABLED */
#if UC_BT_CTRL_LE_CIS_ENABLED
sym_cis_coXGBkWhDUZWHDFo80gN,
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
),
#if UC_BT_CTRL_LE_CIS_ENABLED
[13] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_cis_3DmpJ8V6gGsnSNopbei0,
),
[14] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_cis_WICEvILg2pK6JZvhry3j,
),
[15] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_cis_zGkqwv9urnJ8DbX0JZAr,
),
[16] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_cis_Bmj5ai8K8ZKFKqWA8X8B,
),
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
[17] = BTDM_BROKER_ENTRY_DEF_FLASH(
#if UC_BT_CTRL_LE_CIS_CENT_ENABLED
sym_cisCent_jfaA90JGHwEKv1YkKIUO,
#endif /* UC_BT_CTRL_LE_CIS_CENT_ENABLED */
#if UC_BT_CTRL_LE_CIS_ENABLED
sym_cis_mcjvVuw8ttAldZnobGxJ,
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
),
#if UC_BT_CTRL_LE_CIS_ENABLED
[18] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_cis_Guzdzme9CFLxrbjG6HEJ,
),
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
);
#endif /* UC_BT_CTRL_BLE_IS_ENABLE && UC_BLE_CTRL_CONN_ENABLED */
#if UC_BT_CTRL_BLE_IS_ENABLE
const void * const _nrtIsr_linear_broker_flash[] = BTDM_BROKER_NODE_DEF_FLASH(
);
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
#if UC_BT_CTRL_BLE_IS_ENABLE
const void * const _perAdv_linear_broker_flash[] = BTDM_BROKER_NODE_DEF_FLASH(
#if UC_BT_CTRL_LE_BIS_BCAST_ENABLED
[1] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_bisBcast_2a3kgxHeabxbnBIsRh4s,
),
[2] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_bisBcast_EtJ8xQ5EIWS6IjqpsD1U,
),
[3] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_bisBcast_2uiisGIdoGa6SNUZCE2m,
),
#endif /* UC_BT_CTRL_LE_BIS_BCAST_ENABLED */
);
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
#if UC_BT_CTRL_BLE_IS_ENABLE
const void * const _sync_linear_broker_flash[] = BTDM_BROKER_NODE_DEF_FLASH(
#if UC_BLE_CTRL_PAWR_SYNC_SUPPORTED
[1] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrSync_Qifv1iec7w57n2pBwucX,
),
[2] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrSync_bbizSGqM6wZUOT0fQF1M,
),
[3] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrSync_oBwpWArFlWxUJNCnHvsJ,
),
[4] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrSync_vAN2YoeCsSKafv2NdPVC,
),
[5] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrSync_9XvRcZs9CUOgHNbMhe5G,
),
[6] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrSync_zuG0pqdRWK2zt5S09fTS,
),
[7] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrSync_LO7YyFM93srewqVpETY2,
),
[8] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrSync_7bchpvHsUM8DXHyaXC7f,
),
#endif /* UC_BLE_CTRL_PAWR_SYNC_SUPPORTED */
#if UC_BT_CTRL_LE_BIS_SYNC_ENABLED
[9] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_bisSync_3FCcFQdSowAGd7aAejeg,
),
[10] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_bisSync_0xkTwhqVWK4bwJa6dDH6,
),
#endif /* UC_BT_CTRL_LE_BIS_SYNC_ENABLED */
);
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
int
btdm_broker_init(void)
{
#if UC_BT_CTRL_BLE_IS_ENABLE
if (r_btdm_broker_linear_selfcheck(_adv_linear_broker_flash, false)) {
return -1;
}
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
#if UC_BT_CTRL_BLE_IS_ENABLE
if (r_btdm_broker_linear_selfcheck(_base_linear_broker_flash, false)) {
return -2;
}
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
if (r_btdm_broker_linear_selfcheck(_btdm_hal_linear_broker_ram, true)) {
return -3;
}
if (r_btdm_broker_linear_selfcheck(_btdm_hci_linear_broker_flash, false)) {
return -4;
}
if (r_btdm_broker_linear_selfcheck(_btdm_sched_linear_broker_flash, false)) {
return -5;
}
if (r_btdm_broker_linear_selfcheck(_btdm_sched_linear_broker_ram, true)) {
return -6;
}
if (r_btdm_broker_linear_selfcheck(_btdm_sleep_linear_broker_flash, false)) {
return -7;
}
if (r_btdm_broker_linear_selfcheck(_btdm_task_linear_broker_flash, false)) {
return -8;
}
#if UC_BT_CTRL_BLE_IS_ENABLE && UC_BLE_CTRL_CONN_ENABLED
if (r_btdm_broker_linear_selfcheck(_conn_linear_broker_flash, false)) {
return -9;
}
#endif /* UC_BT_CTRL_BLE_IS_ENABLE && UC_BLE_CTRL_CONN_ENABLED */
#if UC_BT_CTRL_BLE_IS_ENABLE
if (r_btdm_broker_linear_selfcheck(_nrtIsr_linear_broker_flash, false)) {
return -10;
}
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
#if UC_BT_CTRL_BLE_IS_ENABLE
if (r_btdm_broker_linear_selfcheck(_perAdv_linear_broker_flash, false)) {
return -11;
}
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
#if UC_BT_CTRL_BLE_IS_ENABLE
if (r_btdm_broker_linear_selfcheck(_sync_linear_broker_flash, false)) {
return -12;
}
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
return 0;
}
void
btdm_broker_deinit(void)
{
}

View File

@@ -57,12 +57,15 @@ 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);
extern int r_btdm_task_init(esp_btdm_controller_config_t *cfg);
extern int r_btdm_task_init(esp_bt_ctrl_btdm_config_t *cfg);
extern void r_btdm_task_deinit(void);
extern int r_btdm_task_enable(void);
extern void r_btdm_task_disable(void);
extern void r_btdm_task_shutdown(void);
extern int btdm_broker_init(void);
extern void btdm_broker_deinit(void);
/*
***************************************************************************************************
* Local Variables
@@ -114,6 +117,8 @@ bt_controller_deinit(void)
btdm_log_deinit();
btdm_osal_elem_mempool_deinit();
btdm_broker_deinit();
return ESP_OK;
}
@@ -169,11 +174,11 @@ esp_err_t
esp_bt_controller_init(esp_bt_controller_config_t *cfg)
{
int ret;
// TODO: Delete workaround
btdm_osal_elem_num_t elem = {
.evt_count = 3 + 100,
.evtq_count = 1 + 2,
.co_count = 0 + 10,
.evt_count = 3,
.evtq_count = 1,
.co_count = 0,
.sem_count = 0,
.mutex_count = 1,
};
@@ -193,6 +198,12 @@ esp_bt_controller_init(esp_bt_controller_config_t *cfg)
return ESP_ERR_INVALID_STATE;
}
ret = btdm_broker_init();
if (ret) {
ESP_LOGE(BTDM_LOG_TAG, "btdm_broker_init failed: %d", ret);
goto init_failed;
}
#if UC_BT_CTRL_BLE_IS_ENABLE
ble_osal_elem_calc(cfg, &elem);
#endif // UC_BT_CTRL_BLE_IS_ENABLE

View File

@@ -0,0 +1,866 @@
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*
* !!! DO NOT MODIFY ANYTHING IN THIS FILE !!!
*/
#include <stdint.h>
#include <stdbool.h>
#include "btdm_user_cfg.h"
#if UC_BT_CTRL_BLE_IS_ENABLE
#include "ble_user_cfg.h"
#endif
#if UC_BT_CTRL_BR_EDR_IS_ENABLE
#include "bredr_user_cfg.h"
#endif
#define BTDM_BROKER_MAGIC (0xc55c0000UL)
#define __BTDM_BROKER_ARRAY_SIZE(storage, ...) \
((sizeof((storage void *storage[]){0, __VA_ARGS__}) / sizeof(void *)) - 1)
#define __BTDM_BROKER_ENTRY(storage, ...) \
((storage void *storage[]){ \
(void *)(BTDM_BROKER_MAGIC | (__BTDM_BROKER_ARRAY_SIZE(storage, __VA_ARGS__) & 0xFFFFU)), \
__VA_ARGS__})
#define BTDM_BROKER_ENTRY_DEF_FLASH(...) __BTDM_BROKER_ENTRY(const, __VA_ARGS__)
#define BTDM_BROKER_ENTRY_DEF_RAM(...) __BTDM_BROKER_ENTRY(, __VA_ARGS__)
#define BTDM_BROKER_NODE_DEF_FLASH(...) \
{(const void *const)(__BTDM_BROKER_ARRAY_SIZE(const, __VA_ARGS__)), __VA_ARGS__}
#define BTDM_BROKER_NODE_DEF_RAM(...) \
{(void *)(__BTDM_BROKER_ARRAY_SIZE(, __VA_ARGS__)), __VA_ARGS__}
/*
********************************************************************************
* External Functions Declaration
********************************************************************************
*/
extern int r_btdm_broker_linear_selfcheck(const void *broker, bool is_ram);
extern int r_btdm_broker_indexed_selfcheck(const void *broker, bool is_ram);
extern int r_sym_bt_8fMePSgKBxkeyUSGQQcU(void *param);
extern int r_sym_bt_CXxFmLXrWP71jb0eVlzN(void *param);
extern int r_sym_bt_z2aLQW3Zvuoq7vASCpLB(void *param);
#if UC_BT_CTRL_BLE_IS_ENABLE
extern int sym_acceptList_E2sQw1uVsjxxiP0PJWNT(void *param);
extern int sym_acceptList_vvIIdyHCcpNAdAdzZrPN(void *param);
extern int sym_acceptList_yfAo03VLjZhjCR2fnGvX(void *param);
extern int sym_adv_S1K3QvkLgRcH2We9Z3KD(void *param);
extern int sym_adv_k0eZcDthWb1sk0Kloemu(void *param);
extern int sym_adv_xfHX4YH2Zb9de4JlBztj(void *param);
extern int sym_arr_CG7zWaZkh7QOTatTjs2v(void *param);
extern int sym_arr_SH7I2IviDsjnpqawpi0F(void *param);
extern int sym_base_CdIdlqttqbZqCmaW9GAc(void *param);
extern int sym_base_IdP4ncGWlpNArj2oW20N(void *param);
extern int sym_base_NVN4AbeIskmtcV2PX3N1(void *param);
extern int sym_base_QIE6fqExGJrsGUIGYNSf(void *param);
extern int sym_base_uevmRkB8BjrlJh1c3VnZ(void *param);
extern int sym_base_uuBMFaiuN71hyzVcBBth(void *param);
extern int sym_coexHook_7UsddOHoZepnYRjYPawG(void *param);
extern int sym_coexHook_WcEp3uxRHd6HYgB0pn0L(void *param);
extern int sym_coexHook_wiWNhAUWlHyTZ7Z5ZC5Z(void *param);
extern int sym_coexStack_hzrw4DdhxAw5xAlGFEwI(void *param);
extern int sym_coexStack_sMPrrpveO5HOIb2qa5I8(void *param);
extern int sym_extAdv_65JKSxhAHiLFV63DSxJk(void *param);
extern int sym_extAdv_cxB4HBdDRajzTQg8DqKC(void *param);
extern int sym_extAdv_j9EFs8yTWikhycyNL2tu(void *param);
extern int sym_memMgmt_7tLw3T7RgI6l7DQc4dMI(void *param);
extern int sym_memMgmt_PpI7zFiJWyV56U0OIURt(void *param);
extern int sym_rand_6102wQhjz4grvtu5s8T3(void *param);
extern int sym_rand_TnYdBCetsq1sndnhcROz(void *param);
extern int sym_resolv_GWz7Tb1ymxsyLQ1208Jj(void *param);
extern int sym_resolv_YX00BNf3Z2oJaizN1uK8(void *param);
extern int sym_resolv_hQFDtxZqj5AP1IMR8s59(void *param);
extern int sym_scan_0gIKmjMRFT37raN6hnDo(void *param);
extern int sym_scan_1G8QO0lWyTS0nKOqvZOE(void *param);
extern int sym_scan_Tfvee56pMZTiTxWnEWgP(void *param);
extern int sym_scan_b8ogEC3hTjGmqL5oRuyw(void *param);
extern int sym_scan_cgn6c03k4ZQqi2dJOtfm(void *param);
extern int sym_scan_fd4yzdFac8vdFTlQ4BPA(void *param);
extern int sym_scan_l1avG2cwTzJAlle4KLdU(void *param);
extern int sym_scan_tdX6OLWyRKYxelkB8vZ1(void *param);
extern int sym_scan_zmw2OczvfXFB4aIFaWkc(void *param);
extern int sym_sched_MzeSZzbQ4ZKhWW6Wu5jV(void *param);
extern int sym_sched_PNMeumLUZPcz8o4UrTLi(void *param);
extern int sym_sched_hOsJ4rGq1XjiY7GjHycG(void *param);
extern int sym_sched_wfZseauvjWnjfiu10yWN(void *param);
extern int sym_sync_NOAs4m6LAUpamsUYHfqm(void *param);
extern int sym_sync_dVvFbZ7ZwsleTM2nkzdV(void *param);
extern int sym_sync_uoa5Xd4XcSSCUjyNsVGo(void *param);
#if UC_BLE_CTRL_CONN_ENABLED
extern int sym_conn_Sw7sI0dtf78paJdn9Uhg(void *param);
extern int sym_conn_eZ0plXo8e56VyJXdcbNn(void *param);
extern int sym_conn_k5hEt7krj8McRSctLS7X(void *param);
extern int sym_conn_nW2gyrsrYX980SM1JXUT(void *param);
extern int sym_conn_sIcAPw7j0toiOGWivJ0e(void *param);
#endif /* UC_BLE_CTRL_CONN_ENABLED */
#if UC_BLE_CTRL_CONN_ENABLED && CONFIG_BT_LE_ERROR_SIM_ENABLED
extern int sym_connSim_2RFEzu4Evi68Nnt4YowZ(void *param);
extern int sym_connSim_3guOkwBVGmSgwrEIVUvL(void *param);
extern int sym_connSim_EIv22SNth3fM1SPgJ9hO(void *param);
extern int sym_connSim_SoaIlItcCgS4km7f1141(void *param);
extern int sym_connSim_dytLpHTAgMtQWf4K3pGc(void *param);
extern int sym_connSim_rsrSBeH3W8LE1yGVrtBc(void *param);
#endif /* UC_BLE_CTRL_CONN_ENABLED && CONFIG_BT_LE_ERROR_SIM_ENABLED */
#if UC_BLE_CTRL_PAWR_BCAST_SUPPORTED
extern int sym_pawrBcast_02YCihGkfXcpLt0zh1uM(void *param);
extern int sym_pawrBcast_0PNup0d8oI1288mfULNW(void *param);
extern int sym_pawrBcast_0Wq1DOQE0eOWEGV2grxM(void *param);
extern int sym_pawrBcast_1y9l4P0a3qWUSydU3cDY(void *param);
extern int sym_pawrBcast_7jK56jlcfafMtoQgLg6t(void *param);
extern int sym_pawrBcast_7qGF1F9weQ363Ml7Gj0n(void *param);
extern int sym_pawrBcast_JHmbFJCpV155hIYyDVQ8(void *param);
extern int sym_pawrBcast_JPGtn7AltqyvIRT8iPtF(void *param);
extern int sym_pawrBcast_Jrj3qAmZkOoWxL1jFdmP(void *param);
extern int sym_pawrBcast_KBuKVEBVXwxouWjaJUva(void *param);
extern int sym_pawrBcast_OEzQrCBnW7rhUIi6H6gM(void *param);
extern int sym_pawrBcast_SB1LBCzybPoDd0XYyLM8(void *param);
extern int sym_pawrBcast_WNd7Y6n56cZrTlhBjFRU(void *param);
extern int sym_pawrBcast_eBH7HrPT8y2Fj9382el3(void *param);
extern int sym_pawrBcast_g6t1IjxRbcv5GUq1uXIA(void *param);
extern int sym_pawrBcast_lk2Wpy4u04ukjtC7Ijcb(void *param);
extern int sym_pawrBcast_on08yxBjym4I0iV3tlPo(void *param);
extern int sym_pawrBcast_sSbQFGKMJszbA895ddLO(void *param);
extern int sym_pawrBcast_w9Kcjl02BFd1e11Ic3A0(void *param);
#endif /* UC_BLE_CTRL_PAWR_BCAST_SUPPORTED */
#if UC_BLE_CTRL_PAWR_SYNC_SUPPORTED
extern int sym_pawrSync_1cW8RtQRnVveTqFg9OSR(void *param);
extern int sym_pawrSync_2gh2xSEYHokuhQ7UohkM(void *param);
extern int sym_pawrSync_7bchpvHsUM8DXHyaXC7f(void *param);
extern int sym_pawrSync_9XvRcZs9CUOgHNbMhe5G(void *param);
extern int sym_pawrSync_LO7YyFM93srewqVpETY2(void *param);
extern int sym_pawrSync_Qifv1iec7w57n2pBwucX(void *param);
extern int sym_pawrSync_bbizSGqM6wZUOT0fQF1M(void *param);
extern int sym_pawrSync_fn4PoAB0qFmYpbwqTO2H(void *param);
extern int sym_pawrSync_k4txvaSWHJBXXqtE62MG(void *param);
extern int sym_pawrSync_oBwpWArFlWxUJNCnHvsJ(void *param);
extern int sym_pawrSync_pbTRKlIHoevVfNidtKZb(void *param);
extern int sym_pawrSync_vAN2YoeCsSKafv2NdPVC(void *param);
extern int sym_pawrSync_vBce2UGY5s0PhM3gRF8p(void *param);
extern int sym_pawrSync_zuG0pqdRWK2zt5S09fTS(void *param);
#endif /* UC_BLE_CTRL_PAWR_SYNC_SUPPORTED */
#if UC_BT_CTRL_LE_BIS_BCAST_ENABLED
extern int sym_bisBcast_2a3kgxHeabxbnBIsRh4s(void *param);
extern int sym_bisBcast_2dWM4hoGuoEwy8loUGlI(void *param);
extern int sym_bisBcast_2uiisGIdoGa6SNUZCE2m(void *param);
extern int sym_bisBcast_BcOOZfvM58VUQK6uC2ew(void *param);
extern int sym_bisBcast_EtJ8xQ5EIWS6IjqpsD1U(void *param);
extern int sym_bisBcast_Pe7M3vC0UOSbZWC7Bm8D(void *param);
extern int sym_bisBcast_vATQ5EU18M2xnmNZ84fY(void *param);
extern int sym_bisBcast_vKPkmtQzLc0ZU4R3Mpa1(void *param);
extern int sym_bisBcast_zlcnIBGOIfWlPC3WJ66f(void *param);
#endif /* UC_BT_CTRL_LE_BIS_BCAST_ENABLED */
#if UC_BT_CTRL_LE_BIS_SYNC_ENABLED
extern int sym_bisSync_0xkTwhqVWK4bwJa6dDH6(void *param);
extern int sym_bisSync_3FCcFQdSowAGd7aAejeg(void *param);
extern int sym_bisSync_BO46u3KvbiXYsPrQplUT(void *param);
extern int sym_bisSync_DuQGVcBNN6l6ggZp4Y8J(void *param);
extern int sym_bisSync_EaKbiRZI30mvH3KWkMY5(void *param);
extern int sym_bisSync_cB4uyzKmrYjduUbWqXdb(void *param);
extern int sym_bisSync_qLbiM85U90F0BvzUDhgt(void *param);
#endif /* UC_BT_CTRL_LE_BIS_SYNC_ENABLED */
#if UC_BT_CTRL_LE_CIS_CENT_ENABLED
extern int sym_cisCent_9P0KC1xZQpumJC2psVXO(void *param);
extern int sym_cisCent_GSToGcnDAoUIQsFaBPr7(void *param);
extern int sym_cisCent_JUzUk54A9UNHtsUAHT8F(void *param);
extern int sym_cisCent_f2xo5SuAzLb4iRlhLPhf(void *param);
extern int sym_cisCent_jfaA90JGHwEKv1YkKIUO(void *param);
extern int sym_cisCent_wt1P0oioDDyNz026HxsK(void *param);
#endif /* UC_BT_CTRL_LE_CIS_CENT_ENABLED */
#if UC_BT_CTRL_LE_CIS_ENABLED
extern int sym_cis_3DmpJ8V6gGsnSNopbei0(void *param);
extern int sym_cis_5PzTPmH8LVt7wMSC7YnP(void *param);
extern int sym_cis_Bmj5ai8K8ZKFKqWA8X8B(void *param);
extern int sym_cis_Guzdzme9CFLxrbjG6HEJ(void *param);
extern int sym_cis_QxmCCIxcxCfrWCKZmT3X(void *param);
extern int sym_cis_UBu7crU2pIczpNc5cEcP(void *param);
extern int sym_cis_WICEvILg2pK6JZvhry3j(void *param);
extern int sym_cis_coXGBkWhDUZWHDFo80gN(void *param);
extern int sym_cis_eeNELMi6IB5X3UF8MMvQ(void *param);
extern int sym_cis_f2SkEM3LCeOCgMzDRq24(void *param);
extern int sym_cis_i4bfG8waTBMteoJaWD40(void *param);
extern int sym_cis_j0GHq32oPR9AN7YHYxEI(void *param);
extern int sym_cis_mcjvVuw8ttAldZnobGxJ(void *param);
extern int sym_cis_vY92iDVk3ph4SrNh5ccy(void *param);
extern int sym_cis_wQtv7EbxMlyUdVE0TQ9T(void *param);
extern int sym_cis_zGkqwv9urnJ8DbX0JZAr(void *param);
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
#if UC_BT_CTRL_LE_CIS_PRPH_ENABLED
extern int sym_cisPrph_6ORekVL63tenTy0sCT2O(void *param);
extern int sym_cisPrph_Dw8FBGfBWm2LptzYq46z(void *param);
extern int sym_cisPrph_Kb3o0Y7oUCdHJ1SXcoqj(void *param);
extern int sym_cisPrph_xR7NheKHstTWkDAuZROL(void *param);
extern int sym_cisPrph_zr8KQ3aEASRV2ZptTSnX(void *param);
#endif /* UC_BT_CTRL_LE_CIS_PRPH_ENABLED */
#if UC_BT_CTRL_LE_CTE_CAL_ENABLED
extern int sym_cteCal_Lxc6TR3r9tNnhSe66bmE(void *param);
extern int sym_cteCal_NKbWd6AypEyH2B338dAx(void *param);
extern int sym_cteCal_ixMlNDshScz4WVTbiOKl(void *param);
extern int sym_cteCal_j700khui6oomGLu22Rgb(void *param);
extern int sym_cteCal_uWSKv9wSYw0nIY0GhuZF(void *param);
#endif /* UC_BT_CTRL_LE_CTE_CAL_ENABLED */
#if UC_BT_CTRL_LE_CTE_ENABLED
extern int sym_cte_NjXx2EHiiDoBXhq2trhx(void *param);
extern int sym_cte_P7A06WogxnY1JlnvQaGe(void *param);
extern int sym_cte_aMtk23FR89BNAXNthzRu(void *param);
extern int sym_cte_onkmOjIkv3QCPJVJQuUB(void *param);
extern int sym_cte_vx3COozMkhCXFbq2ZjHK(void *param);
#endif /* UC_BT_CTRL_LE_CTE_ENABLED */
#if UC_BT_CTRL_LE_DTM_ENABLED
extern int sym_dtm_8YKzWpU1Xe3NGGMtUeY6(void *param);
extern int sym_dtm_Er3Vd8hhSABNIkl9x3At(void *param);
extern int sym_dtm_wW4wnzkRa1kpb5NfwZVi(void *param);
#endif /* UC_BT_CTRL_LE_DTM_ENABLED */
#if UC_BT_CTRL_LE_ISO_ENABLED
extern int sym_coexIsoHal_RVw8jrRQybFIlwvrONo9(void *param);
extern int sym_iso_6SFIpEwXw1SsCdgfyN88(void *param);
extern int sym_iso_8HHndXTSYyYcW1EhDzAN(void *param);
extern int sym_iso_WJJo4fn6Hkvt9xXAvziZ(void *param);
extern int sym_iso_Ywq26gNcDI3MQQVQbDEF(void *param);
extern int sym_iso_gk1uwrtqhb5WsUZoPUJq(void *param);
extern int sym_iso_qYKZbEBVIsH27HGf5VCS(void *param);
extern int sym_iso_xew5NrC4aBwCavwqySPp(void *param);
#endif /* UC_BT_CTRL_LE_ISO_ENABLED */
#if UC_BT_CTRL_LE_VS_CMD_EVT_ENABLED && CONFIG_BT_CTRL_SLEEP_ENABLE
extern int sym_sleep_Ayr8PrlSNd7F6hhsmt13(void *param);
#endif /* UC_BT_CTRL_LE_VS_CMD_EVT_ENABLED && CONFIG_BT_CTRL_SLEEP_ENABLE */
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
#if UC_BT_CTRL_BR_EDR_IS_ENABLE
extern int btdm_common_sched_bredr_on_sched_check_remaining(void *param);
extern int btdm_common_sched_bredr_on_sched_hw_list_done(void *param);
extern int hci_tl_bredr_on_rx_cmd_c2h_num_pkt(void *param);
extern int hci_tl_bredr_on_rx_cmd_set_c2h_flow_ctrl(void *param);
extern int odm_afh_on_coex_wifi_channel_change(void *param);
extern int olc_intc_on_hal_exit_isr(void *param);
extern int olc_sleep_on_sched_actual_time_get(void *param);
extern int olc_sleep_on_sched_get_earlist_ticks(void *param);
extern int orca_ctrl_on_task_disable(void *param);
extern int orca_ctrl_on_task_enable(void *param);
extern int orca_ctrl_on_task_reset(void *param);
#endif /* UC_BT_CTRL_BR_EDR_IS_ENABLE */
/*
********************************************************************************
* Linear Broker Definitions
********************************************************************************
*/
#if UC_BT_CTRL_BLE_IS_ENABLE
const void * const _adv_linear_broker_flash[] = BTDM_BROKER_NODE_DEF_FLASH(
#if UC_BLE_CTRL_PAWR_BCAST_SUPPORTED
[1] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_0PNup0d8oI1288mfULNW,
),
[2] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_02YCihGkfXcpLt0zh1uM,
),
[3] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_g6t1IjxRbcv5GUq1uXIA,
),
[4] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_7jK56jlcfafMtoQgLg6t,
),
[5] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_w9Kcjl02BFd1e11Ic3A0,
),
[6] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_0Wq1DOQE0eOWEGV2grxM,
),
[7] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_JPGtn7AltqyvIRT8iPtF,
),
[8] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_1y9l4P0a3qWUSydU3cDY,
),
[9] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_lk2Wpy4u04ukjtC7Ijcb,
),
[10] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_OEzQrCBnW7rhUIi6H6gM,
),
[11] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_KBuKVEBVXwxouWjaJUva,
),
[12] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_sSbQFGKMJszbA895ddLO,
),
[13] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_WNd7Y6n56cZrTlhBjFRU,
),
#endif /* UC_BLE_CTRL_PAWR_BCAST_SUPPORTED */
);
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
#if UC_BT_CTRL_BLE_IS_ENABLE
const void * const _base_linear_broker_flash[] = BTDM_BROKER_NODE_DEF_FLASH(
[1] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_acceptList_E2sQw1uVsjxxiP0PJWNT,
sym_adv_k0eZcDthWb1sk0Kloemu,
#if UC_BT_CTRL_LE_BIS_BCAST_ENABLED
sym_bisBcast_Pe7M3vC0UOSbZWC7Bm8D,
#endif /* UC_BT_CTRL_LE_BIS_BCAST_ENABLED */
#if UC_BT_CTRL_LE_BIS_SYNC_ENABLED
sym_bisSync_BO46u3KvbiXYsPrQplUT,
#endif /* UC_BT_CTRL_LE_BIS_SYNC_ENABLED */
#if UC_BT_CTRL_LE_CIS_ENABLED
sym_cis_5PzTPmH8LVt7wMSC7YnP,
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
sym_coexStack_hzrw4DdhxAw5xAlGFEwI,
#if UC_BLE_CTRL_CONN_ENABLED && CONFIG_BT_LE_ERROR_SIM_ENABLED
sym_connSim_dytLpHTAgMtQWf4K3pGc,
#endif /* UC_BLE_CTRL_CONN_ENABLED && CONFIG_BT_LE_ERROR_SIM_ENABLED */
#if UC_BLE_CTRL_CONN_ENABLED
sym_conn_k5hEt7krj8McRSctLS7X,
#endif /* UC_BLE_CTRL_CONN_ENABLED */
#if UC_BT_CTRL_LE_CTE_CAL_ENABLED
sym_cteCal_j700khui6oomGLu22Rgb,
#endif /* UC_BT_CTRL_LE_CTE_CAL_ENABLED */
#if UC_BT_CTRL_LE_CTE_ENABLED
sym_cte_aMtk23FR89BNAXNthzRu,
#endif /* UC_BT_CTRL_LE_CTE_ENABLED */
#if UC_BT_CTRL_LE_DTM_ENABLED
sym_dtm_Er3Vd8hhSABNIkl9x3At,
#endif /* UC_BT_CTRL_LE_DTM_ENABLED */
sym_extAdv_65JKSxhAHiLFV63DSxJk,
#if UC_BT_CTRL_LE_ISO_ENABLED
sym_iso_gk1uwrtqhb5WsUZoPUJq,
#endif /* UC_BT_CTRL_LE_ISO_ENABLED */
#if UC_BLE_CTRL_PAWR_BCAST_SUPPORTED
sym_pawrBcast_7qGF1F9weQ363Ml7Gj0n,
#endif /* UC_BLE_CTRL_PAWR_BCAST_SUPPORTED */
#if UC_BLE_CTRL_PAWR_SYNC_SUPPORTED
sym_pawrSync_vBce2UGY5s0PhM3gRF8p,
#endif /* UC_BLE_CTRL_PAWR_SYNC_SUPPORTED */
sym_rand_TnYdBCetsq1sndnhcROz,
sym_resolv_YX00BNf3Z2oJaizN1uK8,
sym_scan_Tfvee56pMZTiTxWnEWgP,
sym_sync_uoa5Xd4XcSSCUjyNsVGo,
),
[2] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_acceptList_yfAo03VLjZhjCR2fnGvX,
sym_adv_S1K3QvkLgRcH2We9Z3KD,
#if UC_BT_CTRL_LE_BIS_BCAST_ENABLED
sym_bisBcast_vKPkmtQzLc0ZU4R3Mpa1,
#endif /* UC_BT_CTRL_LE_BIS_BCAST_ENABLED */
#if UC_BT_CTRL_LE_BIS_SYNC_ENABLED
sym_bisSync_qLbiM85U90F0BvzUDhgt,
#endif /* UC_BT_CTRL_LE_BIS_SYNC_ENABLED */
#if UC_BT_CTRL_LE_CIS_ENABLED
sym_cis_j0GHq32oPR9AN7YHYxEI,
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
sym_coexStack_sMPrrpveO5HOIb2qa5I8,
#if UC_BLE_CTRL_CONN_ENABLED && CONFIG_BT_LE_ERROR_SIM_ENABLED
sym_connSim_rsrSBeH3W8LE1yGVrtBc,
#endif /* UC_BLE_CTRL_CONN_ENABLED && CONFIG_BT_LE_ERROR_SIM_ENABLED */
#if UC_BLE_CTRL_CONN_ENABLED
sym_conn_nW2gyrsrYX980SM1JXUT,
#endif /* UC_BLE_CTRL_CONN_ENABLED */
#if UC_BT_CTRL_LE_CTE_CAL_ENABLED
sym_cteCal_Lxc6TR3r9tNnhSe66bmE,
#endif /* UC_BT_CTRL_LE_CTE_CAL_ENABLED */
#if UC_BT_CTRL_LE_CTE_ENABLED
sym_cte_onkmOjIkv3QCPJVJQuUB,
#endif /* UC_BT_CTRL_LE_CTE_ENABLED */
#if UC_BT_CTRL_LE_DTM_ENABLED
sym_dtm_8YKzWpU1Xe3NGGMtUeY6,
#endif /* UC_BT_CTRL_LE_DTM_ENABLED */
sym_extAdv_cxB4HBdDRajzTQg8DqKC,
#if UC_BT_CTRL_LE_ISO_ENABLED
sym_iso_xew5NrC4aBwCavwqySPp,
#endif /* UC_BT_CTRL_LE_ISO_ENABLED */
#if UC_BLE_CTRL_PAWR_BCAST_SUPPORTED
sym_pawrBcast_SB1LBCzybPoDd0XYyLM8,
#endif /* UC_BLE_CTRL_PAWR_BCAST_SUPPORTED */
#if UC_BLE_CTRL_PAWR_SYNC_SUPPORTED
sym_pawrSync_1cW8RtQRnVveTqFg9OSR,
#endif /* UC_BLE_CTRL_PAWR_SYNC_SUPPORTED */
sym_rand_6102wQhjz4grvtu5s8T3,
sym_resolv_hQFDtxZqj5AP1IMR8s59,
sym_scan_cgn6c03k4ZQqi2dJOtfm,
sym_sync_dVvFbZ7ZwsleTM2nkzdV,
),
#if UC_BT_CTRL_LE_CIS_ENABLED
[3] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_cis_vY92iDVk3ph4SrNh5ccy,
),
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
#if UC_BT_CTRL_LE_BIS_BCAST_ENABLED
[4] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_bisBcast_BcOOZfvM58VUQK6uC2ew,
),
#endif /* UC_BT_CTRL_LE_BIS_BCAST_ENABLED */
);
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
const void * const _btdm_coex_linear_broker_flash[] = BTDM_BROKER_NODE_DEF_FLASH(
#if UC_BT_CTRL_BLE_IS_ENABLE
[1] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_coexHook_WcEp3uxRHd6HYgB0pn0L,
),
[2] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_coexHook_wiWNhAUWlHyTZ7Z5ZC5Z,
),
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
);
void * _btdm_hal_linear_broker_ram[] = BTDM_BROKER_NODE_DEF_RAM(
#if UC_BT_CTRL_BLE_IS_ENABLE
[1] = BTDM_BROKER_ENTRY_DEF_RAM(
sym_base_QIE6fqExGJrsGUIGYNSf,
#if UC_BT_CTRL_LE_ISO_ENABLED
sym_coexIsoHal_RVw8jrRQybFIlwvrONo9,
sym_iso_6SFIpEwXw1SsCdgfyN88,
#endif /* UC_BT_CTRL_LE_ISO_ENABLED */
),
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
[2] = BTDM_BROKER_ENTRY_DEF_RAM(
r_sym_bt_z2aLQW3Zvuoq7vASCpLB,
#if UC_BT_CTRL_BLE_IS_ENABLE
sym_base_NVN4AbeIskmtcV2PX3N1,
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
),
);
const void * const _btdm_hci_linear_broker_flash[] = BTDM_BROKER_NODE_DEF_FLASH(
#if UC_BT_CTRL_BLE_IS_ENABLE
#if UC_BLE_CTRL_CONN_ENABLED
sym_conn_eZ0plXo8e56VyJXdcbNn,
#endif /* UC_BLE_CTRL_CONN_ENABLED */
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
#if UC_BT_CTRL_BR_EDR_IS_ENABLE
hci_tl_bredr_on_rx_cmd_c2h_num_pkt,
#endif /* UC_BT_CTRL_BR_EDR_IS_ENABLE */
),
[3] = BTDM_BROKER_ENTRY_DEF_FLASH(
#if UC_BT_CTRL_BLE_IS_ENABLE
#if UC_BLE_CTRL_CONN_ENABLED
sym_conn_Sw7sI0dtf78paJdn9Uhg,
#endif /* UC_BLE_CTRL_CONN_ENABLED */
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
#if UC_BT_CTRL_BR_EDR_IS_ENABLE
hci_tl_bredr_on_rx_cmd_set_c2h_flow_ctrl,
#endif /* UC_BT_CTRL_BR_EDR_IS_ENABLE */
),
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
);
const void * const _btdm_sched_linear_broker_flash[] = BTDM_BROKER_NODE_DEF_FLASH(
#if UC_BT_CTRL_BLE_IS_ENABLE
[1] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_memMgmt_7tLw3T7RgI6l7DQc4dMI,
),
[2] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_memMgmt_PpI7zFiJWyV56U0OIURt,
),
[3] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_scan_0gIKmjMRFT37raN6hnDo,
),
[6] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_sched_MzeSZzbQ4ZKhWW6Wu5jV,
),
[7] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_sched_wfZseauvjWnjfiu10yWN,
),
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
);
void * _btdm_sched_linear_broker_ram[] = BTDM_BROKER_NODE_DEF_RAM(
#if UC_BT_CTRL_BLE_IS_ENABLE
[1] = BTDM_BROKER_ENTRY_DEF_RAM(
#if UC_BT_CTRL_LE_ISO_ENABLED
sym_iso_qYKZbEBVIsH27HGf5VCS,
#endif /* UC_BT_CTRL_LE_ISO_ENABLED */
sym_sched_PNMeumLUZPcz8o4UrTLi,
),
[2] = BTDM_BROKER_ENTRY_DEF_RAM(
sym_scan_b8ogEC3hTjGmqL5oRuyw,
),
[3] = BTDM_BROKER_ENTRY_DEF_RAM(
sym_scan_fd4yzdFac8vdFTlQ4BPA,
),
[4] = BTDM_BROKER_ENTRY_DEF_RAM(
sym_scan_tdX6OLWyRKYxelkB8vZ1,
),
[6] = BTDM_BROKER_ENTRY_DEF_RAM(
sym_sched_hOsJ4rGq1XjiY7GjHycG,
),
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
);
const void * const _btdm_sleep_linear_broker_flash[] = BTDM_BROKER_NODE_DEF_FLASH(
#if UC_BT_CTRL_BLE_IS_ENABLE
#if UC_BT_CTRL_LE_VS_CMD_EVT_ENABLED && CONFIG_BT_CTRL_SLEEP_ENABLE
[1] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_sleep_Ayr8PrlSNd7F6hhsmt13,
),
#endif /* UC_BT_CTRL_LE_VS_CMD_EVT_ENABLED && CONFIG_BT_CTRL_SLEEP_ENABLE */
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
);
void * _btdm_sleep_linear_broker_ram[] = BTDM_BROKER_NODE_DEF_RAM(
[3] = BTDM_BROKER_ENTRY_DEF_RAM(
r_sym_bt_CXxFmLXrWP71jb0eVlzN,
),
);
const void * const _btdm_task_linear_broker_flash[] = BTDM_BROKER_NODE_DEF_FLASH(
#if UC_BT_CTRL_BLE_IS_ENABLE
[1] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_arr_CG7zWaZkh7QOTatTjs2v,
sym_base_uevmRkB8BjrlJh1c3VnZ,
#if UC_BT_CTRL_LE_BIS_BCAST_ENABLED
sym_bisBcast_2dWM4hoGuoEwy8loUGlI,
#endif /* UC_BT_CTRL_LE_BIS_BCAST_ENABLED */
#if UC_BT_CTRL_LE_BIS_SYNC_ENABLED
sym_bisSync_cB4uyzKmrYjduUbWqXdb,
#endif /* UC_BT_CTRL_LE_BIS_SYNC_ENABLED */
#if UC_BT_CTRL_LE_CIS_ENABLED
sym_cis_f2SkEM3LCeOCgMzDRq24,
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
#if UC_BLE_CTRL_CONN_ENABLED && CONFIG_BT_LE_ERROR_SIM_ENABLED
sym_connSim_EIv22SNth3fM1SPgJ9hO,
#endif /* UC_BLE_CTRL_CONN_ENABLED && CONFIG_BT_LE_ERROR_SIM_ENABLED */
#if UC_BT_CTRL_LE_CTE_CAL_ENABLED
sym_cteCal_NKbWd6AypEyH2B338dAx,
#endif /* UC_BT_CTRL_LE_CTE_CAL_ENABLED */
#if UC_BT_CTRL_LE_CTE_ENABLED
sym_cte_NjXx2EHiiDoBXhq2trhx,
#endif /* UC_BT_CTRL_LE_CTE_ENABLED */
sym_extAdv_j9EFs8yTWikhycyNL2tu,
#if UC_BT_CTRL_LE_ISO_ENABLED
sym_iso_8HHndXTSYyYcW1EhDzAN,
#endif /* UC_BT_CTRL_LE_ISO_ENABLED */
#if UC_BLE_CTRL_PAWR_BCAST_SUPPORTED
sym_pawrBcast_Jrj3qAmZkOoWxL1jFdmP,
#endif /* UC_BLE_CTRL_PAWR_BCAST_SUPPORTED */
#if UC_BLE_CTRL_PAWR_SYNC_SUPPORTED
sym_pawrSync_k4txvaSWHJBXXqtE62MG,
#endif /* UC_BLE_CTRL_PAWR_SYNC_SUPPORTED */
sym_scan_1G8QO0lWyTS0nKOqvZOE,
),
[2] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_arr_SH7I2IviDsjnpqawpi0F,
sym_base_uuBMFaiuN71hyzVcBBth,
#if UC_BT_CTRL_LE_BIS_BCAST_ENABLED
sym_bisBcast_vATQ5EU18M2xnmNZ84fY,
#endif /* UC_BT_CTRL_LE_BIS_BCAST_ENABLED */
#if UC_BT_CTRL_LE_BIS_SYNC_ENABLED
sym_bisSync_DuQGVcBNN6l6ggZp4Y8J,
#endif /* UC_BT_CTRL_LE_BIS_SYNC_ENABLED */
#if UC_BT_CTRL_LE_CIS_ENABLED
sym_cis_UBu7crU2pIczpNc5cEcP,
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
#if UC_BT_CTRL_LE_CTE_CAL_ENABLED
sym_cteCal_uWSKv9wSYw0nIY0GhuZF,
#endif /* UC_BT_CTRL_LE_CTE_CAL_ENABLED */
#if UC_BT_CTRL_LE_CTE_ENABLED
sym_cte_vx3COozMkhCXFbq2ZjHK,
#endif /* UC_BT_CTRL_LE_CTE_ENABLED */
#if UC_BT_CTRL_LE_ISO_ENABLED
sym_iso_Ywq26gNcDI3MQQVQbDEF,
#endif /* UC_BT_CTRL_LE_ISO_ENABLED */
#if UC_BLE_CTRL_PAWR_BCAST_SUPPORTED
sym_pawrBcast_JHmbFJCpV155hIYyDVQ8,
#endif /* UC_BLE_CTRL_PAWR_BCAST_SUPPORTED */
#if UC_BLE_CTRL_PAWR_SYNC_SUPPORTED
sym_pawrSync_2gh2xSEYHokuhQ7UohkM,
#endif /* UC_BLE_CTRL_PAWR_SYNC_SUPPORTED */
sym_scan_zmw2OczvfXFB4aIFaWkc,
),
[3] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_base_IdP4ncGWlpNArj2oW20N,
sym_coexHook_7UsddOHoZepnYRjYPawG,
),
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
[4] = BTDM_BROKER_ENTRY_DEF_FLASH(
r_sym_bt_8fMePSgKBxkeyUSGQQcU,
#if UC_BT_CTRL_BLE_IS_ENABLE
sym_acceptList_vvIIdyHCcpNAdAdzZrPN,
sym_adv_xfHX4YH2Zb9de4JlBztj,
sym_base_CdIdlqttqbZqCmaW9GAc,
#if UC_BT_CTRL_LE_BIS_BCAST_ENABLED
sym_bisBcast_zlcnIBGOIfWlPC3WJ66f,
#endif /* UC_BT_CTRL_LE_BIS_BCAST_ENABLED */
#if UC_BT_CTRL_LE_BIS_SYNC_ENABLED
sym_bisSync_EaKbiRZI30mvH3KWkMY5,
#endif /* UC_BT_CTRL_LE_BIS_SYNC_ENABLED */
#if UC_BT_CTRL_LE_CIS_ENABLED
sym_cis_QxmCCIxcxCfrWCKZmT3X,
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
#if UC_BLE_CTRL_CONN_ENABLED && CONFIG_BT_LE_ERROR_SIM_ENABLED
sym_connSim_3guOkwBVGmSgwrEIVUvL,
#endif /* UC_BLE_CTRL_CONN_ENABLED && CONFIG_BT_LE_ERROR_SIM_ENABLED */
#if UC_BLE_CTRL_CONN_ENABLED
sym_conn_sIcAPw7j0toiOGWivJ0e,
#endif /* UC_BLE_CTRL_CONN_ENABLED */
#if UC_BT_CTRL_LE_CTE_CAL_ENABLED
sym_cteCal_ixMlNDshScz4WVTbiOKl,
#endif /* UC_BT_CTRL_LE_CTE_CAL_ENABLED */
#if UC_BT_CTRL_LE_CTE_ENABLED
sym_cte_P7A06WogxnY1JlnvQaGe,
#endif /* UC_BT_CTRL_LE_CTE_ENABLED */
#if UC_BT_CTRL_LE_DTM_ENABLED
sym_dtm_wW4wnzkRa1kpb5NfwZVi,
#endif /* UC_BT_CTRL_LE_DTM_ENABLED */
#if UC_BT_CTRL_LE_ISO_ENABLED
sym_iso_WJJo4fn6Hkvt9xXAvziZ,
#endif /* UC_BT_CTRL_LE_ISO_ENABLED */
#if UC_BLE_CTRL_PAWR_BCAST_SUPPORTED
sym_pawrBcast_eBH7HrPT8y2Fj9382el3,
#endif /* UC_BLE_CTRL_PAWR_BCAST_SUPPORTED */
sym_resolv_GWz7Tb1ymxsyLQ1208Jj,
sym_scan_l1avG2cwTzJAlle4KLdU,
sym_sync_NOAs4m6LAUpamsUYHfqm,
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
),
);
#if UC_BT_CTRL_BLE_IS_ENABLE && UC_BLE_CTRL_CONN_ENABLED
const void * const _conn_linear_broker_flash[] = BTDM_BROKER_NODE_DEF_FLASH(
#if UC_BLE_CTRL_CONN_ENABLED && CONFIG_BT_LE_ERROR_SIM_ENABLED
[1] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_connSim_2RFEzu4Evi68Nnt4YowZ,
),
[2] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_connSim_SoaIlItcCgS4km7f1141,
),
#endif /* UC_BLE_CTRL_CONN_ENABLED && CONFIG_BT_LE_ERROR_SIM_ENABLED */
#if UC_BLE_CTRL_PAWR_SYNC_SUPPORTED
[3] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrSync_pbTRKlIHoevVfNidtKZb,
),
[4] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrSync_fn4PoAB0qFmYpbwqTO2H,
),
#endif /* UC_BLE_CTRL_PAWR_SYNC_SUPPORTED */
#if UC_BLE_CTRL_PAWR_BCAST_SUPPORTED
[5] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrBcast_on08yxBjym4I0iV3tlPo,
),
#endif /* UC_BLE_CTRL_PAWR_BCAST_SUPPORTED */
[6] = BTDM_BROKER_ENTRY_DEF_FLASH(
#if UC_BT_CTRL_LE_CIS_CENT_ENABLED
sym_cisCent_9P0KC1xZQpumJC2psVXO,
#endif /* UC_BT_CTRL_LE_CIS_CENT_ENABLED */
#if UC_BT_CTRL_LE_CIS_PRPH_ENABLED
sym_cisPrph_6ORekVL63tenTy0sCT2O,
#endif /* UC_BT_CTRL_LE_CIS_PRPH_ENABLED */
#if UC_BT_CTRL_LE_CIS_ENABLED
sym_cis_wQtv7EbxMlyUdVE0TQ9T,
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
),
[7] = BTDM_BROKER_ENTRY_DEF_FLASH(
#if UC_BT_CTRL_LE_CIS_CENT_ENABLED
sym_cisCent_GSToGcnDAoUIQsFaBPr7,
#endif /* UC_BT_CTRL_LE_CIS_CENT_ENABLED */
#if UC_BT_CTRL_LE_CIS_PRPH_ENABLED
sym_cisPrph_zr8KQ3aEASRV2ZptTSnX,
#endif /* UC_BT_CTRL_LE_CIS_PRPH_ENABLED */
),
[8] = BTDM_BROKER_ENTRY_DEF_FLASH(
#if UC_BT_CTRL_LE_CIS_CENT_ENABLED
sym_cisCent_JUzUk54A9UNHtsUAHT8F,
#endif /* UC_BT_CTRL_LE_CIS_CENT_ENABLED */
#if UC_BT_CTRL_LE_CIS_PRPH_ENABLED
sym_cisPrph_xR7NheKHstTWkDAuZROL,
#endif /* UC_BT_CTRL_LE_CIS_PRPH_ENABLED */
),
#if UC_BT_CTRL_LE_CIS_ENABLED
[9] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_cis_eeNELMi6IB5X3UF8MMvQ,
),
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
[10] = BTDM_BROKER_ENTRY_DEF_FLASH(
#if UC_BT_CTRL_LE_CIS_CENT_ENABLED
sym_cisCent_wt1P0oioDDyNz026HxsK,
#endif /* UC_BT_CTRL_LE_CIS_CENT_ENABLED */
#if UC_BT_CTRL_LE_CIS_PRPH_ENABLED
sym_cisPrph_Kb3o0Y7oUCdHJ1SXcoqj,
#endif /* UC_BT_CTRL_LE_CIS_PRPH_ENABLED */
#if UC_BT_CTRL_LE_CIS_ENABLED
sym_cis_i4bfG8waTBMteoJaWD40,
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
),
[12] = BTDM_BROKER_ENTRY_DEF_FLASH(
#if UC_BT_CTRL_LE_CIS_CENT_ENABLED
sym_cisCent_f2xo5SuAzLb4iRlhLPhf,
#endif /* UC_BT_CTRL_LE_CIS_CENT_ENABLED */
#if UC_BT_CTRL_LE_CIS_PRPH_ENABLED
sym_cisPrph_Dw8FBGfBWm2LptzYq46z,
#endif /* UC_BT_CTRL_LE_CIS_PRPH_ENABLED */
#if UC_BT_CTRL_LE_CIS_ENABLED
sym_cis_coXGBkWhDUZWHDFo80gN,
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
),
#if UC_BT_CTRL_LE_CIS_ENABLED
[13] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_cis_3DmpJ8V6gGsnSNopbei0,
),
[14] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_cis_WICEvILg2pK6JZvhry3j,
),
[15] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_cis_zGkqwv9urnJ8DbX0JZAr,
),
[16] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_cis_Bmj5ai8K8ZKFKqWA8X8B,
),
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
[17] = BTDM_BROKER_ENTRY_DEF_FLASH(
#if UC_BT_CTRL_LE_CIS_CENT_ENABLED
sym_cisCent_jfaA90JGHwEKv1YkKIUO,
#endif /* UC_BT_CTRL_LE_CIS_CENT_ENABLED */
#if UC_BT_CTRL_LE_CIS_ENABLED
sym_cis_mcjvVuw8ttAldZnobGxJ,
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
),
#if UC_BT_CTRL_LE_CIS_ENABLED
[18] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_cis_Guzdzme9CFLxrbjG6HEJ,
),
#endif /* UC_BT_CTRL_LE_CIS_ENABLED */
);
#endif /* UC_BT_CTRL_BLE_IS_ENABLE && UC_BLE_CTRL_CONN_ENABLED */
#if UC_BT_CTRL_BLE_IS_ENABLE
const void * const _nrtIsr_linear_broker_flash[] = BTDM_BROKER_NODE_DEF_FLASH(
);
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
#if UC_BT_CTRL_BLE_IS_ENABLE
const void * const _perAdv_linear_broker_flash[] = BTDM_BROKER_NODE_DEF_FLASH(
#if UC_BT_CTRL_LE_BIS_BCAST_ENABLED
[1] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_bisBcast_2a3kgxHeabxbnBIsRh4s,
),
[2] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_bisBcast_EtJ8xQ5EIWS6IjqpsD1U,
),
[3] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_bisBcast_2uiisGIdoGa6SNUZCE2m,
),
#endif /* UC_BT_CTRL_LE_BIS_BCAST_ENABLED */
);
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
#if UC_BT_CTRL_BLE_IS_ENABLE
const void * const _sync_linear_broker_flash[] = BTDM_BROKER_NODE_DEF_FLASH(
#if UC_BLE_CTRL_PAWR_SYNC_SUPPORTED
[1] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrSync_Qifv1iec7w57n2pBwucX,
),
[2] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrSync_bbizSGqM6wZUOT0fQF1M,
),
[3] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrSync_oBwpWArFlWxUJNCnHvsJ,
),
[4] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrSync_vAN2YoeCsSKafv2NdPVC,
),
[5] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrSync_9XvRcZs9CUOgHNbMhe5G,
),
[6] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrSync_zuG0pqdRWK2zt5S09fTS,
),
[7] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrSync_LO7YyFM93srewqVpETY2,
),
[8] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_pawrSync_7bchpvHsUM8DXHyaXC7f,
),
#endif /* UC_BLE_CTRL_PAWR_SYNC_SUPPORTED */
#if UC_BT_CTRL_LE_BIS_SYNC_ENABLED
[9] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_bisSync_3FCcFQdSowAGd7aAejeg,
),
[10] = BTDM_BROKER_ENTRY_DEF_FLASH(
sym_bisSync_0xkTwhqVWK4bwJa6dDH6,
),
#endif /* UC_BT_CTRL_LE_BIS_SYNC_ENABLED */
);
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
int
btdm_broker_init(void)
{
#if UC_BT_CTRL_BLE_IS_ENABLE
if (r_btdm_broker_linear_selfcheck(_adv_linear_broker_flash, false)) {
return -1;
}
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
#if UC_BT_CTRL_BLE_IS_ENABLE
if (r_btdm_broker_linear_selfcheck(_base_linear_broker_flash, false)) {
return -2;
}
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
if (r_btdm_broker_linear_selfcheck(_btdm_coex_linear_broker_flash, false)) {
return -3;
}
if (r_btdm_broker_linear_selfcheck(_btdm_hal_linear_broker_ram, true)) {
return -4;
}
if (r_btdm_broker_linear_selfcheck(_btdm_hci_linear_broker_flash, false)) {
return -5;
}
if (r_btdm_broker_linear_selfcheck(_btdm_sched_linear_broker_flash, false)) {
return -6;
}
if (r_btdm_broker_linear_selfcheck(_btdm_sched_linear_broker_ram, true)) {
return -7;
}
if (r_btdm_broker_linear_selfcheck(_btdm_sleep_linear_broker_flash, false)) {
return -8;
}
if (r_btdm_broker_linear_selfcheck(_btdm_sleep_linear_broker_ram, true)) {
return -9;
}
if (r_btdm_broker_linear_selfcheck(_btdm_task_linear_broker_flash, false)) {
return -10;
}
#if UC_BT_CTRL_BLE_IS_ENABLE && UC_BLE_CTRL_CONN_ENABLED
if (r_btdm_broker_linear_selfcheck(_conn_linear_broker_flash, false)) {
return -11;
}
#endif /* UC_BT_CTRL_BLE_IS_ENABLE && UC_BLE_CTRL_CONN_ENABLED */
#if UC_BT_CTRL_BLE_IS_ENABLE
if (r_btdm_broker_linear_selfcheck(_nrtIsr_linear_broker_flash, false)) {
return -12;
}
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
#if UC_BT_CTRL_BLE_IS_ENABLE
if (r_btdm_broker_linear_selfcheck(_perAdv_linear_broker_flash, false)) {
return -13;
}
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
#if UC_BT_CTRL_BLE_IS_ENABLE
if (r_btdm_broker_linear_selfcheck(_sync_linear_broker_flash, false)) {
return -14;
}
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
return 0;
}
void
btdm_broker_deinit(void)
{
}

View File

@@ -4,17 +4,21 @@ entries:
[sections:high_perf_iram_text]
entries:
.high_perf_code_iram1+
.iram_high_perf+
[sections:adv_fast_execute_code_iram_text]
entries:
.adv_fast_execute_code_iram1+
.iram_adv_fast_tx+
[sections:sleep_text]
entries:
.iram_sleep+
.iram_btslp+
[sections:sleep_text_fast_adv]
entries:
.iram_adv_fast_tx_sleep_adv+
[sections:sleep_text_adv]
entries:
.iram_sleep_adv+
@@ -49,6 +53,11 @@ entries:
else:
sleep_text -> flash_text
if BT_LE_CTRL_ADV_FAST_TX_EN = y || BT_CTRL_LE_ADV_SLEEP_CODE_IN_IRAM = y:
sleep_text_fast_adv -> iram0_text
else:
sleep_text_fast_adv -> flash_text
if BT_CTRL_LE_ADV_SLEEP_CODE_IN_IRAM = y:
sleep_text_adv->iram0_text
else:

View File

@@ -579,7 +579,7 @@ menu "Memory Settings"
config BT_NIMBLE_MEMPOOL_RUNTIME_ALLOC
bool "Support on-demand runtime memory allocation for mempool"
depends on BT_NIMBLE_ENABLED && BT_NIMBLE_STATIC_TO_DYNAMIC && !BT_DUAL_MODE_ARCH
depends on BT_NIMBLE_ENABLED && BT_NIMBLE_STATIC_TO_DYNAMIC
default n
help
When this option is enabled, mempool does not require pre-allocating memory.

View File

@@ -0,0 +1,156 @@
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "btdm_user_cfg.h"
#include "bredr_user_cfg.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
***************************************************************************************************
* Local Defined Macros
***************************************************************************************************
*/
#define ESP_BREDR_CTRL_CONFIG_MAGIC_VAL 0x5A5AA5A5
#define ESP_BREDR_CTRL_CONFIG_VERSION 0x20250327
#if UC_BT_CTRL_BR_EDR_IS_ENABLE
#define _BT_CTRL_BREDR_INIT_CONFIG_DEFAULT() \
{ \
.bredr_version = ESP_BREDR_CTRL_CONFIG_VERSION, \
.sleep_mode = 0, \
.bt_test_mode_en = UC_BR_EDR_TEST_MODE_EN, \
.acl_cca_en = UC_BR_EDR_TX_CCA_EN, \
.cca_rssi_thr = -UC_BR_EDR_CCA_RSSI_THRESH, \
.max_acl_conn = UC_BR_EDR_MAX_ACL_CONN, \
.max_sync_conn = UC_BR_EDR_CTRL_MAX_SYNC_CONN, \
.cpb_tx_link_num = UC_BR_EDR_CPB_TX_LINK_NB, \
.cpb_rx_link_num = UC_BR_EDR_CPB_RX_LINK_NB, \
.bt_sco_datapath = UC_BR_EDR_SCO_DATA_PATH, \
.hci_tl_type = 0, \
.hci_tl_funcs = NULL, \
.cfg_mask = 0, \
.hw_target_code = 0, \
.acl_min_tx_pwr = CONFIG_BT_CTRL_BR_EDR_TX_PWR_ACL_MIN, \
.acl_max_tx_pwr = CONFIG_BT_CTRL_BR_EDR_TX_PWR_ACL_MAX, \
.apb_tx_pwr = UC_BR_EDR_TX_PWR_APB, \
.page_tx_pwr = CONFIG_BT_CTRL_BR_EDR_TX_PWR_PAGE, \
.pscan_tx_pwr = CONFIG_BT_CTRL_BR_EDR_TX_PWR_PSCAN, \
.iscan_tx_pwr = CONFIG_BT_CTRL_BR_EDR_TX_PWR_ISCAN, \
.cpb_tx_pwr = UC_BR_EDR_TX_PWR_CPB, \
.strain_tx_pwr = UC_BR_EDR_TX_PWR_STRAIN, \
.rf_hw_type = 0, \
.static_aclu_tx_buf_nb = UC_BR_EDR_ACLU_TX_BUF_NB - UC_BR_EDR_DYNAMIC_ACLU_TX_BUF_NB, \
.dynamic_aclu_tx_buf_nb = UC_BR_EDR_DYNAMIC_ACLU_TX_BUF_NB, \
.aclu_rx_buf_nb = UC_BR_EDR_ACLU_RX_BUF_NB, \
.sync_tx_buf_nb = UC_BR_EDR_SYNC_TX_BUF_NB, \
.sync_rx_buf_nb = UC_BR_EDR_SYNC_RX_BUF_NB, \
.esco_ev4_supp = UC_BR_EDR_ESCO_EV4_SUPP, \
.esco_ev5_supp = UC_BR_EDR_ESCO_EV5_SUPP, \
.esco_ev3_2_supp = UC_BR_EDR_ESCO_EV3_2_SUPP, \
.esco_ev3_3_supp = UC_BR_EDR_ESCO_EV3_3_SUPP, \
.esco_3_slots_supp = UC_BR_EDR_ESCO_3_SLOTS_SUPP, \
.bt_legacy_auth_vs_evt = UC_BR_EDR_LEGACY_AUTH_VENDOR_EVT, \
.inq_filter_en = 0, \
.dtm_en = 0, \
.bredr_magic = ESP_BREDR_CTRL_CONFIG_MAGIC_VAL, \
}
#else
#define _BT_CTRL_BREDR_INIT_CONFIG_DEFAULT() {0}
#endif // UC_BT_CTRL_BR_EDR_IS_ENABLE
/*
***************************************************************************************************
* Type Definitions
***************************************************************************************************
*/
/**
* @brief BR/EDR audio data transport path
*/
typedef enum {
ESP_SCO_DATA_PATH_HCI = 0, /*!< data over HCI transport */
ESP_SCO_DATA_PATH_PCM = 1, /*!< data over PCM interface */
} esp_sco_data_path_t;
/**
* @brief mempool handle type used in BR/EDR controller
*/
typedef void *orca_mempool_t;
/**
* @brief mempool operations used in BR/EDR controller
*/
struct orca_mempool_ops {
orca_mempool_t (*create_with_pool)(void *mem, size_t pool_bytes,
size_t max_bytes); /*!< mempool construction */
void (*destroy)(orca_mempool_t mempool); /*!< mempool destruction */
void *(*malloc)(orca_mempool_t mempool, size_t size); /*!< allocate memory from mempool */
void (*free)(orca_mempool_t mempool, void *ptr); /*!< release memory */
};
/**
* @brief BR/EDR controller configuration options
*/
typedef struct {
/*
* Following parameters can not be configured runtime when call esp_bt_controller_init()
* They will be overwritten by constant values from menuconfig options or from macros.
* So, do not modify the value when esp_bt_controller_init()
*/
uint32_t bredr_version; /*!< version number of the defined structure */
/*
* Following parameters can be configured runtime, when call esp_bt_controller_init()
*/
uint8_t sleep_mode; /*!< controller sleep mode */
uint8_t bt_test_mode_en; /*!< enable br/edr test mode */
uint8_t acl_cca_en; /*!< Enable BR/EDR ACL Transmit Clear Channel Assessment (TX CCA) */
int8_t cca_rssi_thr; /*!< BR/EDR RSSI threshold for Transmit Clear Channel Assessment (CCA) */
uint8_t
max_acl_conn; /*!< Maximum number of BR/EDR ACL connections. Configurable in menuconfig */
uint8_t max_sync_conn; /*!< Maximum number of BR/EDR synchronous connections. Configurable in
menuconfig */
uint8_t cpb_tx_link_num; /*!< BR/EDR CPB TX link number */
uint8_t cpb_rx_link_num; /*!< BR/EDR CPB RX link number */
uint8_t bt_sco_datapath; /*!< SCO data path, i.e. HCI(0) or PCM(1) */
uint8_t hci_tl_type; /*!< HCI transport layer, UART, VHCI, etc */
void *hci_tl_funcs; /*!< hci transport functions used, must be set when hci_tl_type is UART */
uint32_t cfg_mask; /*!< reserved */
uint32_t hw_target_code; /*!< hardware target */
int8_t acl_min_tx_pwr; /*!< Default transmit power for ACL minimum */
int8_t acl_max_tx_pwr; /*!< Default transmit power for ACL maximum */
int8_t apb_tx_pwr; /*!< Default transmit power for APB */
int8_t page_tx_pwr; /*!< Default transmit power for Page */
int8_t pscan_tx_pwr; /*!< Default transmit power for Page Scan */
int8_t iscan_tx_pwr; /*!< Default transmit power for Inquiry Scan */
int8_t cpb_tx_pwr; /*!< Default transmit power for CPB TX */
int8_t strain_tx_pwr; /*!< Default transmit power for Synchronization Train */
uint8_t rf_hw_type; /*!< RF hardware type */
uint8_t static_aclu_tx_buf_nb; /*!< Static ACL-U TX buffer number */
uint8_t dynamic_aclu_tx_buf_nb; /*!< Dynamic ACL-U TX buffer number */
uint8_t aclu_rx_buf_nb; /*!< ACL-U RX buffer number */
uint8_t sync_tx_buf_nb; /*!< SCO TX buffer number */
uint8_t sync_rx_buf_nb; /*!< SCO RX buffer number */
uint8_t esco_ev4_supp : 1; /*!< eSCO support EV4 packet type */
uint8_t esco_ev5_supp : 1; /*!< eSCO support EV5 packet type */
uint8_t esco_ev3_2_supp : 1; /*!< eSCO support 2-EV3 packet type */
uint8_t esco_ev3_3_supp : 1; /*!< eSCO support 3-EV3 packet type */
uint8_t esco_3_slots_supp : 1; /*!< eSCO support 2-EV5 and/or 3-EV5 packet type */
uint8_t bt_legacy_auth_vs_evt
: 1; /*!< 1 if BR/EDR Legacy Authentication Vendor Specific Event is enabled, which is
required to protect from BIAS attack; 0 otherwise. Configurable in menuconfig */
uint8_t inq_filter_en : 1; /*!< Enable inquiry result filter */
uint8_t dtm_en : 1; /*!< BR/EDR direct test mode */
uint32_t mempool_size; /*!< Required mempool size used in BR/EDR controller */
struct orca_mempool_ops *mempool_ops; /*!< mempool operations used in BR/EDR controller */
uint32_t bredr_magic; /*!< Magic number */
} esp_bt_ctrl_bredr_config_t;
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,329 @@
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "btdm_user_cfg.h"
#include "ble_user_cfg.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
***************************************************************************************************
* Local Defined Macros
***************************************************************************************************
*/
#define BLE_CONFIG_VERSION 0x20260123
#define BLE_CONFIG_MAGIC 0x5A5AA5A5
#if defined(CONFIG_BT_LE_ISO_SUPPORT)
#define DEFAULT_BT_LE_ISO_ENABLED 1
#if defined(CONFIG_BT_LE_ISO_FRA_UNSEG)
#define DEFAULT_BT_LE_ISO_FRA_UNSEG CONFIG_BT_LE_ISO_FRA_UNSEG
#else
#define DEFAULT_BT_LE_ISO_FRA_UNSEG (0)
#endif
#if defined(CONFIG_BT_LE_ISO_NSFC_EN)
#define DEFAULT_BT_LE_ISO_NSFC_EN CONFIG_BT_LE_ISO_NSFC_EN
#define DEFAULT_BT_LE_ISO_NSFC_NUM CONFIG_BT_LE_ISO_NSFC_NUM
#else
#define DEFAULT_BT_LE_ISO_NSFC_EN (0)
#define DEFAULT_BT_LE_ISO_NSFC_NUM (0)
#endif
#define DEFAULT_BT_LE_ISO_BUF_COUNT CONFIG_BT_LE_ISO_BUF_COUNT
#define DEFAULT_BT_LE_ISO_BUF_SIZE CONFIG_BT_LE_ISO_BUF_SIZE
#define DEFAULT_BT_LE_ISO_BIG CONFIG_BT_LE_ISO_BIG
#define DEFAULT_BT_LE_ISO_BIS CONFIG_BT_LE_ISO_BIS
#define DEFAULT_BT_LE_ISO_BIS_PER_BIG CONFIG_BT_LE_ISO_BIS_PER_BIG
#define DEFAULT_BT_LE_ISO_CIG CONFIG_BT_LE_ISO_CIG
#define DEFAULT_BT_LE_ISO_CIS CONFIG_BT_LE_ISO_CIS
#define DEFAULT_BT_LE_ISO_CIS_PER_CIG CONFIG_BT_LE_ISO_CIS_PER_CIG
#define DEFAULT_BT_LE_ISO_CONFIG \
&(esp_bt_ctrl_le_iso_config_t){ \
.iso_enabled = DEFAULT_BT_LE_ISO_ENABLED, \
.iso_fra_unseg = DEFAULT_BT_LE_ISO_FRA_UNSEG, \
.iso_nsfc_en = DEFAULT_BT_LE_ISO_NSFC_EN, \
.iso_nsfc_num = DEFAULT_BT_LE_ISO_NSFC_NUM, \
.iso_buf_count = DEFAULT_BT_LE_ISO_BUF_COUNT, \
.iso_buf_size = DEFAULT_BT_LE_ISO_BUF_SIZE, \
.iso_big_count = DEFAULT_BT_LE_ISO_BIG, \
.iso_bis_count = DEFAULT_BT_LE_ISO_BIS, \
.iso_bis_per_big = DEFAULT_BT_LE_ISO_BIS_PER_BIG, \
.iso_cig_count = DEFAULT_BT_LE_ISO_CIG, \
.iso_cis_count = DEFAULT_BT_LE_ISO_CIS, \
.iso_cis_per_cig = DEFAULT_BT_LE_ISO_CIS_PER_CIG, \
}
#else // defined(CONFIG_BT_LE_ISO_SUPPORT)
#define DEFAULT_BT_LE_ISO_ENABLED 0
#define DEFAULT_BT_LE_ISO_FRA_UNSEG 0
#define DEFAULT_BT_LE_ISO_NSFC_EN 0
#define DEFAULT_BT_LE_ISO_NSFC_NUM 0
#define DEFAULT_BT_LE_ISO_BUF_COUNT 0
#define DEFAULT_BT_LE_ISO_BUF_SIZE 0
#define DEFAULT_BT_LE_ISO_BIG 0
#define DEFAULT_BT_LE_ISO_BIS 0
#define DEFAULT_BT_LE_ISO_BIS_PER_BIG 0
#define DEFAULT_BT_LE_ISO_CIG 0
#define DEFAULT_BT_LE_ISO_CIS 0
#define DEFAULT_BT_LE_ISO_CIS_PER_CIG 0
#define DEFAULT_BT_LE_ISO_CONFIG NULL
#endif // defined(CONFIG_BT_LE_ISO_SUPPORT)
#if UC_BT_CTRL_BLE_IS_ENABLE
#define _BT_CTRL_LE_INIT_CONFIG_DEFAULT() \
{ \
.config_version = BLE_CONFIG_VERSION, \
.ble_ll_resolv_list_size = CONFIG_BT_LE_LL_RESOLV_LIST_SIZE, \
.ble_hci_evt_hi_buf_count = DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT, \
.ble_hci_evt_lo_buf_count = DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT, \
.ble_ll_sync_list_cnt = DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST, \
.ble_ll_sync_cnt = DEFAULT_BT_LE_MAX_PERIODIC_SYNCS, \
.ble_ll_rsp_dup_list_count = CONFIG_BT_LE_LL_DUP_SCAN_LIST_COUNT, \
.ble_ll_adv_dup_list_count = CONFIG_BT_LE_LL_DUP_SCAN_LIST_COUNT, \
.ble_ll_tx_pwr_dbm = 0, \
.rtc_freq = 32000, \
.ble_ll_sca = CONFIG_BT_LE_LL_SCA, \
.ble_ll_scan_phy_number = BLE_LL_SCAN_PHY_NUMBER_N, \
.ble_ll_conn_def_auth_pyld_tmo = BLE_LL_CONN_DEF_AUTH_PYLD_TMO_N, \
.ble_ll_jitter_usecs = BLE_LL_JITTER_USECS_N, \
.ble_ll_sched_max_adv_pdu_usecs = BLE_LL_SCHED_MAX_ADV_PDU_USECS_N, \
.ble_ll_sched_direct_adv_max_usecs = BLE_LL_SCHED_DIRECT_ADV_MAX_USECS_N, \
.ble_ll_sched_adv_max_usecs = BLE_LL_SCHED_ADV_MAX_USECS_N, \
.ble_scan_rsp_data_max_len = DEFAULT_BT_LE_SCAN_RSP_DATA_MAX_LEN_N, \
.ble_ll_cfg_num_hci_cmd_pkts = BLE_LL_CFG_NUM_HCI_CMD_PKTS_N, \
.ble_ll_ctrl_proc_timeout_ms = BLE_LL_CTRL_PROC_TIMEOUT_MS_N, \
.nimble_max_connections = DEFAULT_BT_LE_MAX_CONNECTIONS, \
.ble_whitelist_size = DEFAULT_BT_NIMBLE_WHITELIST_SIZE, \
.ble_acl_buf_size = DEFAULT_BT_LE_ACL_BUF_SIZE, \
.ble_acl_buf_count = DEFAULT_BT_LE_ACL_BUF_COUNT, \
.ble_hci_evt_buf_size = DEFAULT_BT_LE_HCI_EVT_BUF_SIZE, \
.ble_multi_adv_instances = DEFAULT_BT_LE_MAX_EXT_ADV_INSTANCES, \
.ble_ext_adv_max_size = DEFAULT_BT_LE_EXT_ADV_MAX_SIZE, \
.controller_task_stack_size = UC_BT_CTRL_TASK_STACK_SIZE, \
.controller_task_prio = ESP_TASK_BT_CONTROLLER_PRIO, \
.controller_run_cpu = 0, \
.enable_qa_test = RUN_QA_TEST, \
.enable_bqb_test = RUN_BQB_TEST, \
.enable_tx_cca = DEFAULT_BT_LE_TX_CCA_ENABLED, \
.cca_rssi_thresh = 256 - DEFAULT_BT_LE_CCA_RSSI_THRESH, \
.sleep_en = UC_BT_CTRL_SLEEP_ENABLE, \
.coex_phy_coded_tx_rx_time_limit = DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF, \
.dis_scan_backoff = NIMBLE_DISABLE_SCAN_BACKOFF, \
.ble_scan_classify_filter_enable = 1, \
.main_xtal_freq = CONFIG_XTAL_FREQ, \
.ignore_wl_for_direct_adv = 0, \
.enable_pcl = UC_BT_CTRL_LE_POWER_CONTROL_ENABLED, \
.csa2_select = UC_BT_CTRL_LE_50_FEATURE_SUPPORT, \
.enable_csr = UC_BT_CTRL_LE_SUBRATE_ENABLED, \
.ble_aa_check = UC_BT_CTRL_LE_CHECK_CONNECT_IND_ACCESS_ADDRESS, \
.ble_llcp_disc_flag = UC_BT_CTRL_LLCP_INSTANT_PASSED_DISC_FLAGS, \
.scan_backoff_upperlimitmax = UC_BT_CTRL_LE_SCAN_BACKOFF_UPPERLIMITMAX, \
.ble_chan_ass_en = UC_BT_CTRL_LE_CHAN_ASS_ENABLED, \
.ble_data_lenth_zero_aux = UC_BT_CTRL_LE_ADV_DATA_LENGTH_ZERO_AUX, \
.vhci_enabled = CONFIG_BT_CTRL_HCI_INTERFACE_USE_RAM, \
.ptr_check_enabled = UC_BT_CTRL_LE_PTR_CHECK_ENABLED, \
.ble_adv_tx_options = UC_BT_CTRL_LE_ADV_TX_OPTIONS, \
.skip_unnecessary_checks_en = 0, \
.fast_conn_data_tx_en = UC_BT_CTRL_LE_FAST_CONN_DATA_TX_EN, \
.ch39_txpwr = UC_BT_CTRL_LE_CH39_TX_PWR_DBM, \
.adv_rsv_cnt = 1, \
.conn_rsv_cnt = 1, \
.priority_level_cfg = 0, \
.slv_fst_rx_lat_en = 0, \
.dl_itvl_phy_sync_en = 0, \
.scan_allow_adi_filter = 1, \
.enhanced_mem_resv = 1, \
.iso_config = DEFAULT_BT_LE_ISO_CONFIG, \
.config_magic = BLE_CONFIG_MAGIC, \
}
#else
#define _BT_CTRL_LE_INIT_CONFIG_DEFAULT() {0}
#endif // UC_BT_CTRL_BLE_IS_ENABLE
/*
***************************************************************************************************
* Type Definitions
***************************************************************************************************
*/
typedef enum esp_power_level esp_power_level_t;
typedef enum esp_ble_power_type esp_ble_power_type_t;
/**
* @brief The enhanced type of which tx power, could set Advertising/Connection/Default and etc.
*/
typedef enum {
ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT = 0,
ESP_BLE_ENHANCED_PWR_TYPE_ADV,
ESP_BLE_ENHANCED_PWR_TYPE_SCAN,
ESP_BLE_ENHANCED_PWR_TYPE_INIT,
ESP_BLE_ENHANCED_PWR_TYPE_CONN,
ESP_BLE_ENHANCED_PWR_TYPE_MAX,
} esp_ble_enhanced_power_type_t;
#if SOC_BLE_ISO_SUPPORTED
/**
* @brief Bluetooth LE controller ISO configuration options
*/
typedef struct {
bool iso_enabled; /*!< Enable ISO support */
bool iso_fra_unseg; /*!< Enable ISO FRA unsegmented */
bool iso_nsfc_en; /*!< Enable ISO NSF-C */
uint8_t iso_nsfc_num; /*!< ISO NSF-C number */
uint8_t iso_buf_count; /*!< ISO buffer count */
uint16_t iso_buf_size; /*!< ISO buffer size */
uint8_t iso_big_count; /*!< ISO BIG count */
uint16_t iso_bis_count; /*!< ISO BIS count */
uint8_t iso_bis_per_big; /*!< ISO BIS per BIG */
uint8_t iso_cig_count; /*!< ISO CIG count */
uint16_t iso_cis_count; /*!< ISO CIS count */
uint8_t iso_cis_per_cig; /*!< ISO CIS per CIG */
} esp_bt_ctrl_le_iso_config_t;
#endif // SOC_BLE_ISO_SUPPORTED
/**
* @brief Bluetooth LE controller configuration options
*/
typedef struct {
uint32_t config_version; /*!< Version number of the defined structure */
uint16_t ble_ll_resolv_list_size; /*!< Size of the resolvable private address list */
uint16_t ble_hci_evt_hi_buf_count; /*!< Count of high buffers for HCI events */
uint16_t ble_hci_evt_lo_buf_count; /*!< Count of low buffers for HCI events */
uint8_t ble_ll_sync_list_cnt; /*!< Number of synchronization lists */
uint8_t ble_ll_sync_cnt; /*!< Number of synchronizations */
uint16_t ble_ll_rsp_dup_list_count; /*!< Count of duplicated lists for scan response packets */
uint16_t ble_ll_adv_dup_list_count; /*!< Count of duplicated lists for advertising packets */
uint8_t ble_ll_tx_pwr_dbm; /*!< Tx power (transmit power) in dBm */
uint64_t rtc_freq; /*!< Frequency of RTC (Real-Time Clock) */
uint16_t ble_ll_sca; /*!< Sleep Clock Accuracy (SCA) parameter */
uint8_t ble_ll_scan_phy_number; /*!< Number of PHYs supported for scanning */
uint16_t
ble_ll_conn_def_auth_pyld_tmo; /*!< Connection default authentication payload timeout */
uint8_t ble_ll_jitter_usecs; /*!< Jitter time in microseconds */
uint16_t ble_ll_sched_max_adv_pdu_usecs; /*!< Maximum time in microseconds for advertising PDU
scheduling */
uint16_t ble_ll_sched_direct_adv_max_usecs; /*!< Maximum time in microseconds for directed
advertising scheduling */
uint16_t
ble_ll_sched_adv_max_usecs; /*!< Maximum time in microseconds for advertising scheduling */
uint16_t ble_scan_rsp_data_max_len; /*!< Maximum length of scan response data */
uint8_t ble_ll_cfg_num_hci_cmd_pkts; /*!< Number of HCI command packets that can be queued */
uint32_t ble_ll_ctrl_proc_timeout_ms; /*!< Control processing timeout in milliseconds */
uint16_t nimble_max_connections; /*!< Maximum number of connections supported */
uint8_t ble_whitelist_size; /*!< Size of the white list */
uint16_t ble_acl_buf_size; /*!< Buffer size of ACL (Asynchronous Connection-Less) data */
uint16_t ble_acl_buf_count; /*!< Buffer count of ACL data */
uint16_t ble_hci_evt_buf_size; /*!< Buffer size for HCI event data */
uint16_t ble_multi_adv_instances; /*!< Number of advertising instances */
uint16_t ble_ext_adv_max_size; /*!< Maximum size of extended advertising data */
uint16_t
controller_task_stack_size; /*!< Size of Bluetooth controller task stack, to be removed */
uint8_t controller_task_prio; /*!< Priority of the Bluetooth task, to be removed */
uint8_t controller_run_cpu; /*!< CPU number on which the Bluetooth controller task runs, to be
removed */
uint8_t enable_qa_test; /*!< Enable for QA test */
uint8_t enable_bqb_test; /*!< Enable for BQB test */
uint8_t enable_tx_cca; /*!< Enable Clear Channel Assessment (CCA) when transmitting */
uint8_t cca_rssi_thresh; /*!< RSSI threshold for CCA */
uint8_t sleep_en; /*!< Enable sleep functionality */
uint8_t coex_phy_coded_tx_rx_time_limit; /*!< Coexistence PHY coded TX and RX time limit */
uint8_t dis_scan_backoff; /*!< Disable scan backoff */
uint8_t ble_scan_classify_filter_enable; /*!< Enable classification filter for BLE scan */
uint8_t cca_drop_mode; /*!< CCA drop mode */
int8_t cca_low_tx_pwr; /*!< Low TX power setting for CCA */
uint8_t main_xtal_freq; /*!< Main crystal frequency */
uint8_t ignore_wl_for_direct_adv; /*!< Ignore the white list for directed advertising */
uint8_t enable_pcl; /*!< Enable power control */
uint8_t csa2_select; /*!< Select CSA#2*/
uint8_t enable_csr; /*!< Enable CSR */
uint8_t ble_aa_check; /*!< True if adds a verification step for the Access Address within the
CONNECT_IND PDU; false otherwise. Configurable in menuconfig */
uint8_t ble_llcp_disc_flag; /*!< Flag indicating whether the Controller disconnects after
Instant Passed (0x28) error occurs. Configurable in menuconfig.
- The Controller does not disconnect after Instant Passed (0x28)
by default. */
uint16_t scan_backoff_upperlimitmax; /*!< The value of upperlimitmax is 2^n, The maximum value
is 256 */
uint8_t
ble_chan_ass_en; /*!< Enable / disable BLE channel assessment. Configurable in menuconfig.
- 0 - Disable
- 1 - Enable (default) */
uint8_t ble_data_lenth_zero_aux; /*!< Enable / disable auxiliary packets when the extended ADV
data length is zero. Configurable in menuconfig.
- 0 - Disable (default)
- 1 - Enable */
uint8_t vhci_enabled; /*!< VHCI is enabled */
uint8_t ptr_check_enabled; /*!< Enable boundary check for internal memory. */
uint8_t ble_adv_tx_options; /*!< The options for Extended advertising sending. */
uint8_t skip_unnecessary_checks_en; /*!< The option to skip non-fatal state checks and perform
extra handling for fatal checks. */
uint8_t fast_conn_data_tx_en; /*!< The option for fast transmission of connection data
- 0 - Disable
- 1 - Enable (default) */
int8_t ch39_txpwr; /*!< BLE transmit power (in dBm) used for BLE advertising on channel 39. */
uint8_t adv_rsv_cnt; /*!< BLE adv state machine reserve count number */
uint8_t conn_rsv_cnt; /*!< BLE conn state machine reserve count number */
uint8_t priority_level_cfg; /*!< The option for priority level configuration */
uint8_t
slv_fst_rx_lat_en; /*!< The option for enabling slave fast PDU reception during latency. */
uint8_t dl_itvl_phy_sync_en; /*!< The option for automatically initiate the data length update
when phy update or connect interval update. */
uint8_t scan_allow_adi_filter; /*!< The option for ext scan to allow PDU with specific adi. */
uint8_t enhanced_mem_resv; /*!< The option masks the BLE events with all reserved memory. */
// at initialization. */
#if SOC_BLE_ISO_SUPPORTED
esp_bt_ctrl_le_iso_config_t *iso_config; /*!< The option for ISO configuration */
#endif // SOC_BLE_ISO_SUPPORTED
uint32_t config_magic; /*!< Configuration magic value */
} esp_bt_ctrl_le_config_t;
/**
* @brief Set BLE TX power
* Connection Tx power should only be set after connection created.
* @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc
* @param power_level: Power level(index) corresponding to absolute value(dbm)
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_t power_level);
/**
* @brief Get BLE TX power
* Connection Tx power should only be get after connection created.
* @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc
* @return >= 0 - Power level, < 0 - Invalid
*/
esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type);
/**
* @brief ENHANCED API for Setting BLE TX power
* Connection Tx power should only be set after connection created.
* @param power_type : The enhanced type of which tx power, could set
* Advertising/Connection/Default and etc
* @param handle : The handle of Advertising or Connection and the value 0 for other enhanced power
* types.
* @param power_level: Power level(index) corresponding to absolute value(dbm)
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle,
esp_power_level_t power_level);
/**
* @brief ENHANCED API of Getting BLE TX power
* Connection Tx power should only be get after connection created.
* @param power_type : The enhanced type of which tx power, could set
* Advertising/Connection/Default and etc
* @param handle : The handle of Advertising or Connection and the value 0 for other enhanced power
* types.
* @return >= 0 - Power level, < 0 - Invalid
*/
esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t power_type,
uint16_t handle);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,549 @@
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "sdkconfig.h"
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
// @brief HCI VS Commands for Espressif's Bluetooth LE Host
//
// @note The following vendor-specific HCI commands are exclusively for Espressif's Bluetooth LE Host (ESP-Bluedroid Host or ESP-NimBLE Host).
// If you are using a non-ESP host or HCI UART, these commands will remain disabled unless enabling the feature in the menuconfig (CONFIG_BT_CTRL_LE_VS_CMD_EVT_ENABLED).
// Note, these additional HCI VS commands are intended for Espressif's Bluetooth Host use only.
// Application developers **should not** enable these commands in their applications.
//
/**
* @brief Config scanning duplicate exceptional list (OCF: 0x0108)
*
*/
#define ESP_BT_VS_CONFIG_DUP_EXC_LIST_OCF (0x0108)
/**
* @brief Update exception list cmd parameters
*/
struct bt_hci_vs_update_exc_list {
uint8_t subcode; /*!< Add, remove or clear exception list */
uint32_t type; /*!< device type */
uint8_t device_info[6]; /*!< device information */
};
/**
* @brief Enable/disable advertising report flow control (OCF: 0x0109)
*
*/
#define ESP_BT_VS_SET_ADV_REPORT_FLOW_CTRL_OCF (0x0109)
/**
* @brief Init ADV flow control cmd parameters
*/
struct bt_hci_vs_init_adv_flow_ctrl {
uint8_t enable; /*!< Enable ADV flow control */
uint16_t num; /*!< ADV buffer maximum value */
uint16_t adv_lost_threshold; /*!< ADV lost event triggered threshold */
};
/**
* @brief Update the number of advertising report in ADV flow control (OCF: 0x010A)
*
*/
#define ESP_BT_VS_UPD_ADV_REPORT_FLOW_CTRL_NUM_OCF (0x010a)
/**
* @brief Update ADV flow control cmd parameters
*/
struct bt_hci_vs_update_adv_flow_ctrl {
uint16_t num; /*!< The number of ADV report processed */
};
/**
* @brief Clear legacy advertising (same as HCI_LE_Clear_Advertising_Sets) (OCF: 0x010C)
*
*/
#define ESP_BT_VS_CLR_LEGACY_ADV_OCF (0x010c)
/**
* @brief Clear legacy ADV cmd parameters
*/
struct bt_hci_vs_ble_clr_legacy_adv {
// no parameters
};
/**
* @brief Set parameters of duplicate list (OCF: 0x010D)
*
*/
#define ESP_BT_VS_SET_DUP_LIST_PARAMS_OCF (0x010d)
/**
* @brief Set duplicate list cmd parameters
*/
struct bt_hci_vs_ble_set_dup_params {
uint8_t dup_mode; /*!< Duplicate mode */
uint8_t dup_ad_type; /*!< Duplicate data type */
uint16_t ring_list_max_num; /*!< Duplicate list size */
};
/**
* @brief Enable/disable duplicate and exception list (OCF: 0x010E)
*
*/
#define ESP_BT_VS_ENABLE_DUP_EXC_LIST_OCF (0x010e)
/**
* @brief Enable duplicate and exception list cmd parameters
*/
struct bt_hci_vs_ble_enable_dup_exc {
uint8_t enable; /*!< Enable or disable */
uint8_t ring_list_reset; /*!< Reset list */
};
/**
* @brief Enable optimization of multiple connections (OCF: 0x010F)
*
*/
#define ESP_BT_VS_ENABLE_ARRANGEMENT_OCF (0x010f)
/**
* @brief Multiple connections optimization cmd parameters
*/
struct bt_hci_vs_ble_enable_arrangement {
uint32_t common_factor; /*!< The greatest common factor of connection interval */
uint8_t enable; /*!< Enable or disable */
};
/**
* @brief Set scheduling length for a certain role (OCF: 0x0110)
*
*/
#define ESP_BT_VS_SET_SCHED_ROLE_LEN_OCF (0x0110)
/**
* @brief Scheduling length cmd parameters
*/
struct bt_hci_vs_ble_set_sched_role_len {
uint8_t role; /*!< BLE role; 0: central; 1: peripheral */
uint32_t len; /*!< Length is us */
};
/**
* @brief Set RSSI threshold for automatic power control (OCF: 0x0111)
*
*/
#define ESP_BT_VS_SET_PCL_RSSI_THRESH_OCF (0x0111)
/**
* @brief PCL RSSI threshold cmd parameters
*/
struct bt_hci_vs_ble_set_pcl_rssi_thresh {
uint16_t conn_handle; /*!< Connection handle */
uint8_t rssi_thresh_min_1M; /*!< Lower limit for 1M */
uint8_t rssi_thresh_max_1M; /*!< Upper limit for 1M */
uint8_t rssi_thresh_min_2M; /*!< Lower limit for 2M */
uint8_t rssi_thresh_max_2M; /*!< Upper limit for 2M */
uint8_t rssi_thresh_min_s2coded; /*!< Lower limit for s2 coded */
uint8_t rssi_thresh_max_s2coded; /*!< Upper limit for s2 coded */
uint8_t rssi_thresh_min_s8coded; /*!< Lower limit for s8 coded */
uint8_t rssi_thresh_max_s8coded; /*!< Upper limit for s8 coded */
};
/**
* @brief Enable/disable channel selection algorithm #2 (OCF: 0x0112)
*
*/
#define ESP_BT_VS_ENABLE_CSA2_OCF (0x0112)
/**
* @brief Enable/disable channel selection algorithm #2 cmd parameters
*/
struct bt_hci_vs_ble_csa_enable {
uint8_t csa2_select; /*!< Select CSA2 */
};
/**
* @brief Set parameters of controller logs (OCF: 0x0114)
*
*/
#define ESP_BT_VS_SET_LOG_PARAMS_OCF (0x0114)
/**
* @brief Controller logs cmd parameters
*/
struct bt_hci_vs_ble_log_params {
uint8_t type; /*!< Operation type */
uint32_t output_enable; /*!< Enable/disable output */
uint8_t buffer_optoin; /*!< Select log buffers */
};
/**
* @brief Set BLE vendor events mask (OCF: 0x0116)
*
*/
#define ESP_BT_VS_SET_LE_VENDOR_EVTS_MASK_OCF (0x0116)
/**
* @brief Set BLE vendor events mask cmd parameters
*/
struct bt_hci_vs_ble_set_vs_evts_mask {
uint32_t evt_masks; /*!< BLE vendor events Mask */
};
/**
* @brief Set connection protected TX/RX threshold (OCF: 0x0117)
*
*/
#define ESP_BT_VS_SET_CONN_PROT_TX_RX_THRESH_OCF (0x0117)
/**
* @brief Set connection protected TX/RX threshold cmd parameters
*/
struct bt_hci_vs_set_conn_prot_tx_rx_thresh {
uint8_t use_default_thresh; /*!< Use default threshold */
uint8_t threshold; /*!< Threshold */
};
/**
* @brief Set peer sleep clock accuracy to a constant value (OCF: 0x0118)
*
*/
#define ESP_BT_VS_SET_CONST_PEER_SCA_OCF (0x0118)
/**
* @brief Peer constant SCA cmd parameters
*/
struct bt_hci_vs_ble_set_const_peer_sca {
uint16_t peer_sca; /*!< Peer SCA */
};
/**
* @brief Get CTE hardware information (OCF: 0x011B)
*
* @note This command is only used by internal test.
*/
#define ESP_BT_VS_GET_CTE_HW_INFO (0x011B)
/**
* @brief Set CTE calibration receive parameter (OCF: 0x011C)
*
* @note This command is only used by internal test.
*/
#define ESP_BT_VS_SET_CTE_CAL_RECV_PARAM (0x011C)
/**
* @brief Set CTE calibration transmit parameter (OCF: 0x011D)
*
* @note This command is only used by internal test.
*/
#define ESP_BT_VS_SET_CTE_CAL_TRANS_PARAM (0x011D)
/**
* @brief Set CTE calibration BB parameter (OCF: 0x011E)
*
* @note This command is only used by internal test.
*/
#define ESP_BT_VS_SET_CTE_CAL_BB_PARAM (0x011E)
/**
* @brief Set CTE calibration LC parameter (OCF: 0x011F)
*
* @note This command is only used by internal test.
*/
#define ESP_BT_VS_SET_CTE_CAL_LC_PARAM (0x011F)
/**
* @brief Set CTE calibration state (OCF: 0x0120)
*
* @note This command is only used by internal test.
*/
#define ESP_BT_VS_SET_CTE_CAL_STATE (0x0120)
/**
* @brief Set CTE calibration TX data (OCF: 0x0121)
*
* @note This command is only used by internal test.
*/
#define ESP_BT_VS_SET_CTE_CAL_TX_DATA (0x0121)
/**
* @brief Disable advertising random delay (OCF: 0x0122)
*
*/
#define ESP_BT_VS_DISABLE_ADV_RANDOM_DELAY_OCF (0x0122)
/**
* @brief Disable advertising random delay cmd parameters
*/
struct bt_hci_vs_disable_adv_random_delay {
uint8_t disable; /*!< Enable or disable */
};
/**
* @brief Set default coded PHY (OCF: 0x0123)
*
*/
#define ESP_BT_VS_SET_PREFERRED_CODED_PHY_OCF (0x0123)
/**
* @brief Set default coded PHY cmd parameters
*/
struct bt_hci_vs_set_preferred_coded_phy {
uint8_t perfer_s2_coded; /*!< 500k by default */
};
/**
* @brief Set scan forever (OCF: 0x0124)
*
*/
#define ESP_BT_VS_SET_SCAN_FOREVER_OCF (0x0124)
/**
* @brief Set scan forever cmd parameters
*/
struct bt_hci_vs_ble_set_scan_forever {
uint8_t scan_forever; /*!< Scan forever */
};
/**
* @brief Set TX power level enhanced (OCF: 0x0125)
*
*/
#define ESP_BT_VS_SET_TXPWR_LVL_ENH_OCF (0x0125)
/**
* @brief Set TX power level enhanced cmd parameters
*/
struct bt_hci_vs_set_txpwr_lvl_enhanced {
uint8_t type; /*!< Type */
int txpwr_lvl; /*!< TX power level enhancement */
uint16_t handle; /*!< Handle */
};
/**
* @brief Get TX power level enhanced (OCF: 0x0126)
*
*/
#define ESP_BT_VS_GET_TXPWR_LVL_ENH_OCF (0x0126)
/**
* @brief Get TX power level enhanced cmd parameters
*/
struct bt_hci_vs_get_txpwr_lvl_enhanced {
uint8_t type; /*!< Type */
uint16_t handle; /*!< Handle */
};
/**
* @brief Enable/disable CCA (OCF: 0x0127)
*
*/
#define ESP_BT_VS_ENABLE_CCA_OCF (0x0127)
/**
* @brief Enable/disable CCA cmd parameters
*/
struct bt_hci_vs_enable_cca {
uint8_t enable; /*!< Enable or disable */
int8_t threshold; /*!< Threshold */
};
/**
* @brief Set RX sensitivity threshold (OCF: 0x0128)
*
*/
#define ESP_BT_VS_SET_RX_SENS_THRESH_OCF (0x0128)
/**
* @brief Set RX sensitivity threshold cmd parameters
*/
struct bt_hci_vs_set_rx_sens_thresh {
uint8_t enabled; /*!< Enable or disable */
uint8_t phy; /*!< Type */
int8_t threshold_dbm; /*!< Threshold in dBm */
};
/**
* @brief Set scan backoff uplimit (OCF: 0x0129)
*
*/
#define ESP_BT_VS_SET_SCAN_BACKOFF_UPLIMIT_OCF (0x0129)
/**
* @brief Set scan backoff uplimit cmd parameters
*/
struct bt_hci_vs_set_scan_backoff_uplimit {
uint16_t max_uplimit; /*!< Maximum uplimit */
};
/**
* @brief Set extended advertising constant DID (OCF: 0x012a)
*
*/
#define ESP_BT_VS_SET_EXT_ADV_CONSTANT_DID_OCF (0x012a)
/**
* @brief Set extended advertising constant DID cmd parameters
*/
struct bt_hci_vs_set_ext_adv_constant_did {
uint16_t handle; /*!< Handle */
uint8_t enable; /*!< Enable or disable */
uint16_t did; /*!< DID */
};
/**
* @brief Set scan ADI filter (OCF: 0x012b)
*
*/
#define ESP_BT_VS_SET_SCAN_ADI_FILTER_OCF (0x012b)
/**
* @brief Scan ADI filter parameter entry
*/
struct bt_hci_vs_adi_entry {
uint8_t sid; /*!< Expected SID */
uint16_t did_cnt; /*!< DID count */
uint16_t did[0]; /*!< Expected DID list */
};
/**
* @brief Set scan ADI filter cmd parameters
*/
struct bt_hci_vs_set_scan_adi_filter {
uint8_t enable; /*!< Enable or disable ADI filter */
uint8_t dup_filter; /*!< Enable duplicate filter */
uint8_t sid_num; /*!< SID number */
struct bt_hci_vs_adi_entry adi_entry[0]; /*!< ADIs list */
};
// @brief HCI VS Events for Espressif's Bluetooth LE Host
//
// @note The following HCI VS events are exclusively for Espressif's Bluetooth LE Host (ESP-Bluedroid Host or ESP-NimBLE Host).
// If you are using a non-ESP host or HCI UART, these events will remain disabled unless the initialization function is explicitly called from the application.
// Note, these init functions as well as these additional HCI VS events are intended for Espressif's Bluetooth Host use only.
// Application developers **should not** call the init functions in their applications.
//
/**
* @brief BLE Scan/Connect Request, Aux Connect Response received event (EVTCODE: 0xFF, SUBCODE: 0xC0)
*
* @note The init function is `adv_stack_enableScanReqRxdVsEvent(true)`
*/
#define ESP_BT_VS_LE_CONN_SCAN_REQ_RXED_EVT_SUBCODE (0xC0)
/**
* @brief BLE Scan/Connect Request, Aux Connect Response received event parameters
*/
struct bt_hci_vs_le_conn_scan_req_rxed_evt {
uint8_t evt_type; /*!< Event type; 0: SCAN_REQ; 1: CONN_IND */
uint8_t handle; /*!< Advertisement handle */
uint8_t peer_addr_type; /*!< Peer address type */
uint8_t peer_addr[6]; /*!< Peer address */
};
/**
* @brief BLE Channel Map Update Completion event (EVTCODE: 0xFF, SUBCODE: 0xC1)
*
* @note The init function is `conn_stack_enableChanMapUpdCompVsEvent(true)`
*/
#define ESP_BT_VS_LE_CHAN_UPDATE_COMP_EVT_SUBCODE (0xC1)
/**
* @brief BLE Channel Map Update Completion event parameters
*/
struct bt_hci_vs_le_chan_update_comp_evt {
uint8_t status; /*!< Controller error code */
uint16_t handle; /*!< Connection handle */
uint8_t ch_map[5]; /*!< Updated channel map */
};
/**
* @brief BLE Wakeup From Sleep event (EVTCODE: 0xFF, SUBCODE: 0xC3)
*
* @note The init function is `sleep_stack_enableWakeupVsEvent(true)`
*/
#define ESP_BT_VS_LE_SLEEP_WAKEUP_EVT_SUBCODE (0xC3)
/**
* @brief BLE wakeup event parameters
*/
struct bt_hci_vs_le_sleep_wakeup_evt {
// no parameters
};
/**
* @brief BLE advertising report lost event for flow control (EVTCODE: 0x3E, SUBCODE: 0xF0)
*
* @note The init function is `scan_stack_enableAdvFlowCtrlVsCmd(true)`
*/
#define ESP_BT_VS_LE_ADV_LOST_EVT_SUBCODE (0xF0)
/**
* @brief ADV lost event parameters
*/
struct bt_hci_vs_le_adv_lost_evt {
uint32_t nb_lost; /*!< The number of ADV report discarded */
};
//
// @brief HCI VS Commands for Espressif's Internal-Use Debugging
//
// @note The following HCI VS debugging commands are implemented in Bluetooth LE controller pre-compiled libraries.
// These commands are not linked into the application binary, unless the function `esp_ble_internalTestFeaturesEnable(true)`is called from the application.
// They are intended for Espressif's internal use only. Application developers **should not** call `esp_ble_internalTestFeaturesEnable(true)` in their applications.
//
#define ESP_BT_VS_CFG_TEST_RELATED_OCF (0x0113)
#define ESP_BT_VS_CFG_TEST_ENABLE_SUBCMD (0X00)
#define ESP_BT_VS_CFG_TEST_ENABLE_ADV_DELAY_SUBCMD (0X01)
#define ESP_BT_VS_CFG_TEST_SET_PREF_CODED_SUBCMD (0X02)
#define ESP_BT_VS_CFG_TEST_SET_DEFAULT_PRIV_MODE_SUBCMD (0X03)
#define ESP_BT_VS_CFG_TEST_SET_SCAN_FOREVER_SUBCMD (0X04)
#define ESP_BT_VS_CFG_TEST_SET_EXPECTED_PEER_SUBCMD (0X05)
#define ESP_BT_VS_CFG_TEST_GET_ADV_TXED_CNT_SUBCMD (0X06)
#define ESP_BT_VS_CFG_TEST_GET_SCAN_RXED_CNT_SUBCMD (0X07)
#define ESP_BT_VS_CFG_TEST_SET_TXPWR_LVL_SUBCMD (0X08)
#define ESP_BT_VS_CFG_TEST_GET_TXPWR_LVL_SUBCMD (0X09)
#define ESP_BT_VS_CFG_TEST_SET_TXPWR_LVL_ENH_SUBCMD (0X0a)
#define ESP_BT_VS_CFG_TEST_GET_TXPWR_LVL_ENH_SUBCMD (0X0b)
#define ESP_BT_VS_CFG_TEST_IGNORE_WL_FOR_DIR_ADV_SUBCMD (0X0c)
#define ESP_BT_VS_CFG_TEST_GET_ADV_RXED_RSSI_SUBCMD (0X0d)
#define ESP_BT_VS_CFG_TEST_ENABLE_CCA_SUBCMD (0X0e)
#define ESP_BT_VS_CFG_TEST_SET_CCA_WIN_SUBCMD (0X0f)
#define ESP_BT_VS_CFG_TEST_READ_CCA_DATA_SUBCM (0X10)
#define ESP_BT_VS_CFG_TEST_CLEAR_RAND_ADDR_SUBCMD (0X11)
#define ESP_BT_VS_CFG_TEST_GET_MAX_TXPWR_SUBCMD (0X12)
#define ESP_BT_VS_CFG_TEST_GET_TXPWR_RANGE_SUBCMD (0X13)
#define ESP_BT_VS_CFG_TEST_SET_SCAN_AA_SUBCMD (0X14)
#define ESP_BT_VS_CFG_TEST_SET_ADV_AA_SUBCMD (0X15)
#define ESP_BT_VS_CFG_TEST_SET_SCAN_CHAN_SUBCMD (0X16)
#define ESP_BT_VS_CFG_TEST_SKIP_LIGHT_SLEEP_CHECK_SUBCMD (0X17)
#define ESP_BT_VS_CFG_TEST_SET_WAKEUP_OVERHEAD_SUBCMD (0X18)
#define ESP_BT_VS_CFG_TEST_GET_ADV_MIN_ITVL_SUBCMD (0X19)
#define ESP_BT_VS_CFG_TEST_GET_CTRL_STATUS_SUBCMD (0X1a)
#define ESP_BT_VS_CFG_TEST_SET_CONN_PHY_TXPWR_SUBCMD (0X1b)
#define ESP_BT_VS_CFG_TEST_GET_CONN_PHY_TXPWR_SUBCMD (0X1c)
#define ESP_BT_VS_CFG_TEST_GET_RXBUF_EMPTY_CNT_SUBCMD (0X1d)
#define ESP_BT_VS_CFG_TEST_RESTART_SUBCMD (0X1e)
#define ESP_BT_VS_CFG_TEST_ENABLE_RECODE_RX_STATE_SUBCMD (0X1f)
#define ESP_BT_VS_CFG_TEST_GET_RECODE_CNT_SUBCMD (0X20)
#define ESP_BT_VS_CFG_TEST_CLR_RECODE_CNT_SUBCMD (0X21)
#define ESP_BT_VS_CFG_TEST_GET_CTRL_COMPILE_VER_SUBCMD (0X24)
#define ESP_BT_VS_CFG_TEST_SET_AUX_ADV_OFFSET_SUBCMD (0X25)
#define ESP_BT_VS_CFG_TEST_INIT_FLEXIBLE_MODE_SUBCMD (0X26)
#define ESP_BT_VS_CFG_TEST_ENABLE_FLEXIBLE_MODE_SUBCMD (0X27)
#define ESP_BT_VS_CFG_TEST_SET_FLEXIBLE_CONN_ERR_SUBCMD (0X28)
#define ESP_BT_VS_CFG_TEST_SET_FLEXIBLE_ADV_ERR_SUBCMD (0X29)
#define ESP_BT_VS_CFG_TEST_SET_FLEXIBLE_SCAN_ERR_SUBCMD (0X2a)
#define ESP_BT_VS_CFG_TEST_GET_TXED_CRCERR_SUBCMD (0X2c)
#define ESP_BT_VS_CFG_TEST_GET_BACKOFF_UPLIMIT_SUBCMD (0X2d)
#define ESP_BT_VS_CFG_TEST_GET_RXED_ADV_ADI_SUBCMD (0X2f)
#define ESP_BT_VS_CFG_TEST_SET_SCH_RAND_MODE_SUBCMD (0X30)
#define ESP_BT_VS_CFG_TEST_SET_RX_SENS_THRESH_SUBCMD (0X31)
#define ESP_BT_VS_CFG_TEST_CHECK_MSYS_BUF_SUBCMD (0X32)
#define ESP_BT_VS_CFG_TEST_UPDATE_BLE_TIMER_SUBCMD (0X33)
#define ESP_BT_VS_CFG_TEST_UPDATE_BLE_RTC_SUBCMD (0X34)
#define ESP_BT_VS_CFG_TEST_SET_LOCKED_MEM_NUM_SUBCMD (0X35)
#define ESP_BT_VS_CFG_TEST_ALLOW_MEM_ALLOC_SUBCMD (0X36)
#define ESP_BT_VS_CFG_TEST_SET_SCH_RAND_INFO_PTR_SUBCMD (0X37)
#define ESP_BT_VS_CFG_TEST_SET_DIAG_IO_SUBCMD (0X38)
#define ESP_BT_VS_CFG_TEST_SET_AGC_MAX_GAIN_SUBCMD (0X39)
#define ESP_BT_VS_CFG_TEST_ENABLE_CHAN_ASSESS_SUBCMD (0X40)
#define ESP_BT_VS_CFG_TEST_SET_BACKOFF_UPLIMIT_SUBCMD (0X41)
#define ESP_BT_VS_CFG_TEST_SET_CONN_TOP_PRIO_RESV_THRESH_SUBCMD (0X42)
#define ESP_BT_VS_CFG_TEST_SET_TEST_EVT_MSK_SUBCMD (0X43)
#define ESP_BT_VS_CFG_TEST_GET_WAKEUP_TIMEOUT_SUBCMD (0X45)
#define ESP_BT_VS_CFG_TEST_RELATED_SUBCMD_MAX (0Xff)
//
// @brief HCI VS Events for Espressif's Internal-Use Debugging
//
// @note The following HCI VS debugging events are implemented in Bluetooth LE controller pre-compiled libraries.
// These events are not linked into the application binary, unless the function `esp_ble_internalTestFeaturesEnable(true)`is called from the application.
// Application developers **should not** call `esp_ble_internalTestFeaturesEnable(true)` in their applications.
//
#define ESP_BT_VS_LE_RUNNING_STATUS_EVT_SUBCODE (0xC3)
#ifdef __cplusplus
}
#endif

View File

@@ -4,533 +4,343 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __ESP_BT_H__
#define __ESP_BT_H__
#ifndef __ESP_BT_H__
#define __ESP_BT_H__
#include <stdint.h>
#include <stdbool.h>
#include "esp_err.h"
#include "sdkconfig.h"
#include "esp_task.h"
#include "esp_assert.h"
#include <stdint.h>
#include <stdbool.h>
#include "esp_err.h"
#include "sdkconfig.h"
#include "esp_task.h"
#include "esp_assert.h"
#include "btdm_user_cfg.h"
#include "btdm_user_cfg.h"
#if CONFIG_BTDM_CTRL_MODE_BLE_ONLY || CONFIG_BTDM_CTRL_MODE_BTDM
#include "ble_user_cfg.h"
#endif /* CONFIG_BTDM_CTRL_MODE_BLE_ONLY || CONFIG_BTDM_CTRL_MODE_BTDM */
#if SOC_BT_CLASSIC_SUPPORTED
#include "../../common/btdm_bredr.h"
#endif // SOC_BT_CLASSIC_SUPPORTED
#ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART
#include "driver/uart.h"
#endif
#if SOC_BLE_SUPPORTED
#include "../../common/btdm_le.h"
#endif /* SOC_BLE_SUPPORTED */
#ifdef __cplusplus
extern "C" {
#endif
#ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART
#include "driver/uart.h"
#endif
/**
* @brief Bluetooth mode for controller enable/disable.
*/
typedef enum {
ESP_BT_MODE_IDLE = 0x00, /*!< Bluetooth is not running */
ESP_BT_MODE_BLE = 0x01, /*!< Run BLE mode */
ESP_BT_MODE_CLASSIC_BT = 0x02, /*!< Run Classic BT mode */
ESP_BT_MODE_BTDM = 0x03, /*!< Run dual mode */
} esp_bt_mode_t;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Bluetooth controller enable/disable/initialised/de-initialised status.
*/
typedef enum {
ESP_BT_CONTROLLER_STATUS_IDLE = 0, /*!< Controller is in idle state */
ESP_BT_CONTROLLER_STATUS_INITED, /*!< Controller is in initialising state */
ESP_BT_CONTROLLER_STATUS_ENABLED, /*!< Controller is in enabled state */
ESP_BT_CONTROLLER_STATUS_NUM, /*!< Controller is in disabled state */
} esp_bt_controller_status_t;
/**
* @brief Bluetooth mode for controller enable/disable.
*/
typedef enum {
ESP_BT_MODE_IDLE = 0x00, /*!< Bluetooth is not running */
ESP_BT_MODE_BLE = 0x01, /*!< Run BLE mode */
ESP_BT_MODE_CLASSIC_BT = 0x02, /*!< Run Classic BT mode */
ESP_BT_MODE_BTDM = 0x03, /*!< Run dual mode */
} esp_bt_mode_t;
/**
* @brief BLE tx power type
* ESP_BLE_PWR_TYPE_CONN_HDL0-8: for each connection, and only be set after connection completed.
* when disconnect, the correspond TX power is not effected.
* ESP_BLE_PWR_TYPE_ADV : for advertising/scan response.
* ESP_BLE_PWR_TYPE_SCAN : for scan.
* ESP_BLE_PWR_TYPE_DEFAULT : if each connection's TX power is not set, it will use this default value.
* if neither in scan mode nor in adv mode, it will use this default value.
* If none of power type is set, system will use ESP_PWR_LVL_P3 as default for ADV/SCAN/CONN0-9.
*/
typedef enum {
ESP_BLE_PWR_TYPE_CONN_HDL0 = 0, /*!< For connection handle 0 */
ESP_BLE_PWR_TYPE_CONN_HDL1 = 1, /*!< For connection handle 1 */
ESP_BLE_PWR_TYPE_CONN_HDL2 = 2, /*!< For connection handle 2 */
ESP_BLE_PWR_TYPE_CONN_HDL3 = 3, /*!< For connection handle 3 */
ESP_BLE_PWR_TYPE_CONN_HDL4 = 4, /*!< For connection handle 4 */
ESP_BLE_PWR_TYPE_CONN_HDL5 = 5, /*!< For connection handle 5 */
ESP_BLE_PWR_TYPE_CONN_HDL6 = 6, /*!< For connection handle 6 */
ESP_BLE_PWR_TYPE_CONN_HDL7 = 7, /*!< For connection handle 7 */
ESP_BLE_PWR_TYPE_CONN_HDL8 = 8, /*!< For connection handle 8 */
ESP_BLE_PWR_TYPE_ADV = 9, /*!< For advertising */
ESP_BLE_PWR_TYPE_SCAN = 10, /*!< For scan */
ESP_BLE_PWR_TYPE_DEFAULT = 11, /*!< For default, if not set other, it will use default value */
ESP_BLE_PWR_TYPE_NUM = 12, /*!< TYPE numbers */
} esp_ble_power_type_t;
/**
* @brief Bluetooth controller enable/disable/initialised/de-initialised status.
*/
typedef enum {
ESP_BT_CONTROLLER_STATUS_IDLE = 0, /*!< Controller is in idle state */
ESP_BT_CONTROLLER_STATUS_INITED, /*!< Controller is in initialising state */
ESP_BT_CONTROLLER_STATUS_ENABLED, /*!< Controller is in enabled state */
ESP_BT_CONTROLLER_STATUS_NUM, /*!< Controller is in disabled state */
} esp_bt_controller_status_t;
/**
* @brief Bluetooth TX power level(index), it's just a index corresponding to power(dbm).
*/
typedef enum {
ESP_PWR_LVL_N24 = 0, /*!< Corresponding to -24dbm */
ESP_PWR_LVL_N21 = 1, /*!< Corresponding to -21dbm */
ESP_PWR_LVL_N18 = 2, /*!< Corresponding to -18dbm */
ESP_PWR_LVL_N15 = 3, /*!< Corresponding to -15dbm */
ESP_PWR_LVL_N12 = 4, /*!< Corresponding to -12dbm */
ESP_PWR_LVL_N9 = 5, /*!< Corresponding to -9dbm */
ESP_PWR_LVL_N6 = 6, /*!< Corresponding to -6dbm */
ESP_PWR_LVL_N3 = 7, /*!< Corresponding to -3dbm */
ESP_PWR_LVL_N0 = 8, /*!< Corresponding to 0dbm */
ESP_PWR_LVL_P3 = 9, /*!< Corresponding to +3dbm */
ESP_PWR_LVL_P6 = 10, /*!< Corresponding to +6dbm */
ESP_PWR_LVL_P9 = 11, /*!< Corresponding to +9dbm */
ESP_PWR_LVL_P12 = 12, /*!< Corresponding to +12dbm */
ESP_PWR_LVL_P15 = 13, /*!< Corresponding to +15dbm */
ESP_PWR_LVL_P16 = 14, /*!< Corresponding to +16dbm */
ESP_PWR_LVL_P17 = 15, /*!< Corresponding to +17dbm */
ESP_PWR_LVL_P18 = 16, /*!< Corresponding to +18dbm */
ESP_PWR_LVL_P19 = 17, /*!< Corresponding to +19dbm */
ESP_PWR_LVL_P20 = 18, /*!< Corresponding to +20dbm */
ESP_PWR_LVL_INVALID = 0xFF, /*!< Indicates an invalid value */
} esp_power_level_t;
/**
* @brief BLE tx power type
* ESP_BLE_PWR_TYPE_CONN_HDL0-8: for each connection, and only be set after connection completed.
* when disconnect, the correspond TX power is not effected.
* ESP_BLE_PWR_TYPE_ADV : for advertising/scan response.
* ESP_BLE_PWR_TYPE_SCAN : for scan.
* ESP_BLE_PWR_TYPE_DEFAULT : if each connection's TX power is not set, it will use this default value.
* if neither in scan mode nor in adv mode, it will use this default value.
* If none of power type is set, system will use ESP_PWR_LVL_P3 as default for ADV/SCAN/CONN0-9.
*/
typedef enum esp_ble_power_type {
ESP_BLE_PWR_TYPE_CONN_HDL0 = 0, /*!< For connection handle 0 */
ESP_BLE_PWR_TYPE_CONN_HDL1 = 1, /*!< For connection handle 1 */
ESP_BLE_PWR_TYPE_CONN_HDL2 = 2, /*!< For connection handle 2 */
ESP_BLE_PWR_TYPE_CONN_HDL3 = 3, /*!< For connection handle 3 */
ESP_BLE_PWR_TYPE_CONN_HDL4 = 4, /*!< For connection handle 4 */
ESP_BLE_PWR_TYPE_CONN_HDL5 = 5, /*!< For connection handle 5 */
ESP_BLE_PWR_TYPE_CONN_HDL6 = 6, /*!< For connection handle 6 */
ESP_BLE_PWR_TYPE_CONN_HDL7 = 7, /*!< For connection handle 7 */
ESP_BLE_PWR_TYPE_CONN_HDL8 = 8, /*!< For connection handle 8 */
ESP_BLE_PWR_TYPE_ADV = 9, /*!< For advertising */
ESP_BLE_PWR_TYPE_SCAN = 10, /*!< For scan */
ESP_BLE_PWR_TYPE_DEFAULT = 11, /*!< For default, if not set other, it will use default value */
ESP_BLE_PWR_TYPE_NUM = 12, /*!< TYPE numbers */
} esp_ble_power_type_t;
/**
* @brief The enhanced type of which tx power, could set Advertising/Connection/Default and etc.
*/
typedef enum {
ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT = 0,
ESP_BLE_ENHANCED_PWR_TYPE_ADV,
ESP_BLE_ENHANCED_PWR_TYPE_SCAN,
ESP_BLE_ENHANCED_PWR_TYPE_INIT,
ESP_BLE_ENHANCED_PWR_TYPE_CONN,
ESP_BLE_ENHANCED_PWR_TYPE_MAX,
} esp_ble_enhanced_power_type_t;
/**
* @brief Bluetooth TX power level(index), it's just a index corresponding to power(dbm).
*/
typedef enum esp_power_level {
ESP_PWR_LVL_N24 = 0, /*!< Corresponding to -24dbm */
ESP_PWR_LVL_N21 = 1, /*!< Corresponding to -21dbm */
ESP_PWR_LVL_N18 = 2, /*!< Corresponding to -18dbm */
ESP_PWR_LVL_N15 = 3, /*!< Corresponding to -15dbm */
ESP_PWR_LVL_N12 = 4, /*!< Corresponding to -12dbm */
ESP_PWR_LVL_N9 = 5, /*!< Corresponding to -9dbm */
ESP_PWR_LVL_N6 = 6, /*!< Corresponding to -6dbm */
ESP_PWR_LVL_N3 = 7, /*!< Corresponding to -3dbm */
ESP_PWR_LVL_N0 = 8, /*!< Corresponding to 0dbm */
ESP_PWR_LVL_P3 = 9, /*!< Corresponding to +3dbm */
ESP_PWR_LVL_P6 = 10, /*!< Corresponding to +6dbm */
ESP_PWR_LVL_P9 = 11, /*!< Corresponding to +9dbm */
ESP_PWR_LVL_P12 = 12, /*!< Corresponding to +12dbm */
ESP_PWR_LVL_P15 = 13, /*!< Corresponding to +15dbm */
ESP_PWR_LVL_P16 = 14, /*!< Corresponding to +16dbm */
ESP_PWR_LVL_P17 = 15, /*!< Corresponding to +17dbm */
ESP_PWR_LVL_P18 = 16, /*!< Corresponding to +18dbm */
ESP_PWR_LVL_P19 = 17, /*!< Corresponding to +19dbm */
ESP_PWR_LVL_P20 = 18, /*!< Corresponding to +20dbm */
ESP_PWR_LVL_INVALID = 0xFF, /*!< Indicates an invalid value */
} esp_power_level_t;
/**
* @brief Select buffers
*/
typedef enum {
ESP_BLE_LOG_BUF_HCI = 0x02,
ESP_BLE_LOG_BUF_CONTROLLER = 0x05,
} esp_ble_log_buf_t;
/**
* @brief Address type and address value.
*/
/**
* @brief Address type and address value.
*/
typedef struct {
uint8_t type; /*!< Type of the Bluetooth address (public, random, etc.) */
uint8_t val[6]; /*!< Array containing the 6-byte Bluetooth address value */
} esp_ble_addr_t;
uint8_t type; /*!< Type of the Bluetooth address (public, random, etc.) */
uint8_t val[6]; /*!< Array containing the 6-byte Bluetooth address value */
} esp_ble_addr_t;
#define BTDM_CONFIG_VERSION 0x20260127
#define BTDM_CONFIG_MAGIC_VALUE 0x5a5aa5a5
#define BLE_CONFIG_VERSION 0x20241029
#define BLE_CONFIG_MAGIC 0x5A5AA5A5
/* Types definition
************************************************************************
*/
#define BTDM_CONFIG_VERSION 0x20260127
#define BTDM_CONFIG_MAGIC_VALUE 0x5a5aa5a5
/**
* @brief BTDM controller common configuration options
*/
typedef struct {
uint32_t version; /*!< Version number of the defined structure */
uint16_t task_stack_size; /*!< Size of Bluetooth controller task stack */
uint8_t task_prio; /*!< Priority of the Bluetooth controller task */
uint8_t task_run_cpu; /*!< CPU number on which the Bluetooth controller task runs */
uint8_t hci_cmd_num; /*!< HCI command buffer number */
uint8_t sleep_en; /*!< Enable sleep functionality */
uint8_t version_num; /*!< Hardware version number of this chip */
uint8_t bluetooth_mode; /*!< Controller mode: BR/EDR, BLE or Dual Mode */
uint32_t magic; /*!< Magic number for configuration validation */
} esp_bt_ctrl_btdm_config_t;
/* Types definition
************************************************************************
*/
/**
* @brief BTDM controller common configuration options
*/
typedef struct {
uint32_t version; /*!< Version number of the defined structure */
uint16_t task_stack_size; /*!< Size of Bluetooth controller task stack */
uint8_t task_prio; /*!< Priority of the Bluetooth controller task */
uint8_t task_run_cpu; /*!< CPU number on which the Bluetooth controller task runs */
uint8_t hci_cmd_num; /*!< HCI command buffer number */
uint8_t hci_conn_num; /*!< HCI level connection number */
uint8_t sleep_en; /*!< Enable sleep functionality */
uint8_t version_num; /*!< Hardware version number of this chip */
uint8_t bluetooth_mode; /*!< Controller mode: BR/EDR, BLE or Dual Mode */
uint32_t magic; /*!< Magic number for configuration validation */
}esp_btdm_controller_config_t;
/**
* @brief Controller config options, depend on config mask.
* Config mask indicate which functions enabled, this means
* some options or parameters of some functions enabled by config mask.
*/
typedef struct {
esp_bt_ctrl_le_config_t ble; /*!< Bluetooth LE controller configuration options */
#if SOC_BT_CLASSIC_SUPPORTED
esp_bt_ctrl_bredr_config_t bredr; /*!< Bluetooth Classic controller configuration options */
#endif // SOC_BT_CLASSIC_SUPPORTED
esp_bt_ctrl_btdm_config_t btdm; /*!< Bluetooth controller common configuration options */
} esp_bt_controller_config_t;
/**
* @brief Controller config options, depend on config mask.
* Config mask indicate which functions enabled, this means
* some options or parameters of some functions enabled by config mask.
*/
typedef struct {
struct {
uint32_t config_version; /*!< Version number of the defined structure */
uint16_t ble_ll_resolv_list_size; /*!< Size of the resolvable private address list */
uint16_t ble_hci_evt_hi_buf_count; /*!< Count of high buffers for HCI events */
uint16_t ble_hci_evt_lo_buf_count; /*!< Count of low buffers for HCI events */
uint8_t ble_ll_sync_list_cnt; /*!< Number of synchronization lists */
uint8_t ble_ll_sync_cnt; /*!< Number of synchronizations */
uint16_t ble_ll_rsp_dup_list_count; /*!< Count of duplicated lists for scan response packets */
uint16_t ble_ll_adv_dup_list_count; /*!< Count of duplicated lists for advertising packets */
uint8_t ble_ll_tx_pwr_dbm; /*!< Tx power (transmit power) in dBm */
uint64_t rtc_freq; /*!< Frequency of RTC (Real-Time Clock) */
uint16_t ble_ll_sca; /*!< Sleep Clock Accuracy (SCA) parameter */
uint8_t ble_ll_scan_phy_number; /*!< Number of PHYs supported for scanning */
uint16_t ble_ll_conn_def_auth_pyld_tmo; /*!< Connection default authentication payload timeout */
uint8_t ble_ll_jitter_usecs; /*!< Jitter time in microseconds */
uint16_t ble_ll_sched_max_adv_pdu_usecs; /*!< Maximum time in microseconds for advertising PDU scheduling */
uint16_t ble_ll_sched_direct_adv_max_usecs; /*!< Maximum time in microseconds for directed advertising scheduling */
uint16_t ble_ll_sched_adv_max_usecs; /*!< Maximum time in microseconds for advertising scheduling */
uint16_t ble_scan_rsp_data_max_len; /*!< Maximum length of scan response data */
uint8_t ble_ll_cfg_num_hci_cmd_pkts; /*!< Number of HCI command packets that can be queued */
uint32_t ble_ll_ctrl_proc_timeout_ms; /*!< Control processing timeout in milliseconds */
uint16_t nimble_max_connections; /*!< Maximum number of connections supported */
uint8_t ble_whitelist_size; /*!< Size of the white list */
uint16_t ble_acl_buf_size; /*!< Buffer size of ACL (Asynchronous Connection-Less) data */
uint16_t ble_acl_buf_count; /*!< Buffer count of ACL data */
uint16_t ble_hci_evt_buf_size; /*!< Buffer size for HCI event data */
uint16_t ble_multi_adv_instances; /*!< Number of advertising instances */
uint16_t ble_ext_adv_max_size; /*!< Maximum size of extended advertising data */
uint16_t controller_task_stack_size; /*!< Size of Bluetooth controller task stack, to be removed */
uint8_t controller_task_prio; /*!< Priority of the Bluetooth task, to be removed */
uint8_t controller_run_cpu; /*!< CPU number on which the Bluetooth controller task runs, to be removed */
uint8_t enable_qa_test; /*!< Enable for QA test */
uint8_t enable_bqb_test; /*!< Enable for BQB test */
uint8_t enable_tx_cca; /*!< Enable Clear Channel Assessment (CCA) when transmitting */
uint8_t cca_rssi_thresh; /*!< RSSI threshold for CCA */
uint8_t sleep_en; /*!< Enable sleep functionality */
uint8_t coex_phy_coded_tx_rx_time_limit; /*!< Coexistence PHY coded TX and RX time limit */
uint8_t dis_scan_backoff; /*!< Disable scan backoff */
uint8_t ble_scan_classify_filter_enable; /*!< Enable classification filter for BLE scan */
uint8_t cca_drop_mode; /*!< CCA drop mode */
int8_t cca_low_tx_pwr; /*!< Low TX power setting for CCA */
uint8_t main_xtal_freq; /*!< Main crystal frequency */
uint8_t ignore_wl_for_direct_adv; /*!< Ignore the white list for directed advertising */
uint8_t enable_pcl; /*!< Enable power control */
uint8_t csa2_select; /*!< Select CSA2 */
uint8_t enable_csr; /*!< Enable connection subrate */
int8_t backoff_rssi; /*!< Set the lowest rssi threshold for backoff */
bool iso_enabled; /*!< Enable ISO */
bool iso_bqb_test; /*!< Enable ISO BQB test */
bool iso_fra_unseg; /*!< Enable ISO FRA unsegmented */
bool iso_nsfc_en; /*!< Enable ISO NSCF */
uint8_t iso_nsfc_num; /*!< Number of ISO NSCF */
uint8_t iso_buf_count; /*!< Number of ISO buffer */
uint16_t iso_buf_size; /*!< Size of ISO buffer */
uint8_t iso_big_count; /*!< Number of ISO big */
uint16_t iso_bis_count; /*!< Number of ISO bis */
uint8_t iso_bis_per_big; /*!< Number of ISO bis per big */
uint8_t iso_cig_count; /*!< Number of ISO cig */
uint16_t iso_cis_count; /*!< Number of ISO cis */
uint8_t iso_cis_per_cig; /*!< Number of ISO cis per cig */
uint32_t config_magic; /*!< Configuration magic value */
} ble; /*!< Bluetooth LE controller configuration options */
#if defined(CONFIG_BTDM_CTRL_MODE_BLE_ONLY)
#define BTDM_CONTROLLER_MODE_EFF ESP_BT_MODE_BLE
#elif defined(CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY)
#define BTDM_CONTROLLER_MODE_EFF ESP_BT_MODE_CLASSIC_BT
#else
#define BTDM_CONTROLLER_MODE_EFF ESP_BT_MODE_BTDM
#endif // defined(CONFIG_BTDM_CTRL_MODE_BLE_ONLY)
esp_btdm_controller_config_t btdm; /*!< BTDM controller common configuration options */
} esp_bt_controller_config_t;
#if SOC_BT_CLASSIC_SUPPORTED
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() \
{ \
.ble = _BT_CTRL_LE_INIT_CONFIG_DEFAULT(), \
.bredr = _BT_CTRL_BREDR_INIT_CONFIG_DEFAULT(), \
.btdm = \
{ \
.version = BTDM_CONFIG_VERSION, \
.task_stack_size = UC_BT_CTRL_TASK_STACK_SIZE, \
.task_prio = ESP_TASK_BT_CONTROLLER_PRIO, \
.task_run_cpu = CONFIG_BT_CTRL_PINNED_TO_CORE, \
.hci_cmd_num = CONFIG_BT_CTRL_HCI_CMD_NUM, \
.sleep_en = UC_BT_CTRL_SLEEP_ENABLE, \
.version_num = 0, \
.bluetooth_mode = BTDM_CONTROLLER_MODE_EFF, \
.magic = BTDM_CONFIG_MAGIC_VALUE, \
}, \
}
#else
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() \
{ \
.ble = _BT_CTRL_LE_INIT_CONFIG_DEFAULT(), \
.btdm = \
{ \
.version = BTDM_CONFIG_VERSION, \
.task_stack_size = UC_BT_CTRL_TASK_STACK_SIZE, \
.task_prio = ESP_TASK_BT_CONTROLLER_PRIO, \
.task_run_cpu = CONFIG_BT_CTRL_PINNED_TO_CORE, \
.hci_cmd_num = CONFIG_BT_CTRL_HCI_CMD_NUM, \
.sleep_en = UC_BT_CTRL_SLEEP_ENABLE, \
.version_num = 0, \
.bluetooth_mode = BTDM_CONTROLLER_MODE_EFF, \
.magic = BTDM_CONFIG_MAGIC_VALUE, \
}, \
}
#endif // SOC_BT_CLASSIC_SUPPORTED
#if defined(CONFIG_BTDM_CTRL_MODE_BLE_ONLY)
#define BTDM_CONTROLLER_MODE_EFF ESP_BT_MODE_BLE
#elif defined(CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY)
#define BTDM_CONTROLLER_MODE_EFF ESP_BT_MODE_CLASSIC_BT
#else
#define BTDM_CONTROLLER_MODE_EFF ESP_BT_MODE_BTDM
#endif
/**
* @brief Initialize BT controller to allocate task and other resource.
* This function should be called only once, before any other BT functions are called.
* @param cfg: Initial configuration of BT controller. Different from previous version, there's a mode and some
* connection configuration in "cfg" to configure controller work mode and allocate the resource which is needed.
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg);
#if defined(CONFIG_BT_LE_ISO_SUPPORT)
#define DEFAULT_BT_LE_ISO_ENABLED 1
#if defined(CONFIG_BT_LE_ISO_FRA_UNSEG)
#define DEFAULT_BT_LE_ISO_FRA_UNSEG CONFIG_BT_LE_ISO_FRA_UNSEG
#else
#define DEFAULT_BT_LE_ISO_FRA_UNSEG (0)
#endif
#if defined(CONFIG_BT_LE_ISO_NSFC_EN)
#define DEFAULT_BT_LE_ISO_NSFC_EN CONFIG_BT_LE_ISO_NSFC_EN
#define DEFAULT_BT_LE_ISO_NSFC_NUM CONFIG_BT_LE_ISO_NSFC_NUM
#else
#define DEFAULT_BT_LE_ISO_NSFC_EN (0)
#define DEFAULT_BT_LE_ISO_NSFC_NUM (0)
#endif
#define DEFAULT_BT_LE_ISO_BUF_COUNT CONFIG_BT_LE_ISO_BUF_COUNT
#define DEFAULT_BT_LE_ISO_BUF_SIZE CONFIG_BT_LE_ISO_BUF_SIZE
#define DEFAULT_BT_LE_ISO_BIG CONFIG_BT_LE_ISO_BIG
#define DEFAULT_BT_LE_ISO_BIS CONFIG_BT_LE_ISO_BIS
#define DEFAULT_BT_LE_ISO_BIS_PER_BIG CONFIG_BT_LE_ISO_BIS_PER_BIG
#define DEFAULT_BT_LE_ISO_CIG CONFIG_BT_LE_ISO_CIG
#define DEFAULT_BT_LE_ISO_CIS CONFIG_BT_LE_ISO_CIS
#define DEFAULT_BT_LE_ISO_CIS_PER_CIG CONFIG_BT_LE_ISO_CIS_PER_CIG
#else
#define DEFAULT_BT_LE_ISO_ENABLED 0
#define DEFAULT_BT_LE_ISO_FRA_UNSEG 0
#define DEFAULT_BT_LE_ISO_NSFC_EN 0
#define DEFAULT_BT_LE_ISO_NSFC_NUM 0
#define DEFAULT_BT_LE_ISO_BUF_COUNT 0
#define DEFAULT_BT_LE_ISO_BUF_SIZE 0
#define DEFAULT_BT_LE_ISO_BIG 0
#define DEFAULT_BT_LE_ISO_BIS 0
#define DEFAULT_BT_LE_ISO_BIS_PER_BIG 0
#define DEFAULT_BT_LE_ISO_CIG 0
#define DEFAULT_BT_LE_ISO_CIS 0
#define DEFAULT_BT_LE_ISO_CIS_PER_CIG 0
#endif
/**
* @brief Get BT controller is initialised/de-initialised/enabled/disabled
* @return status value
*/
esp_bt_controller_status_t esp_bt_controller_get_status(void);
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() { \
.ble = { \
.config_version = BLE_CONFIG_VERSION, \
.ble_ll_resolv_list_size = CONFIG_BT_LE_LL_RESOLV_LIST_SIZE, \
.ble_hci_evt_hi_buf_count = DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT, \
.ble_hci_evt_lo_buf_count = DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT, \
.ble_ll_sync_list_cnt = DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST, \
.ble_ll_sync_cnt = DEFAULT_BT_LE_MAX_PERIODIC_SYNCS, \
.ble_ll_rsp_dup_list_count = CONFIG_BT_LE_LL_DUP_SCAN_LIST_COUNT, \
.ble_ll_adv_dup_list_count = CONFIG_BT_LE_LL_DUP_SCAN_LIST_COUNT, \
.ble_ll_tx_pwr_dbm = 0, \
.rtc_freq = 32000, \
.ble_ll_sca = CONFIG_BT_LE_LL_SCA, \
.ble_ll_scan_phy_number = BLE_LL_SCAN_PHY_NUMBER_N, \
.ble_ll_conn_def_auth_pyld_tmo = BLE_LL_CONN_DEF_AUTH_PYLD_TMO_N, \
.ble_ll_jitter_usecs = BLE_LL_JITTER_USECS_N, \
.ble_ll_sched_max_adv_pdu_usecs = BLE_LL_SCHED_MAX_ADV_PDU_USECS_N, \
.ble_ll_sched_direct_adv_max_usecs = BLE_LL_SCHED_DIRECT_ADV_MAX_USECS_N, \
.ble_ll_sched_adv_max_usecs = BLE_LL_SCHED_ADV_MAX_USECS_N, \
.ble_scan_rsp_data_max_len = DEFAULT_BT_LE_SCAN_RSP_DATA_MAX_LEN_N, \
.ble_ll_cfg_num_hci_cmd_pkts = BLE_LL_CFG_NUM_HCI_CMD_PKTS_N, \
.ble_ll_ctrl_proc_timeout_ms = BLE_LL_CTRL_PROC_TIMEOUT_MS_N, \
.nimble_max_connections = DEFAULT_BT_LE_MAX_CONNECTIONS, \
.ble_whitelist_size = DEFAULT_BT_NIMBLE_WHITELIST_SIZE, \
.ble_acl_buf_size = DEFAULT_BT_LE_ACL_BUF_SIZE, \
.ble_acl_buf_count = DEFAULT_BT_LE_ACL_BUF_COUNT, \
.ble_hci_evt_buf_size = DEFAULT_BT_LE_HCI_EVT_BUF_SIZE, \
.ble_multi_adv_instances = DEFAULT_BT_LE_MAX_EXT_ADV_INSTANCES, \
.ble_ext_adv_max_size = DEFAULT_BT_LE_EXT_ADV_MAX_SIZE, \
.controller_task_stack_size = UC_BT_CTRL_TASK_STACK_SIZE, \
.controller_task_prio = ESP_TASK_BT_CONTROLLER_PRIO, \
.controller_run_cpu = 0, \
.enable_qa_test = RUN_QA_TEST, \
.enable_bqb_test = RUN_BQB_TEST, \
.enable_tx_cca = DEFAULT_BT_LE_TX_CCA_ENABLED, \
.cca_rssi_thresh = 256 - DEFAULT_BT_LE_CCA_RSSI_THRESH, \
.sleep_en = UC_BT_CTRL_SLEEP_ENABLE, \
.coex_phy_coded_tx_rx_time_limit = DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF, \
.dis_scan_backoff = NIMBLE_DISABLE_SCAN_BACKOFF, \
.ble_scan_classify_filter_enable = 1, \
.main_xtal_freq = CONFIG_XTAL_FREQ, \
.ignore_wl_for_direct_adv = 0, \
.enable_pcl = 0, \
.csa2_select = 1, \
.enable_csr = 0, \
.backoff_rssi = -100, \
.iso_enabled = DEFAULT_BT_LE_ISO_ENABLED, \
.iso_bqb_test = false, \
.iso_fra_unseg = DEFAULT_BT_LE_ISO_FRA_UNSEG, \
.iso_nsfc_en = DEFAULT_BT_LE_ISO_NSFC_EN, \
.iso_nsfc_num = DEFAULT_BT_LE_ISO_NSFC_NUM, \
.iso_buf_count = DEFAULT_BT_LE_ISO_BUF_COUNT, \
.iso_buf_size = DEFAULT_BT_LE_ISO_BUF_SIZE, \
.iso_big_count = DEFAULT_BT_LE_ISO_BIG, \
.iso_bis_count = DEFAULT_BT_LE_ISO_BIS, \
.iso_bis_per_big = DEFAULT_BT_LE_ISO_BIS_PER_BIG, \
.iso_cig_count = DEFAULT_BT_LE_ISO_CIG, \
.iso_cis_count = DEFAULT_BT_LE_ISO_CIS, \
.iso_cis_per_cig = DEFAULT_BT_LE_ISO_CIS_PER_CIG, \
.config_magic = BLE_CONFIG_MAGIC, \
}, \
.btdm = { \
.version = BTDM_CONFIG_VERSION, \
.task_stack_size = UC_BT_CTRL_TASK_STACK_SIZE, \
.task_prio = ESP_TASK_BT_CONTROLLER_PRIO, \
.task_run_cpu = CONFIG_BT_CTRL_PINNED_TO_CORE, \
.hci_cmd_num = CONFIG_BT_CTRL_HCI_CMD_NUM, \
.hci_conn_num = DEFAULT_BT_LE_MAX_CONNECTIONS + DEFAULT_BT_LE_ISO_CIS + DEFAULT_BT_LE_ISO_BIS, \
.sleep_en = UC_BT_CTRL_SLEEP_ENABLE, \
.version_num = 0, \
.bluetooth_mode = BTDM_CONTROLLER_MODE_EFF, \
.magic = BTDM_CONFIG_MAGIC_VALUE, \
}, \
}
/**
* @brief De-initialize BT controller to free resource and delete task.
* You should stop advertising and scanning, as well as
* disconnect all existing connections before de-initializing BT controller.
*
* This function should be called only once, after any other BT functions are called.
* This function is not whole completed, esp_bt_controller_init cannot called after this function.
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_bt_controller_deinit(void);
/**
* @brief Set BLE TX power
* Connection Tx power should only be set after connection created.
* @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc
* @param power_level: Power level(index) corresponding to absolute value(dbm)
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_t power_level);
/**
* @brief Enable BT controller.
* Due to a known issue, you cannot call esp_bt_controller_enable() a second time
* to change the controller mode dynamically. To change controller mode, call
* esp_bt_controller_disable() and then call esp_bt_controller_enable() with the new mode.
* @param mode : the mode(BLE/BT/BTDM) to enable. For compatible of API, retain this argument. This mode must be
* equal as the mode in "cfg" of esp_bt_controller_init().
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode);
/**
* @brief Get BLE TX power
* Connection Tx power should only be get after connection created.
* @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc
* @return >= 0 - Power level, < 0 - Invalid
*/
esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type);
/**
* @brief Disable BT controller
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_bt_controller_disable(void);
/**
* @brief ENHANCED API for Setting BLE TX power
* Connection Tx power should only be set after connection created.
* @param power_type : The enhanced type of which tx power, could set Advertising/Connection/Default and etc
* @param handle : The handle of Advertising or Connection and the value 0 for other enhanced power types.
* @param power_level: Power level(index) corresponding to absolute value(dbm)
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle, esp_power_level_t power_level);
/** @brief esp_vhci_host_callback
* used for vhci call host function to notify what host need to do
*/
typedef struct esp_vhci_host_callback {
void (*notify_host_send_available)(void); /*!< callback used to notify that the host can send packet to controller */
int (*notify_host_recv)(uint8_t *data, uint16_t len); /*!< callback used to notify that the controller has a packet to send to the host*/
} esp_vhci_host_callback_t;
/**
* @brief ENHANCED API of Getting BLE TX power
* Connection Tx power should only be get after connection created.
* @param power_type : The enhanced type of which tx power, could set Advertising/Connection/Default and etc
* @param handle : The handle of Advertising or Connection and the value 0 for other enhanced power types.
* @return >= 0 - Power level, < 0 - Invalid
*/
esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle);
/** @brief esp_vhci_host_check_send_available
* used for check actively if the host can send packet to controller or not.
* @return true for ready to send, false means cannot send packet
*/
bool esp_vhci_host_check_send_available(void);
/**
* @brief Initialize BT controller to allocate task and other resource.
* This function should be called only once, before any other BT functions are called.
* @param cfg: Initial configuration of BT controller. Different from previous version, there's a mode and some
* connection configuration in "cfg" to configure controller work mode and allocate the resource which is needed.
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg);
/** @brief esp_vhci_host_send_packet
* host send packet to controller
*
* Should not call this function from within a critical section
* or when the scheduler is suspended.
*
* @param data the packet point
* @param len the packet length
*/
void esp_vhci_host_send_packet(uint8_t *data, uint16_t len);
/**
* @brief Get BT controller is initialised/de-initialised/enabled/disabled
* @return status value
*/
esp_bt_controller_status_t esp_bt_controller_get_status(void);
/** @brief esp_vhci_host_register_callback
* register the vhci reference callback
* struct defined by vhci_host_callback structure.
* @param callback esp_vhci_host_callback type variable
* @return ESP_OK - success, ESP_FAIL - failed
*/
esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callback);
/**
* @brief De-initialize BT controller to free resource and delete task.
* You should stop advertising and scanning, as well as
* disconnect all existing connections before de-initializing BT controller.
*
* This function should be called only once, after any other BT functions are called.
* This function is not whole completed, esp_bt_controller_init cannot called after this function.
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_bt_controller_deinit(void);
/** @brief esp_bt_controller_mem_release
* release the controller memory as per the mode
*
* This function releases the BSS, data and other sections of the controller to heap. The total size is about 70k bytes.
*
* esp_bt_controller_mem_release(mode) should be called only before esp_bt_controller_init()
* or after esp_bt_controller_deinit().
*
* Note that once BT controller memory is released, the process cannot be reversed. It means you cannot use the bluetooth
* mode which you have released by this function.
*
* If your firmware will later upgrade the Bluetooth controller mode (BLE -> BT Classic or disabled -> enabled)
* then do not call this function.
*
* If the app calls esp_bt_controller_enable(ESP_BT_MODE_BLE) to use BLE only then it is safe to call
* esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT) at initialization time to free unused BT Classic memory.
*
* If the mode is ESP_BT_MODE_BTDM, then it may be useful to call API esp_bt_mem_release(ESP_BT_MODE_BTDM) instead,
* which internally calls esp_bt_controller_mem_release(ESP_BT_MODE_BTDM) and additionally releases the BSS and data
* consumed by the BT/BLE host stack to heap. For more details about usage please refer to the documentation of
* esp_bt_mem_release() function
*
* @param mode : the mode want to release memory
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode);
/**
* @brief Enable BT controller.
* Due to a known issue, you cannot call esp_bt_controller_enable() a second time
* to change the controller mode dynamically. To change controller mode, call
* esp_bt_controller_disable() and then call esp_bt_controller_enable() with the new mode.
* @param mode : the mode(BLE/BT/BTDM) to enable. For compatible of API, retain this argument. This mode must be
* equal as the mode in "cfg" of esp_bt_controller_init().
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode);
/** @brief esp_bt_mem_release
* release controller memory and BSS and data section of the BT/BLE host stack as per the mode
*
* This function first releases controller memory by internally calling esp_bt_controller_mem_release().
* Additionally, if the mode is set to ESP_BT_MODE_BTDM, it also releases the BSS and data consumed by the BT/BLE host stack to heap
*
* Note that once BT memory is released, the process cannot be reversed. It means you cannot use the bluetooth
* mode which you have released by this function.
*
* If your firmware will later upgrade the Bluetooth controller mode (BLE -> BT Classic or disabled -> enabled)
* then do not call this function.
*
* If you never intend to use bluetooth in a current boot-up cycle, you can call esp_bt_mem_release(ESP_BT_MODE_BTDM)
* before esp_bt_controller_init or after esp_bt_controller_deinit.
*
* For example, if a user only uses bluetooth for setting the WiFi configuration, and does not use bluetooth in the rest of the product operation".
* In such cases, after receiving the WiFi configuration, you can disable/deinit bluetooth and release its memory.
* Below is the sequence of APIs to be called for such scenarios:
*
* esp_bluedroid_disable();
* esp_bluedroid_deinit();
* esp_bt_controller_disable();
* esp_bt_controller_deinit();
* esp_bt_mem_release(ESP_BT_MODE_BTDM);
*
* @param mode : the mode whose memory is to be released
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_bt_mem_release(esp_bt_mode_t mode);
/**
* @brief Disable BT controller
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_bt_controller_disable(void);
/**
* @brief Returns random static address or -1 if not present.
* @return ESP_OK - success, other - failed
*/
extern int esp_ble_hw_get_static_addr(esp_ble_addr_t *addr);
/** @brief esp_vhci_host_callback
* used for vhci call host function to notify what host need to do
*/
typedef struct esp_vhci_host_callback {
void (*notify_host_send_available)(void); /*!< callback used to notify that the host can send packet to controller */
int (*notify_host_recv)(uint8_t *data, uint16_t len); /*!< callback used to notify that the controller has a packet to send to the host*/
} esp_vhci_host_callback_t;
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
/**
* @brief dump all log information cached in buffers.
* @param output : true for log dump, false will take no effect
*/
void esp_ble_controller_log_dump_all(bool output);
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
/** @brief esp_vhci_host_check_send_available
* used for check actively if the host can send packet to controller or not.
* @return true for ready to send, false means cannot send packet
*/
bool esp_vhci_host_check_send_available(void);
#ifdef __cplusplus
}
#endif
/** @brief esp_vhci_host_send_packet
* host send packet to controller
*
* Should not call this function from within a critical section
* or when the scheduler is suspended.
*
* @param data the packet point
* @param len the packet length
*/
void esp_vhci_host_send_packet(uint8_t *data, uint16_t len);
/** @brief esp_vhci_host_register_callback
* register the vhci reference callback
* struct defined by vhci_host_callback structure.
* @param callback esp_vhci_host_callback type variable
* @return ESP_OK - success, ESP_FAIL - failed
*/
esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callback);
/** @brief esp_bt_controller_mem_release
* release the controller memory as per the mode
*
* This function releases the BSS, data and other sections of the controller to heap. The total size is about 70k bytes.
*
* esp_bt_controller_mem_release(mode) should be called only before esp_bt_controller_init()
* or after esp_bt_controller_deinit().
*
* Note that once BT controller memory is released, the process cannot be reversed. It means you cannot use the bluetooth
* mode which you have released by this function.
*
* If your firmware will later upgrade the Bluetooth controller mode (BLE -> BT Classic or disabled -> enabled)
* then do not call this function.
*
* If the app calls esp_bt_controller_enable(ESP_BT_MODE_BLE) to use BLE only then it is safe to call
* esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT) at initialization time to free unused BT Classic memory.
*
* If the mode is ESP_BT_MODE_BTDM, then it may be useful to call API esp_bt_mem_release(ESP_BT_MODE_BTDM) instead,
* which internally calls esp_bt_controller_mem_release(ESP_BT_MODE_BTDM) and additionally releases the BSS and data
* consumed by the BT/BLE host stack to heap. For more details about usage please refer to the documentation of
* esp_bt_mem_release() function
*
* @param mode : the mode want to release memory
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode);
/** @brief esp_bt_mem_release
* release controller memory and BSS and data section of the BT/BLE host stack as per the mode
*
* This function first releases controller memory by internally calling esp_bt_controller_mem_release().
* Additionally, if the mode is set to ESP_BT_MODE_BTDM, it also releases the BSS and data consumed by the BT/BLE host stack to heap
*
* Note that once BT memory is released, the process cannot be reversed. It means you cannot use the bluetooth
* mode which you have released by this function.
*
* If your firmware will later upgrade the Bluetooth controller mode (BLE -> BT Classic or disabled -> enabled)
* then do not call this function.
*
* If you never intend to use bluetooth in a current boot-up cycle, you can call esp_bt_mem_release(ESP_BT_MODE_BTDM)
* before esp_bt_controller_init or after esp_bt_controller_deinit.
*
* For example, if a user only uses bluetooth for setting the WiFi configuration, and does not use bluetooth in the rest of the product operation".
* In such cases, after receiving the WiFi configuration, you can disable/deinit bluetooth and release its memory.
* Below is the sequence of APIs to be called for such scenarios:
*
* esp_bluedroid_disable();
* esp_bluedroid_deinit();
* esp_bt_controller_disable();
* esp_bt_controller_deinit();
* esp_bt_mem_release(ESP_BT_MODE_BTDM);
*
* @param mode : the mode whose memory is to be released
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_bt_mem_release(esp_bt_mode_t mode);
/**
* @brief Returns random static address or -1 if not present.
* @return ESP_OK - success, other - failed
*/
extern int esp_ble_hw_get_static_addr(esp_ble_addr_t *addr);
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
/**
* @brief dump all log information cached in buffers.
* @param output : true for log dump, false will take no effect
*/
void esp_ble_controller_log_dump_all(bool output);
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
#ifdef __cplusplus
}
#endif
#endif /* __ESP_BT_H__ */
#endif /* __ESP_BT_H__ */

View File

@@ -6,355 +6,4 @@
#pragma once
#include "sdkconfig.h"
#ifdef __cplusplus
extern "C" {
#endif
// @brief HCI VS Commands for Espressif's Bluetooth Host
//
// @note The following vendor-specific HCI commands are exclusively for Espressif's Bluetooth Host (ESP-Bluedroid Host or ESP-NimBLE Host).
// If you are using a non-ESP host or HCI UART, these commands will remain disabled unless the initialization function is explicitly called from the application.
// Note, these init functions as well as these additional HCI VS commands are intended for Espressif's Bluetooth Host use only.
// Application developers **should not** call the init functions in their applications.
//
/**
* @brief Config scanning duplicate exceptional list (OCF: 0x0108)
*
* @note The init function is `advFilter_stack_eanbleDupExcListCmd(true)`
*/
#define ESP_BT_VS_CONFIG_DUP_EXC_LIST_OCF (0x0108)
/**
* @brief Update exception list cmd parameters
*/
struct bt_hci_vs_update_exc_list {
uint8_t subcode; /*!< Add, remove or clear exception list */
uint32_t type; /*!< device type */
uint8_t device_info[6]; /*!< device information */
};
/**
* @brief Enable/disable advertising report flow control (OCF: 0x0109)
*
* @note The init function is `scan_stack_enableAdvFlowCtrlVsCmd(true)`
*/
#define ESP_BT_VS_SET_ADV_REPORT_FLOW_CTRL_OCF (0x0109)
/**
* @brief Init ADV flow control cmd parameters
*/
struct bt_hci_vs_init_adv_flow_ctrl {
uint8_t enable; /*!< Enable ADV flow control */
uint16_t num; /*!< ADV buffer maximum value */
uint16_t adv_lost_threshold; /*!< ADV lost event triggered threshold */
};
/**
* @brief Update the number of advertising report in ADV flow control (OCF: 0x010A)
*
* @note The init function is `scan_stack_enableAdvFlowCtrlVsCmd(true)`
*/
#define ESP_BT_VS_UPD_ADV_REPORT_FLOW_CTRL_NUM_OCF (0x010a)
/**
* @brief Update ADV flow control cmd parameters
*/
struct bt_hci_vs_update_adv_flow_ctrl {
uint16_t num; /*!< The number of ADV report processed */
};
/**
* @brief Clear legacy advertising (same as HCI_LE_Clear_Advertising_Sets) (OCF: 0x010C)
*
* @note The init function is `adv_stack_enableClearLegacyAdvVsCmd(true)`
*/
#define ESP_BT_VS_CLR_LEGACY_ADV_OCF (0x010c)
/**
* @brief Clear legacy ADV cmd parameters
*/
struct bt_hci_vs_ble_clr_legacy_adv {
// no parameters
};
/**
* @brief Set parameters of duplicate list (OCF: 0x010D)
*
* @note The init function is `advFilter_stack_eanbleDupExcListCmd(true)`
*/
#define ESP_BT_VS_SET_DUP_LIST_PARAMS_OCF (0x010d)
/**
* @brief Set duplicate list cmd parameters
*/
struct bt_hci_vs_ble_set_dup_params {
uint8_t dup_mode; /*!< Duplicate mode */
uint8_t dup_ad_type; /*!< Duplicate data type */
uint16_t ring_list_max_num; /*!< Duplicate list size */
};
/**
* @brief Enable/disable duplicate and exception list (OCF: 0x010E)
*
* @note The init function is `advFilter_stack_eanbleDupExcListCmd(true)`
*/
#define ESP_BT_VS_ENABLE_DUP_EXC_LIST_OCF (0x010e)
/**
* @brief Enable duplicate and exception list cmd parameters
*/
struct bt_hci_vs_ble_enable_dup_exc {
uint8_t enable; /*!< Enable or disable */
uint8_t ring_list_reset; /*!< Reset list */
};
/**
* @brief Enable optimization of multiple connections (OCF: 0x010F)
*
* @note The init function is `arr_stack_enableMultiConnVsCmd(true)`
*/
#define ESP_BT_VS_ENABLE_ARRANGEMENT_OCF (0x010f)
/**
* @brief Multiple connections optimization cmd parameters
*/
struct bt_hci_vs_ble_enable_arrangement {
uint32_t common_factor; /*!< The greatest common factor of connection interval */
uint8_t enable; /*!< Enable or disable */
};
/**
* @brief Set scheduling length for a certain role (OCF: 0x0110)
*
* @note The init function is `arr_stack_enableMultiConnVsCmd(true)`
*/
#define ESP_BT_VS_SET_SCHED_ROLE_LEN_OCF (0x0110)
/**
* @brief Scheduling length cmd parameters
*/
struct bt_hci_vs_ble_set_sched_role_len {
uint8_t role; /*!< BLE role; 0: central; 1: peripheral */
uint32_t len; /*!< Length is us */
};
/**
* @brief Set RSSI threshold for automatic power control (OCF: 0x0111)
*
* @note The init function is `pcl_stack_enableSetRssiThreshVsCmd(true)`
*/
#define ESP_BT_VS_SET_PCL_RSSI_THRESH_OCF (0x0111)
/**
* @brief PCL RSSI threshold cmd parameters
*/
struct bt_hci_vs_ble_set_pcl_rssi_thresh {
uint16_t conn_handle; /*!< Connection handle */
uint8_t rssi_thresh_min_1M; /*!< Lower limit for 1M */
uint8_t rssi_thresh_max_1M; /*!< Upper limit for 1M */
uint8_t rssi_thresh_min_2M; /*!< Lower limit for 2M */
uint8_t rssi_thresh_max_2M; /*!< Upper limit for 2M */
uint8_t rssi_thresh_min_s2coded; /*!< Lower limit for s2 coded */
uint8_t rssi_thresh_max_s2coded; /*!< Upper limit for s2 coded */
uint8_t rssi_thresh_min_s8coded; /*!< Lower limit for s8 coded */
uint8_t rssi_thresh_max_s8coded; /*!< Upper limit for s8 coded */
};
/**
* @brief Enable/disable channel selection algorithm #2 (OCF: 0x0112)
*
* @note The init function is `chanSel_stack_enableSetCsaVsCmd(true)`
*/
#define ESP_BT_VS_ENABLE_CSA2_OCF (0x0112)
/**
* @brief Enable/disable channel selection algorithm #2 cmd parameters
*/
struct bt_hci_vs_ble_csa_enable {
uint8_t csa2_select; /*!< Select CSA2 */
};
/**
* @brief Set parameters of controller logs (OCF: 0x0114)
*
* @note The init function is `log_stack_enableLogsRelatedVsCmd(true)`
*/
#define ESP_BT_VS_SET_LOG_PARAMS_OCF (0x0114)
/**
* @brief Controller logs cmd parameters
*/
struct bt_hci_vs_ble_log_params {
uint8_t type; /*!< Operation type */
uint32_t output_enable; /*!< Enable/disable output */
uint8_t buffer_optoin /*!< Select log buffers */
};
/**
* @brief Set BLE vendor events mask (OCF: 0x0116)
*
* @note The init function is `hci_stack_enableSetVsEvtMaskVsCmd(true)`
*/
#define ESP_BT_VS_SET_LE_VENDOR_EVTS_MASK_OCF (0x0116)
/**
* @brief Set BLE vendor events mask cmd parameters
*/
struct bt_hci_vs_ble_set_vs_evts_mask {
uint32_t evt_masks; /*!< BLE vendor events Mask */
};
/**
* @brief Set peer sleep clock accuracy to a constant value (OCF: 0x0118)
*
* @note The init function is `winWiden_stack_enableSetConstPeerScaVsCmd(true)`
*/
#define ESP_BT_VS_SET_CONST_PEER_SCA_OCF (0x0118)
/**
* @brief Peer constant SCA cmd parameters
*/
struct bt_hci_vs_ble_set_const_peer_sca {
uint16_t peer_sca; /*!< Peer SCA */
};
// @brief HCI VS Events for Espressif's Bluetooth Host
//
// @note The following HCI VS events are exclusively for Espressif's Bluetooth Host (ESP-Bluedroid Host or ESP-NimBLE Host).
// If you are using a non-ESP host or HCI UART, these events will remain disabled unless the initialization function is explicitly called from the application.
// Note, these init functions as well as these additional HCI VS events are intended for Espressif's Bluetooth Host use only.
// Application developers **should not** call the init functions in their applications.
//
/**
* @brief BLE Scan/Connect Request, Aux Connect Response received event (EVTCODE: 0xFF, SUBCODE: 0xC0)
*
* @note The init function is `adv_stack_enableScanReqRxdVsEvent(true)`
*/
#define ESP_BT_VS_LE_CONN_SCAN_REQ_RXED_EVT_SUBCODE (0xC0)
/**
* @brief BLE Scan/Connect Request, Aux Connect Response received event parameters
*/
struct bt_hci_vs_le_conn_scan_req_rxed_evt {
uint8_t evt_type; /*!< Event type; 0: SCAN_REQ; 1: CONN_IND */
uint8_t handle; /*!< Advertisement handle */
uint8_t peer_addr_type; /*!< Peer address type */
uint8_t peer_addr[6]; /*!< Peer address */
};
/**
* @brief BLE Channel Map Update Completion event (EVTCODE: 0xFF, SUBCODE: 0xC1)
*
* @note The init function is `conn_stack_enableChanMapUpdCompVsEvent(true)`
*/
#define ESP_BT_VS_LE_CHAN_UPDATE_COMP_EVT_SUBCODE (0xC1)
/**
* @brief BLE Channel Map Update Completion event parameters
*/
struct bt_hci_vs_le_chan_update_comp_evt {
uint8_t status; /*!< Controller error code */
uint16_t handle; /*!< Connection handle */
uint8_t ch_map[5]; /*!< Updated channel map */
};
/**
* @brief BLE Wakeup From Sleep event (EVTCODE: 0xFF, SUBCODE: 0xC3)
*
* @note The init function is `sleep_stack_enableWakeupVsEvent(true)`
*/
#define ESP_BT_VS_LE_SLEEP_WAKEUP_EVT_SUBCODE (0xC3)
/**
* @brief BLE wakeup event parameters
*/
struct bt_hci_vs_le_sleep_wakeup_evt {
// no parameters
};
/**
* @brief BLE advertising report lost event for flow control (EVTCODE: 0x3E, SUBCODE: 0xF0)
*
* @note The init function is `scan_stack_enableAdvFlowCtrlVsCmd(true)`
*/
#define ESP_BT_VS_LE_ADV_LOST_EVT_SUBCODE (0xF0)
/**
* @brief ADV lost event parameters
*/
struct bt_hci_vs_le_adv_lost_evt {
uint32_t nb_lost; /*!< The number of ADV report discarded */
};
//
// @brief HCI VS Commands for Espressif's Internal-Use Debugging
//
// @note The following HCI VS debugging commands are implemented in Bluetooth controller pre-compiled libraries.
// These commands are not linked into the application binary, unless the function `esp_ble_internalTestFeaturesEnable(true)`is called from the application.
// They are intended for Espressif's internal use only. Application developers **should not** call `esp_ble_internalTestFeaturesEnable(true)` in their applications.
//
#define ESP_BT_VS_CFG_TEST_RELATED_OCF (0x0113)
#define ESP_BT_VS_CFG_TEST_ENABLE_SUBCMD (0X00)
#define ESP_BT_VS_CFG_TEST_ENABLE_ADV_DELAY_SUBCMD (0X01)
#define ESP_BT_VS_CFG_TEST_SET_PREF_CODED_SUBCMD (0X02)
#define ESP_BT_VS_CFG_TEST_SET_DEFAULT_PRIV_MODE_SUBCMD (0X03)
#define ESP_BT_VS_CFG_TEST_SET_SCAN_FOREVER_SUBCMD (0X04)
#define ESP_BT_VS_CFG_TEST_SET_EXPECTED_PEER_SUBCMD (0X05)
#define ESP_BT_VS_CFG_TEST_GET_ADV_TXED_CNT_SUBCMD (0X06)
#define ESP_BT_VS_CFG_TEST_GET_SCAN_RXED_CNT_SUBCMD (0X07)
#define ESP_BT_VS_CFG_TEST_SET_TXPWR_LVL_SUBCMD (0X08)
#define ESP_BT_VS_CFG_TEST_GET_TXPWR_LVL_SUBCMD (0X09)
#define ESP_BT_VS_CFG_TEST_SET_TXPWR_LVL_ENH_SUBCMD (0X0a)
#define ESP_BT_VS_CFG_TEST_GET_TXPWR_LVL_ENH_SUBCMD (0X0b)
#define ESP_BT_VS_CFG_TEST_IGNORE_WL_FOR_DIR_ADV_SUBCMD (0X0c)
#define ESP_BT_VS_CFG_TEST_GET_ADV_RXED_RSSI_SUBCMD (0X0d)
#define ESP_BT_VS_CFG_TEST_ENABLE_CCA_SUBCMD (0X0e)
#define ESP_BT_VS_CFG_TEST_SET_CCA_WIN_SUBCMD (0X0f)
#define ESP_BT_VS_CFG_TEST_READ_CCA_DATA_SUBCM (0X10)
#define ESP_BT_VS_CFG_TEST_CLEAR_RAND_ADDR_SUBCMD (0X11)
#define ESP_BT_VS_CFG_TEST_GET_MAX_TXPWR_SUBCMD (0X12)
#define ESP_BT_VS_CFG_TEST_GET_TXPWR_RANGE_SUBCMD (0X13)
#define ESP_BT_VS_CFG_TEST_SET_SCAN_AA_SUBCMD (0X14)
#define ESP_BT_VS_CFG_TEST_SET_ADV_AA_SUBCMD (0X15)
#define ESP_BT_VS_CFG_TEST_SET_SCAN_CHAN_SUBCMD (0X16)
#define ESP_BT_VS_CFG_TEST_SKIP_LIGHT_SLEEP_CHECK_SUBCMD (0X17)
#define ESP_BT_VS_CFG_TEST_SET_WAKEUP_OVERHEAD_SUBCMD (0X18)
#define ESP_BT_VS_CFG_TEST_GET_ADV_MIN_ITVL_SUBCMD (0X19)
#define ESP_BT_VS_CFG_TEST_GET_CTRL_STATUS_SUBCMD (0X1a)
#define ESP_BT_VS_CFG_TEST_SET_CONN_PHY_TXPWR_SUBCMD (0X1b)
#define ESP_BT_VS_CFG_TEST_GET_CONN_PHY_TXPWR_SUBCMD (0X1c)
#define ESP_BT_VS_CFG_TEST_GET_RXBUF_EMPTY_CNT_SUBCMD (0X1d)
#define ESP_BT_VS_CFG_TEST_RESTART_SUBCMD (0X1e)
#define ESP_BT_VS_CFG_TEST_ENABLE_RECODE_RX_STATE_SUBCMD (0X1f)
#define ESP_BT_VS_CFG_TEST_GET_RECODE_CNT_SUBCMD (0X20)
#define ESP_BT_VS_CFG_TEST_CLR_RECODE_CNT_SUBCMD (0X21)
#define ESP_BT_VS_CFG_TEST_GET_CTRL_COMPILE_VER_SUBCMD (0X24)
#define ESP_BT_VS_CFG_TEST_SET_AUX_ADV_OFFSET_SUBCMD (0X25)
#define ESP_BT_VS_CFG_TEST_INIT_FLEXIBLE_MODE_SUBCMD (0X26)
#define ESP_BT_VS_CFG_TEST_ENABLE_FLEXIBLE_MODE_SUBCMD (0X27)
#define ESP_BT_VS_CFG_TEST_SET_FLEXIBLE_CONN_ERR_SUBCMD (0X28)
#define ESP_BT_VS_CFG_TEST_SET_FLEXIBLE_ADV_ERR_SUBCMD (0X29)
#define ESP_BT_VS_CFG_TEST_SET_FLEXIBLE_SCAN_ERR_SUBCMD (0X2a)
#define ESP_BT_VS_CFG_TEST_GET_TXED_CRCERR_SUBCMD (0X2c)
#define ESP_BT_VS_CFG_TEST_GET_BACKOFF_UPLIMIT_SUBCMD (0X2d)
#define ESP_BT_VS_CFG_TEST_GET_RXED_ADV_ADI_SUBCMD (0X2f)
#define ESP_BT_VS_CFG_TEST_SET_SCH_RAND_MODE_SUBCMD (0X30)
#define ESP_BT_VS_CFG_TEST_SET_RX_SENS_THRESH_SUBCMD (0X31)
#define ESP_BT_VS_CFG_TEST_CHECK_MSYS_BUF_SUBCMD (0X32)
#define ESP_BT_VS_CFG_TEST_UPDATE_BLE_TIMER_SUBCMD (0X33)
#define ESP_BT_VS_CFG_TEST_UPDATE_BLE_RTC_SUBCMD (0X34)
#define ESP_BT_VS_CFG_TEST_SET_LOCKED_MEM_NUM_SUBCMD (0X35)
#define ESP_BT_VS_CFG_TEST_ALLOW_MEM_ALLOC_SUBCMD (0X36)
#define ESP_BT_VS_CFG_TEST_SET_SCH_RAND_INFO_PTR_SUBCMD (0X37)
#define ESP_BT_VS_CFG_TEST_SET_DIAG_IO_SUBCMD (0X38)
#define ESP_BT_VS_CFG_TEST_SET_AGC_MAX_GAIN_SUBCMD (0X39)
#define ESP_BT_VS_CFG_TEST_ENABLE_CHAN_ASSESS_SUBCMD (0X40)
#define ESP_BT_VS_CFG_TEST_SET_BACKOFF_UPLIMIT_SUBCMD (0X41)
#define ESP_BT_VS_CFG_TEST_SET_CONN_TOP_PRIO_RESV_THRESH_SUBCMD (0X42)
#define ESP_BT_VS_CFG_TEST_SET_TEST_EVT_MSK_SUBCMD (0X43)
#define ESP_BT_VS_CFG_TEST_GET_WAKEUP_TIMEOUT_SUBCMD (0X45)
#define ESP_BT_VS_CFG_TEST_RELATED_SUBCMD_MAX (0Xff)
//
// @brief HCI VS Events for Espressif's Internal-Use Debugging
//
// @note The following HCI VS debugging events are implemented in Bluetooth controller pre-compiled libraries.
// These events are not linked into the application binary, unless the function `esp_ble_internalTestFeaturesEnable(true)`is called from the application.
// Application developers **should not** call `esp_ble_internalTestFeaturesEnable(true)` in their applications.
//
#define ESP_BT_VS_LE_RUNNING_STATUS_EVT_SUBCODE (0xC3)
#ifdef __cplusplus
}
#endif
#include "../../common/btdm_le_vs.h"

View File

@@ -16,13 +16,13 @@
#include "btdm_user_cfg.h"
#if UC_BT_CTRL_BR_EDR_IS_ENABLE
#include "bredr_user_cfg.h"
#endif
#if SOC_BT_CLASSIC_SUPPORTED
#include "../../common/btdm_bredr.h"
#endif // SOC_BT_CLASSIC_SUPPORTED
#if UC_BT_CTRL_BLE_IS_ENABLE
#include "ble_user_cfg.h"
#endif /* UC_BT_CTRL_BLE_IS_ENABLE */
#if SOC_BLE_SUPPORTED
#include "../../common/btdm_le.h"
#endif /* SOC_BLE_SUPPORTED */
#ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART
#include "driver/uart.h"
@@ -52,11 +52,6 @@ typedef enum {
ESP_BT_CONTROLLER_STATUS_NUM, /*!< Controller is in disabled state */
} esp_bt_controller_status_t;
#if (UC_BT_CTRL_BR_EDR_IS_ENABLE)
#define ESP_BREDR_CTRL_CONFIG_MAGIC_VAL 0x5A5AA5A5
#define ESP_BREDR_CTRL_CONFIG_VERSION 0x20250327
#endif // #if (UC_BT_CTRL_BR_EDR_IS_ENABLE)
/**
* @brief BLE tx power type
* ESP_BLE_PWR_TYPE_CONN_HDL0-8: for each connection, and only be set after connection completed.
@@ -67,7 +62,7 @@ typedef enum {
* if neither in scan mode nor in adv mode, it will use this default value.
* If none of power type is set, system will use ESP_PWR_LVL_P3 as default for ADV/SCAN/CONN0-9.
*/
typedef enum {
typedef enum esp_ble_power_type {
ESP_BLE_PWR_TYPE_CONN_HDL0 = 0, /*!< For connection handle 0 */
ESP_BLE_PWR_TYPE_CONN_HDL1 = 1, /*!< For connection handle 1 */
ESP_BLE_PWR_TYPE_CONN_HDL2 = 2, /*!< For connection handle 2 */
@@ -86,7 +81,7 @@ typedef enum {
/**
* @brief Bluetooth TX power level(index), it's just a index corresponding to power(dbm).
*/
typedef enum {
typedef enum esp_power_level {
ESP_PWR_LVL_N24 = 0, /*!< Corresponding to -24dbm */
ESP_PWR_LVL_N21 = 1, /*!< Corresponding to -21dbm */
ESP_PWR_LVL_N18 = 2, /*!< Corresponding to -18dbm */
@@ -109,26 +104,6 @@ typedef enum {
ESP_PWR_LVL_INVALID = 0xFF, /*!< Indicates an invalid value */
} esp_power_level_t;
/**
* @brief The enhanced type of which tx power, could set Advertising/Connection/Default and etc.
*/
typedef enum {
ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT = 0,
ESP_BLE_ENHANCED_PWR_TYPE_ADV,
ESP_BLE_ENHANCED_PWR_TYPE_SCAN,
ESP_BLE_ENHANCED_PWR_TYPE_INIT,
ESP_BLE_ENHANCED_PWR_TYPE_CONN,
ESP_BLE_ENHANCED_PWR_TYPE_MAX,
} esp_ble_enhanced_power_type_t;
/**
* @brief BR/EDR audio data transport path
*/
typedef enum {
ESP_SCO_DATA_PATH_HCI = 0, /*!< data over HCI transport */
ESP_SCO_DATA_PATH_PCM = 1, /*!< data over PCM interface */
} esp_sco_data_path_t;
/**
* @brief Address type and address value.
*/
@@ -137,17 +112,6 @@ typedef struct {
uint8_t val[6]; /*!< Array containing the 6-byte Bluetooth address value */
} esp_ble_addr_t;
/**
* @brief Select buffers
*/
typedef enum {
ESP_BLE_LOG_BUF_HCI = 0x02,
ESP_BLE_LOG_BUF_CONTROLLER = 0x05,
} esp_ble_log_buf_t;
#define BLE_CONFIG_VERSION 0x20241029
#define BLE_CONFIG_MAGIC 0x5A5AA5A5
#define BTDM_CONFIG_VERSION 0x20260127
#define BTDM_CONFIG_MAGIC_VALUE 0x5a5aa5a5
@@ -155,74 +119,6 @@ typedef enum {
************************************************************************
*/
/**
* @brief mempool handle type used in BR/EDR controller
*/
typedef void * orca_mempool_t;
/**
* @brief mempool operations used in BR/EDR controller
*/
struct orca_mempool_ops {
orca_mempool_t (*create_with_pool)(void *mem, size_t pool_bytes, size_t max_bytes); /*!< mempool construction */
void (*destroy)(orca_mempool_t mempool); /*!< mempool destruction */
void *(*malloc)(orca_mempool_t mempool, size_t size); /*!< allocate memory from mempool */
void (*free)(orca_mempool_t mempool, void *ptr); /*!< release memory */
};
/**
* @brief BR/EDR controller configuration options
*/
typedef struct {
/*
* Following parameters can not be configured runtime when call esp_bt_controller_init()
* They will be overwritten by constant values from menuconfig options or from macros.
* So, do not modify the value when esp_bt_controller_init()
*/
uint32_t bredr_version; /*!< version number of the defined structure */
/*
* Following parameters can be configured runtime, when call esp_bt_controller_init()
*/
uint8_t sleep_mode; /*!< controller sleep mode */
uint8_t bt_test_mode_en; /*!< enable br/edr test mode */
uint8_t acl_cca_en; /*!< Enable BR/EDR ACL Transmit Clear Channel Assessment (TX CCA) */
int8_t cca_rssi_thr; /*!< BR/EDR RSSI threshold for Transmit Clear Channel Assessment (CCA) */
uint8_t max_acl_conn; /*!< Maximum number of BR/EDR ACL connections. Configurable in menuconfig */
uint8_t max_sync_conn; /*!< Maximum number of BR/EDR synchronous connections. Configurable in menuconfig */
uint8_t cpb_tx_link_num; /*!< BR/EDR CPB TX link number */
uint8_t cpb_rx_link_num; /*!< BR/EDR CPB RX link number */
uint8_t bt_sco_datapath; /*!< SCO data path, i.e. HCI(0) or PCM(1) */
uint8_t hci_tl_type; /*!< HCI transport layer, UART, VHCI, etc */
void *hci_tl_funcs; /*!< hci transport functions used, must be set when hci_tl_type is UART */
uint32_t cfg_mask; /*!< reserved */
uint32_t hw_target_code; /*!< hardware target */
int8_t acl_min_tx_pwr; /*!< Default transmit power for ACL minimum */
int8_t acl_max_tx_pwr; /*!< Default transmit power for ACL maximum */
int8_t apb_tx_pwr; /*!< Default transmit power for APB */
int8_t page_tx_pwr; /*!< Default transmit power for Page */
int8_t pscan_tx_pwr; /*!< Default transmit power for Page Scan */
int8_t iscan_tx_pwr; /*!< Default transmit power for Inquiry Scan */
int8_t cpb_tx_pwr; /*!< Default transmit power for CPB TX */
int8_t strain_tx_pwr; /*!< Default transmit power for Synchronization Train */
uint8_t rf_hw_type; /*!< RF hardware type */
uint8_t static_aclu_tx_buf_nb; /*!< Static ACL-U TX buffer number */
uint8_t dynamic_aclu_tx_buf_nb; /*!< Dynamic ACL-U TX buffer number */
uint8_t aclu_rx_buf_nb; /*!< ACL-U RX buffer number */
uint8_t sync_tx_buf_nb; /*!< SCO TX buffer number */
uint8_t sync_rx_buf_nb; /*!< SCO RX buffer number */
uint8_t esco_ev4_supp : 1; /*!< eSCO support EV4 packet type */
uint8_t esco_ev5_supp : 1; /*!< eSCO support EV5 packet type */
uint8_t esco_ev3_2_supp : 1; /*!< eSCO support 2-EV3 packet type */
uint8_t esco_ev3_3_supp : 1; /*!< eSCO support 3-EV3 packet type */
uint8_t esco_3_slots_supp : 1; /*!< eSCO support 2-EV5 and/or 3-EV5 packet type */
uint8_t bt_legacy_auth_vs_evt :1; /*!< 1 if BR/EDR Legacy Authentication Vendor Specific Event is enabled, which is required to protect from BIAS attack; 0 otherwise. Configurable in menuconfig */
uint8_t inq_filter_en : 1; /*!< Enable inquiry result filter */
uint8_t dtm_en :1; /*!< BR/EDR direct test mode */
uint32_t mempool_size; /*!< Required mempool size used in BR/EDR controller */
struct orca_mempool_ops *mempool_ops; /*!< mempool operations used in BR/EDR controller */
uint32_t bredr_magic; /*!< Magic number */
} esp_bredr_controller_config_t;
/**
* @brief BTDM controller common configuration options
*/
@@ -232,12 +128,11 @@ typedef struct {
uint8_t task_prio; /*!< Priority of the Bluetooth controller task */
uint8_t task_run_cpu; /*!< CPU number on which the Bluetooth controller task runs */
uint8_t hci_cmd_num; /*!< HCI command buffer number */
uint8_t hci_conn_num; /*!< HCI level connection number */
uint8_t sleep_en; /*!< Enable sleep functionality */
uint8_t version_num; /*!< Hardware version number of this chip */
uint8_t bluetooth_mode; /*!< Controller mode: BR/EDR, BLE or Dual Mode */
uint32_t magic; /*!< Magic number for configuration validation */
} esp_btdm_controller_config_t;
} esp_bt_ctrl_btdm_config_t;
/**
* @brief Controller config options, depend on config mask.
@@ -245,81 +140,11 @@ typedef struct {
* some options or parameters of some functions enabled by config mask.
*/
typedef struct {
/**
* @brief Bluetooth LE controller configuration options
*/
struct {
uint32_t config_version; /*!< Version number of the defined structure */
uint16_t ble_ll_resolv_list_size; /*!< Size of the resolvable private address list */
uint16_t ble_hci_evt_hi_buf_count; /*!< Count of high buffers for HCI events */
uint16_t ble_hci_evt_lo_buf_count; /*!< Count of low buffers for HCI events */
uint8_t ble_ll_sync_list_cnt; /*!< Number of synchronization lists */
uint8_t ble_ll_sync_cnt; /*!< Number of synchronizations */
uint16_t ble_ll_rsp_dup_list_count; /*!< Count of duplicated lists for scan response packets */
uint16_t ble_ll_adv_dup_list_count; /*!< Count of duplicated lists for advertising packets */
uint8_t ble_ll_tx_pwr_dbm; /*!< Tx power (transmit power) in dBm */
uint64_t rtc_freq; /*!< Frequency of RTC (Real-Time Clock) */
uint16_t ble_ll_sca; /*!< Sleep Clock Accuracy (SCA) parameter */
uint8_t ble_ll_scan_phy_number; /*!< Number of PHYs supported for scanning */
uint16_t ble_ll_conn_def_auth_pyld_tmo; /*!< Connection default authentication payload timeout */
uint8_t ble_ll_jitter_usecs; /*!< Jitter time in microseconds */
uint16_t ble_ll_sched_max_adv_pdu_usecs; /*!< Maximum time in microseconds for advertising PDU scheduling */
uint16_t ble_ll_sched_direct_adv_max_usecs; /*!< Maximum time in microseconds for directed advertising scheduling */
uint16_t ble_ll_sched_adv_max_usecs; /*!< Maximum time in microseconds for advertising scheduling */
uint16_t ble_scan_rsp_data_max_len; /*!< Maximum length of scan response data */
uint8_t ble_ll_cfg_num_hci_cmd_pkts; /*!< Number of HCI command packets that can be queued */
uint32_t ble_ll_ctrl_proc_timeout_ms; /*!< Control processing timeout in milliseconds */
uint16_t nimble_max_connections; /*!< Maximum number of connections supported */
uint8_t ble_whitelist_size; /*!< Size of the white list */
uint16_t ble_acl_buf_size; /*!< Buffer size of ACL (Asynchronous Connection-Less) data */
uint16_t ble_acl_buf_count; /*!< Buffer count of ACL data */
uint16_t ble_hci_evt_buf_size; /*!< Buffer size for HCI event data */
uint16_t ble_multi_adv_instances; /*!< Number of advertising instances */
uint16_t ble_ext_adv_max_size; /*!< Maximum size of extended advertising data */
uint16_t controller_task_stack_size; /*!< Size of Bluetooth controller task stack, to be removed */
uint8_t controller_task_prio; /*!< Priority of the Bluetooth task, to be removed */
uint8_t controller_run_cpu; /*!< CPU number on which the Bluetooth controller task runs, to be removed */
uint8_t enable_qa_test; /*!< Enable for QA test */
uint8_t enable_bqb_test; /*!< Enable for BQB test */
uint8_t enable_tx_cca; /*!< Enable Clear Channel Assessment (CCA) when transmitting */
uint8_t cca_rssi_thresh; /*!< RSSI threshold for CCA */
uint8_t sleep_en; /*!< Enable sleep functionality */
uint8_t coex_phy_coded_tx_rx_time_limit; /*!< Coexistence PHY coded TX and RX time limit */
uint8_t dis_scan_backoff; /*!< Disable scan backoff */
uint8_t ble_scan_classify_filter_enable; /*!< Enable classification filter for BLE scan */
uint8_t cca_drop_mode; /*!< CCA drop mode */
int8_t cca_low_tx_pwr; /*!< Low TX power setting for CCA */
uint8_t main_xtal_freq; /*!< Main crystal frequency */
uint8_t ignore_wl_for_direct_adv; /*!< Ignore the white list for directed advertising */
uint8_t enable_pcl; /*!< Enable power control */
uint8_t csa2_select; /*!< Select CSA2 */
uint8_t enable_csr; /*!< Enable connection subrate */
int8_t backoff_rssi; /*!< Set the lowest rssi threshold for backoff */
bool iso_enabled; /*!< Enable ISO */
bool iso_bqb_test; /*!< Enable ISO BQB test */
bool iso_fra_unseg; /*!< Enable ISO FRA unsegmented */
bool iso_nsfc_en; /*!< Enable ISO NSCF */
uint8_t iso_nsfc_num; /*!< Number of ISO NSCF */
uint8_t iso_buf_count; /*!< Number of ISO buffer */
uint16_t iso_buf_size; /*!< Size of ISO buffer */
uint8_t iso_big_count; /*!< Number of ISO big */
uint16_t iso_bis_count; /*!< Number of ISO bis */
uint8_t iso_bis_per_big; /*!< Number of ISO bis per big */
uint8_t iso_cig_count; /*!< Number of ISO cig */
uint16_t iso_cis_count; /*!< Number of ISO cis */
uint8_t iso_cis_per_cig; /*!< Number of ISO cis per cig */
uint32_t config_magic; /*!< Configuration magic value */
} ble; /*!< Bluetooth LE controller configuration options */
/**
* @brief Bluetooth Classic controller configuration options
*/
esp_bredr_controller_config_t bredr; /*!< Bluetooth Classic controller configuration options */
/**
* @brief Bluetooth controller common configuration options
*/
esp_btdm_controller_config_t btdm; /*!< Bluetooth controller common configuration options */
esp_bt_ctrl_le_config_t ble; /*!< Bluetooth LE controller configuration options */
#if SOC_BT_CLASSIC_SUPPORTED
esp_bt_ctrl_bredr_config_t bredr; /*!< Bluetooth Classic controller configuration options */
#endif // SOC_BT_CLASSIC_SUPPORTED
esp_bt_ctrl_btdm_config_t btdm; /*!< Bluetooth controller common configuration options */
} esp_bt_controller_config_t;
#if defined(CONFIG_BTDM_CTRL_MODE_BLE_ONLY)
@@ -328,329 +153,44 @@ typedef struct {
#define BTDM_CONTROLLER_MODE_EFF ESP_BT_MODE_CLASSIC_BT
#else
#define BTDM_CONTROLLER_MODE_EFF ESP_BT_MODE_BTDM
#endif
#endif // defined(CONFIG_BTDM_CTRL_MODE_BLE_ONLY)
#if defined(CONFIG_BT_LE_ISO_SUPPORT)
#define DEFAULT_BT_LE_ISO_ENABLED 1
#if defined(CONFIG_BT_LE_ISO_FRA_UNSEG)
#define DEFAULT_BT_LE_ISO_FRA_UNSEG CONFIG_BT_LE_ISO_FRA_UNSEG
#if SOC_BT_CLASSIC_SUPPORTED
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() \
{ \
.ble = _BT_CTRL_LE_INIT_CONFIG_DEFAULT(), \
.bredr = _BT_CTRL_BREDR_INIT_CONFIG_DEFAULT(), \
.btdm = \
{ \
.version = BTDM_CONFIG_VERSION, \
.task_stack_size = UC_BT_CTRL_TASK_STACK_SIZE, \
.task_prio = ESP_TASK_BT_CONTROLLER_PRIO, \
.task_run_cpu = CONFIG_BT_CTRL_PINNED_TO_CORE, \
.hci_cmd_num = CONFIG_BT_CTRL_HCI_CMD_NUM, \
.sleep_en = UC_BT_CTRL_SLEEP_ENABLE, \
.version_num = 0, \
.bluetooth_mode = BTDM_CONTROLLER_MODE_EFF, \
.magic = BTDM_CONFIG_MAGIC_VALUE, \
}, \
}
#else
#define DEFAULT_BT_LE_ISO_FRA_UNSEG (0)
#endif
#if defined(CONFIG_BT_LE_ISO_NSFC_EN)
#define DEFAULT_BT_LE_ISO_NSFC_EN CONFIG_BT_LE_ISO_NSFC_EN
#define DEFAULT_BT_LE_ISO_NSFC_NUM CONFIG_BT_LE_ISO_NSFC_NUM
#else
#define DEFAULT_BT_LE_ISO_NSFC_EN (0)
#define DEFAULT_BT_LE_ISO_NSFC_NUM (0)
#endif
#define DEFAULT_BT_LE_ISO_BUF_COUNT CONFIG_BT_LE_ISO_BUF_COUNT
#define DEFAULT_BT_LE_ISO_BUF_SIZE CONFIG_BT_LE_ISO_BUF_SIZE
#define DEFAULT_BT_LE_ISO_BIG CONFIG_BT_LE_ISO_BIG
#define DEFAULT_BT_LE_ISO_BIS CONFIG_BT_LE_ISO_BIS
#define DEFAULT_BT_LE_ISO_BIS_PER_BIG CONFIG_BT_LE_ISO_BIS_PER_BIG
#define DEFAULT_BT_LE_ISO_CIG CONFIG_BT_LE_ISO_CIG
#define DEFAULT_BT_LE_ISO_CIS CONFIG_BT_LE_ISO_CIS
#define DEFAULT_BT_LE_ISO_CIS_PER_CIG CONFIG_BT_LE_ISO_CIS_PER_CIG
#else
#define DEFAULT_BT_LE_ISO_ENABLED 0
#define DEFAULT_BT_LE_ISO_FRA_UNSEG 0
#define DEFAULT_BT_LE_ISO_NSFC_EN 0
#define DEFAULT_BT_LE_ISO_NSFC_NUM 0
#define DEFAULT_BT_LE_ISO_BUF_COUNT 0
#define DEFAULT_BT_LE_ISO_BUF_SIZE 0
#define DEFAULT_BT_LE_ISO_BIG 0
#define DEFAULT_BT_LE_ISO_BIS 0
#define DEFAULT_BT_LE_ISO_BIS_PER_BIG 0
#define DEFAULT_BT_LE_ISO_CIG 0
#define DEFAULT_BT_LE_ISO_CIS 0
#define DEFAULT_BT_LE_ISO_CIS_PER_CIG 0
#endif
#if CONFIG_BTDM_CTRL_MODE_BTDM
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() { \
.ble = { \
.config_version = BLE_CONFIG_VERSION, \
.ble_ll_resolv_list_size = CONFIG_BT_LE_LL_RESOLV_LIST_SIZE, \
.ble_hci_evt_hi_buf_count = DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT, \
.ble_hci_evt_lo_buf_count = DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT, \
.ble_ll_sync_list_cnt = DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST, \
.ble_ll_sync_cnt = DEFAULT_BT_LE_MAX_PERIODIC_SYNCS, \
.ble_ll_rsp_dup_list_count = CONFIG_BT_LE_LL_DUP_SCAN_LIST_COUNT, \
.ble_ll_adv_dup_list_count = CONFIG_BT_LE_LL_DUP_SCAN_LIST_COUNT, \
.ble_ll_tx_pwr_dbm = 0, \
.rtc_freq = 32000, \
.ble_ll_sca = CONFIG_BT_LE_LL_SCA, \
.ble_ll_scan_phy_number = BLE_LL_SCAN_PHY_NUMBER_N, \
.ble_ll_conn_def_auth_pyld_tmo = BLE_LL_CONN_DEF_AUTH_PYLD_TMO_N, \
.ble_ll_jitter_usecs = BLE_LL_JITTER_USECS_N, \
.ble_ll_sched_max_adv_pdu_usecs = BLE_LL_SCHED_MAX_ADV_PDU_USECS_N, \
.ble_ll_sched_direct_adv_max_usecs = BLE_LL_SCHED_DIRECT_ADV_MAX_USECS_N, \
.ble_ll_sched_adv_max_usecs = BLE_LL_SCHED_ADV_MAX_USECS_N, \
.ble_scan_rsp_data_max_len = DEFAULT_BT_LE_SCAN_RSP_DATA_MAX_LEN_N, \
.ble_ll_cfg_num_hci_cmd_pkts = BLE_LL_CFG_NUM_HCI_CMD_PKTS_N, \
.ble_ll_ctrl_proc_timeout_ms = BLE_LL_CTRL_PROC_TIMEOUT_MS_N, \
.nimble_max_connections = DEFAULT_BT_LE_MAX_CONNECTIONS, \
.ble_whitelist_size = DEFAULT_BT_NIMBLE_WHITELIST_SIZE, \
.ble_acl_buf_size = DEFAULT_BT_LE_ACL_BUF_SIZE, \
.ble_acl_buf_count = DEFAULT_BT_LE_ACL_BUF_COUNT, \
.ble_hci_evt_buf_size = DEFAULT_BT_LE_HCI_EVT_BUF_SIZE, \
.ble_multi_adv_instances = DEFAULT_BT_LE_MAX_EXT_ADV_INSTANCES, \
.ble_ext_adv_max_size = DEFAULT_BT_LE_EXT_ADV_MAX_SIZE, \
.controller_task_stack_size = UC_BT_CTRL_TASK_STACK_SIZE, \
.controller_task_prio = ESP_TASK_BT_CONTROLLER_PRIO, \
.controller_run_cpu = 0, \
.enable_qa_test = RUN_QA_TEST, \
.enable_bqb_test = RUN_BQB_TEST, \
.enable_tx_cca = DEFAULT_BT_LE_TX_CCA_ENABLED, \
.cca_rssi_thresh = 256 - DEFAULT_BT_LE_CCA_RSSI_THRESH, \
.sleep_en = UC_BT_CTRL_SLEEP_ENABLE, \
.coex_phy_coded_tx_rx_time_limit = DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF, \
.dis_scan_backoff = NIMBLE_DISABLE_SCAN_BACKOFF, \
.ble_scan_classify_filter_enable = 1, \
.main_xtal_freq = CONFIG_XTAL_FREQ, \
.ignore_wl_for_direct_adv = 0, \
.enable_pcl = 0, \
.csa2_select = 1, \
.enable_csr = 0, \
.backoff_rssi = -100, \
.iso_enabled = DEFAULT_BT_LE_ISO_ENABLED, \
.iso_bqb_test = false, \
.iso_fra_unseg = DEFAULT_BT_LE_ISO_FRA_UNSEG, \
.iso_nsfc_en = DEFAULT_BT_LE_ISO_NSFC_EN, \
.iso_nsfc_num = DEFAULT_BT_LE_ISO_NSFC_NUM, \
.iso_buf_count = DEFAULT_BT_LE_ISO_BUF_COUNT, \
.iso_buf_size = DEFAULT_BT_LE_ISO_BUF_SIZE, \
.iso_big_count = DEFAULT_BT_LE_ISO_BIG, \
.iso_bis_count = DEFAULT_BT_LE_ISO_BIS, \
.iso_bis_per_big = DEFAULT_BT_LE_ISO_BIS_PER_BIG, \
.iso_cig_count = DEFAULT_BT_LE_ISO_CIG, \
.iso_cis_count = DEFAULT_BT_LE_ISO_CIS, \
.iso_cis_per_cig = DEFAULT_BT_LE_ISO_CIS_PER_CIG, \
.config_magic = BLE_CONFIG_MAGIC, \
}, \
.bredr = { \
.bredr_version = ESP_BREDR_CTRL_CONFIG_VERSION, \
.sleep_mode = 0, \
.bt_test_mode_en = UC_BR_EDR_TEST_MODE_EN, \
.acl_cca_en = UC_BR_EDR_TX_CCA_EN, \
.cca_rssi_thr = -UC_BR_EDR_CCA_RSSI_THRESH, \
.max_acl_conn = UC_BR_EDR_MAX_ACL_CONN, \
.max_sync_conn = UC_BR_EDR_CTRL_MAX_SYNC_CONN, \
.cpb_tx_link_num = UC_BR_EDR_CPB_TX_LINK_NB, \
.cpb_rx_link_num = UC_BR_EDR_CPB_RX_LINK_NB, \
.bt_sco_datapath = UC_BR_EDR_SCO_DATA_PATH, \
.hci_tl_type = 0, \
.hci_tl_funcs = NULL, \
.cfg_mask = 0, \
.hw_target_code = 0, \
.acl_min_tx_pwr = CONFIG_BT_CTRL_BR_EDR_TX_PWR_ACL_MIN, \
.acl_max_tx_pwr = CONFIG_BT_CTRL_BR_EDR_TX_PWR_ACL_MAX, \
.apb_tx_pwr = UC_BR_EDR_TX_PWR_APB, \
.page_tx_pwr = CONFIG_BT_CTRL_BR_EDR_TX_PWR_PAGE, \
.pscan_tx_pwr = CONFIG_BT_CTRL_BR_EDR_TX_PWR_PSCAN, \
.iscan_tx_pwr = CONFIG_BT_CTRL_BR_EDR_TX_PWR_ISCAN, \
.cpb_tx_pwr = UC_BR_EDR_TX_PWR_CPB, \
.strain_tx_pwr = UC_BR_EDR_TX_PWR_STRAIN, \
.rf_hw_type = 0, \
.static_aclu_tx_buf_nb = UC_BR_EDR_ACLU_TX_BUF_NB - UC_BR_EDR_DYNAMIC_ACLU_TX_BUF_NB, \
.dynamic_aclu_tx_buf_nb = UC_BR_EDR_DYNAMIC_ACLU_TX_BUF_NB, \
.aclu_rx_buf_nb = UC_BR_EDR_ACLU_RX_BUF_NB, \
.sync_tx_buf_nb = UC_BR_EDR_SYNC_TX_BUF_NB, \
.sync_rx_buf_nb = UC_BR_EDR_SYNC_RX_BUF_NB, \
.esco_ev4_supp = UC_BR_EDR_ESCO_EV4_SUPP, \
.esco_ev5_supp = UC_BR_EDR_ESCO_EV5_SUPP, \
.esco_ev3_2_supp = UC_BR_EDR_ESCO_EV3_2_SUPP, \
.esco_ev3_3_supp = UC_BR_EDR_ESCO_EV3_3_SUPP, \
.esco_3_slots_supp = UC_BR_EDR_ESCO_3_SLOTS_SUPP, \
.bt_legacy_auth_vs_evt = UC_BR_EDR_LEGACY_AUTH_VENDOR_EVT, \
.inq_filter_en = 0, \
.dtm_en = 0, \
.bredr_magic = ESP_BREDR_CTRL_CONFIG_MAGIC_VAL, \
}, \
.btdm = { \
.version = BTDM_CONFIG_VERSION, \
.task_stack_size = UC_BT_CTRL_TASK_STACK_SIZE, \
.task_prio = ESP_TASK_BT_CONTROLLER_PRIO, \
.task_run_cpu = CONFIG_BT_CTRL_PINNED_TO_CORE, \
.hci_cmd_num = CONFIG_BT_CTRL_HCI_CMD_NUM, \
.hci_conn_num = DEFAULT_BT_LE_MAX_CONNECTIONS + DEFAULT_BT_LE_ISO_CIS + DEFAULT_BT_LE_ISO_BIS + \
UC_BR_EDR_MAX_ACL_CONN + UC_BR_EDR_CTRL_MAX_SYNC_CONN, \
.sleep_en = UC_BT_CTRL_SLEEP_ENABLE, \
.version_num = 0, \
.bluetooth_mode = BTDM_CONTROLLER_MODE_EFF, \
.magic = BTDM_CONFIG_MAGIC_VALUE, \
}, \
}
#elif CONFIG_BTDM_CTRL_MODE_BLE_ONLY
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() { \
.ble = { \
.config_version = BLE_CONFIG_VERSION, \
.ble_ll_resolv_list_size = CONFIG_BT_LE_LL_RESOLV_LIST_SIZE, \
.ble_hci_evt_hi_buf_count = DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT, \
.ble_hci_evt_lo_buf_count = DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT, \
.ble_ll_sync_list_cnt = DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST, \
.ble_ll_sync_cnt = DEFAULT_BT_LE_MAX_PERIODIC_SYNCS, \
.ble_ll_rsp_dup_list_count = CONFIG_BT_LE_LL_DUP_SCAN_LIST_COUNT, \
.ble_ll_adv_dup_list_count = CONFIG_BT_LE_LL_DUP_SCAN_LIST_COUNT, \
.ble_ll_tx_pwr_dbm = 0, \
.rtc_freq = 32000, \
.ble_ll_sca = CONFIG_BT_LE_LL_SCA, \
.ble_ll_scan_phy_number = BLE_LL_SCAN_PHY_NUMBER_N, \
.ble_ll_conn_def_auth_pyld_tmo = BLE_LL_CONN_DEF_AUTH_PYLD_TMO_N, \
.ble_ll_jitter_usecs = BLE_LL_JITTER_USECS_N, \
.ble_ll_sched_max_adv_pdu_usecs = BLE_LL_SCHED_MAX_ADV_PDU_USECS_N, \
.ble_ll_sched_direct_adv_max_usecs = BLE_LL_SCHED_DIRECT_ADV_MAX_USECS_N, \
.ble_ll_sched_adv_max_usecs = BLE_LL_SCHED_ADV_MAX_USECS_N, \
.ble_scan_rsp_data_max_len = DEFAULT_BT_LE_SCAN_RSP_DATA_MAX_LEN_N, \
.ble_ll_cfg_num_hci_cmd_pkts = BLE_LL_CFG_NUM_HCI_CMD_PKTS_N, \
.ble_ll_ctrl_proc_timeout_ms = BLE_LL_CTRL_PROC_TIMEOUT_MS_N, \
.nimble_max_connections = DEFAULT_BT_LE_MAX_CONNECTIONS, \
.ble_whitelist_size = DEFAULT_BT_NIMBLE_WHITELIST_SIZE, \
.ble_acl_buf_size = DEFAULT_BT_LE_ACL_BUF_SIZE, \
.ble_acl_buf_count = DEFAULT_BT_LE_ACL_BUF_COUNT, \
.ble_hci_evt_buf_size = DEFAULT_BT_LE_HCI_EVT_BUF_SIZE, \
.ble_multi_adv_instances = DEFAULT_BT_LE_MAX_EXT_ADV_INSTANCES, \
.ble_ext_adv_max_size = DEFAULT_BT_LE_EXT_ADV_MAX_SIZE, \
.controller_task_stack_size = UC_BT_CTRL_TASK_STACK_SIZE, \
.controller_task_prio = ESP_TASK_BT_CONTROLLER_PRIO, \
.controller_run_cpu = 0, \
.enable_qa_test = RUN_QA_TEST, \
.enable_bqb_test = RUN_BQB_TEST, \
.enable_tx_cca = DEFAULT_BT_LE_TX_CCA_ENABLED, \
.cca_rssi_thresh = 256 - DEFAULT_BT_LE_CCA_RSSI_THRESH, \
.sleep_en = UC_BT_CTRL_SLEEP_ENABLE, \
.coex_phy_coded_tx_rx_time_limit = DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF, \
.dis_scan_backoff = NIMBLE_DISABLE_SCAN_BACKOFF, \
.ble_scan_classify_filter_enable = 1, \
.main_xtal_freq = CONFIG_XTAL_FREQ, \
.ignore_wl_for_direct_adv = 0, \
.enable_pcl = 0, \
.csa2_select = 1, \
.enable_csr = 0, \
.backoff_rssi = -100, \
.iso_enabled = DEFAULT_BT_LE_ISO_ENABLED, \
.iso_bqb_test = false, \
.iso_fra_unseg = DEFAULT_BT_LE_ISO_FRA_UNSEG, \
.iso_nsfc_en = DEFAULT_BT_LE_ISO_NSFC_EN, \
.iso_nsfc_num = DEFAULT_BT_LE_ISO_NSFC_NUM, \
.iso_buf_count = DEFAULT_BT_LE_ISO_BUF_COUNT, \
.iso_buf_size = DEFAULT_BT_LE_ISO_BUF_SIZE, \
.iso_big_count = DEFAULT_BT_LE_ISO_BIG, \
.iso_bis_count = DEFAULT_BT_LE_ISO_BIS, \
.iso_bis_per_big = DEFAULT_BT_LE_ISO_BIS_PER_BIG, \
.iso_cig_count = DEFAULT_BT_LE_ISO_CIG, \
.iso_cis_count = DEFAULT_BT_LE_ISO_CIS, \
.iso_cis_per_cig = DEFAULT_BT_LE_ISO_CIS_PER_CIG, \
.config_magic = BLE_CONFIG_MAGIC, \
}, \
.bredr = { 0 }, \
.btdm = { \
.version = BTDM_CONFIG_VERSION, \
.task_stack_size = UC_BT_CTRL_TASK_STACK_SIZE, \
.task_prio = ESP_TASK_BT_CONTROLLER_PRIO, \
.task_run_cpu = CONFIG_BT_CTRL_PINNED_TO_CORE, \
.hci_cmd_num = CONFIG_BT_CTRL_HCI_CMD_NUM, \
.hci_conn_num = DEFAULT_BT_LE_MAX_CONNECTIONS + DEFAULT_BT_LE_ISO_CIS + DEFAULT_BT_LE_ISO_BIS, \
.sleep_en = UC_BT_CTRL_SLEEP_ENABLE, \
.version_num = 0, \
.bluetooth_mode = BTDM_CONTROLLER_MODE_EFF, \
.magic = BTDM_CONFIG_MAGIC_VALUE, \
}, \
}
#elif CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() { \
.ble = { 0 }, \
.bredr = { \
.bredr_version = ESP_BREDR_CTRL_CONFIG_VERSION, \
.sleep_mode = 0, \
.bt_test_mode_en = UC_BR_EDR_TEST_MODE_EN, \
.acl_cca_en = UC_BR_EDR_TX_CCA_EN, \
.cca_rssi_thr = -UC_BR_EDR_CCA_RSSI_THRESH, \
.max_acl_conn = UC_BR_EDR_MAX_ACL_CONN, \
.max_sync_conn = UC_BR_EDR_CTRL_MAX_SYNC_CONN, \
.cpb_tx_link_num = UC_BR_EDR_CPB_TX_LINK_NB, \
.cpb_rx_link_num = UC_BR_EDR_CPB_RX_LINK_NB, \
.bt_sco_datapath = UC_BR_EDR_SCO_DATA_PATH, \
.hci_tl_type = 0, \
.hci_tl_funcs = NULL, \
.cfg_mask = 0, \
.hw_target_code = 0, \
.acl_min_tx_pwr = CONFIG_BT_CTRL_BR_EDR_TX_PWR_ACL_MIN, \
.acl_max_tx_pwr = CONFIG_BT_CTRL_BR_EDR_TX_PWR_ACL_MAX, \
.apb_tx_pwr = UC_BR_EDR_TX_PWR_APB, \
.page_tx_pwr = CONFIG_BT_CTRL_BR_EDR_TX_PWR_PAGE, \
.pscan_tx_pwr = CONFIG_BT_CTRL_BR_EDR_TX_PWR_PSCAN, \
.iscan_tx_pwr = CONFIG_BT_CTRL_BR_EDR_TX_PWR_ISCAN, \
.cpb_tx_pwr = UC_BR_EDR_TX_PWR_CPB, \
.strain_tx_pwr = UC_BR_EDR_TX_PWR_STRAIN, \
.rf_hw_type = 0, \
.static_aclu_tx_buf_nb = UC_BR_EDR_ACLU_TX_BUF_NB - UC_BR_EDR_DYNAMIC_ACLU_TX_BUF_NB, \
.dynamic_aclu_tx_buf_nb = UC_BR_EDR_DYNAMIC_ACLU_TX_BUF_NB, \
.aclu_rx_buf_nb = UC_BR_EDR_ACLU_RX_BUF_NB, \
.sync_tx_buf_nb = UC_BR_EDR_SYNC_TX_BUF_NB, \
.sync_rx_buf_nb = UC_BR_EDR_SYNC_RX_BUF_NB, \
.esco_ev4_supp = UC_BR_EDR_ESCO_EV4_SUPP, \
.esco_ev5_supp = UC_BR_EDR_ESCO_EV5_SUPP, \
.esco_ev3_2_supp = UC_BR_EDR_ESCO_EV3_2_SUPP, \
.esco_ev3_3_supp = UC_BR_EDR_ESCO_EV3_3_SUPP, \
.esco_3_slots_supp = UC_BR_EDR_ESCO_3_SLOTS_SUPP, \
.bt_legacy_auth_vs_evt = UC_BR_EDR_LEGACY_AUTH_VENDOR_EVT, \
.inq_filter_en = 0, \
.dtm_en = 0, \
.bredr_magic = ESP_BREDR_CTRL_CONFIG_MAGIC_VAL, \
}, \
.btdm = { \
.version = BTDM_CONFIG_VERSION, \
.task_stack_size = UC_BT_CTRL_TASK_STACK_SIZE, \
.task_prio = ESP_TASK_BT_CONTROLLER_PRIO, \
.task_run_cpu = CONFIG_BT_CTRL_PINNED_TO_CORE, \
.hci_cmd_num = CONFIG_BT_CTRL_HCI_CMD_NUM, \
.hci_conn_num = UC_BR_EDR_MAX_ACL_CONN + UC_BR_EDR_CTRL_MAX_SYNC_CONN, \
.sleep_en = UC_BT_CTRL_SLEEP_ENABLE, \
.version_num = 0, \
.bluetooth_mode = BTDM_CONTROLLER_MODE_EFF, \
.magic = BTDM_CONFIG_MAGIC_VALUE, \
}, \
}
#endif
/**
* @brief Set BLE TX power
* Connection Tx power should only be set after connection created.
* @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc
* @param power_level: Power level(index) corresponding to absolute value(dbm)
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_t power_level);
/**
* @brief Get BLE TX power
* Connection Tx power should only be get after connection created.
* @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc
* @return >= 0 - Power level, < 0 - Invalid
*/
esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type);
/**
* @brief ENHANCED API for Setting BLE TX power
* Connection Tx power should only be set after connection created.
* @param power_type : The enhanced type of which tx power, could set Advertising/Connection/Default and etc
* @param handle : The handle of Advertising or Connection and the value 0 for other enhanced power types.
* @param power_level: Power level(index) corresponding to absolute value(dbm)
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle, esp_power_level_t power_level);
/**
* @brief ENHANCED API of Getting BLE TX power
* Connection Tx power should only be get after connection created.
* @param power_type : The enhanced type of which tx power, could set Advertising/Connection/Default and etc
* @param handle : The handle of Advertising or Connection and the value 0 for other enhanced power types.
* @return >= 0 - Power level, < 0 - Invalid
*/
esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle);
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() \
{ \
.ble = _BT_CTRL_LE_INIT_CONFIG_DEFAULT(), \
.btdm = \
{ \
.version = BTDM_CONFIG_VERSION, \
.task_stack_size = UC_BT_CTRL_TASK_STACK_SIZE, \
.task_prio = ESP_TASK_BT_CONTROLLER_PRIO, \
.task_run_cpu = CONFIG_BT_CTRL_PINNED_TO_CORE, \
.hci_cmd_num = CONFIG_BT_CTRL_HCI_CMD_NUM, \
.sleep_en = UC_BT_CTRL_SLEEP_ENABLE, \
.version_num = 0, \
.bluetooth_mode = BTDM_CONTROLLER_MODE_EFF, \
.magic = BTDM_CONFIG_MAGIC_VALUE, \
}, \
}
#endif // SOC_BT_CLASSIC_SUPPORTED
/**
* @brief Initialize BT controller to allocate task and other resource.

View File

@@ -4,474 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#pragma once
#include "sdkconfig.h"
#ifdef __cplusplus
extern "C" {
#endif
// @brief HCI VS Commands for Espressif's Bluetooth Host
//
// @note The following vendor-specific HCI commands are exclusively for Espressif's Bluetooth Host (ESP-Bluedroid Host or ESP-NimBLE Host).
// If you are using a non-ESP host or HCI UART, these commands will remain disabled unless the initialization function is explicitly called from the application.
// Note, these init functions as well as these additional HCI VS commands are intended for Espressif's Bluetooth Host use only.
// Application developers **should not** call the init functions in their applications.
//
/**
* @brief Config scanning duplicate exceptional list (OCF: 0x0108)
*
* @note The init function is `advFilter_stack_eanbleDupExcListCmd(true)`
*/
#define ESP_BT_VS_CONFIG_DUP_EXC_LIST_OCF (0x0108)
/**
* @brief Update exception list cmd parameters
*/
struct bt_hci_vs_update_exc_list {
uint8_t subcode; /*!< Add, remove or clear exception list */
uint32_t type; /*!< device type */
uint8_t device_info[6]; /*!< device information */
};
/**
* @brief Enable/disable advertising report flow control (OCF: 0x0109)
*
* @note The init function is `scan_stack_enableAdvFlowCtrlVsCmd(true)`
*/
#define ESP_BT_VS_SET_ADV_REPORT_FLOW_CTRL_OCF (0x0109)
/**
* @brief Init ADV flow control cmd parameters
*/
struct bt_hci_vs_init_adv_flow_ctrl {
uint8_t enable; /*!< Enable ADV flow control */
uint16_t num; /*!< ADV buffer maximum value */
uint16_t adv_lost_threshold; /*!< ADV lost event triggered threshold */
};
/**
* @brief Update the number of advertising report in ADV flow control (OCF: 0x010A)
*
* @note The init function is `scan_stack_enableAdvFlowCtrlVsCmd(true)`
*/
#define ESP_BT_VS_UPD_ADV_REPORT_FLOW_CTRL_NUM_OCF (0x010a)
/**
* @brief Update ADV flow control cmd parameters
*/
struct bt_hci_vs_update_adv_flow_ctrl {
uint16_t num; /*!< The number of ADV report processed */
};
/**
* @brief Clear legacy advertising (same as HCI_LE_Clear_Advertising_Sets) (OCF: 0x010C)
*
* @note The init function is `adv_stack_enableClearLegacyAdvVsCmd(true)`
*/
#define ESP_BT_VS_CLR_LEGACY_ADV_OCF (0x010c)
/**
* @brief Clear legacy ADV cmd parameters
*/
struct bt_hci_vs_ble_clr_legacy_adv {
// no parameters
};
/**
* @brief Set parameters of duplicate list (OCF: 0x010D)
*
* @note The init function is `advFilter_stack_eanbleDupExcListCmd(true)`
*/
#define ESP_BT_VS_SET_DUP_LIST_PARAMS_OCF (0x010d)
/**
* @brief Set duplicate list cmd parameters
*/
struct bt_hci_vs_ble_set_dup_params {
uint8_t dup_mode; /*!< Duplicate mode */
uint8_t dup_ad_type; /*!< Duplicate data type */
uint16_t ring_list_max_num; /*!< Duplicate list size */
};
/**
* @brief Enable/disable duplicate and exception list (OCF: 0x010E)
*
* @note The init function is `advFilter_stack_eanbleDupExcListCmd(true)`
*/
#define ESP_BT_VS_ENABLE_DUP_EXC_LIST_OCF (0x010e)
/**
* @brief Enable duplicate and exception list cmd parameters
*/
struct bt_hci_vs_ble_enable_dup_exc {
uint8_t enable; /*!< Enable or disable */
uint8_t ring_list_reset; /*!< Reset list */
};
/**
* @brief Enable optimization of multiple connections (OCF: 0x010F)
*
* @note The init function is `arr_stack_enableMultiConnVsCmd(true)`
*/
#define ESP_BT_VS_ENABLE_ARRANGEMENT_OCF (0x010f)
/**
* @brief Multiple connections optimization cmd parameters
*/
struct bt_hci_vs_ble_enable_arrangement {
uint32_t common_factor; /*!< The greatest common factor of connection interval */
uint8_t enable; /*!< Enable or disable */
};
/**
* @brief Set scheduling length for a certain role (OCF: 0x0110)
*
* @note The init function is `arr_stack_enableMultiConnVsCmd(true)`
*/
#define ESP_BT_VS_SET_SCHED_ROLE_LEN_OCF (0x0110)
/**
* @brief Scheduling length cmd parameters
*/
struct bt_hci_vs_ble_set_sched_role_len {
uint8_t role; /*!< BLE role; 0: central; 1: peripheral */
uint32_t len; /*!< Length is us */
};
/**
* @brief Set RSSI threshold for automatic power control (OCF: 0x0111)
*
* @note The init function is `pcl_stack_enableSetRssiThreshVsCmd(true)`
*/
#define ESP_BT_VS_SET_PCL_RSSI_THRESH_OCF (0x0111)
/**
* @brief PCL RSSI threshold cmd parameters
*/
struct bt_hci_vs_ble_set_pcl_rssi_thresh {
uint16_t conn_handle; /*!< Connection handle */
uint8_t rssi_thresh_min_1M; /*!< Lower limit for 1M */
uint8_t rssi_thresh_max_1M; /*!< Upper limit for 1M */
uint8_t rssi_thresh_min_2M; /*!< Lower limit for 2M */
uint8_t rssi_thresh_max_2M; /*!< Upper limit for 2M */
uint8_t rssi_thresh_min_s2coded; /*!< Lower limit for s2 coded */
uint8_t rssi_thresh_max_s2coded; /*!< Upper limit for s2 coded */
uint8_t rssi_thresh_min_s8coded; /*!< Lower limit for s8 coded */
uint8_t rssi_thresh_max_s8coded; /*!< Upper limit for s8 coded */
};
/**
* @brief Enable/disable channel selection algorithm #2 (OCF: 0x0112)
*
* @note The init function is `chanSel_stack_enableSetCsaVsCmd(true)`
*/
#define ESP_BT_VS_ENABLE_CSA2_OCF (0x0112)
/**
* @brief Enable/disable channel selection algorithm #2 cmd parameters
*/
struct bt_hci_vs_ble_csa_enable {
uint8_t csa2_select; /*!< Select CSA2 */
};
/**
* @brief Set parameters of controller logs (OCF: 0x0114)
*
* @note The init function is `log_stack_enableLogsRelatedVsCmd(true)`
*/
#define ESP_BT_VS_SET_LOG_PARAMS_OCF (0x0114)
/**
* @brief Controller logs cmd parameters
*/
struct bt_hci_vs_ble_log_params {
uint8_t type; /*!< Operation type */
uint32_t output_enable; /*!< Enable/disable output */
uint8_t buffer_optoin /*!< Select log buffers */
};
/**
* @brief Set BLE vendor events mask (OCF: 0x0116)
*
* @note The init function is `hci_stack_enableSetVsEvtMaskVsCmd(true)`
*/
#define ESP_BT_VS_SET_LE_VENDOR_EVTS_MASK_OCF (0x0116)
/**
* @brief Set BLE vendor events mask cmd parameters
*/
struct bt_hci_vs_ble_set_vs_evts_mask {
uint32_t evt_masks; /*!< BLE vendor events Mask */
};
/**
* @brief Set peer sleep clock accuracy to a constant value (OCF: 0x0118)
*
* @note The init function is `winWiden_stack_enableSetConstPeerScaVsCmd(true)`
*/
#define ESP_BT_VS_SET_CONST_PEER_SCA_OCF (0x0118)
/**
* @brief Peer constant SCA cmd parameters
*/
struct bt_hci_vs_ble_set_const_peer_sca {
uint16_t peer_sca; /*!< Peer SCA */
};
// @brief HCI VS Events for Espressif's Bluetooth Host
//
// @note The following HCI VS events are exclusively for Espressif's Bluetooth Host (ESP-Bluedroid Host or ESP-NimBLE Host).
// If you are using a non-ESP host or HCI UART, these events will remain disabled unless the initialization function is explicitly called from the application.
// Note, these init functions as well as these additional HCI VS events are intended for Espressif's Bluetooth Host use only.
// Application developers **should not** call the init functions in their applications.
//
/**
* @brief BLE Scan/Connect Request, Aux Connect Response received event (EVTCODE: 0xFF, SUBCODE: 0xC0)
*
* @note The init function is `adv_stack_enableScanReqRxdVsEvent(true)`
*/
#define ESP_BT_VS_LE_CONN_SCAN_REQ_RXED_EVT_SUBCODE (0xC0)
/**
* @brief BLE Scan/Connect Request, Aux Connect Response received event parameters
*/
struct bt_hci_vs_le_conn_scan_req_rxed_evt {
uint8_t evt_type; /*!< Event type; 0: SCAN_REQ; 1: CONN_IND */
uint8_t handle; /*!< Advertisement handle */
uint8_t peer_addr_type; /*!< Peer address type */
uint8_t peer_addr[6]; /*!< Peer address */
};
/**
* @brief BLE Channel Map Update Completion event (EVTCODE: 0xFF, SUBCODE: 0xC1)
*
* @note The init function is `conn_stack_enableChanMapUpdCompVsEvent(true)`
*/
#define ESP_BT_VS_LE_CHAN_UPDATE_COMP_EVT_SUBCODE (0xC1)
/**
* @brief BLE Channel Map Update Completion event parameters
*/
struct bt_hci_vs_le_chan_update_comp_evt {
uint8_t status; /*!< Controller error code */
uint16_t handle; /*!< Connection handle */
uint8_t ch_map[5]; /*!< Updated channel map */
};
/**
* @brief BLE Wakeup From Sleep event (EVTCODE: 0xFF, SUBCODE: 0xC3)
*
* @note The init function is `sleep_stack_enableWakeupVsEvent(true)`
*/
#define ESP_BT_VS_LE_SLEEP_WAKEUP_EVT_SUBCODE (0xC3)
/**
* @brief BLE wakeup event parameters
*/
struct bt_hci_vs_le_sleep_wakeup_evt {
// no parameters
};
/**
* @brief BLE advertising report lost event for flow control (EVTCODE: 0x3E, SUBCODE: 0xF0)
*
* @note The init function is `scan_stack_enableAdvFlowCtrlVsCmd(true)`
*/
#define ESP_BT_VS_LE_ADV_LOST_EVT_SUBCODE (0xF0)
/**
* @brief ADV lost event parameters
*/
struct bt_hci_vs_le_adv_lost_evt {
uint32_t nb_lost; /*!< The number of ADV report discarded */
};
/**
* @brief This event indicates legacy authentication is completed by remote device (EVTCODE: 0xFF, SUBCODE: 0x03)
*
* @note The init function is `bt_stack_enableSecCtrlVsCmd(true)`
*/
#define ESP_BT_VS_LEGACY_REM_AUTH_EVT_SUBCODE (0x03)
/**
* @brief legacy remote auth event parameters
*/
struct bt_hci_vs_legacy_rem_auth_evt {
uint16_t conhdl; /*!< connection handle */
};
//
// @brief HCI VS Commands for Espressif's Internal-Use Debugging
//
// @note The following HCI VS debugging commands are implemented in Bluetooth controller pre-compiled libraries.
// These commands are not linked into the application binary, unless the function `esp_ble_internalTestFeaturesEnable(true)`is called from the application.
// They are intended for Espressif's internal use only. Application developers **should not** call `esp_ble_internalTestFeaturesEnable(true)` in their applications.
//
#define ESP_BT_VS_CFG_TEST_RELATED_OCF (0x0113)
#define ESP_BT_VS_CFG_TEST_ENABLE_SUBCMD (0X00)
#define ESP_BT_VS_CFG_TEST_ENABLE_ADV_DELAY_SUBCMD (0X01)
#define ESP_BT_VS_CFG_TEST_SET_PREF_CODED_SUBCMD (0X02)
#define ESP_BT_VS_CFG_TEST_SET_DEFAULT_PRIV_MODE_SUBCMD (0X03)
#define ESP_BT_VS_CFG_TEST_SET_SCAN_FOREVER_SUBCMD (0X04)
#define ESP_BT_VS_CFG_TEST_SET_EXPECTED_PEER_SUBCMD (0X05)
#define ESP_BT_VS_CFG_TEST_GET_ADV_TXED_CNT_SUBCMD (0X06)
#define ESP_BT_VS_CFG_TEST_GET_SCAN_RXED_CNT_SUBCMD (0X07)
#define ESP_BT_VS_CFG_TEST_SET_TXPWR_LVL_SUBCMD (0X08)
#define ESP_BT_VS_CFG_TEST_GET_TXPWR_LVL_SUBCMD (0X09)
#define ESP_BT_VS_CFG_TEST_SET_TXPWR_LVL_ENH_SUBCMD (0X0a)
#define ESP_BT_VS_CFG_TEST_GET_TXPWR_LVL_ENH_SUBCMD (0X0b)
#define ESP_BT_VS_CFG_TEST_IGNORE_WL_FOR_DIR_ADV_SUBCMD (0X0c)
#define ESP_BT_VS_CFG_TEST_GET_ADV_RXED_RSSI_SUBCMD (0X0d)
#define ESP_BT_VS_CFG_TEST_ENABLE_CCA_SUBCMD (0X0e)
#define ESP_BT_VS_CFG_TEST_SET_CCA_WIN_SUBCMD (0X0f)
#define ESP_BT_VS_CFG_TEST_READ_CCA_DATA_SUBCM (0X10)
#define ESP_BT_VS_CFG_TEST_CLEAR_RAND_ADDR_SUBCMD (0X11)
#define ESP_BT_VS_CFG_TEST_GET_MAX_TXPWR_SUBCMD (0X12)
#define ESP_BT_VS_CFG_TEST_GET_TXPWR_RANGE_SUBCMD (0X13)
#define ESP_BT_VS_CFG_TEST_SET_SCAN_AA_SUBCMD (0X14)
#define ESP_BT_VS_CFG_TEST_SET_ADV_AA_SUBCMD (0X15)
#define ESP_BT_VS_CFG_TEST_SET_SCAN_CHAN_SUBCMD (0X16)
#define ESP_BT_VS_CFG_TEST_SKIP_LIGHT_SLEEP_CHECK_SUBCMD (0X17)
#define ESP_BT_VS_CFG_TEST_SET_WAKEUP_OVERHEAD_SUBCMD (0X18)
#define ESP_BT_VS_CFG_TEST_GET_ADV_MIN_ITVL_SUBCMD (0X19)
#define ESP_BT_VS_CFG_TEST_GET_CTRL_STATUS_SUBCMD (0X1a)
#define ESP_BT_VS_CFG_TEST_SET_CONN_PHY_TXPWR_SUBCMD (0X1b)
#define ESP_BT_VS_CFG_TEST_GET_CONN_PHY_TXPWR_SUBCMD (0X1c)
#define ESP_BT_VS_CFG_TEST_GET_RXBUF_EMPTY_CNT_SUBCMD (0X1d)
#define ESP_BT_VS_CFG_TEST_RESTART_SUBCMD (0X1e)
#define ESP_BT_VS_CFG_TEST_ENABLE_RECODE_RX_STATE_SUBCMD (0X1f)
#define ESP_BT_VS_CFG_TEST_GET_RECODE_CNT_SUBCMD (0X20)
#define ESP_BT_VS_CFG_TEST_CLR_RECODE_CNT_SUBCMD (0X21)
#define ESP_BT_VS_CFG_TEST_GET_CTRL_COMPILE_VER_SUBCMD (0X24)
#define ESP_BT_VS_CFG_TEST_SET_AUX_ADV_OFFSET_SUBCMD (0X25)
#define ESP_BT_VS_CFG_TEST_INIT_FLEXIBLE_MODE_SUBCMD (0X26)
#define ESP_BT_VS_CFG_TEST_ENABLE_FLEXIBLE_MODE_SUBCMD (0X27)
#define ESP_BT_VS_CFG_TEST_SET_FLEXIBLE_CONN_ERR_SUBCMD (0X28)
#define ESP_BT_VS_CFG_TEST_SET_FLEXIBLE_ADV_ERR_SUBCMD (0X29)
#define ESP_BT_VS_CFG_TEST_SET_FLEXIBLE_SCAN_ERR_SUBCMD (0X2a)
#define ESP_BT_VS_CFG_TEST_GET_TXED_CRCERR_SUBCMD (0X2c)
#define ESP_BT_VS_CFG_TEST_GET_BACKOFF_UPLIMIT_SUBCMD (0X2d)
#define ESP_BT_VS_CFG_TEST_GET_RXED_ADV_ADI_SUBCMD (0X2f)
#define ESP_BT_VS_CFG_TEST_SET_SCH_RAND_MODE_SUBCMD (0X30)
#define ESP_BT_VS_CFG_TEST_SET_RX_SENS_THRESH_SUBCMD (0X31)
#define ESP_BT_VS_CFG_TEST_CHECK_MSYS_BUF_SUBCMD (0X32)
#define ESP_BT_VS_CFG_TEST_UPDATE_BLE_TIMER_SUBCMD (0X33)
#define ESP_BT_VS_CFG_TEST_UPDATE_BLE_RTC_SUBCMD (0X34)
#define ESP_BT_VS_CFG_TEST_SET_LOCKED_MEM_NUM_SUBCMD (0X35)
#define ESP_BT_VS_CFG_TEST_ALLOW_MEM_ALLOC_SUBCMD (0X36)
#define ESP_BT_VS_CFG_TEST_SET_SCH_RAND_INFO_PTR_SUBCMD (0X37)
#define ESP_BT_VS_CFG_TEST_SET_DIAG_IO_SUBCMD (0X38)
#define ESP_BT_VS_CFG_TEST_SET_AGC_MAX_GAIN_SUBCMD (0X39)
#define ESP_BT_VS_CFG_TEST_ENABLE_CHAN_ASSESS_SUBCMD (0X40)
#define ESP_BT_VS_CFG_TEST_SET_BACKOFF_UPLIMIT_SUBCMD (0X41)
#define ESP_BT_VS_CFG_TEST_SET_CONN_TOP_PRIO_RESV_THRESH_SUBCMD (0X42)
#define ESP_BT_VS_CFG_TEST_SET_TEST_EVT_MSK_SUBCMD (0X43)
#define ESP_BT_VS_CFG_TEST_GET_WAKEUP_TIMEOUT_SUBCMD (0X45)
#define ESP_BT_VS_CFG_TEST_RELATED_SUBCMD_MAX (0Xff)
/**
* @note The init function is `bt_stack_enablePktCtrlVsCmd(true)`
*/
#define ESP_BT_VS_WR_DM1_ENABLE_OCF (0x0181)
/**
* @note The init function is `bt_stack_enableClkCtrlVsCmd(true)`
*/
#define ESP_BT_VS_CLK_UPDATE_OCF (0x0183)
/**
* @note The init function is `bt_stack_enableAfhVsCmd(true)`
*/
#define ESP_BT_VS_SET_AFH_OCF (0x0187)
/**
* @note The init function is `bt_stack_enableBasicVsCmd(true)`
*/
#define ESP_BT_VS_SET_EVT_MASK_OCF (0x0188)
/**
* @note The init function is `bt_stack_enableAfhVsCmd(true)`
*/
#define ESP_BT_VS_SET_AFH_REPORTING_MODE_OCF (0x0189)
/**
* @note The init function is `bt_stack_enableAfhVsCmd(true)`
*/
#define ESP_BT_VS_MASK_RMT_CHANNEL_CLASSIFICATION_OCF (0x018a)
/**
* @note The init function is `bt_stack_enableDTMVsCmd(true)`
*/
#define ESP_BT_VS_DTM_TX_TEST_START_OCF (0x018c)
/**
* @note The init function is `bt_stack_enableDTMVsCmd(true)`
*/
#define ESP_BT_VS_DTM_RX_TEST_START_OCF (0x018d)
/**
* @note The init function is `bt_stack_enableDTMVsCmd(true)`
*/
#define ESP_BT_VS_DTM_TX_TEST_END_OCF (0x018e)
/**
* @note The init function is `bt_stack_enableDTMVsCmd(true)`
*/
#define ESP_BT_VS_DTM_RX_TEST_END_OCF (0x018f)
/**
* @note The init function is `bt_stack_enableInternalDbgVsCmd(true)`
*/
#define ESP_BT_VS_PCA_OCF (0x0190)
/**
* @note The init function is `bt_stack_enableInternalDbgVsCmd(true)`
*/
#define ESP_BT_VS_DISCARD_PING_OCF (0x0191)
/**
* @note The init function is `bt_stack_enableInternalDbgVsCmd(true)`
*/
#define ESP_BT_VS_LMP_DBG_ENABLE_OCF (0x019a)
/**
* @note The init function is `bt_stack_enableInternalDbgVsCmd(true)`
*/
#define ESP_BT_VS_SEND_LMP_OCF (0x019b)
/**
* @note The init function is `bt_stack_enableInternalDbgVsCmd(true)`
*/
#define ESP_BT_VS_LMP_DBG_SAVE_OCF (0x019c)
//
// @brief HCI VS Events for Espressif's Internal-Use Debugging
//
// @note The following HCI VS debugging events are implemented in Bluetooth controller pre-compiled libraries.
// These events are not linked into the application binary, unless the function `esp_ble_internalTestFeaturesEnable(true)`is called from the application.
// Application developers **should not** call `esp_ble_internalTestFeaturesEnable(true)` in their applications.
//
#define ESP_BT_VS_LE_RUNNING_STATUS_EVT_SUBCODE (0xC3)
/**
* @note The init function is `bt_stack_enableAfhVsCmd(true)`
*/
#define ESP_BT_VS_AFH_CHG_EVT_SUBCODE (0x05)
/**
* @note The init function is `bt_stack_enableAfhVsCmd(true)`
*/
#define ESP_BT_VS_CH_CLASSIFICATION_EVT_SUBCODE (0x06)
/**
* @note The init function is `bt_stack_enableAfhVsCmd(true)`
*/
#define ESP_BT_VS_CH_CLASSIFICATION_REPORTING_MODE_EVT_SUBCODE (0x07)
/**
* @note The init function is `bt_stack_enableInternalDbgVsCmd(true)`
*/
#define ESP_BT_VS_LMP_RECEIVED_EVT_SUBCODE (0x0a)
/**
* @note The init function is `bt_stack_enableInternalDbgVsCmd(true)`
*/
#define ESP_BT_VS_LMP_TX_CFM_EVT_SUBCODE (0x0b)
/**
* @note The init function is `bt_stack_enableInternalDbgVsCmd(true)`
*/
#define ESP_BT_VS_LMP_DBG_ENTERED_EVT_SUBCODE (0x0c)
#ifdef __cplusplus
}
#endif
#include "../../common/btdm_le_vs.h"

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -169,11 +169,10 @@ hci_transport_deinit(void)
{
hci_driver_ops_t *ops;
r_ble_hci_trans_cfg_hs((esp_hci_internal_rx_cmd_fn *)hci_transport_controller_tx_dummy, NULL,
(esp_hci_internal_rx_acl_fn *)hci_transport_controller_tx_dummy, NULL);
ops = s_hci_transport_env.driver_ops;
if (ops) {
r_ble_hci_trans_cfg_hs((esp_hci_internal_rx_cmd_fn *)hci_transport_controller_tx_dummy, NULL,
(esp_hci_internal_rx_acl_fn *)hci_transport_controller_tx_dummy, NULL);
ops->hci_driver_deinit();
}
memset(&s_hci_transport_env, 0, sizeof(hci_transport_env_t));

View File

@@ -12,15 +12,15 @@ list(APPEND porting_srcs ${BTDM_COMMON_SRCS})
list(APPEND porting_include_dirs "${CMAKE_CURRENT_SOURCE_DIR}/controller/btdm_common/include")
# ble
list(APPEND porting_include_dirs "${CMAKE_CURRENT_SOURCE_DIR}/controller/ble/include")
if(CONFIG_BT_CTRL_BLE_ENABLE)
list(APPEND porting_include_dirs "${CMAKE_CURRENT_SOURCE_DIR}/controller/ble/include")
file(GLOB_RECURSE BLE_SRCS "controller/ble/src/*.c")
list(APPEND porting_srcs ${BLE_SRCS})
endif()
# bredr
list(APPEND porting_include_dirs "${CMAKE_CURRENT_SOURCE_DIR}/controller/bredr/include")
if(CONFIG_BT_CTRL_BREDR_ENABLE)
list(APPEND porting_include_dirs "${CMAKE_CURRENT_SOURCE_DIR}/controller/bredr/include")
file(GLOB_RECURSE BREDR_SRCS "controller/bredr/src/*.c")
list(APPEND porting_srcs ${BREDR_SRCS})
endif()

View File

@@ -1,3 +1,112 @@
menu "Connection vendor/Optimization Options"
config BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
bool "Enable enhanced Access Address check in CONNECT_IND"
default n
help
Enabling this option will add stricter verification of the Access Address in the CONNECT_IND PDU.
This improves security by ensuring that only connection requests with valid Access Addresses are accepted.
If disabled, only basic checks are applied, improving compatibility.
config BT_LE_CTRL_CHAN_ASS_EN
bool "Enable channel assessment(Experimental)"
default n
help
If this option is enabled, The Controller will records the communication quality
for each channel and then start a timer to check and update the channel map every 4 seconds.
menu "BLE disconnects when Instant Passed (0x28) occurs"
config BT_LE_CTRL_LLCP_CONN_UPDATE
bool "BLE ACL connection update procedure"
default n
help
If this option is enabled, Controller will terminate the connection
when Instant Passed (0x28) error occurs during connection update procedure.
config BT_LE_CTRL_LLCP_CHAN_MAP_UPDATE
bool "BLE ACL channel map update procedure"
default n
help
If this option is enabled, Controller will terminate the connection
when Instant Passed (0x28) error occurs in channel map update procedure.
config BT_LE_CTRL_LLCP_PHY_UPDATE
bool "BLE ACL PHY update procedure"
default n
help
If this option is enabled, Controller will terminate the connection
when Instant Passed (0x28) error occurs in PHY update procedure.
endmenu # "BLE disconnects when Instant Passed (0x28) occurs"
endmenu # "Connection vendor/Optimization Options"
menu "Scanning vendor/Optimization Options"
config BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
int "The value of upperlimitmax during scan backoff procedure"
range 1 256
default 32
help
The value of upperlimitmax needs to be a power of 2.
endmenu # "Scanning vendor/Optimization Options"
menu "Advertising vendor/Optimization Options"
config BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX
bool "Enable aux packet when ext adv data length is zero(Experimental)"
default y
help
When this option is enabled, auxiliary packets will be present in the events of
'Non-Connectable and Non-Scannable' regardless of whether the advertising length is 0.
If this option is not enabled, auxiliary packets will only be present when the advertising length is not 0.
config BT_LE_CTRL_ADV_EVENT_INC_ON_FULL_TX_EN
bool "Increment advertising event count only on full PDU TX success"
default n
help
When enabled, the advertising event count is incremented only
if all PDUs in an advertising event are transmitted successfully.
If disabled, the event count is incremented regardless of transmission success.
config BT_LE_CTRL_ADV_CH38_39_TX_AVOID_CONFLICT_EN
bool "Delay advertising TX on channels 38/39 to avoid scheduling conflicts"
default n
help
When enabled, advertising transmissions on channels 38 and 39
are delayed if a scheduling conflict occurs.
config BT_LE_ADV_CH39_TXPWR_CONFIG_SEPARATELY_EN
bool "(Unsupported !!) Enable separate TX power for advertising on channel 39"
default n
help
When enabled, the TX power for advertising transmissions
on channel 39 can be configured independently of other channels.
config BT_LE_DFT_CH39_TX_POWER_LEVEL_DBM_EFF
int "Tx power for advertising on channel 39 (dBm)"
depends on BT_LE_ADV_CH39_TXPWR_CONFIG_SEPARATELY_EN
range -15 20
default 0
config BT_LE_CTRL_ADV_TX_CONTINUE_WHEN_EXCEED_ITVL_EN
bool "Allow advertising TX to continue if data TX exceeds interval"
default n
help
When enabled, advertising transmission continues even if the
TX duration for advertising data exceeds the configured advertising interval.
config BT_LE_CTRL_ADV_RAND_CH_IDX_EN
bool "Enable Randomized Advertising Channel Indexing"
default n
help
When enabled, the advertising channel sequence is randomized
according to the Randomized Advertising Channel Indexing feature.
If disabled, the standard channel sequence is used.
config BT_LE_CTRL_FAST_CONN_DATA_TX_EN
bool "Enable fast sending of connection data"
default y
help
If this option is enabled, The Controller will continue to
Send an empty PDU after sending valid connection data within an interval.
endmenu # "Advertising vendor/Optimization Options"
menuconfig BT_LE_50_FEATURE_SUPPORT
bool "Enable BLE 5 feature"
@@ -64,6 +173,19 @@ if BT_LE_EXT_ADV
help
This enables controller transfer periodic sync events to host
config BT_LE_PERIODIC_ADV_WITH_RESPONSE_ENABLED
bool "Enable BLE periodic advertising with response"
depends on BT_LE_ENABLE_PERIODIC_ADV && SOC_BLE_PERIODIC_ADV_WITH_RESPONSE
default n
help
This enables BLE periodic advertising with response feature
config BT_LE_PERIODIC_SYNC_WITH_RESPONSE_ENABLED
bool "Enable BLE periodic sync with response"
depends on BT_LE_ENABLE_PERIODIC_ADV && SOC_BLE_PERIODIC_ADV_WITH_RESPONSE
default n
help
This enables BLE periodic sync with response feature
endif
config BT_LE_MAX_PERIODIC_SYNCS
@@ -110,13 +232,6 @@ config BT_LE_CTE_FEATURE_ENABLED
This feature allows devices to determine the direction of a Bluetooth CTE signal,
enabling Angle of Arrival (AoA) and Angle of Departure (AoD) functionality.
config BT_LE_PERIODIC_ADV_WITH_RESPONSE_ENABLED
bool "Enable BLE periodic advertising with response"
depends on BT_LE_50_FEATURE_SUPPORT && SOC_BLE_PERIODIC_ADV_WITH_RESPONSE
default n
help
This enables BLE periodic advertising with response feature
menuconfig BT_LE_ISO_SUPPORT
bool "Enable BLE ISO feature"
default n
@@ -616,3 +731,23 @@ config BT_LE_DFT_TX_POWER_LEVEL_DBM_EFF
config BT_LE_DTM_ENABLED
bool "Enable Direct Test Mode (DTM) feature"
default n
menuconfig BT_CTRL_LE_VS_CMD_EVT_ENABLED
bool "Enable vendor-specific HCI commands"
default n if BT_CONTROLLER_ONLY
default y
help
Enable controller's vendor-specific HCI commands
config BT_CTRL_LE_VS_ADI_FILTER_ENABLED
depends on BT_CTRL_LE_VS_CMD_EVT_ENABLED && !BT_NIMBLE_ENABLED
bool "Use ADI to failter adv reports"
default n
help
ADI can be utilized to filter advertisement reports,
which will help to reduce time consumption on the secondary channel.
config BT_CTRL_LE_VS_CONST_EXT_ADV_DID
default n
depends on BT_CTRL_LE_VS_CMD_EVT_ENABLED && !BT_NIMBLE_ENABLED
bool "Allow setting constant extended advertisement DID"

View File

@@ -16,6 +16,8 @@ int ble_stack_enable(void);
void ble_stack_disable(void);
void ble_stack_reset(void);
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
esp_err_t sleep_modem_ble_mac_modem_state_init(void);
#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE

View File

@@ -7,8 +7,9 @@
#ifndef __BLE_USER_CFG_H__
#define __BLE_USER_CFG_H__
#include <stdint.h>
#include <sdkconfig.h>
#include <stdbool.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
@@ -20,156 +21,339 @@ extern "C" {
#if CONFIG_BT_NIMBLE_ENABLED
#if CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_CODED_PHY
#define BLE_LL_SCAN_PHY_NUMBER_N (2)
#else
#define BLE_LL_SCAN_PHY_NUMBER_N (1)
#endif
#define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST MYNEWT_VAL(BLE_MAX_PERIODIC_ADVERTISER_LIST)
#define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS MYNEWT_VAL(BLE_MAX_PERIODIC_SYNCS)
#define DEFAULT_BT_LE_MAX_CONNECTIONS MYNEWT_VAL(BLE_MAX_CONNECTIONS)
#define DEFAULT_BT_LE_ACL_BUF_SIZE MYNEWT_VAL(BLE_TRANSPORT_ACL_SIZE)
#define DEFAULT_BT_LE_ACL_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_ACL_FROM_LL_COUNT)
#define DEFAULT_BT_LE_HCI_EVT_BUF_SIZE MYNEWT_VAL(BLE_TRANSPORT_EVT_SIZE)
#define DEFAULT_BT_LE_EXT_ADV_MAX_SIZE MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE)
#define DEFAULT_BT_LE_MAX_EXT_ADV_INSTANCES MYNEWT_VAL(BLE_MULTI_ADV_INSTANCES)
#define DEFAULT_BT_NIMBLE_WHITELIST_SIZE MYNEWT_VAL(BLE_LL_WHITELIST_SIZE)
#define DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_EVT_COUNT)
#define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_EVT_DISCARDABLE_COUNT)
#define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF
#define DEFAULT_BT_LE_POWER_CONTROL_ENABLED MYNEWT_VAL(BLE_POWER_CONTROL)
#if CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_CODED_PHY
#define BLE_LL_SCAN_PHY_NUMBER_N (2)
#else
#define BLE_LL_SCAN_PHY_NUMBER_N (1)
#endif
#define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST MYNEWT_VAL(BLE_MAX_PERIODIC_ADVERTISER_LIST)
#define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS MYNEWT_VAL(BLE_MAX_PERIODIC_SYNCS)
#define DEFAULT_BT_LE_MAX_CONNECTIONS MYNEWT_VAL(BLE_MAX_CONNECTIONS)
#define DEFAULT_BT_LE_ACL_BUF_SIZE MYNEWT_VAL(BLE_TRANSPORT_ACL_SIZE)
#define DEFAULT_BT_LE_ACL_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_ACL_FROM_LL_COUNT)
#define DEFAULT_BT_LE_HCI_EVT_BUF_SIZE MYNEWT_VAL(BLE_TRANSPORT_EVT_SIZE)
#define DEFAULT_BT_LE_EXT_ADV_MAX_SIZE MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE)
#define DEFAULT_BT_LE_MAX_EXT_ADV_INSTANCES MYNEWT_VAL(BLE_MULTI_ADV_INSTANCES)
#define DEFAULT_BT_NIMBLE_WHITELIST_SIZE MYNEWT_VAL(BLE_LL_WHITELIST_SIZE)
#define DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_EVT_COUNT)
#define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_EVT_DISCARDABLE_COUNT)
#define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF
#else
#if CONFIG_BT_LE_LL_CFG_FEAT_LE_CODED_PHY
#define BLE_LL_SCAN_PHY_NUMBER_N (2)
#else
#define BLE_LL_SCAN_PHY_NUMBER_N (1)
#endif
#if defined(CONFIG_BT_LE_MAX_PERIODIC_ADVERTISER_LIST)
#define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST (CONFIG_BT_LE_MAX_PERIODIC_ADVERTISER_LIST)
#else
#define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST (5)
#endif
#if defined(CONFIG_BT_LE_MAX_PERIODIC_SYNCS)
#define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS (CONFIG_BT_LE_MAX_PERIODIC_SYNCS)
#else
#define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS (1)
#endif
#if defined(CONFIG_BT_LE_MAX_CONNECTIONS)
#define DEFAULT_BT_LE_MAX_CONNECTIONS (CONFIG_BT_LE_MAX_CONNECTIONS)
#else
#define DEFAULT_BT_LE_MAX_CONNECTIONS (2)
#endif
#if defined(CONFIG_BT_LE_ACL_BUF_SIZE)
#define DEFAULT_BT_LE_ACL_BUF_SIZE (CONFIG_BT_LE_ACL_BUF_SIZE)
#else
#define DEFAULT_BT_LE_ACL_BUF_SIZE (255)
#endif
#if defined(CONFIG_BT_LE_ACL_BUF_COUNT)
#define DEFAULT_BT_LE_ACL_BUF_COUNT (CONFIG_BT_LE_ACL_BUF_COUNT)
#else
#define DEFAULT_BT_LE_ACL_BUF_COUNT (24)
#endif
#if defined(CONFIG_BT_LE_HCI_EVT_BUF_SIZE)
#define DEFAULT_BT_LE_HCI_EVT_BUF_SIZE (CONFIG_BT_LE_HCI_EVT_BUF_SIZE)
#else
#define DEFAULT_BT_LE_HCI_EVT_BUF_SIZE (70)
#endif
#if defined(CONFIG_BT_LE_EXT_ADV_MAX_SIZE)
#define DEFAULT_BT_LE_EXT_ADV_MAX_SIZE (CONFIG_BT_LE_EXT_ADV_MAX_SIZE)
#else
#define DEFAULT_BT_LE_EXT_ADV_MAX_SIZE (31)
#endif
#if defined(CONFIG_BT_LE_MAX_EXT_ADV_INSTANCES)
#define DEFAULT_BT_LE_MAX_EXT_ADV_INSTANCES (CONFIG_BT_LE_MAX_EXT_ADV_INSTANCES)
#else
#define DEFAULT_BT_LE_MAX_EXT_ADV_INSTANCES (1)
#endif
#if defined(CONFIG_BT_LE_WHITELIST_SIZE)
#define DEFAULT_BT_NIMBLE_WHITELIST_SIZE (CONFIG_BT_LE_WHITELIST_SIZE)
#else
#define DEFAULT_BT_NIMBLE_WHITELIST_SIZE (12)
#endif
#if defined(CONFIG_BT_LE_HCI_EVT_HI_BUF_COUNT)
#define DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT (CONFIG_BT_LE_HCI_EVT_HI_BUF_COUNT)
#else
#define DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT (30)
#endif
#if defined(CONFIG_BT_LE_HCI_EVT_LO_BUF_COUNT)
#define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT (CONFIG_BT_LE_HCI_EVT_LO_BUF_COUNT)
#else
#define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT (8)
#endif
#define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF
#if defined(CONFIG_BT_LE_POWER_CONTROL_ENABLED)
#define DEFAULT_BT_LE_POWER_CONTROL_ENABLED (CONFIG_BT_LE_POWER_CONTROL_ENABLED)
#else
#define DEFAULT_BT_LE_POWER_CONTROL_ENABLED (0)
#endif
#if CONFIG_BT_LE_LL_CFG_FEAT_LE_CODED_PHY
#define BLE_LL_SCAN_PHY_NUMBER_N (2)
#else
#define BLE_LL_SCAN_PHY_NUMBER_N (1)
#endif
#if defined(CONFIG_BT_LE_MAX_PERIODIC_ADVERTISER_LIST)
#define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST (CONFIG_BT_LE_MAX_PERIODIC_ADVERTISER_LIST)
#else
#define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST (5)
#endif
#if defined(CONFIG_BT_LE_MAX_PERIODIC_SYNCS)
#define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS (CONFIG_BT_LE_MAX_PERIODIC_SYNCS)
#else
#define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS (1)
#endif
#if defined(CONFIG_BT_LE_MAX_CONNECTIONS)
#define DEFAULT_BT_LE_MAX_CONNECTIONS (CONFIG_BT_LE_MAX_CONNECTIONS)
#else
#define DEFAULT_BT_LE_MAX_CONNECTIONS (2)
#endif
#if defined(CONFIG_BT_LE_ACL_BUF_SIZE)
#define DEFAULT_BT_LE_ACL_BUF_SIZE (CONFIG_BT_LE_ACL_BUF_SIZE)
#else
#define DEFAULT_BT_LE_ACL_BUF_SIZE (255)
#endif
#if defined(CONFIG_BT_LE_ACL_BUF_COUNT)
#define DEFAULT_BT_LE_ACL_BUF_COUNT (CONFIG_BT_LE_ACL_BUF_COUNT)
#else
#define DEFAULT_BT_LE_ACL_BUF_COUNT (24)
#endif
#if defined(CONFIG_BT_LE_HCI_EVT_BUF_SIZE)
#define DEFAULT_BT_LE_HCI_EVT_BUF_SIZE (CONFIG_BT_LE_HCI_EVT_BUF_SIZE)
#else
#define DEFAULT_BT_LE_HCI_EVT_BUF_SIZE (70)
#endif
#if defined(CONFIG_BT_LE_EXT_ADV_MAX_SIZE)
#define DEFAULT_BT_LE_EXT_ADV_MAX_SIZE (CONFIG_BT_LE_EXT_ADV_MAX_SIZE)
#else
#define DEFAULT_BT_LE_EXT_ADV_MAX_SIZE (31)
#endif
#if defined(CONFIG_BT_LE_MAX_EXT_ADV_INSTANCES)
#define DEFAULT_BT_LE_MAX_EXT_ADV_INSTANCES (CONFIG_BT_LE_MAX_EXT_ADV_INSTANCES)
#else
#define DEFAULT_BT_LE_MAX_EXT_ADV_INSTANCES (1)
#endif
#if defined(CONFIG_BT_LE_WHITELIST_SIZE)
#define DEFAULT_BT_NIMBLE_WHITELIST_SIZE (CONFIG_BT_LE_WHITELIST_SIZE)
#else
#define DEFAULT_BT_NIMBLE_WHITELIST_SIZE (12)
#endif
#if defined(CONFIG_BT_LE_HCI_EVT_HI_BUF_COUNT)
#define DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT (CONFIG_BT_LE_HCI_EVT_HI_BUF_COUNT)
#else
#define DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT (30)
#endif
#if defined(CONFIG_BT_LE_HCI_EVT_LO_BUF_COUNT)
#define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT (CONFIG_BT_LE_HCI_EVT_LO_BUF_COUNT)
#else
#define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT (8)
#endif
#define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF
#endif // CONFIG_BT_NIMBLE_ENABLED
#ifdef CONFIG_BT_LE_TX_CCA_ENABLED
#define DEFAULT_BT_LE_TX_CCA_ENABLED (CONFIG_BT_LE_TX_CCA_ENABLED)
#define DEFAULT_BT_LE_TX_CCA_ENABLED (CONFIG_BT_LE_TX_CCA_ENABLED)
#else
#define DEFAULT_BT_LE_TX_CCA_ENABLED (0)
#define DEFAULT_BT_LE_TX_CCA_ENABLED (0)
#endif
#ifdef CONFIG_BT_LE_CCA_RSSI_THRESH
#define DEFAULT_BT_LE_CCA_RSSI_THRESH (CONFIG_BT_LE_CCA_RSSI_THRESH)
#define DEFAULT_BT_LE_CCA_RSSI_THRESH (CONFIG_BT_LE_CCA_RSSI_THRESH)
#else
#define DEFAULT_BT_LE_CCA_RSSI_THRESH (50)
#define DEFAULT_BT_LE_CCA_RSSI_THRESH (50)
#endif
#define DEFAULT_BT_LE_SCAN_RSP_DATA_MAX_LEN_N DEFAULT_BT_LE_EXT_ADV_MAX_SIZE
#define UC_BLE_CTRL_CONN_ENABLED (1)
#if defined(CONFIG_BT_NIMBLE_AOA_AOD)
#define UC_BT_CTRL_LE_CTE_ENABLED (CONFIG_BT_NIMBLE_AOA_AOD)
#elif defined(CONFIG_BT_LE_CTE_ENABLED)
#define UC_BT_CTRL_LE_CTE_ENABLED (CONFIG_BT_LE_CTE_ENABLED)
#elif defined(CONFIG_BT_LE_CTE_FEATURE_ENABLED)
#define UC_BT_CTRL_LE_CTE_ENABLED (CONFIG_BT_LE_CTE_FEATURE_ENABLED)
#else
#define UC_BT_CTRL_LE_CTE_ENABLED (0)
#endif // CONFIG_BT_NIMBLE_AOA_AOD
#define UC_BT_CTRL_LE_CTE_CAL_ENABLED (0)
#if CONFIG_BT_LE_DTM_ENABLED
#define UC_BT_CTRL_LE_DTM_ENABLED (CONFIG_BT_LE_DTM_ENABLED)
#else
#define UC_BT_CTRL_LE_DTM_ENABLED (0)
#endif
#if defined(CONFIG_BT_NIMBLE_PERIODIC_ADV_WITH_RESPONSES)
#define UC_BLE_CTRL_PAWR_BCAST_SUPPORTED (CONFIG_BT_NIMBLE_PERIODIC_ADV_WITH_RESPONSES)
#elif defined(CONFIG_BT_BLE_FEAT_PAWR_EN)
#define UC_BLE_CTRL_PAWR_BCAST_SUPPORTED (CONFIG_BT_BLE_FEAT_PAWR_EN)
#elif defined(CONFIG_BT_LE_PERIODIC_ADV_WITH_RESPONSE_ENABLED)
#define UC_BLE_CTRL_PAWR_BCAST_SUPPORTED (CONFIG_BT_LE_PERIODIC_ADV_WITH_RESPONSE_ENABLED)
#else
#define UC_BLE_CTRL_PAWR_BCAST_SUPPORTED (0)
#endif // CONFIG_BT_NIMBLE_PERIODIC_ADV_WITH_RESPONSES
#if defined(CONFIG_BT_NIMBLE_PERIODIC_ADV_WITH_RESPONSES)
#define UC_BLE_CTRL_PAWR_SYNC_SUPPORTED (CONFIG_BT_NIMBLE_PERIODIC_ADV_WITH_RESPONSES)
#elif defined(CONFIG_BT_BLE_FEAT_PAWR_EN)
#define UC_BLE_CTRL_PAWR_SYNC_SUPPORTED (CONFIG_BT_BLE_FEAT_PAWR_EN)
#elif defined(CONFIG_BT_LE_PERIODIC_SYNC_WITH_RESPONSE_ENABLED)
#define UC_BLE_CTRL_PAWR_SYNC_SUPPORTED (CONFIG_BT_LE_PERIODIC_SYNC_WITH_RESPONSE_ENABLED)
#else
#define UC_BLE_CTRL_PAWR_SYNC_SUPPORTED (0)
#endif // CONFIG_BT_NIMBLE_PERIODIC_ADV_WITH_RESPONSES
#define UC_BT_CTRL_LE_BIS_BCAST_ENABLED (CONFIG_BT_LE_ISO_SUPPORT)
#define UC_BT_CTRL_LE_BIS_SYNC_ENABLED (CONFIG_BT_LE_ISO_SUPPORT)
#define UC_BT_CTRL_LE_CIS_CENT_ENABLED (CONFIG_BT_LE_ISO_SUPPORT)
#define UC_BT_CTRL_LE_CIS_PRPH_ENABLED (CONFIG_BT_LE_ISO_SUPPORT)
#define UC_BT_CTRL_LE_CIS_ENABLED (CONFIG_BT_LE_ISO_SUPPORT)
#define UC_BT_CTRL_LE_ISO_ENABLED (CONFIG_BT_LE_ISO_SUPPORT)
#define UC_BT_CTRL_LE_ISO_TEST_ENABLED (CONFIG_BT_LE_ISO_SUPPORT)
#if defined(CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT)
#define UC_BT_CTRL_LE_50_FEATURE_SUPPORT (CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT)
#elif defined(CONFIG_BT_LE_50_FEATURE_SUPPORT)
#define UC_BT_CTRL_LE_50_FEATURE_SUPPORT (CONFIG_BT_LE_50_FEATURE_SUPPORT)
#else
#define UC_BT_CTRL_LE_50_FEATURE_SUPPORT (0)
#endif // CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT
#if defined(CONFIG_BT_NIMBLE_SUBRATE)
#define UC_BT_CTRL_LE_SUBRATE_ENABLED (CONFIG_BT_NIMBLE_SUBRATE)
#elif defined(CONFIG_BT_BLE_FEAT_CONN_SUBRATING)
#define UC_BT_CTRL_LE_SUBRATE_ENABLED (CONFIG_BT_BLE_FEAT_CONN_SUBRATING)
#elif defined(CONFIG_BT_LE_SUBRATE_ENABLED)
#define UC_BT_CTRL_LE_SUBRATE_ENABLED (CONFIG_BT_LE_SUBRATE_ENABLED)
#else
#define UC_BT_CTRL_LE_SUBRATE_ENABLED (0)
#endif // CONFIG_BT_NIMBLE_SUBRATE
#if defined(CONFIG_BT_NIMBLE_BLE_POWER_CONTROL)
#define UC_BT_CTRL_LE_POWER_CONTROL_ENABLED (CONFIG_BT_NIMBLE_BLE_POWER_CONTROL)
#elif defined(CONFIG_BT_LE_POWER_CONTROL_ENABLED)
#define UC_BT_CTRL_LE_POWER_CONTROL_ENABLED (CONFIG_BT_LE_POWER_CONTROL_ENABLED)
#else
#define UC_BT_CTRL_LE_POWER_CONTROL_ENABLED (0)
#endif // CONFIG_BT_NIMBLE_BLE_POWER_CONTROL
#if defined(CONFIG_BT_CTRL_LE_VS_CMD_EVT_ENABLED)
#define UC_BT_CTRL_LE_VS_CMD_EVT_ENABLED (CONFIG_BT_CTRL_LE_VS_CMD_EVT_ENABLED)
#else
#define UC_BT_CTRL_LE_VS_CMD_EVT_ENABLED (0)
#endif // CONFIG_BT_CTRL_LE_VS_CMD_EVT_ENABLED
#if defined(CONFIG_BT_NIMBLE_ADV_SEND_CONSTANT_DID)
#define UC_BT_CTRL_LE_VS_CONST_EXT_ADV_DID (CONFIG_BT_NIMBLE_ADV_SEND_CONSTANT_DID)
#elif defined(CONFIG_BT_CTRL_LE_VS_CONST_EXT_ADV_DID)
#define UC_BT_CTRL_LE_VS_CONST_EXT_ADV_DID (CONFIG_BT_CTRL_LE_VS_CONST_EXT_ADV_DID)
#else
#define UC_BT_CTRL_LE_VS_CONST_EXT_ADV_DID (0)
#endif // CONFIG_BT_NIMBLE_ADV_SEND_CONSTANT_DID
#if defined(CONFIG_BT_NIMBLE_SCAN_ALLOW_ENH_ADI_FILTER)
#define UC_BT_CTRL_LE_VS_ADI_FILTER_ENABLED (CONFIG_BT_NIMBLE_SCAN_ALLOW_ENH_ADI_FILTER)
#elif defined(CONFIG_BT_CTRL_LE_VS_ADI_FILTER_ENABLED)
#define UC_BT_CTRL_LE_VS_ADI_FILTER_ENABLED (CONFIG_BT_CTRL_LE_VS_ADI_FILTER_ENABLED)
#else
#define UC_BT_CTRL_LE_VS_ADI_FILTER_ENABLED (0)
#endif // CONFIG_BT_NIMBLE_SCAN_ALLOW_ENH_ADI_FILTER
#if defined(CONFIG_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS)
#define UC_BT_CTRL_LE_CHECK_CONNECT_IND_ACCESS_ADDRESS (CONFIG_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS)
#else
#define UC_BT_CTRL_LE_CHECK_CONNECT_IND_ACCESS_ADDRESS (0)
#endif // CONFIG_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
#if defined(CONFIG_BT_LE_CTRL_LLCP_CONN_UPDATE)
#define UC_BT_CTRL_LE_CONN_UPDATE_PASSED_DISC_FLAG (1 << 0)
#else
#define UC_BT_CTRL_LE_CONN_UPDATE_PASSED_DISC_FLAG (0 << 0)
#endif // CONFIG_BT_LE_CTRL_LLCP_CONN_UPDATE
#if defined(CONFIG_BT_LE_CTRL_LLCP_CHAN_MAP_UPDATE)
#define UC_BT_CTRL_LE_CHAN_UPDATE_PASSED_DISC_FLAG (1 << 1)
#else
#define UC_BT_CTRL_LE_CHAN_UPDATE_PASSED_DISC_FLAG (0 << 1)
#endif // CONFIG_BT_LE_CTRL_LLCP_CHAN_MAP_UPDATE
#if defined(CONFIG_BT_LE_CTRL_LLCP_PHY_UPDATE)
#define UC_BT_CTRL_LE_PHY_UPDATE_PASSED_DISC_FLAG (1 << 2)
#else
#define UC_BT_CTRL_LE_PHY_UPDATE_PASSED_DISC_FLAG (0 << 2)
#endif // CONFIG_BT_LE_CTRL_LLCP_PHY_UPDATE
#define UC_BT_CTRL_LLCP_INSTANT_PASSED_DISC_FLAGS \
(UC_BT_CTRL_LE_CONN_UPDATE_PASSED_DISC_FLAG | UC_BT_CTRL_LE_CHAN_UPDATE_PASSED_DISC_FLAG | \
UC_BT_CTRL_LE_PHY_UPDATE_PASSED_DISC_FLAG)
#if defined(CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX)
#define UC_BT_CTRL_LE_SCAN_BACKOFF_UPPERLIMITMAX (CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX)
#else
#define UC_BT_CTRL_LE_SCAN_BACKOFF_UPPERLIMITMAX (256)
#endif // CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
#if defined(CONFIG_BT_LE_CTRL_CHAN_ASS_EN)
#define UC_BT_CTRL_LE_CHAN_ASS_ENABLED (CONFIG_BT_LE_CTRL_CHAN_ASS_EN)
#else
#define UC_BT_CTRL_LE_CHAN_ASS_ENABLED (0)
#endif // CONFIG_BT_LE_CTRL_CHAN_ASS_EN
#if defined(CONFIG_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX)
#define UC_BT_CTRL_LE_ADV_DATA_LENGTH_ZERO_AUX (CONFIG_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX)
#else
#define UC_BT_CTRL_LE_ADV_DATA_LENGTH_ZERO_AUX (1)
#endif // CONFIG_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX
#if defined(CONFIG_BT_LE_PTR_CHECK_ENABLED)
#define UC_BT_CTRL_LE_PTR_CHECK_ENABLED (CONFIG_BT_LE_PTR_CHECK_ENABLED)
#else
#define UC_BT_CTRL_LE_PTR_CHECK_ENABLED (0)
#endif // CONFIG_BT_LE_PTR_CHECK_ENABLED
#if defined(CONFIG_BT_LE_CTRL_ADV_EVENT_INC_ON_FULL_TX_EN)
#define UC_BT_CTRL_LE_ADV_EVENT_INC_ON_FULL_TX_EN (1 << 0)
#else
#define UC_BT_CTRL_LE_ADV_EVENT_INC_ON_FULL_TX_EN (0)
#endif // BT_LE_CTRL_ADV_EVENT_INC_ON_FULL_TX_EN
#if defined(CONFIG_BT_LE_CTRL_ADV_CH38_39_TX_AVOID_CONFLICT_EN)
#define UC_BT_CTRL_LE_ADV_CH38_39_TX_AVOID_CONFLICT_EN (1 << 1)
#else
#define UC_BT_CTRL_LE_ADV_CH38_39_TX_AVOID_CONFLICT_EN (0)
#endif // BT_LE_CTRL_ADV_CH38_39_TX_AVOID_CONFLICT_EN
#if defined(CONFIG_BT_LE_ADV_CH39_TXPWR_CONFIG_SEPARATELY_EN)
#define UC_BT_ADV__LECH39_TXPWR_CONFIG_SEPARATELY_EN (1 << 2)
#define UC_BT_CTRL_LE_CH39_TX_PWR_DBM (CONFIG_BT_LE_DFT_CH39_TX_POWER_LEVEL_DBM_EFF)
#else
#define UC_BT_ADV__LECH39_TXPWR_CONFIG_SEPARATELY_EN (0)
#define UC_BT_CTRL_LE_CH39_TX_PWR_DBM (CONFIG_BT_LE_DFT_TX_POWER_LEVEL_DBM_EFF)
#endif // BT_LE_ADV_CH39_TXPWR_CONFIG_SEPARATELY_EN
#if defined(CONFIG_BT_LE_CTRL_ADV_TX_CONTINUE_WHEN_EXCEED_ITVL_EN)
#define UC_BT_CTRL_LE_ADV_TX_CONTINUE_WHEN_EXCEED_ITVL_EN (1 << 3)
#else
#define UC_BT_CTRL_LE_ADV_TX_CONTINUE_WHEN_EXCEED_ITVL_EN (0)
#endif // BT_LE_CTRL_ADV_TX_CONTINUE_WHEN_EXCEED_ITVL_EN
#if defined(CONFIG_BT_LE_CTRL_ADV_RAND_CH_IDX_EN)
#define UC_BT_CTRL_LE_ADV_RAND_CH_IDX_EN (1 << 4)
#else
#define UC_BT_CTRL_LE_ADV_RAND_CH_IDX_EN (0)
#endif // BT_LE_CTRL_ADV_RAND_CH_IDX_EN
#define UC_BT_CTRL_LE_ADV_TX_OPTIONS \
(UC_BT_CTRL_LE_ADV_EVENT_INC_ON_FULL_TX_EN | UC_BT_CTRL_LE_ADV_CH38_39_TX_AVOID_CONFLICT_EN | \
UC_BT_ADV__LECH39_TXPWR_CONFIG_SEPARATELY_EN | \
UC_BT_CTRL_LE_ADV_TX_CONTINUE_WHEN_EXCEED_ITVL_EN | UC_BT_CTRL_LE_ADV_RAND_CH_IDX_EN)
#if defined(CONFIG_BT_LE_CTRL_FAST_CONN_DATA_TX_EN)
#define UC_BT_CTRL_LE_FAST_CONN_DATA_TX_EN (CONFIG_BT_LE_CTRL_FAST_CONN_DATA_TX_EN)
#else
#define UC_BT_CTRL_LE_FAST_CONN_DATA_TX_EN (0)
#endif // CONFIG_BT_LE_CTRL_FAST_CONN_DATA_TX_EN
/* Unchanged configuration */
#define BLE_LL_CTRL_PROC_TIMEOUT_MS_N (40000) /* ms */
#define BLE_LL_CTRL_PROC_TIMEOUT_MS_N (40000) /* ms */
#define BLE_LL_CFG_NUM_HCI_CMD_PKTS_N (1)
#define BLE_LL_CFG_NUM_HCI_CMD_PKTS_N (1)
#define BLE_LL_SCHED_ADV_MAX_USECS_N (852)
#define BLE_LL_SCHED_ADV_MAX_USECS_N (852)
#define BLE_LL_SCHED_DIRECT_ADV_MAX_USECS_N (502)
#define BLE_LL_SCHED_MAX_ADV_PDU_USECS_N (376)
#define BLE_LL_SCHED_MAX_ADV_PDU_USECS_N (376)
#define BLE_LL_SUB_VERS_NR_N (0x0000)
#define BLE_LL_SUB_VERS_NR_N (0x0000)
#define BLE_LL_JITTER_USECS_N (16)
#define BLE_LL_JITTER_USECS_N (16)
#define BLE_PHY_MAX_PWR_DBM_N (10)
#define BLE_PHY_MAX_PWR_DBM_N (10)
#define BLE_LL_CONN_DEF_AUTH_PYLD_TMO_N (3000)
#define BLE_LL_CONN_DEF_AUTH_PYLD_TMO_N (3000)
#define RTC_FREQ_N (32768) /* in Hz */
#define RTC_FREQ_N (32768) /* in Hz */
#define BLE_LL_TX_PWR_DBM_N (9)
#define BLE_LL_TX_PWR_DBM_N (9)
#ifdef CONFIG_BT_LE_BQB_TEST_EN
#define RUN_BQB_TEST (CONFIG_BT_LE_BQB_TEST_EN)
#define RUN_BQB_TEST (CONFIG_BT_LE_BQB_TEST_EN)
#else
#define RUN_BQB_TEST (0)
#define RUN_BQB_TEST (0)
#endif // CONFIG_BT_LE_BQB_TEST_EN
#define RUN_QA_TEST (0)
#define NIMBLE_DISABLE_SCAN_BACKOFF (0)
#define RUN_QA_TEST (0)
#define NIMBLE_DISABLE_SCAN_BACKOFF (0)
#ifdef __cplusplus
}

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2025-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -34,10 +34,9 @@
#define _OS_MEMPOOL_H_
#include <stdbool.h>
#include "os/os.h"
#include "os/os_error.h"
#include "os/queue.h"
#include "btdm_mempool.h"
#include "syscfg/syscfg.h"
#ifdef __cplusplus
extern "C" {
@@ -78,20 +77,28 @@ struct os_mempool {
SLIST_HEAD(,os_memblock);
/** Name for memory block */
const char *name;
#if MYNEWT_VAL(MP_BLOCK_REUSED)
/** The number of allocated blocks. */
uint16_t mp_alloc_blocks;
#endif // MYNEWT_VAL(MP_BLOCK_REUSED)
};
static_assert(sizeof(struct os_mempool) == sizeof(struct btdm_mempool),
"Error: size of os_mempool");
/**
* Indicates an extended mempool. Address can be safely cast to
* (struct os_mempool_ext *).
*/
#define OS_MEMPOOL_F_EXT 0x01
#define OS_MEMPOOL_F_EXT BIT(0)
/* Flag to indicate runtime allocation mode */
#define OS_MEMPOOL_F_RUNTIME 0x02
#define OS_MEMPOOL_F_RUNTIME BIT(1)
/* Flag to indicate reuse block for runtime allocation mode */
#define OS_MEMPOOL_F_REUSED 0x04
#define OS_MEMPOOL_F_REUSED BIT(2)
/* Flag to indicate no address range comparison */
#define OS_MEMPOOL_F_FRAG BIT(3)
/* Flag to indicate mempool source */
#define OS_MEMPOOL_F_CONTROLLER BIT(4)
#define OS_MEMPOOL_F_LOW_PRIO BIT(5)
#define OS_MEMPOOL_F_FORBID BIT(6)
#define OS_MEMPOOL_F_COMBINATION BIT(7)
struct os_mempool_ext;
@@ -116,12 +123,27 @@ struct os_mempool_ext;
typedef os_error_t os_mempool_put_fn(struct os_mempool_ext *ome, void *data,
void *arg);
/**
* Block get callback function. If configured, this callback gets executed
* whenever a block is fetched from the corresponding extended mempool.
*
* @param ome The extended mempool that a block is being
* fetched.
* @param arg Optional argument configured along with the
* callback.
*
* @return void * pointer of block, return NULL if get failed
*/
typedef void *os_mempool_get_fn(struct os_mempool_ext *ome, void *arg);
struct os_mempool_ext {
struct os_mempool mpe_mp;
/* Callback that is executed immediately when a block is freed. */
os_mempool_put_fn *mpe_put_cb;
void *mpe_put_arg;
os_mempool_get_fn *mpe_get_cb;
void *mpe_get_arg;
};
#define OS_MEMPOOL_INFO_NAME_LEN (32)
@@ -156,19 +178,6 @@ struct os_mempool_info {
struct os_mempool *os_mempool_info_get_next(struct os_mempool *,
struct os_mempool_info *);
/*
* To calculate size of the memory buffer needed for the pool. NOTE: This size
* is NOT in bytes! The size is the number of os_membuf_t elements required for
* the memory pool.
*/
#if MYNEWT_VAL(OS_MEMPOOL_GUARD)
/*
* Leave extra 4 bytes of guard area at the end.
*/
#define OS_MEMPOOL_BLOCK_SZ(sz) ((sz) + sizeof(os_membuf_t))
#else
#define OS_MEMPOOL_BLOCK_SZ(sz) (sz)
#endif
#if (OS_ALIGNMENT == 4)
typedef uint32_t os_membuf_t;
#elif (OS_ALIGNMENT == 8)
@@ -184,123 +193,7 @@ typedef __uint128_t os_membuf_t;
#define OS_MEMPOOL_BYTES(n,blksize) \
(sizeof (os_membuf_t) * OS_MEMPOOL_SIZE((n), (blksize)))
#if SOC_ESP_NIMBLE_CONTROLLER && CONFIG_BT_CONTROLLER_ENABLED
/**
* Initialize a memory pool.
*
* @param mp Pointer to a pointer to a mempool
* @param blocks The number of blocks in the pool
* @param blocks_size The size of the block, in bytes.
* @param membuf Pointer to memory to contain blocks.
* @param name Name of the pool.
*
* @return os_error_t
*/
os_error_t r_os_mempool_init(struct os_mempool *mp, uint16_t blocks,
uint32_t block_size, void *membuf, const char *name);
#define os_mempool_init r_os_mempool_init
/**
* Initializes an extended memory pool. Extended attributes (e.g., callbacks)
* are not specified when this function is called; they are assigned manually
* after initialization.
*
* @param mpe The extended memory pool to initialize.
* @param blocks The number of blocks in the pool.
* @param block_size The size of each block, in bytes.
* @param membuf Pointer to memory to contain blocks.
* @param name Name of the pool.
*
* @return os_error_t
*/
os_error_t r_os_mempool_ext_init(struct os_mempool_ext *mpe, uint16_t blocks,
uint32_t block_size, void *membuf, const char *name);
#define os_mempool_ext_init r_os_mempool_ext_init
/**
* Removes the specified mempool from the list of initialized mempools.
*
* @param mp The mempool to unregister.
*
* @return 0 on success;
* OS_INVALID_PARM if the mempool is not
* registered.
*/
// os_error_t r_os_mempool_unregister(struct os_mempool *mp);
#define os_mempool_unregister(mp)
/**
* Clears a memory pool.
*
* @param mp The mempool to clear.
*
* @return os_error_t
*/
os_error_t r_os_mempool_clear(struct os_mempool *mp);
#define os_mempool_clear r_os_mempool_clear
/**
* Performs an integrity check of the specified mempool. This function
* attempts to detect memory corruption in the specified memory pool.
*
* @param mp The mempool to check.
*
* @return true if the memory pool passes the integrity
* check;
* false if the memory pool is corrupt.
*/
bool r_os_mempool_is_sane(const struct os_mempool *mp);
#define os_mempool_is_sane r_os_mempool_is_sane
/**
* Checks if a memory block was allocated from the specified mempool.
*
* @param mp The mempool to check as parent.
* @param block_addr The memory block to check as child.
*
* @return 0 if the block does not belong to the mempool;
* 1 if the block does belong to the mempool.
*/
int r_os_memblock_from(const struct os_mempool *mp, const void *block_addr);
#define os_memblock_from r_os_memblock_from
/**
* Get a memory block from a memory pool
*
* @param mp Pointer to the memory pool
*
* @return void* Pointer to block if available; NULL otherwise
*/
void *r_os_memblock_get(struct os_mempool *mp);
#define os_memblock_get r_os_memblock_get
/**
* Puts the memory block back into the pool, ignoring the put callback, if any.
* This function should only be called from a put callback to free a block
* without causing infinite recursion.
*
* @param mp Pointer to memory pool
* @param block_addr Pointer to memory block
*
* @return os_error_t
*/
os_error_t r_os_memblock_put_from_cb(struct os_mempool *mp, void *block_addr);
#define os_memblock_put_from_cb r_os_memblock_put_from_cb
/**
* Puts the memory block back into the pool
*
* @param mp Pointer to memory pool
* @param block_addr Pointer to memory block
*
* @return os_error_t
*/
os_error_t r_os_memblock_put(struct os_mempool *mp, void *block_addr);
#define os_memblock_put r_os_memblock_put
#else
#if !CONFIG_BT_DUAL_MODE_ARCH
/**
* Initialize a memory pool.
*
@@ -315,6 +208,24 @@ os_error_t r_os_memblock_put(struct os_mempool *mp, void *block_addr);
os_error_t os_mempool_init(struct os_mempool *mp, uint16_t blocks,
uint32_t block_size, void *membuf, const char *name);
/**
* @brief Initialize a memory pool.
* INTERNAL USE ONLY
*
* @param mp Pointer to a pointer to a mempool
* @param blocks The number of blocks in the pool
* @param blocks_size The size of the block, in bytes.
* @param membuf Pointer to memory to contain blocks.
* @param name Name of the pool.
* @param flags Mempool flags
*
* @return os_error_t
*/
os_error_t
os_mempool_init_internal(struct os_mempool *mp, uint16_t blocks,
uint32_t block_size, void *membuf, const char *name,
uint8_t flags);
/**
* Initializes an extended memory pool. Extended attributes (e.g., callbacks)
* are not specified when this function is called; they are assigned manually
@@ -331,6 +242,18 @@ os_error_t os_mempool_init(struct os_mempool *mp, uint16_t blocks,
os_error_t os_mempool_ext_init(struct os_mempool_ext *mpe, uint16_t blocks,
uint32_t block_size, void *membuf, const char *name);
/**
* Assign the put and get callback for an extended memory pool.
*
* @param mpe The extended memory pool
* @param put_cb Block put callback function
* @param put_arg Argument for put callback
* @param get_cb Block put callback function
* @param get_arg Argument for get callback
*/
void os_ext_mempool_register_cb(struct os_mempool_ext *mpe, void *put_cb, void *put_arg,
void *get_cb, void *get_arg);
/**
* Removes the specified mempool from the list of initialized mempools.
*
@@ -413,7 +336,116 @@ os_error_t os_memblock_put_from_cb(struct os_mempool *mp, void *block_addr);
* @return os_error_t
*/
os_error_t os_memblock_put(struct os_mempool *mp, void *block_addr);
#endif
/**
* @brief Set the mp_flags of memory pool
*
* @param mp Pointer to memory pool
* @param flags Flags value
*/
void os_mempool_flags_set(struct os_mempool *mp, uint8_t flags);
/**
* @brief Clear the mp_flags of memory pool
*
* @param mp Pointer to memory pool
* @param flags Flags value
*/
void os_mempool_flags_clear(struct os_mempool *mp, uint8_t flags);
#else /* !CONFIG_BT_DUAL_MODE_ARCH */
#include "btdm_mempool.h"
static_assert(sizeof(struct os_mempool) == sizeof(struct btdm_mempool), "Error: size of os_mempool");
static_assert(sizeof(struct os_mempool_ext) == sizeof(struct btdm_mempool_ext), "Error: size of os_mempool_ext");
static_assert(sizeof(struct os_memblock) == sizeof(struct btdm_memblock), "Error: size of os_memblock");
static inline os_error_t
os_mempool_init(struct os_mempool *mp, uint16_t blocks, uint32_t block_size,
void *membuf, const char *name)
{
return btdm_mempool_init((struct btdm_mempool *)mp, blocks, block_size,
membuf, name);
}
static inline os_error_t
os_mempool_ext_init(struct os_mempool_ext *mpe, uint16_t blocks,
uint32_t block_size, void *membuf, const char *name)
{
return btdm_mempool_ext_init((struct btdm_mempool_ext *)mpe, blocks,
block_size, membuf, name);
}
static inline void
os_ext_mempool_register_cb(struct os_mempool_ext *mpe, void *put_cb,
void *put_arg, void *get_cb, void *get_arg)
{
btdm_mempool_ext_register_cb((struct btdm_mempool_ext *)mpe, put_cb,
put_arg, get_cb, get_arg);
}
static inline os_error_t
os_mempool_unregister(struct os_mempool *mp)
{
return btdm_mempool_unregister((struct btdm_mempool *)mp);
}
static inline os_error_t
os_mempool_clear(struct os_mempool *mp)
{
return btdm_mempool_clear((struct btdm_mempool *)mp);
}
static inline os_error_t
os_mempool_ext_clear(struct os_mempool_ext *mpe)
{
return btdm_mempool_ext_clear((struct btdm_mempool_ext *)mpe);
}
static inline bool
os_mempool_is_sane(const struct os_mempool *mp)
{
return btdm_mempool_is_sane((const struct btdm_mempool *)mp);
}
static inline int
os_memblock_from(const struct os_mempool *mp, const void *block_addr)
{
return btdm_memblock_from((const struct btdm_mempool *)mp, block_addr);
}
static inline void *
os_memblock_get(struct os_mempool *mp)
{
return btdm_memblock_get((struct btdm_mempool *)mp);
}
static inline os_error_t
os_memblock_put_from_cb(struct os_mempool *mp, void *block_addr)
{
return btdm_memblock_put_from_cb((struct btdm_mempool *)mp, block_addr);
}
static inline os_error_t
os_memblock_put(struct os_mempool *mp, void *block_addr)
{
return btdm_memblock_put((struct btdm_mempool *)mp, block_addr);
}
static inline void
os_mempool_flags_set(struct os_mempool *mp, uint8_t flags)
{
btdm_mempool_flags_set((struct btdm_mempool *)mp, flags);
}
static inline void
os_mempool_flags_clear(struct os_mempool *mp, uint8_t flags)
{
btdm_mempool_flags_clear((struct btdm_mempool *)mp, flags);
}
#endif /* !CONFIG_BT_DUAL_MODE_ARCH */
#ifdef __cplusplus
}

File diff suppressed because it is too large Load Diff

View File

@@ -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
*/
@@ -16,6 +16,11 @@ int bredr_stack_enable(void);
void bredr_stack_disable(void);
int bredr_stack_reset(void);
int bredr_hci_cmd_rx_handler(uint16_t opcode, const uint8_t *cmdbuf, uint8_t len, uint8_t *rspbuf,
uint8_t *rsplen);
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
esp_err_t sleep_modem_bredr_mac_modem_state_init(void);
#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE

View File

@@ -7,7 +7,7 @@
#define _BTDM_LP_H_
#include "esp_private/esp_modem_clock.h"
void btdm_lp_enable_clock(esp_btdm_controller_config_t *cfg);
void btdm_lp_enable_clock(esp_bt_ctrl_btdm_config_t *cfg);
void btdm_lp_disable_clock(void);

View File

@@ -0,0 +1,81 @@
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _BTDM_MEM_DEBUG_H_
#define _BTDM_MEM_DEBUG_H_
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Enable BTDM OSAL malloc/free leak tracking.
* Set to 0 to compile out the tracking hooks.
*/
#ifndef BTDM_MEM_DEBUG
#define BTDM_MEM_DEBUG 1
#endif
#if BTDM_MEM_DEBUG
/**
* @brief Record an allocation (address, size, and auto-incremented sequence).
*
* @param ptr Allocated memory address
* @param size Allocation size in bytes
*/
void btdm_mem_debug_record(void *ptr, uint32_t size);
/**
* @brief Clear the record for a freed address.
*
* @param ptr Memory address being freed
*/
void btdm_mem_debug_clear(void *ptr);
/**
* @brief Print all outstanding (not yet freed) allocations.
*
* Prints address, size and sequence number for each leak.
*/
void btdm_mem_debug_dump(void);
/**
* @brief Get number of currently tracked (unfreed) allocations.
*/
uint32_t btdm_mem_debug_get_count(void);
#else /* !BTDM_MEM_DEBUG */
static inline void btdm_mem_debug_record(void *ptr, uint32_t size)
{
(void)ptr;
(void)size;
}
static inline void btdm_mem_debug_clear(void *ptr)
{
(void)ptr;
}
static inline void btdm_mem_debug_dump(void)
{
}
static inline uint32_t btdm_mem_debug_get_count(void)
{
return 0;
}
#endif /* BTDM_MEM_DEBUG */
#ifdef __cplusplus
}
#endif
#endif /* _BTDM_MEM_DEBUG_H_ */

View File

@@ -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
*/
@@ -27,12 +27,15 @@
#define _BTDM_MEMPOOL_H_
#include "btdm_osal.h"
#include "btdm_user_cfg.h"
#include "queue.h"
#ifdef __cplusplus
extern "C" {
#endif
#define BTDM_MEMPOOL_EXT_FUNC(f) e_##f
/**
* A memory block structure. This simply contains a pointer to the free list
* chain and is only used when the block is on the free list. When the block
@@ -40,7 +43,7 @@ extern "C" {
* caller.
*/
struct btdm_memblock {
SLIST_ENTRY(btdm_memblock) mb_next;
SLIST_ENTRY(btdm_memblock) mb_next;
};
/* XXX: Change this structure so that we keep the first address in the pool? */
@@ -52,33 +55,31 @@ struct btdm_memblock {
* Memory pool
*/
struct btdm_mempool {
/** Size of the memory blocks, in bytes. */
uint32_t mp_block_size;
/** The number of memory blocks. */
uint16_t mp_num_blocks;
/** The number of free blocks left */
uint16_t mp_num_free;
/** The lowest number of free blocks seen */
uint16_t mp_min_free;
/** Bitmap of OS_MEMPOOL_F_[...] values. */
uint8_t mp_flags;
/** Address of memory buffer used by pool */
uint32_t mp_membuf_addr;
STAILQ_ENTRY(btdm_mempool) mp_list;
SLIST_HEAD(, btdm_memblock);
/** Name for memory block */
const char *name;
/** Size of the memory blocks, in bytes. */
uint32_t mp_block_size;
/** The number of memory blocks. */
uint16_t mp_num_blocks;
/** The number of free blocks left */
uint16_t mp_num_free;
/** The lowest number of free blocks seen */
uint16_t mp_min_free;
/** Bitmap of OS_MEMPOOL_F_[...] values. */
uint8_t mp_flags;
/** Address of memory buffer used by pool */
uint32_t mp_membuf_addr;
STAILQ_ENTRY(btdm_mempool) mp_list;
SLIST_HEAD(, btdm_memblock);
/** Name for memory block */
const char *name;
#if UC_BT_CTRL_MEMPOOL_BLOCK_REUSED
/** The number of allocated blocks. */
uint16_t mp_alloc_blocks;
#endif // UC_BT_CTRL_MEMPOOL_BLOCK_REUSED
};
/**
* Indicates an extended mempool. Address can be safely cast to
* (struct btdm_mempool_ext *).
*/
#define BTDM_MEMPOOL_F_EXT 0x01
#define BTDM_ALIGNMENT 4
#define BTDM_MEMPOOL_SIZE(n, blksize) \
((((blksize) + ((BTDM_ALIGNMENT) - 1)) / (BTDM_ALIGNMENT)) * (n))
#define BTDM_MEMPOOL_SIZE(n, blksize) \
((((blksize) + ((BTDM_ALIGNMENT)-1)) / (BTDM_ALIGNMENT)) * (n))
#if (BTDM_ALIGNMENT == 4)
typedef uint32_t btdm_membuf_t;
@@ -90,6 +91,69 @@ typedef __uint128_t btdm_membuf_t;
#error "Unhandled `BTDM_ALIGNMENT` for `btdm_membuf_t`"
#endif /* BTDM_ALIGNMENT == * */
/**
* Indicates an extended mempool. Address can be safely cast to
* (struct btdm_mempool_ext *).
*/
#define BTDM_MEMPOOL_F_EXT (1 << 0)
/* Flag to indicate runtime allocation mode */
#define BTDM_MEMPOOL_F_RUNTIME (1 << 1)
/* Flag to indicate reuse block for runtime allocation mode */
#define BTDM_MEMPOOL_F_REUSED (1 << 2)
/* Flag to indicate no address range comparison */
#define BTDM_MEMPOOL_F_FRAG (1 << 3)
/* Flag to indicate mempool source */
#define BTDM_MEMPOOL_F_CONTROLLER (1 << 4)
#define BTDM_MEMPOOL_F_LOW_PRIO (1 << 5)
#define BTDM_MEMPOOL_F_FORBID (1 << 6)
#define BTDM_MEMPOOL_F_COMBINATION (1 << 7)
struct btdm_mempool_ext;
/**
* Block put callback function. If configured, this callback gets executed
* whenever a block is freed to the corresponding extended mempool. Note: The
* os_memblock_put() function calls this callback instead of freeing the block
* itself. Therefore, it is the callback's responsibility to free the block
* via a call to os_memblock_put_from_cb().
*
* @param ome The extended mempool that a block is being
* freed back to.
* @param data The block being freed.
* @param arg Optional argument configured along with the
* callback.
*
* @return Indicates whether the block was successfully
* freed. A non-zero value should only be
* returned if the block was not successfully
* released back to its pool.
*/
typedef btdm_osal_error_t btdm_mempool_put_fn(struct btdm_mempool_ext *ome,
void *data, void *arg);
/**
* Block get callback function. If configured, this callback gets executed
* whenever a block is fetched from the corresponding extended mempool.
*
* @param ome The extended mempool that a block is being
* fetched.
* @param arg Optional argument configured along with the
* callback.
*
* @return void * pointer of block, return NULL if get failed
*/
typedef void *btdm_mempool_get_fn(struct btdm_mempool_ext *ome, void *arg);
struct btdm_mempool_ext {
struct btdm_mempool mpe_mp;
/* Callback that is executed immediately when a block is freed. */
btdm_mempool_put_fn *mpe_put_cb;
void *mpe_put_arg;
btdm_mempool_get_fn *mpe_get_cb;
void *mpe_get_arg;
};
/**
* Initialize a memory pool.
*
@@ -101,17 +165,11 @@ typedef __uint128_t btdm_membuf_t;
*
* @return btdm_osal_error_t
*/
static inline btdm_osal_error_t
btdm_mempool_init(struct btdm_mempool *mp, uint16_t blocks, uint32_t block_size, void *membuf,
const char *name)
{
extern btdm_osal_error_t r_btdm_os_mempool_init(struct btdm_mempool * mp, uint16_t blocks,
uint32_t block_size, void *membuf,
const char *name);
return r_btdm_os_mempool_init(mp, blocks, block_size, membuf, name);
}
btdm_osal_error_t e_btdm_mempool_init(struct btdm_mempool *mp, uint16_t blocks,
uint32_t block_size, void *membuf,
const char *name);
#define btdm_mempool_init BTDM_MEMPOOL_EXT_FUNC(btdm_mempool_init)
#if 0
/**
* Initializes an extended memory pool. Extended attributes (e.g., callbacks)
* are not specified when this function is called; they are assigned manually
@@ -125,16 +183,36 @@ btdm_mempool_init(struct btdm_mempool *mp, uint16_t blocks, uint32_t block_size,
*
* @return btdm_osal_error_t
*/
static inline btdm_osal_error_t
btdm_mempool_ext_init(struct btdm_mempool_ext *mpe, uint16_t blocks, uint32_t block_size,
void *membuf, const char *name)
{
extern btdm_osal_error_t r_btdm_os_mempool_ext_init(struct btdm_mempool_ext * mpe,
uint16_t blocks, uint32_t block_size,
void *membuf, const char *name);
return r_btdm_os_mempool_ext_init(mpe, blocks, block_size, membuf, name);
}
#endif
btdm_osal_error_t e_btdm_mempool_ext_init(struct btdm_mempool_ext *mpe,
uint16_t blocks, uint32_t block_size,
void *membuf, const char *name);
#define btdm_mempool_ext_init BTDM_MEMPOOL_EXT_FUNC(btdm_mempool_ext_init)
/**
* Assign the put and get callback for an extended memory pool.
*
* @param mpe The extended memory pool
* @param put_cb Block put callback function
* @param put_arg Argument for put callback
* @param get_cb Block put callback function
* @param get_arg Argument for get callback
*/
void e_btdm_mempool_ext_register_cb(struct btdm_mempool_ext *mpe, void *put_cb,
void *put_arg, void *get_cb, void *get_arg);
#define btdm_mempool_ext_register_cb \
BTDM_MEMPOOL_EXT_FUNC(btdm_mempool_ext_register_cb)
/**
* Removes the specified mempool from the list of initialized mempools.
*
* @param mp The mempool to unregister.
*
* @return 0 on success;
* OS_INVALID_PARM if the mempool is not
* registered.
*/
btdm_osal_error_t e_btdm_mempool_unregister(struct btdm_mempool *mp);
#define btdm_mempool_unregister BTDM_MEMPOOL_EXT_FUNC(btdm_mempool_unregister)
/**
* Clears a memory pool.
@@ -143,12 +221,18 @@ btdm_mempool_ext_init(struct btdm_mempool_ext *mpe, uint16_t blocks, uint32_t bl
*
* @return btdm_osal_error_t
*/
static inline btdm_osal_error_t
btdm_mempool_clear(struct btdm_mempool *mp)
{
extern btdm_osal_error_t r_btdm_os_mempool_clear(struct btdm_mempool * mp);
return r_btdm_os_mempool_clear(mp);
}
btdm_osal_error_t e_btdm_mempool_clear(struct btdm_mempool *mp);
#define btdm_mempool_clear BTDM_MEMPOOL_EXT_FUNC(btdm_mempool_clear)
/**
* Clears an extended memory pool.
*
* @param mpe The extended memory pool to clear.
*
* @return btdm_osal_error_t
*/
btdm_osal_error_t e_btdm_mempool_ext_clear(struct btdm_mempool_ext *mpe);
#define btdm_mempool_ext_clear BTDM_MEMPOOL_EXT_FUNC(btdm_mempool_ext_clear)
/**
* Performs an integrity check of the specified mempool. This function
@@ -160,12 +244,8 @@ btdm_mempool_clear(struct btdm_mempool *mp)
* check;
* false if the memory pool is corrupt.
*/
static inline bool
btdm_mempool_is_sane(const struct btdm_mempool *mp)
{
extern bool r_btdm_os_mempool_is_sane(const struct btdm_mempool *mp);
return r_btdm_os_mempool_is_sane(mp);
}
bool e_btdm_mempool_is_sane(const struct btdm_mempool *mp);
#define btdm_mempool_is_sane BTDM_MEMPOOL_EXT_FUNC(btdm_mempool_is_sane)
/**
* Checks if a memory block was allocated from the specified mempool.
@@ -176,12 +256,8 @@ btdm_mempool_is_sane(const struct btdm_mempool *mp)
* @return 0 if the block does not belong to the mempool;
* 1 if the block does belong to the mempool.
*/
static inline int
btdm_memblock_from(const struct btdm_mempool *mp, const void *block_addr)
{
extern int r_btdm_os_memblock_from(const struct btdm_mempool *mp, const void *block_addr);
return r_btdm_os_memblock_from(mp, block_addr);
}
int e_btdm_memblock_from(const struct btdm_mempool *mp, const void *block_addr);
#define btdm_memblock_from BTDM_MEMPOOL_EXT_FUNC(btdm_memblock_from)
/**
* Get a memory block from a memory pool
@@ -190,12 +266,8 @@ btdm_memblock_from(const struct btdm_mempool *mp, const void *block_addr)
*
* @return void* Pointer to block if available; NULL otherwise
*/
static inline void *
btdm_memblock_get(struct btdm_mempool *mp)
{
extern void *r_btdm_os_memblock_get(struct btdm_mempool * mp);
return r_btdm_os_memblock_get(mp);
}
void *e_btdm_memblock_get(struct btdm_mempool *mp);
#define btdm_memblock_get BTDM_MEMPOOL_EXT_FUNC(btdm_memblock_get)
/**
* Puts the memory block back into the pool, ignoring the put callback, if any.
@@ -207,13 +279,8 @@ btdm_memblock_get(struct btdm_mempool *mp)
*
* @return btdm_osal_error_t
*/
static inline btdm_osal_error_t
btdm_mempool_put_from_cb(struct btdm_mempool *mp, void *block_addr)
{
extern btdm_osal_error_t r_btdm_os_memblock_put_from_cb(struct btdm_mempool * mp,
void *block_addr);
return r_btdm_os_memblock_put_from_cb(mp, block_addr);
}
btdm_osal_error_t e_btdm_memblock_put_from_cb(struct btdm_mempool *mp, void *block_addr);
#define btdm_memblock_put_from_cb BTDM_MEMPOOL_EXT_FUNC(btdm_memblock_put_from_cb)
/**
* Puts the memory block back into the pool
@@ -223,19 +290,52 @@ btdm_mempool_put_from_cb(struct btdm_mempool *mp, void *block_addr)
*
* @return btdm_osal_error_t
*/
static inline btdm_osal_error_t
btdm_memblock_put(struct btdm_mempool *mp, void *block_addr)
{
extern btdm_osal_error_t r_btdm_os_memblock_put(struct btdm_mempool * mp, void *block_addr);
return r_btdm_os_memblock_put(mp, block_addr);
}
btdm_osal_error_t e_btdm_memblock_put(struct btdm_mempool *mp,
void *block_addr);
#define btdm_memblock_put BTDM_MEMPOOL_EXT_FUNC(btdm_memblock_put)
static inline uint16_t
btdm_memblock_free_num_get(struct btdm_mempool *mp)
{
extern uint16_t r_btdm_os_memblock_num_free(struct btdm_mempool * mp);
return r_btdm_os_memblock_num_free(mp);
}
/**
* Set the flags of a memory pool.
*
* @param mp Pointer to memory pool
* @param flags Flags value
*/
void e_btdm_mempool_flags_set(struct btdm_mempool *mp, uint8_t flags);
#define btdm_mempool_flags_set BTDM_MEMPOOL_EXT_FUNC(btdm_mempool_flags_set)
/**
* Clear the flags of a memory pool.
*
* @param mp Pointer to memory pool
* @param flags Flags value
*/
void e_btdm_mempool_flags_clear(struct btdm_mempool *mp, uint8_t flags);
#define btdm_mempool_flags_clear BTDM_MEMPOOL_EXT_FUNC(btdm_mempool_flags_clear)
/**
* Get the number of free blocks in a memory pool.
*
* @param mp Pointer to memory pool
*
* @return uint16_t Number of free blocks
*/
uint16_t e_btdm_mempool_free_blocks_num(struct btdm_mempool *mp);
#define btdm_mempool_free_blocks_num \
BTDM_MEMPOOL_EXT_FUNC(btdm_mempool_free_blocks_num)
/**
* Initialize the memory pool module.
*/
void e_btdm_mempool_module_init(void);
#define btdm_mempool_module_init BTDM_MEMPOOL_EXT_FUNC(btdm_mempool_module_init)
/**
* Deinitialize the memory pool module.
*
* @param is_controller Whether called from controller.
*/
void e_btdm_mempool_deinit(bool is_controller);
#define btdm_mempool_deinit BTDM_MEMPOOL_EXT_FUNC(btdm_mempool_deinit)
#ifdef __cplusplus
}

View File

@@ -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
*/
@@ -65,6 +65,11 @@ struct btdm_osal_sem {
void *sem;
};
#define BTDM_OSAL_ALIGN(__n, __a) \
((((__n) & ((__a)-1)) == 0) ? (__n) : ((__n) + ((__a) - ((__n) & ((__a)-1)))))
#define BTDM_OSAL_ALIGNMENT (sizeof(void *))
/*
* Type definitions for BTDM OSAL
*/

View File

@@ -33,9 +33,9 @@ extern "C" {
#endif
struct btdm_osal_event_freertos {
bool queued;
void (*fn)(struct btdm_osal_event *ev);
void *arg;
bool queued;
};
struct btdm_osal_eventq_freertos {

View File

@@ -107,6 +107,28 @@ extern "C" {
//TODO
#define UC_BT_CTRL_CONN_FC_ENABLE (1)
#ifdef CONFIG_BT_NIMBLE_STATIC_TO_DYNAMIC
#define UC_BT_CTRL_DYNAMIC_MEMPOOL (CONFIG_BT_NIMBLE_STATIC_TO_DYNAMIC)
#else
#define UC_BT_CTRL_DYNAMIC_MEMPOOL (0)
#endif
#ifdef CONFIG_BT_NIMBLE_MEMPOOL_RUNTIME_ALLOC
#define UC_BT_CTRL_RUNTIME_ALLOC_MEMPOOL (CONFIG_BT_NIMBLE_MEMPOOL_RUNTIME_ALLOC)
#else
#define UC_BT_CTRL_RUNTIME_ALLOC_MEMPOOL (0)
#endif
#ifdef CONFIG_BT_NIMBLE_MEMPOOL_BLOCK_REUSED
#define UC_BT_CTRL_MEMPOOL_BLOCK_REUSED (CONFIG_BT_NIMBLE_MEMPOOL_BLOCK_REUSED)
#else
#define UC_BT_CTRL_MEMPOOL_BLOCK_REUSED (0)
#endif
#define UC_BT_CTRL_MEMPOOL_CHECK (0)
#ifdef __cplusplus
}
#endif

View File

@@ -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
*/
@@ -161,7 +161,7 @@ wr_btdm_coex_iso_protect_frame_thres_get(void)
#endif /* CONFIG_SW_COEXIST_ENABLE */
}
void
void IRAM_ATTR
wr_btdm_coex_iso_start_int_handle(uint16_t handle, uint32_t duration)
{
#if CONFIG_SW_COEXIST_ENABLE && CONFIG_BT_LE_ISO_SUPPORT
@@ -169,7 +169,7 @@ wr_btdm_coex_iso_start_int_handle(uint16_t handle, uint32_t duration)
#endif /* CONFIG_SW_COEXIST_ENABLE */
}
void
void IRAM_ATTR
wr_btdm_coex_iso_end_int_handle(uint16_t handle, uint32_t duration)
{
#if CONFIG_SW_COEXIST_ENABLE && CONFIG_BT_LE_ISO_SUPPORT
@@ -177,7 +177,7 @@ wr_btdm_coex_iso_end_int_handle(uint16_t handle, uint32_t duration)
#endif /* CONFIG_SW_COEXIST_ENABLE */
}
void
void IRAM_ATTR
wr_btdm_coex_ble_idle_time_inform(uint32_t start_offset, uint32_t duration)
{
#if CONFIG_SW_COEXIST_ENABLE
@@ -188,7 +188,7 @@ wr_btdm_coex_ble_idle_time_inform(uint32_t start_offset, uint32_t duration)
int
wr_btdm_coex_register_ble_cb(uint32_t type, coex_funcs_ble_cb_t func)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE && CONFIG_BT_LE_ISO_SUPPORT
return coex_register_ble_cb(type, func);
#else
return ESP_OK;

View File

@@ -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
*/
@@ -17,9 +17,12 @@ wr_btdm_external_bb_get_tx_pwr_table(uint8_t *length, uint8_t modem_cfg)
assert(length != NULL);
assert (modem_cfg < TX_PWR_TABLE_MODEM_CFG_MAX);
#if UC_BT_CTRL_BR_EDR_IS_ENABLE
if (modem_cfg == TX_PWR_TABLE_MODEM_CFG_BREDR) {
return bt_bb_tx_pwr_table_get(length, modem_cfg);
} else {
} else
#endif // UC_BT_CTRL_BR_EDR_IS_ENABLE
{
// TODO: replace with bt_bb_tx_pwr_table_get when all the targets(h4, s31, etc) support this API
return bt_bb_get_tx_pwr_table(length);
}

View File

@@ -1,14 +1,48 @@
/*
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdint.h>
#include <stdbool.h>
#include "btdm_osal.h"
#include "sdkconfig.h"
#include "assert.h"
#include "esp_attr.h"
#include "esp_rom_sys.h"
#include "btdm_osal.h"
#include "esp_err.h"
#include "esp_log.h"
#if CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2
#include "ble_log.h"
#else /* !CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
#include "ble_log/ble_log_spi_out.h"
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
#if CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
#include "ble_log/ble_log_uhci_out.h"
#endif // CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
#endif /* CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
typedef void (*interface_func_t) (uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag);
enum {
BLE_LOG_INTERFACE_FLAG_CONTINUE = 0,
BLE_LOG_INTERFACE_FLAG_END,
};
/**
* @brief Select buffers
*/
typedef enum {
ESP_BLE_LOG_BUF_HCI = 0x02,
ESP_BLE_LOG_BUF_CONTROLLER = 0x05,
} esp_ble_log_buf_t;
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
/*
***************************************************************************************************
@@ -16,11 +50,321 @@
***************************************************************************************************
*/
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
void api_base_ll_dumpDebugStatus(void);
void r_btdm_sched_list_details_dump(void);
void r_ble_phy_hw_state_dump(uint8_t);
void esp_ble_controller_log_dump_all(bool);
void esp_panic_handler_feed_wdts(void);
void r_ble_log_async_output_dump_all(bool output);
int r_ble_log_init_async(interface_func_t interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
int r_ble_log_deinit_async(void);
int r_ble_log_init_simple(interface_func_t interface, void *handler);
void r_ble_log_deinit_simple(void);
void r_ble_log_async_select_dump_buffers(uint8_t buffers);
int r_ble_log_ctrl_level_and_mod(uint8_t log_level, uint32_t mod_switch);
int r_ble_ctrl_mod_type(uint16_t mod, uint32_t mod_type_switch);
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
/*
***************************************************************************************************
* Static Function Definitions
***************************************************************************************************
*/
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
static bool log_is_inited = false;
#if CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2
/* TODO: Remove event handler dependency in lib */
static void void_handler(void) {}
/* TODO: Declare public interfaces in a public header */
void esp_bt_controller_log_deinit(void)
{
log_is_inited = false;
r_ble_log_deinit_simple();
ble_log_deinit();
}
esp_err_t esp_bt_controller_log_init(void)
{
if (log_is_inited) {
return ESP_OK;
}
if (!ble_log_init()) {
goto exit;
}
if (r_ble_log_init_simple(ble_log_write_hex_ll, void_handler) != 0) {
goto exit;
}
if (r_ble_log_ctrl_level_and_mod(CONFIG_BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL,
CONFIG_BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH) != ESP_OK) {
goto exit;
}
log_is_inited = true;
return ESP_OK;
exit:
esp_bt_controller_log_deinit();
return ESP_FAIL;
}
#else /* !CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */
const static uint32_t log_bufs_size[] = {CONFIG_BT_LE_LOG_CTRL_BUF1_SIZE, CONFIG_BT_LE_LOG_HCI_BUF_SIZE, CONFIG_BT_LE_LOG_CTRL_BUF2_SIZE};
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
#error "This function has been deprecated."
#include "esp_partition.h"
#include "hal/wdt_hal.h"
#define MAX_STORAGE_SIZE (CONFIG_BT_LE_CONTROLLER_LOG_PARTITION_SIZE)
#define BLOCK_SIZE (4096)
#define THRESHOLD (3072)
#define PARTITION_NAME "bt_ctrl_log"
static const esp_partition_t *log_partition;
static uint32_t write_index = 0;
static uint32_t next_erase_index = BLOCK_SIZE;
static bool block_erased = false;
static bool stop_write = false;
static bool is_filled = false;
static void esp_bt_ctrl_log_partition_get_and_erase_first_block(void)
{
log_partition = NULL;
assert(MAX_STORAGE_SIZE % BLOCK_SIZE == 0);
// Find the partition map in the partition table
log_partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, PARTITION_NAME);
assert(log_partition != NULL);
// Prepare data to be read later using the mapped address
ESP_ERROR_CHECK(esp_partition_erase_range(log_partition, 0, BLOCK_SIZE));
write_index = 0;
next_erase_index = BLOCK_SIZE;
block_erased = false;
is_filled = false;
stop_write = false;
}
static int esp_bt_controller_log_storage(uint32_t len, const uint8_t *addr, bool end)
{
if (len > MAX_STORAGE_SIZE) {
return -1;
}
if (stop_write) {
return 0;
}
if (((write_index) % BLOCK_SIZE) >= THRESHOLD && !block_erased) {
// esp_rom_printf("Ers nxt: %d,%d\n", next_erase_index, write_index);
esp_partition_erase_range(log_partition, next_erase_index, BLOCK_SIZE);
next_erase_index = (next_erase_index + BLOCK_SIZE) % MAX_STORAGE_SIZE;
block_erased = true;
}
if (((write_index + len) / BLOCK_SIZE) > (write_index / BLOCK_SIZE)) {
block_erased = false;
}
if (write_index + len <= MAX_STORAGE_SIZE) {
esp_partition_write(log_partition, write_index, addr, len);
write_index = (write_index + len) % MAX_STORAGE_SIZE;
} else {
uint32_t first_part_len = MAX_STORAGE_SIZE - write_index;
esp_partition_write(log_partition, write_index, addr, first_part_len);
esp_partition_write(log_partition, 0, addr + first_part_len, len - first_part_len);
write_index = len - first_part_len;
is_filled = true;
// esp_rom_printf("old idx: %d,%d\n",next_erase_index, write_index);
}
return 0;
}
void esp_bt_read_ctrl_log_from_flash(bool output)
{
esp_partition_mmap_handle_t mmap_handle;
uint32_t read_index;
const void *mapped_ptr;
const uint8_t *buffer;
uint32_t print_len;
uint32_t max_print_len;
esp_err_t err;
print_len = 0;
max_print_len = 4096;
err = esp_partition_mmap(log_partition, 0, MAX_STORAGE_SIZE, ESP_PARTITION_MMAP_DATA, &mapped_ptr, &mmap_handle);
if (err != ESP_OK) {
ESP_LOGE("FLASH", "Mmap failed: %s", esp_err_to_name(err));
return;
}
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
portENTER_CRITICAL_SAFE(&spinlock);
esp_panic_handler_feed_wdts();
r_ble_log_async_output_dump_all(true);
esp_bt_controller_log_deinit();
stop_write = true;
buffer = (const uint8_t *)mapped_ptr;
esp_panic_handler_feed_wdts();
if (is_filled) {
read_index = next_erase_index;
} else {
read_index = 0;
}
esp_rom_printf("\r\nREAD_CHECK:%ld,%ld,%d\r\n",read_index, write_index, is_filled);
esp_rom_printf("\r\n[DUMP_START:");
while (read_index != write_index) {
esp_rom_printf("%02x ", buffer[read_index]);
if (print_len > max_print_len) {
esp_panic_handler_feed_wdts();
print_len = 0;
}
print_len++;
read_index = (read_index + 1) % MAX_STORAGE_SIZE;
}
esp_rom_printf(":DUMP_END]\r\n");
portEXIT_CRITICAL_SAFE(&spinlock);
esp_partition_munmap(mmap_handle);
err = esp_bt_controller_log_init();
assert(err == ESP_OK);
}
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
#if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED && !CONFIG_BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag)
{
bool end = (flag & (1 << BLE_LOG_INTERFACE_FLAG_END));
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
esp_bt_controller_log_storage(len, addr, end);
#else // !CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
btdm_osal_hw_enter_critical();
esp_panic_handler_feed_wdts();
if (len && addr) {
for (int i = 0; i < len; i++) {
esp_rom_printf("%02x ", addr[i]);
}
}
if (len_append && addr_append) {
for (int i = 0; i < len_append; i++) {
esp_rom_printf("%02x ", addr_append[i]);
}
}
if (end) {
esp_rom_printf("\n");
}
btdm_osal_hw_exit_critical(0);
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
}
#endif // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED && !CONFIG_BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
esp_err_t esp_bt_controller_log_init(void)
{
if (log_is_inited) {
return ESP_OK;
}
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
if (ble_log_spi_out_init() != 0) {
goto spi_out_init_failed;
}
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
#if CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
if (ble_log_uhci_out_init() != 0) {
goto uhci_out_init_failed;
}
#endif // CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
#if CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
if (r_ble_log_init_simple(ble_log_spi_out_ll_write, ble_log_spi_out_ll_log_ev_proc) != 0) {
goto log_init_failed;
}
#elif CONFIG_BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
if (r_ble_log_init_simple(ble_log_uhci_out_ll_write, ble_log_uhci_out_ll_log_ev_proc) != 0) {
goto log_init_failed;
}
#else
uint8_t buffers = 0;
#if CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED
buffers |= ESP_BLE_LOG_BUF_CONTROLLER;
#endif // CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED
#if CONFIG_BT_LE_CONTROLLER_LOG_HCI_ENABLED
buffers |= ESP_BLE_LOG_BUF_HCI;
#endif // CONFIG_BT_LE_CONTROLLER_LOG_HCI_ENABLED
bool task_create = true;
#if CONFIG_BT_LE_CONTROLLER_LOG_DUMP_ONLY
task_create = false;
#elif CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
esp_bt_ctrl_log_partition_get_and_erase_first_block();
#endif
if (r_ble_log_init_async(esp_bt_controller_log_interface, task_create, buffers, (uint32_t *)log_bufs_size) != 0) {
goto log_init_failed;
}
#endif
if (r_ble_log_ctrl_level_and_mod(CONFIG_BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL, CONFIG_BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH) != ESP_OK) {
goto ctrl_level_init_failed;
}
log_is_inited = true;
return ESP_OK;
ctrl_level_init_failed:
#if CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
r_ble_log_deinit_simple();
#elif CONFIG_BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
r_ble_log_deinit_simple();
#else
r_ble_log_deinit_async();
#endif
log_init_failed:
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
ble_log_spi_out_deinit();
spi_out_init_failed:
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
#if CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
ble_log_uhci_out_deinit();
uhci_out_init_failed:
#endif // CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
return ESP_FAIL;
}
void esp_bt_controller_log_deinit(void)
{
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
ble_log_spi_out_deinit();
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
#if CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
ble_log_uhci_out_deinit();
#endif // CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
#if CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
r_ble_log_deinit_simple();
#elif CONFIG_BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
r_ble_log_deinit_simple();
#else
r_ble_log_deinit_async();
#endif
log_is_inited = false;
}
#endif /* CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
/*
***************************************************************************************************
* Public Function Definitions
@@ -102,7 +446,7 @@ void IRAM_ATTR
wr_btdm_assert(const char *file, int line, int p0, int p1, uint8_t type)
{
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
r_ble_phy_hw_state_dump(false);
api_base_ll_dumpDebugStatus();
r_btdm_sched_list_details_dump();
esp_ble_controller_log_dump_all(true);
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
@@ -111,6 +455,50 @@ wr_btdm_assert(const char *file, int line, int p0, int p1, uint8_t type)
assert(0);
}
#if CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
void __real_esp_panic_handler(void *info);
void __wrap_esp_panic_handler (void *info)
{
esp_ble_controller_log_dump_all(true);
__real_esp_panic_handler(info);
}
#endif // CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
#if CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2
void esp_ble_controller_log_dump_all(bool output)
{
ble_log_dump_to_console();
}
#else /* !CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */
void esp_ble_controller_log_dump_all(bool output)
{
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
ble_log_spi_out_dump_all();
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
esp_bt_read_ctrl_log_from_flash(output);
#elif !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
btdm_osal_hw_enter_critical();
esp_panic_handler_feed_wdts();
esp_rom_printf("\r\n[DUMP_START:");
r_ble_log_async_output_dump_all(output);
esp_rom_printf(":DUMP_END]\r\n");
btdm_osal_hw_exit_critical(0);
#endif
}
#endif // CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
#if CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
void esp_task_wdt_isr_user_handler(void)
{
esp_ble_controller_log_dump_all(true);
}
#endif // CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
/*
***************************************************************************************************
* BTDM LOG Initialization
@@ -119,11 +507,21 @@ wr_btdm_assert(const char *file, int line, int p0, int p1, uint8_t type)
int
btdm_log_init(void)
{
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
esp_err_t ret;
ret = esp_bt_controller_log_init();
if (ret != ESP_OK) {
return ret;
}
#endif // CONFIG_BT_CONTROLLER_LOG_ENABLED
return 0;
}
void
btdm_log_deinit(void)
{
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
esp_bt_controller_log_deinit();
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
}

View File

@@ -121,7 +121,7 @@ btdm_lp_rtc_slow_clk_select(uint8_t slow_clk_src)
}
static void
btdm_lp_timer_clk_init(esp_btdm_controller_config_t *cfg)
btdm_lp_timer_clk_init(esp_bt_ctrl_btdm_config_t *cfg)
{
if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_INVALID) {
#if CONFIG_BT_CTRL_LP_CLK_SRC_MAIN_XTAL
@@ -164,10 +164,10 @@ modem_clock_lpclk_src_t btdm_lp_get_lpclk_src(void)
return s_bt_lpclk_src;
}
extern esp_bt_controller_status_t esp_ble_controller_get_status(void);
void btdm_lp_set_lpclk_src(modem_clock_lpclk_src_t clk_src)
{
if (esp_ble_controller_get_status() != ESP_BT_CONTROLLER_STATUS_IDLE) {
if (esp_bt_controller_get_status() != ESP_BT_CONTROLLER_STATUS_IDLE) {
return;
}
@@ -187,7 +187,7 @@ void btdm_lp_set_lpclk_freq(uint32_t clk_freq)
{
uint32_t xtal_freq;
if (esp_ble_controller_get_status() != ESP_BT_CONTROLLER_STATUS_IDLE) {
if (esp_bt_controller_get_status() != ESP_BT_CONTROLLER_STATUS_IDLE) {
return;
}
@@ -209,21 +209,6 @@ btdm_lp_timer_clk_deinit(void)
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
}
void IRAM_ATTR e_btdm_lp_modem_clock_set(bool enable)
{
if (enable) {
if (!s_btdm_lp_modem_clk_en) {
modem_clock_module_enable(PERIPH_BT_MODULE);
s_btdm_lp_modem_clk_en = 1;
}
} else {
if (!s_bt_active && s_btdm_lp_modem_clk_en) {
modem_clock_module_disable(PERIPH_BT_MODULE);
s_btdm_lp_modem_clk_en = 0;
}
}
}
void
btdm_lp_sleep_cb(uint32_t enable_tick, void *arg)
{
@@ -280,12 +265,12 @@ btdm_lp_modem_retention_create(void)
}
#if UC_BT_CTRL_BR_EDR_IS_ENABLE
// TODO: check the return value
// TODO: check the return value. Shouldn't invoke the upper layer function directly.
sleep_modem_bredr_mac_modem_state_init();
#endif // UC_BT_CTRL_BR_EDR_IS_ENABLE
#if UC_BT_CTRL_BLE_IS_ENABLE
// TODO: check the return value
// TODO: check the return value. Shouldn't invoke the upper layer function directly.
sleep_modem_ble_mac_modem_state_init();
#endif // UC_BT_CTRL_BLE_IS_ENABLE
return err;
@@ -348,7 +333,7 @@ btdm_lp_modem_state_deinit(void)
***************************************************************************************************
*/
void
btdm_lp_enable_clock(esp_btdm_controller_config_t *cfg)
btdm_lp_enable_clock(esp_bt_ctrl_btdm_config_t *cfg)
{
if (!s_btdm_lp_modem_clk_en) {
modem_clock_module_enable(PERIPH_BT_MODULE);
@@ -472,3 +457,24 @@ btdm_lp_shutdown(void)
s_bt_active = false;
}
}
/*
***************************************************************************************************
* External Function Definitions for other modules
***************************************************************************************************
*/
void IRAM_ATTR
e_btdm_lp_modem_clock_set(bool enable)
{
if (enable) {
if (!s_btdm_lp_modem_clk_en) {
modem_clock_module_enable(PERIPH_BT_MODULE);
s_btdm_lp_modem_clk_en = 1;
}
} else {
if (!s_bt_active && s_btdm_lp_modem_clk_en) {
modem_clock_module_disable(PERIPH_BT_MODULE);
s_btdm_lp_modem_clk_en = 0;
}
}
}

View File

@@ -0,0 +1,147 @@
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "btdm_mem_debug.h"
#include <stdint.h>
#if BTDM_MEM_DEBUG
#include <stddef.h>
#include "esp_rom_sys.h"
#include "freertos/FreeRTOS.h"
#include "freertos/portmacro.h"
#include <string.h>
#define BTDM_MEM_DEBUG_MAX 1024 * 5
typedef struct {
void *ptr;
uint32_t size;
uint32_t seq;
} btdm_mem_debug_entry_t;
static btdm_mem_debug_entry_t s_mem_dbg_tbl[BTDM_MEM_DEBUG_MAX];
static uint32_t s_mem_dbg_seq;
static uint32_t s_mem_dbg_count;
static portMUX_TYPE s_mem_dbg_lock = portMUX_INITIALIZER_UNLOCKED;
void
btdm_mem_debug_record(void *ptr, uint32_t size)
{
int i;
if (ptr == NULL || size == 0) {
return;
}
portENTER_CRITICAL(&s_mem_dbg_lock);
for (i = 0; i < BTDM_MEM_DEBUG_MAX; i++) {
if (s_mem_dbg_tbl[i].ptr == NULL) {
s_mem_dbg_seq++;
s_mem_dbg_tbl[i].ptr = ptr;
s_mem_dbg_tbl[i].size = size;
s_mem_dbg_tbl[i].seq = s_mem_dbg_seq;
s_mem_dbg_count++;
portEXIT_CRITICAL(&s_mem_dbg_lock);
return;
}
}
portEXIT_CRITICAL(&s_mem_dbg_lock);
esp_rom_printf("[BTDM_MEM] record full, drop ptr=%p size=%u\n", ptr, (unsigned)size);
}
void
btdm_mem_debug_clear(void *ptr)
{
int i;
if (ptr == NULL) {
return;
}
portENTER_CRITICAL(&s_mem_dbg_lock);
for (i = 0; i < BTDM_MEM_DEBUG_MAX; i++) {
if (s_mem_dbg_tbl[i].ptr == ptr) {
s_mem_dbg_tbl[i].ptr = NULL;
s_mem_dbg_tbl[i].size = 0;
s_mem_dbg_tbl[i].seq = 0;
s_mem_dbg_count--;
portEXIT_CRITICAL(&s_mem_dbg_lock);
return;
}
}
portEXIT_CRITICAL(&s_mem_dbg_lock);
esp_rom_printf("[BTDM_MEM] clear miss ptr=%p\n", ptr);
}
void
btdm_mem_debug_dump(void)
{
int i;
void *ptr;
uint32_t size;
uint32_t seq;
uint32_t count = 0;
uint32_t total_size = 0;
esp_rom_printf("[BTDM_MEM] ===== unfreed dump begin =====\n");
for (i = 0; i < BTDM_MEM_DEBUG_MAX; i++) {
portENTER_CRITICAL(&s_mem_dbg_lock);
ptr = s_mem_dbg_tbl[i].ptr;
size = s_mem_dbg_tbl[i].size;
seq = s_mem_dbg_tbl[i].seq;
portEXIT_CRITICAL(&s_mem_dbg_lock);
if (ptr != NULL) {
esp_rom_printf("[BTDM_MEM] ptr=%p size=%u seq=%u\n",
ptr, (unsigned)size, (unsigned)seq);
count++;
total_size += size;
}
}
esp_rom_printf("[BTDM_MEM] unfreed count=%u total_size=%u\n",
(unsigned)count, (unsigned)total_size);
esp_rom_printf("[BTDM_MEM] ===== unfreed dump end =====\n");
portENTER_CRITICAL(&s_mem_dbg_lock);
memset(s_mem_dbg_tbl, 0, sizeof(s_mem_dbg_tbl));
s_mem_dbg_seq = 0;
s_mem_dbg_count = 0;
portEXIT_CRITICAL(&s_mem_dbg_lock);
}
uint32_t
btdm_mem_debug_get_count(void)
{
uint32_t count;
portENTER_CRITICAL(&s_mem_dbg_lock);
count = s_mem_dbg_count;
portEXIT_CRITICAL(&s_mem_dbg_lock);
return count;
}
uint32_t
btdm_mem_debug_get_seq_num(void)
{
uint32_t sequence;
portENTER_CRITICAL(&s_mem_dbg_lock);
sequence = s_mem_dbg_seq;
portEXIT_CRITICAL(&s_mem_dbg_lock);
return sequence;
}
#endif /* BTDM_MEM_DEBUG */

View File

@@ -0,0 +1,608 @@
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdint.h>
#include <string.h>
#include <stdbool.h>
#include "btdm_mempool.h"
#define BTDM_MEM_TRUE_BLOCK_SIZE(bsize) BTDM_OSAL_ALIGN(bsize, BTDM_OSAL_ALIGNMENT)
#define BTDM_MEMPOOL_TRUE_BLOCK_SIZE(mp) BTDM_MEM_TRUE_BLOCK_SIZE(mp->mp_block_size)
static STAILQ_HEAD(, btdm_mempool) s_btdm_osal_mempool_list = STAILQ_HEAD_INITIALIZER(s_btdm_osal_mempool_list);
#if UC_BT_CTRL_RUNTIME_ALLOC_MEMPOOL
static btdm_osal_error_t
e_btdm_mempool_mem_free(struct btdm_mempool *mp)
{
/* For runtime allocation mode, check whether all blocks have been freed */
if (!(mp->mp_flags & BTDM_MEMPOOL_F_RUNTIME)) {
return BTDM_OSAL_EINVAL;
}
/* NOTE: if mempool gets cleared before all mem block is retrieved, it may leads to mem trampling */
assert(mp->mp_num_free == mp->mp_num_blocks);
#if UC_BT_CTRL_MEMPOOL_BLOCK_REUSED
struct btdm_memblock *block_ptr;
/* For block reused mode, free all allocated blocks */
if (mp->mp_flags & BTDM_MEMPOOL_F_REUSED) {
uint16_t cnt;
for (cnt = 0; cnt < mp->mp_alloc_blocks; cnt ++) {
block_ptr = SLIST_FIRST(mp);
if (block_ptr) {
assert(block_ptr);
SLIST_REMOVE_HEAD(mp, mb_next);
btdm_osal_free(block_ptr);
}
}
mp->mp_alloc_blocks = 0;
}
#endif
/* Only reset statistics */
SLIST_FIRST(mp) = NULL;
mp->mp_min_free = mp->mp_num_blocks;
return BTDM_OSAL_OK;
}
#endif // UC_BT_CTRL_RUNTIME_ALLOC_MEMPOOL
static btdm_osal_error_t
e_btdm_mempool_init_internal(struct btdm_mempool *mp, uint16_t blocks,
uint32_t block_size, void *membuf, const char *name,
uint8_t flags)
{
int true_block_size;
int i;
uint8_t *block_addr;
struct btdm_memblock *block_ptr;
/* Check for valid parameters */
if (!mp || (block_size == 0)) {
return BTDM_OSAL_INVALID_PARM;
}
/* For runtime allocation mode, membuf can be NULL */
#if !UC_BT_CTRL_RUNTIME_ALLOC_MEMPOOL
if ((!membuf) && (blocks != 0)) {
return BTDM_OSAL_INVALID_PARM;
}
#endif
if (membuf != NULL) {
/* Blocks need to be sized properly and memory buffer should be
* aligned
*/
if (((uint32_t)(uintptr_t)membuf & (BTDM_OSAL_ALIGNMENT - 1)) != 0) {
return BTDM_OSAL_MEM_NOT_ALIGNED;
}
}
/* Initialize the memory pool structure */
mp->mp_block_size = block_size;
mp->mp_num_free = blocks;
mp->mp_min_free = blocks;
mp->mp_flags = flags;
mp->mp_num_blocks = blocks;
mp->mp_membuf_addr = (uint32_t)(uintptr_t)membuf;
mp->name = name;
SLIST_FIRST(mp) = membuf;
#if UC_BT_CTRL_RUNTIME_ALLOC_MEMPOOL
if (membuf == NULL) {
/* Runtime allocation mode */
mp->mp_membuf_addr = 0;
mp->mp_flags |= BTDM_MEMPOOL_F_RUNTIME;
#if UC_BT_CTRL_MEMPOOL_BLOCK_REUSED
mp->mp_flags |= BTDM_MEMPOOL_F_REUSED;
mp->mp_alloc_blocks = 0;
#endif
SLIST_FIRST(mp) = NULL;
/* Check if mempool is already in the list (reinitialization case) */
struct btdm_mempool *cur;
if (!STAILQ_EMPTY(&s_btdm_osal_mempool_list)) {
STAILQ_FOREACH(cur, &s_btdm_osal_mempool_list, mp_list) {
if (cur->name == mp->name) {
/* Mempool is already in the list, remove it first */
btdm_mempool_unregister(cur);
break;
}
}
}
STAILQ_INSERT_TAIL(&s_btdm_osal_mempool_list, mp, mp_list);
return BTDM_OSAL_OK;
}
#endif
if (blocks > 0) {
true_block_size = BTDM_MEMPOOL_TRUE_BLOCK_SIZE(mp);
/* Chain the memory blocks to the free list */
block_addr = (uint8_t *)membuf;
block_ptr = (struct btdm_memblock *)block_addr;
for (i = 1; i < blocks; i++) {
block_addr += true_block_size;
SLIST_NEXT(block_ptr, mb_next) = (struct btdm_memblock *)block_addr;
block_ptr = (struct btdm_memblock *)block_addr;
}
/* Last one in the list should be NULL */
SLIST_NEXT(block_ptr, mb_next) = NULL;
}
/* Check if mempool is already in the list (reinitialization case) */
struct btdm_mempool *cur;
if (!STAILQ_EMPTY(&s_btdm_osal_mempool_list)) {
STAILQ_FOREACH(cur, &s_btdm_osal_mempool_list, mp_list) {
if (cur->name == mp->name) {
/* Mempool is already in the list, remove it first */
btdm_mempool_unregister(cur);
break;
}
}
}
STAILQ_INSERT_TAIL(&s_btdm_osal_mempool_list, mp, mp_list);
return BTDM_OSAL_OK;
}
btdm_osal_error_t
e_btdm_mempool_init(struct btdm_mempool *mp, uint16_t blocks, uint32_t block_size,
void *membuf, const char *name)
{
return e_btdm_mempool_init_internal(mp, blocks, block_size, membuf, name, 0);
}
btdm_osal_error_t
e_btdm_mempool_ext_init(struct btdm_mempool_ext *mpe, uint16_t blocks,
uint32_t block_size, void *membuf, const char *name)
{
int rc;
rc = e_btdm_mempool_init_internal(&mpe->mpe_mp, blocks, block_size, membuf,
name, BTDM_MEMPOOL_F_EXT);
if (rc != 0) {
return rc;
}
mpe->mpe_put_cb = NULL;
mpe->mpe_put_arg = NULL;
mpe->mpe_get_cb = NULL;
mpe->mpe_get_arg = NULL;
return 0;
}
void
e_btdm_mempool_ext_register_cb(struct btdm_mempool_ext *mpe,
void *put_cb, void *put_arg,
void *get_cb, void *get_arg)
{
mpe->mpe_put_cb = put_cb;
mpe->mpe_put_arg = put_arg;
mpe->mpe_get_cb = get_cb;
mpe->mpe_get_arg = get_arg;
}
btdm_osal_error_t
e_btdm_mempool_unregister(struct btdm_mempool *mp)
{
struct btdm_mempool *cur;
/* Remove the mempool from the global stailq. This is done manually rather
* than with `STAILQ_REMOVE` to allow for a graceful failure if the mempool
* isn't found.
*/
cur = NULL;
if (!STAILQ_EMPTY(&s_btdm_osal_mempool_list)) {
STAILQ_FOREACH(cur, &s_btdm_osal_mempool_list, mp_list) {
if (cur == mp) {
break;
}
}
}
if (cur == NULL) {
return BTDM_OSAL_INVALID_PARM;
}
#if UC_BT_CTRL_RUNTIME_ALLOC_MEMPOOL
e_btdm_mempool_mem_free(cur);
#endif // UC_BT_CTRL_RUNTIME_ALLOC_MEMPOOL
STAILQ_REMOVE(&s_btdm_osal_mempool_list, cur, btdm_mempool, mp_list);
return 0;
}
btdm_osal_error_t
e_btdm_mempool_clear(struct btdm_mempool *mp)
{
struct btdm_memblock *block_ptr;
int true_block_size;
uint8_t *block_addr;
uint16_t blocks;
if (!mp) {
return BTDM_OSAL_INVALID_PARM;
}
#if UC_BT_CTRL_RUNTIME_ALLOC_MEMPOOL
if (e_btdm_mempool_mem_free(mp) == BTDM_OSAL_OK) {
return BTDM_OSAL_OK;
}
#endif // UC_BT_CTRL_RUNTIME_ALLOC_MEMPOOL
true_block_size = BTDM_MEMPOOL_TRUE_BLOCK_SIZE(mp);
/* cleanup the memory pool structure */
mp->mp_num_free = mp->mp_num_blocks;
mp->mp_min_free = mp->mp_num_blocks;
SLIST_FIRST(mp) = (void *)(uintptr_t)mp->mp_membuf_addr;
/* Chain the memory blocks to the free list */
block_addr = (uint8_t *)(uintptr_t)mp->mp_membuf_addr;
block_ptr = (struct btdm_memblock *)block_addr;
blocks = mp->mp_num_blocks;
while (blocks > 1) {
block_addr += true_block_size;
SLIST_NEXT(block_ptr, mb_next) = (struct btdm_memblock *)block_addr;
block_ptr = (struct btdm_memblock *)block_addr;
--blocks;
}
/* Last one in the list should be NULL */
SLIST_NEXT(block_ptr, mb_next) = NULL;
return BTDM_OSAL_OK;
}
btdm_osal_error_t
e_btdm_mempool_ext_clear(struct btdm_mempool_ext *mpe)
{
btdm_osal_error_t rc;
mpe->mpe_put_cb = NULL;
mpe->mpe_put_arg = NULL;
mpe->mpe_get_cb = NULL;
mpe->mpe_get_arg = NULL;
rc = btdm_mempool_clear(&mpe->mpe_mp);
#if UC_BT_CTRL_RUNTIME_ALLOC_MEMPOOL
mpe->mpe_mp.mp_flags &= ~BTDM_MEMPOOL_F_EXT;
#else
mpe->mpe_mp.mp_flags = 0;
#endif
return rc;
}
bool
e_btdm_mempool_is_sane(const struct btdm_mempool *mp)
{
struct btdm_memblock *block;
#if UC_BT_CTRL_RUNTIME_ALLOC_MEMPOOL
/* Runtime mode cannot verify sanity */
if (mp->mp_flags & BTDM_MEMPOOL_F_RUNTIME) {
assert(0);
}
#endif
/* Verify that each block in the free list belongs to the mempool. */
SLIST_FOREACH(block, mp, mb_next) {
if (!e_btdm_memblock_from(mp, block)) {
return false;
}
}
return true;
}
int
e_btdm_memblock_from(const struct btdm_mempool *mp, const void *block_addr)
{
uint32_t true_block_size;
uintptr_t baddr32;
uint32_t end;
#if UC_BT_CTRL_RUNTIME_ALLOC_MEMPOOL
/* Runtime allocation mode doesn't support from */
if (mp->mp_flags & BTDM_MEMPOOL_F_RUNTIME) {
assert(0);
}
#endif
static_assert(sizeof block_addr == sizeof baddr32,
"Pointer to void must be 32-bits.");
baddr32 = (uint32_t)(uintptr_t)block_addr;
true_block_size = BTDM_MEMPOOL_TRUE_BLOCK_SIZE(mp);
end = mp->mp_membuf_addr + (mp->mp_num_blocks * true_block_size);
/* Check that the block is in the memory buffer range. */
if ((baddr32 < mp->mp_membuf_addr) || (baddr32 >= end)) {
return 0;
}
/* All freed blocks should be on true block size boundaries! */
if (!(mp->mp_flags & BTDM_MEMPOOL_F_COMBINATION) &&
((baddr32 - mp->mp_membuf_addr) % true_block_size) != 0) {
return 0;
}
return 1;
}
void *
e_btdm_memblock_get(struct btdm_mempool *mp)
{
struct btdm_mempool_ext *mpe;
struct btdm_memblock *block;
/* Check to make sure they passed in a memory pool (or something) */
block = NULL;
if (mp && mp->mp_flags & BTDM_MEMPOOL_F_EXT) {
mpe = (struct btdm_mempool_ext *)mp;
if (mpe->mpe_get_cb != NULL) {
block = mpe->mpe_get_cb(mpe, mpe->mpe_get_arg);
return block;
}
}
#if UC_BT_CTRL_RUNTIME_ALLOC_MEMPOOL
/* Runtime allocation mode */
if (mp && mp->mp_flags & BTDM_MEMPOOL_F_RUNTIME) {
bool need_alloc = false;
void *allocated_block;
uint32_t alloc_size;
btdm_osal_hw_enter_critical();
if (mp->mp_num_free) {
#if UC_BT_CTRL_MEMPOOL_BLOCK_REUSED
if (mp->mp_flags & BTDM_MEMPOOL_F_REUSED) {
if (!SLIST_EMPTY(mp)) {
block = SLIST_FIRST(mp);
SLIST_REMOVE_HEAD(mp, mb_next);
} else {
assert(mp->mp_alloc_blocks < mp->mp_num_blocks);
need_alloc = true;
mp->mp_alloc_blocks++;
}
} else
#endif
{
need_alloc = true;
}
/* Decrement number free by 1 */
mp->mp_num_free--;
if (mp->mp_min_free > mp->mp_num_free) {
mp->mp_min_free = mp->mp_num_free;
}
}
btdm_osal_hw_exit_critical(0);
/* Allocate outside critical section to avoid holding lock too long */
if (need_alloc) {
alloc_size = BTDM_MEMPOOL_TRUE_BLOCK_SIZE(mp);
allocated_block = btdm_osal_malloc(alloc_size, BTDM_OSAL_MALLOC_F_INTERNAL);
if (allocated_block) {
/* Save mempool pointer for block */
block = (struct btdm_memblock *)(allocated_block);
} else {
// Should not happen
btdm_osal_hw_enter_critical();
mp->mp_num_free++;
#if UC_BT_CTRL_MEMPOOL_BLOCK_REUSED
if (mp->mp_flags & BTDM_MEMPOOL_F_REUSED) {
mp->mp_alloc_blocks--;
}
#endif
btdm_osal_hw_exit_critical(0);
}
}
return block;
}
#endif
if (mp) {
btdm_osal_hw_enter_critical();
/* Check for any free */
if (mp->mp_num_free) {
/* Get a free block */
block = SLIST_FIRST(mp);
/* Set new free list head */
SLIST_FIRST(mp) = SLIST_NEXT(block, mb_next);
/* Decrement number free by 1 */
mp->mp_num_free--;
if (mp->mp_min_free > mp->mp_num_free) {
mp->mp_min_free = mp->mp_num_free;
}
}
btdm_osal_hw_exit_critical(0);
}
return (void *)block;
}
btdm_osal_error_t
e_btdm_memblock_put_from_cb(struct btdm_mempool *mp, void *block_addr)
{
struct btdm_memblock *block;
#if UC_BT_CTRL_RUNTIME_ALLOC_MEMPOOL
bool need_free = true;
if (mp->mp_flags & BTDM_MEMPOOL_F_RUNTIME) {
/* Runtime allocation mode - free directly */
btdm_osal_hw_enter_critical();
#if UC_BT_CTRL_MEMPOOL_BLOCK_REUSED
if (mp->mp_flags & BTDM_MEMPOOL_F_REUSED) {
block = (struct btdm_memblock *)block_addr;
SLIST_INSERT_HEAD(mp, block, mb_next);
need_free = false;
}
#endif
mp->mp_num_free++;
assert(mp->mp_num_blocks >= mp->mp_num_free);
btdm_osal_hw_exit_critical(0);
/* Free outside critical section */
if (need_free) {
btdm_osal_free(block_addr);
}
return BTDM_OSAL_OK;
}
#endif
/* Validate that the block belongs to this mempool */
if (!(mp->mp_flags & BTDM_MEMPOOL_F_FRAG) &&
!e_btdm_memblock_from(mp, block_addr)) {
return BTDM_OSAL_INVALID_PARM;
}
block = (struct btdm_memblock *)block_addr;
btdm_osal_hw_enter_critical();
/* Check for duplicate free - verify block is not already in free list */
{
struct btdm_memblock *cur;
SLIST_FOREACH(cur, mp, mb_next) {
if (cur == block) {
btdm_osal_hw_exit_critical(0);
return BTDM_OSAL_INVALID_PARM;
}
}
}
/* Check that the number free doesn't exceed number blocks */
if (mp->mp_num_free >= mp->mp_num_blocks) {
btdm_osal_hw_exit_critical(0);
return BTDM_OSAL_INVALID_PARM;
}
/* Chain current free list pointer to this block; make this block head */
SLIST_NEXT(block, mb_next) = SLIST_FIRST(mp);
SLIST_FIRST(mp) = block;
/* Increment number free */
mp->mp_num_free++;
btdm_osal_hw_exit_critical(0);
return BTDM_OSAL_OK;
}
btdm_osal_error_t
e_btdm_memblock_put(struct btdm_mempool *mp, void *block_addr)
{
struct btdm_mempool_ext *mpe;
btdm_osal_error_t ret;
#if UC_BT_CTRL_MEMPOOL_CHECK
struct btdm_memblock *block;
#endif
/* Make sure parameters are valid */
if ((mp == NULL) || (block_addr == NULL)) {
ret = BTDM_OSAL_INVALID_PARM;
goto done;
}
#if UC_BT_CTRL_MEMPOOL_CHECK
#if UC_BT_CTRL_RUNTIME_ALLOC_MEMPOOL
if (!(mp->mp_flags & BTDM_MEMPOOL_F_RUNTIME))
#endif
{
/* Check that the block we are freeing is a valid block! */
assert(btdm_memblock_from(mp, block_addr));
}
/*
* Check for duplicate free.
*/
SLIST_FOREACH(block, mp, mb_next) {
assert(block != (struct btdm_memblock *)block_addr);
}
#endif
/* If this is an extended mempool with a put callback, call the callback
* instead of freeing the block directly.
*/
if (mp->mp_flags & BTDM_MEMPOOL_F_EXT) {
mpe = (struct btdm_mempool_ext *)mp;
if (mpe->mpe_put_cb != NULL) {
ret = mpe->mpe_put_cb(mpe, block_addr, mpe->mpe_put_arg);
goto done;
}
}
/* No callback; free the block. */
ret = btdm_memblock_put_from_cb(mp, block_addr);
done:
return ret;
}
void
e_btdm_mempool_flags_set(struct btdm_mempool *mp, uint8_t flags)
{
mp->mp_flags |= flags;
}
void
e_btdm_mempool_flags_clear(struct btdm_mempool *mp, uint8_t flags)
{
mp->mp_flags &= ~flags;
}
uint16_t
e_btdm_mempool_free_blocks_num(struct btdm_mempool *mp)
{
uint16_t free_blocks_num;
btdm_osal_hw_enter_critical();
free_blocks_num = mp->mp_num_free;
btdm_osal_hw_exit_critical(0);
return free_blocks_num;
}
void
e_btdm_mempool_module_init(void)
{
}
void
e_btdm_mempool_deinit(bool is_controller)
{
struct btdm_mempool *mp = NULL;
struct btdm_mempool *next = NULL;
mp = STAILQ_FIRST(&s_btdm_osal_mempool_list);
// All mempool blocks should be reclaimed and mempool removed from mempool list after nimble deinit
while (mp) {
if (is_controller == !!(mp->mp_flags & BTDM_MEMPOOL_F_CONTROLLER)) {
next = STAILQ_NEXT(mp, mp_list);
btdm_mempool_unregister(mp);
mp = next;
} else {
mp = STAILQ_NEXT(mp, mp_list);
}
}
}

View File

@@ -30,12 +30,12 @@ extern int esp_rom_printf(const char *fmt, ...);
} \
} while (0)
#define BTDM_MEMPOOL_ALLOC (1)
#if (!defined(SOC_ESP_NIMBLE_CONTROLLER) || !SOC_ESP_NIMBLE_CONTROLLER)
#error "not defined SOC_ESP_NIMBLE_CONTROLLER or SOC_ESP_NIMBLE_CONTROLLER is zero"
#endif
#define BTDM_OSAL_DYNAMIC_ALLOC (1)
struct btdm_intr_alloc_params {
union {
struct {
@@ -54,18 +54,9 @@ static const char *TAG __attribute__((unused)) = "BTDM OSAL";
struct btdm_mempool s_btdm_osal_ev_pool;
static btdm_membuf_t *s_btdm_osal_ev_buf = NULL;
struct btdm_mempool s_btdm_osal_evq_pool;
static btdm_membuf_t *s_btdm_osal_evq_buf = NULL;
struct btdm_mempool s_btdm_osal_co_pool;
static btdm_membuf_t *s_btdm_osal_co_buf = NULL;
struct btdm_mempool s_btdm_osal_sem_pool;
static btdm_membuf_t *s_btdm_osal_sem_buf = NULL;
struct btdm_mempool s_btdm_osal_mutex_pool;
static btdm_membuf_t *s_btdm_osal_mutex_buf = NULL;
static uint16_t s_btdm_osal_evtq_deepth = 0;
static uint8_t s_btdm_osal_intr_nest = 0;
static portMUX_TYPE s_btsm_osal_intr_mutex = portMUX_INITIALIZER_UNLOCKED;
@@ -90,56 +81,36 @@ in_isr(void)
void
wr_btdm_osal_eventq_init(struct btdm_osal_eventq *evq)
{
struct btdm_osal_eventq_freertos *eventq = NULL;
struct btdm_osal_eventq_freertos *eventq = (struct btdm_osal_eventq_freertos *)evq;
#if BTDM_MEMPOOL_ALLOC
if (!btdm_memblock_from(&s_btdm_osal_evq_pool, evq->eventq)) {
evq->eventq = btdm_memblock_get(&s_btdm_osal_evq_pool);
eventq = (struct btdm_osal_eventq_freertos *)evq->eventq;
BTDM_OSAL_ASSERT(eventq);
memset(eventq, 0, sizeof(*eventq));
eventq->q = xQueueCreate(s_btdm_osal_evtq_deepth, sizeof(struct btdm_osal_eventq *));
BTDM_OSAL_ASSERT(eventq->q);
} else {
eventq = (struct btdm_osal_eventq_freertos *)evq->eventq;
xQueueReset(eventq->q);
static_assert(sizeof(struct btdm_osal_eventq_freertos) == sizeof(struct btdm_osal_eventq),
"size of btdm_osal_eventq_freertos and btdm_osal_eventq must be the same");
if (eventq->q) {
return;
}
#else
if (!evq->eventq) {
evq->eventq = btdm_osal_malloc(sizeof(struct btdm_osal_eventq_freertos),
BTDM_OSAL_MALLOC_F_INTERNAL);
eventq = (struct btdm_osal_eventq_freertos *)evq->eventq;
BTDM_OSAL_ASSERT(eventq);
memset(eventq, 0, sizeof(*eventq));
eventq->q = xQueueCreate(s_btdm_osal_evtq_deepth, sizeof(struct btdm_osal_eventq *));
BTDM_OSAL_ASSERT(eventq->q);
} else {
eventq = (struct btdm_osal_eventq_freertos *)evq->eventq;
xQueueReset(eventq->q);
}
#endif
memset(eventq, 0, sizeof(*eventq));
eventq->q = xQueueCreate(s_btdm_osal_evtq_deepth, sizeof(struct btdm_osal_event *));
BTDM_OSAL_ASSERT(eventq->q);
}
void
wr_btdm_osal_eventq_deinit(struct btdm_osal_eventq *evq)
{
struct btdm_osal_eventq_freertos *eventq = (struct btdm_osal_eventq_freertos *)evq->eventq;
struct btdm_osal_eventq_freertos *eventq = (struct btdm_osal_eventq_freertos *)evq;
BTDM_OSAL_ASSERT(eventq);
BTDM_OSAL_ASSERT(eventq->q);
vQueueDelete(eventq->q);
#if BTDM_MEMPOOL_ALLOC
btdm_memblock_put(&s_btdm_osal_evq_pool, eventq);
#else
btdm_osal_free((void *)eventq);
#endif
evq->eventq = NULL;
eventq->q = NULL;
}
struct btdm_osal_event *IRAM_ATTR
wr_btdm_osal_eventq_get(struct btdm_osal_eventq *evq, btdm_osal_time_t tmo)
{
struct btdm_osal_event *ev = NULL;
struct btdm_osal_eventq_freertos *eventq = (struct btdm_osal_eventq_freertos *)evq->eventq;
struct btdm_osal_eventq_freertos *eventq = (struct btdm_osal_eventq_freertos *)evq;
BaseType_t woken;
BaseType_t ret;
@@ -169,7 +140,7 @@ wr_btdm_osal_eventq_put(struct btdm_osal_eventq *evq, struct btdm_osal_event *ev
{
BaseType_t woken;
BaseType_t ret;
struct btdm_osal_eventq_freertos *eventq = (struct btdm_osal_eventq_freertos *)evq->eventq;
struct btdm_osal_eventq_freertos *eventq = (struct btdm_osal_eventq_freertos *)evq;
struct btdm_osal_event_freertos *event = (struct btdm_osal_event_freertos *)ev->event;
if (event->queued) {
@@ -195,7 +166,7 @@ wr_btdm_osal_eventq_put_to_front(struct btdm_osal_eventq *evq, struct btdm_osal_
{
BaseType_t woken;
BaseType_t ret;
struct btdm_osal_eventq_freertos *eventq = (struct btdm_osal_eventq_freertos *)evq->eventq;
struct btdm_osal_eventq_freertos *eventq = (struct btdm_osal_eventq_freertos *)evq;
struct btdm_osal_event_freertos *event = (struct btdm_osal_event_freertos *)ev->event;
if (event->queued) {
@@ -224,7 +195,7 @@ wr_btdm_osal_eventq_remove(struct btdm_osal_eventq *evq, struct btdm_osal_event
int i;
int count;
BaseType_t woken, woken2;
struct btdm_osal_eventq_freertos *eventq = (struct btdm_osal_eventq_freertos *)evq->eventq;
struct btdm_osal_eventq_freertos *eventq = (struct btdm_osal_eventq_freertos *)evq;
struct btdm_osal_event_freertos *event = (struct btdm_osal_event_freertos *)ev->event;
if (!event->queued) {
@@ -263,7 +234,7 @@ wr_btdm_osal_eventq_remove(struct btdm_osal_eventq *evq, struct btdm_osal_event
/* RISK: For multi-core, this mutex can't protect the queue from being changed by other cores
* with wr_btdm_osal_eventq_put(). The count maybe less than the actual.
*/
portENTER_CRITICAL(&s_btsm_osal_intr_mutex);
portENTER_CRITICAL_SAFE(&s_btsm_osal_intr_mutex);
count = uxQueueMessagesWaiting(eventq->q);
for (i = 0; i < count; i++) {
@@ -278,7 +249,7 @@ wr_btdm_osal_eventq_remove(struct btdm_osal_eventq *evq, struct btdm_osal_event
BTDM_OSAL_ASSERT(ret == pdPASS);
}
portEXIT_CRITICAL(&s_btsm_osal_intr_mutex);
portEXIT_CRITICAL_SAFE(&s_btsm_osal_intr_mutex);
}
event->queued = 0;
@@ -287,7 +258,7 @@ wr_btdm_osal_eventq_remove(struct btdm_osal_eventq *evq, struct btdm_osal_event
bool IRAM_ATTR
wr_btdm_osal_eventq_is_empty(struct btdm_osal_eventq *evq)
{
struct btdm_osal_eventq_freertos *eventq = (struct btdm_osal_eventq_freertos *)evq->eventq;
struct btdm_osal_eventq_freertos *eventq = (struct btdm_osal_eventq_freertos *)evq;
return xQueueIsQueueEmptyFromISR(eventq->q);
}
@@ -308,16 +279,17 @@ wr_btdm_osal_event_init(struct btdm_osal_event *ev, btdm_osal_event_fn *fn, void
{
struct btdm_osal_event_freertos *event = NULL;
#if BTDM_MEMPOOL_ALLOC
if (!btdm_memblock_from(&s_btdm_osal_ev_pool, ev->event)) {
if (!ev->event) {
ev->event = btdm_memblock_get(&s_btdm_osal_ev_pool);
}
#else
#if BTDM_OSAL_DYNAMIC_ALLOC
if (!ev->event) {
ev->event = btdm_osal_malloc(sizeof(struct btdm_osal_event_freertos),
BTDM_OSAL_MALLOC_F_INTERNAL);
ev->event =
btdm_osal_malloc(sizeof(struct btdm_osal_event_freertos), BTDM_OSAL_MALLOC_F_INTERNAL);
}
#endif
#endif // BTDM_OSAL_DYNAMIC_ALLOC
event = (struct btdm_osal_event_freertos *)ev->event;
BTDM_OSAL_ASSERT(event);
@@ -329,16 +301,22 @@ wr_btdm_osal_event_init(struct btdm_osal_event *ev, btdm_osal_event_fn *fn, void
void IRAM_ATTR
wr_btdm_osal_event_deinit(struct btdm_osal_event *ev)
{
if (!ev->event) {
struct btdm_osal_event_freertos *event = (struct btdm_osal_event_freertos *)ev->event;
if (!event) {
return;
}
#if BTDM_MEMPOOL_ALLOC
btdm_memblock_put(&s_btdm_osal_ev_pool, ev->event);
#else
btdm_osal_free(ev->event);
#endif
ev->event = NULL;
#if BTDM_OSAL_DYNAMIC_ALLOC
if (!btdm_memblock_from(&s_btdm_osal_ev_pool, event)) {
btdm_osal_free(event);
return;
}
#endif
btdm_memblock_put(&s_btdm_osal_ev_pool, event);
}
void IRAM_ATTR
@@ -381,57 +359,29 @@ wr_btdm_osal_event_set_arg(struct btdm_osal_event *ev, void *arg)
btdm_osal_error_t
wr_btdm_osal_mutex_init(struct btdm_osal_mutex *mu)
{
struct btdm_osal_mutex_freertos *mutex = NULL;
#if BTDM_MEMPOOL_ALLOC
if (!btdm_memblock_from(&s_btdm_osal_mutex_pool, mu->mutex)) {
mu->mutex = btdm_memblock_get(&s_btdm_osal_mutex_pool);
mutex = (struct btdm_osal_mutex_freertos *)mu->mutex;
struct btdm_osal_mutex_freertos *mutex = (struct btdm_osal_mutex_freertos *)mu;
static_assert(sizeof(struct btdm_osal_mutex_freertos) == sizeof(struct btdm_osal_mutex),
"size of btdm_osal_mutex_freertos and btdm_osal_mutex must be the same");
if (!mutex) {
return BTDM_OSAL_INVALID_PARM;
}
mutex->handle = xSemaphoreCreateRecursiveMutex();
memset(mutex, 0, sizeof(*mutex));
mutex->handle = xSemaphoreCreateRecursiveMutex();
BTDM_OSAL_ASSERT(mutex->handle);
if (!mutex->handle) {
return BTDM_OSAL_ENOMEM;
}
#else
if (!mu->mutex) {
mu->mutex = btdm_osal_malloc(sizeof(struct btdm_osal_mutex_freertos),
BTDM_OSAL_MALLOC_F_INTERNAL);
mutex = (struct btdm_osal_mutex_freertos *)mu->mutex;
if (!mutex) {
return BTDM_OSAL_INVALID_PARM;
}
memset(mutex, 0, sizeof(*mutex));
mutex->handle = xSemaphoreCreateRecursiveMutex();
BTDM_OSAL_ASSERT(mutex->handle);
}
#endif
return BTDM_OSAL_OK;
}
btdm_osal_error_t
wr_btdm_osal_mutex_deinit(struct btdm_osal_mutex *mu)
{
struct btdm_osal_mutex_freertos *mutex = (struct btdm_osal_mutex_freertos *)mu->mutex;
struct btdm_osal_mutex_freertos *mutex = (struct btdm_osal_mutex_freertos *)mu;
if (!mutex) {
if (!mutex->handle) {
return BTDM_OSAL_INVALID_PARM;
}
BTDM_OSAL_ASSERT(mutex->handle);
vSemaphoreDelete(mutex->handle);
#if BTDM_MEMPOOL_ALLOC
btdm_memblock_put(&s_btdm_osal_mutex_pool, mutex);
#else
btdm_osal_free((void *)mutex);
#endif
mu->mutex = NULL;
mutex->handle = NULL;
return BTDM_OSAL_OK;
}
@@ -440,14 +390,12 @@ btdm_osal_error_t IRAM_ATTR
wr_btdm_osal_mutex_pend(struct btdm_osal_mutex *mu, btdm_osal_time_t timeout)
{
BaseType_t ret;
struct btdm_osal_mutex_freertos *mutex = (struct btdm_osal_mutex_freertos *)mu->mutex;
struct btdm_osal_mutex_freertos *mutex = (struct btdm_osal_mutex_freertos *)mu;
if (!mutex) {
if (!mutex->handle) {
return BTDM_OSAL_INVALID_PARM;
}
BTDM_OSAL_ASSERT(mutex->handle);
if (in_isr()) {
ret = pdFAIL;
BTDM_OSAL_ASSERT(0);
@@ -461,14 +409,12 @@ wr_btdm_osal_mutex_pend(struct btdm_osal_mutex *mu, btdm_osal_time_t timeout)
btdm_osal_error_t IRAM_ATTR
wr_btdm_osal_mutex_release(struct btdm_osal_mutex *mu)
{
struct btdm_osal_mutex_freertos *mutex = (struct btdm_osal_mutex_freertos *)mu->mutex;
struct btdm_osal_mutex_freertos *mutex = (struct btdm_osal_mutex_freertos *)mu;
if (!mutex) {
if (!mutex->handle) {
return BTDM_OSAL_INVALID_PARM;
}
BTDM_OSAL_ASSERT(mutex->handle);
if (in_isr()) {
BTDM_OSAL_ASSERT(0);
} else {
@@ -488,36 +434,15 @@ wr_btdm_osal_mutex_release(struct btdm_osal_mutex *mu)
btdm_osal_error_t
wr_btdm_osal_sem_init(struct btdm_osal_sem *sem, uint16_t tokens)
{
struct btdm_osal_sem_freertos *semaphore = NULL;
struct btdm_osal_sem_freertos *semaphore = (struct btdm_osal_sem_freertos *)sem;
#if BTDM_MEMPOOL_ALLOC
if (!btdm_memblock_from(&s_btdm_osal_sem_pool, sem->sem)) {
sem->sem = btdm_memblock_get(&s_btdm_osal_sem_pool);
semaphore = (struct btdm_osal_sem_freertos *)sem->sem;
static_assert(sizeof(struct btdm_osal_sem_freertos) == sizeof(struct btdm_osal_sem),
"size of btdm_osal_sem_freertos and btdm_osal_sem must be the same");
if (!semaphore) {
return BTDM_OSAL_INVALID_PARM;
}
memset(semaphore, 0, sizeof(*semaphore));
semaphore->handle = xSemaphoreCreateCounting(128, tokens);
BTDM_OSAL_ASSERT(semaphore->handle);
semaphore->handle = xSemaphoreCreateCounting(128, tokens);
if (!semaphore->handle) {
return BTDM_OSAL_ENOMEM;
}
#else
if (!sem->sem) {
sem->sem = btdm_osal_malloc(sizeof(struct btdm_osal_sem_freertos),
BTDM_OSAL_MALLOC_F_INTERNAL);
semaphore = (struct btdm_osal_sem_freertos *)sem->sem;
if (!semaphore) {
return BTDM_OSAL_INVALID_PARM;
}
memset(semaphore, 0, sizeof(*semaphore));
semaphore->handle = xSemaphoreCreateCounting(128, tokens);
BTDM_OSAL_ASSERT(semaphore->handle);
}
#endif
return BTDM_OSAL_OK;
}
@@ -525,21 +450,14 @@ wr_btdm_osal_sem_init(struct btdm_osal_sem *sem, uint16_t tokens)
btdm_osal_error_t
wr_btdm_osal_sem_deinit(struct btdm_osal_sem *sem)
{
struct btdm_osal_sem_freertos *semaphore = (struct btdm_osal_sem_freertos *)sem->sem;
struct btdm_osal_sem_freertos *semaphore = (struct btdm_osal_sem_freertos *)sem;
if (!semaphore) {
if (!semaphore->handle) {
return BTDM_OSAL_INVALID_PARM;
}
BTDM_OSAL_ASSERT(semaphore->handle);
vSemaphoreDelete(semaphore->handle);
#if BTDM_MEMPOOL_ALLOC
btdm_memblock_put(&s_btdm_osal_sem_pool, semaphore);
#else
btdm_osal_free((void *)semaphore);
#endif
sem->sem = NULL;
semaphore->handle = NULL;
return BTDM_OSAL_OK;
}
@@ -549,14 +467,12 @@ wr_btdm_osal_sem_pend(struct btdm_osal_sem *sem, btdm_osal_time_t timeout)
{
BaseType_t woken;
BaseType_t ret;
struct btdm_osal_sem_freertos *semaphore = (struct btdm_osal_sem_freertos *)sem->sem;
struct btdm_osal_sem_freertos *semaphore = (struct btdm_osal_sem_freertos *)sem;
if (!semaphore) {
if (!semaphore->handle) {
return BTDM_OSAL_INVALID_PARM;
}
BTDM_OSAL_ASSERT(semaphore->handle);
if (in_isr()) {
BTDM_OSAL_ASSERT(timeout == 0);
ret = xSemaphoreTakeFromISR(semaphore->handle, &woken);
@@ -575,14 +491,12 @@ wr_btdm_osal_sem_release(struct btdm_osal_sem *sem)
{
BaseType_t ret;
BaseType_t woken;
struct btdm_osal_sem_freertos *semaphore = (struct btdm_osal_sem_freertos *)sem->sem;
struct btdm_osal_sem_freertos *semaphore = (struct btdm_osal_sem_freertos *)sem;
if (!semaphore) {
if (!semaphore->handle) {
return BTDM_OSAL_INVALID_PARM;
}
BTDM_OSAL_ASSERT(semaphore->handle);
if (in_isr()) {
ret = xSemaphoreGiveFromISR(semaphore->handle, &woken);
if (woken == pdTRUE) {
@@ -599,7 +513,7 @@ wr_btdm_osal_sem_release(struct btdm_osal_sem *sem)
uint16_t IRAM_ATTR
wr_btdm_osal_sem_get_count(struct btdm_osal_sem *sem)
{
struct btdm_osal_sem_freertos *semaphore = (struct btdm_osal_sem_freertos *)sem->sem;
struct btdm_osal_sem_freertos *semaphore = (struct btdm_osal_sem_freertos *)sem;
return uxSemaphoreGetCount(semaphore->handle);
}
@@ -666,89 +580,58 @@ wr_btdm_osal_callout_init(struct btdm_osal_callout *co, struct btdm_osal_eventq
{
struct btdm_osal_callout_freertos *callout = NULL;
#if BTDM_MEMPOOL_ALLOC
if (!btdm_memblock_from(&s_btdm_osal_co_pool, co->co)) {
if (!co->co) {
co->co = btdm_memblock_get(&s_btdm_osal_co_pool);
callout = (struct btdm_osal_callout_freertos *)co->co;
BTDM_OSAL_ASSERT(callout);
memset(callout, 0, sizeof(*callout));
btdm_osal_event_init(&callout->ev, ev_cb, ev_arg);
#if BTDM_OSAL_USE_ESP_TIMER
callout->evq = evq;
esp_timer_create_args_t create_args = {
.callback = btdm_osal_event_fn_wrapper,
.arg = callout,
.name = "nimble_timer"
};
if (esp_timer_create(&create_args, &callout->handle) != ESP_OK) {
btdm_osal_event_deinit(&callout->ev);
btdm_memblock_put(&s_btdm_osal_co_pool, callout);
co->co = NULL;
return -1;
if (callout) {
memset(callout, 0, sizeof(struct btdm_osal_callout_freertos));
}
#else
callout->handle = xTimerCreate("co", 1, pdFALSE, callout, os_callout_timer_cb);
if (!callout->handle) {
btdm_osal_event_deinit(&callout->ev);
btdm_memblock_put(&s_btdm_osal_co_pool, callout);
co->co = NULL;
return -1;
}
#endif // BTDM_OSAL_USE_ESP_TIMER
} else {
callout = (struct btdm_osal_callout_freertos *)co->co;
BTDM_OSAL_ASSERT(callout);
callout->evq = evq;
btdm_osal_event_init(&callout->ev, ev_cb, ev_arg);
}
#else
#if BTDM_OSAL_DYNAMIC_ALLOC
if (!co->co) {
co->co = btdm_osal_malloc(sizeof(struct btdm_osal_callout_freertos),
BTDM_OSAL_MALLOC_F_INTERNAL);
callout = (struct btdm_osal_callout_freertos *)co->co;
if (!callout) {
return -1;
if (callout) {
memset(callout, 0, sizeof(struct btdm_osal_callout_freertos));
}
}
#endif
memset(callout, 0, sizeof(*callout));
btdm_osal_event_init(&callout->ev, ev_cb, ev_arg);
callout = (struct btdm_osal_callout_freertos *)co->co;
if (!callout) {
return BTDM_OSAL_ENOMEM;
}
btdm_osal_event_init(&callout->ev, ev_cb, ev_arg);
callout->evq = evq;
if (callout->handle) {
return BTDM_OSAL_OK;
}
#if BTDM_OSAL_USE_ESP_TIMER
callout->evq = evq;
esp_timer_create_args_t create_args = {
.callback = btdm_osal_event_fn_wrapper,
.arg = callout,
.name = "btdm_timer"
};
esp_timer_create_args_t create_args = {
.callback = btdm_osal_event_fn_wrapper, .arg = callout, .name = "nimble_timer"};
if (esp_timer_create(&create_args, &callout->handle) != ESP_OK) {
btdm_osal_event_deinit(&callout->ev);
btdm_osal_free((void *)callout);
co->co = NULL;
return -1;
}
#else
callout->handle = xTimerCreate("co", 1, pdFALSE, callout, os_callout_timer_cb);
if (!callout->handle) {
btdm_osal_event_deinit(&callout->ev);
btdm_osal_free((void *)callout);
co->co = NULL;
return -1;
}
#endif // BTDM_OSAL_USE_ESP_TIMER
} else {
callout = (struct btdm_osal_callout_freertos *)co->co;
BTDM_OSAL_ASSERT(callout);
callout->evq = evq;
btdm_osal_event_init(&callout->ev, ev_cb, ev_arg);
if (esp_timer_create(&create_args, &callout->handle) != ESP_OK) {
btdm_osal_callout_deinit(co);
return BTDM_OSAL_ENOMEM;
}
#endif // BTDM_MEMPOOL_ALLOC
return 0;
#else // BTDM_OSAL_USE_ESP_TIMER
callout->handle = xTimerCreate("co", 1, pdFALSE, callout, os_callout_timer_cb);
if (!callout->handle) {
btdm_osal_callout_deinit(co);
return BTDM_OSAL_ENOMEM;
}
#endif // BTDM_OSAL_USE_ESP_TIMER
return BTDM_OSAL_OK;
}
void
@@ -762,34 +645,36 @@ wr_btdm_osal_callout_deinit(struct btdm_osal_callout *co)
return;
}
if (!callout->handle) {
return;
if (callout->handle) {
#if BTDM_OSAL_USE_ESP_TIMER
esp_err_t err = esp_timer_stop(callout->handle);
if (err != ESP_OK) {
/* ESP_ERR_INVALID_STATE is expected when timer is already stopped */
if (err != ESP_ERR_INVALID_STATE) {
ESP_LOGD(TAG, "Timer not stopped");
}
}
err = esp_timer_delete(callout->handle);
if (err != ESP_OK) {
ESP_LOGW(TAG, "Timer not deleted");
}
#else
xTimerDelete(callout->handle, portMAX_DELAY);
#endif // BTDM_OSAL_USE_ESP_TIMER
}
btdm_osal_event_deinit(&callout->ev);
#if BTDM_OSAL_USE_ESP_TIMER
esp_err_t err = esp_timer_stop(callout->handle);
if (err != ESP_OK) {
/* ESP_ERR_INVALID_STATE is expected when timer is already stopped */
if (err != ESP_ERR_INVALID_STATE) {
ESP_LOGD(TAG, "Timer not stopped");
}
}
err = esp_timer_delete(callout->handle);
if (err != ESP_OK) {
ESP_LOGW(TAG, "Timer not deleted");
}
#else
xTimerDelete(callout->handle, portMAX_DELAY);
#endif // BTDM_OSAL_USE_ESP_TIMER
#if BTDM_MEMPOOL_ALLOC
btdm_memblock_put(&s_btdm_osal_co_pool, callout);
#else
btdm_osal_free((void *)callout);
#endif // BTDM_MEMPOOL_ALLOC
co->co = NULL;
memset(co, 0, sizeof(struct btdm_osal_callout));
#if BTDM_OSAL_DYNAMIC_ALLOC
if (!btdm_memblock_from(&s_btdm_osal_co_pool, callout)) {
btdm_osal_free((void *)callout);
return;
}
#endif
btdm_memblock_put(&s_btdm_osal_co_pool, callout);
}
btdm_osal_error_t IRAM_ATTR
@@ -1151,11 +1036,15 @@ wr_btdm_osal_intr_free(btdm_osal_intr_handle_t intr_handle)
void *
wr_btdm_osal_malloc(uint32_t size, btdm_osal_malloc_flag_t flags)
{
void *ptr;
if (flags == BTDM_OSAL_MALLOC_F_INTERNAL) {
return heap_caps_malloc(size, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT | MALLOC_CAP_DMA);
ptr = heap_caps_malloc(size, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT | MALLOC_CAP_DMA);
} else {
return heap_caps_malloc(size, MALLOC_CAP_8BIT);
ptr = heap_caps_malloc(size, MALLOC_CAP_8BIT);
}
return ptr;
}
void
@@ -1253,7 +1142,6 @@ wr_btdm_osal_rand(void)
int
btdm_osal_elem_mempool_init(btdm_osal_elem_num_t *elem_num)
{
#if BTDM_MEMPOOL_ALLOC
int rc;
s_btdm_osal_evtq_deepth = elem_num->evt_count;
@@ -1274,104 +1162,37 @@ btdm_osal_elem_mempool_init(btdm_osal_elem_num_t *elem_num)
}
}
if (elem_num->evtq_count) {
s_btdm_osal_evq_buf = btdm_osal_malloc(
BTDM_MEMPOOL_SIZE(elem_num->evtq_count, sizeof(struct btdm_osal_eventq_freertos)) *
sizeof(btdm_membuf_t),
BTDM_OSAL_MALLOC_F_INTERNAL);
if (!s_btdm_osal_evq_buf) {
return -3;
}
rc = btdm_mempool_init(&s_btdm_osal_evq_pool, elem_num->evtq_count,
sizeof(struct btdm_osal_eventq_freertos), s_btdm_osal_evq_buf,
"s_btdm_osal_evq_pool");
if (rc) {
return -4;
}
}
if (elem_num->co_count) {
s_btdm_osal_co_buf = btdm_osal_malloc(
BTDM_MEMPOOL_SIZE(elem_num->co_count, sizeof(struct btdm_osal_callout_freertos)) *
sizeof(btdm_membuf_t),
BTDM_OSAL_MALLOC_F_INTERNAL);
if (!s_btdm_osal_co_buf) {
return -5;
return -3;
}
rc = btdm_mempool_init(&s_btdm_osal_co_pool, elem_num->co_count,
sizeof(struct btdm_osal_callout_freertos), s_btdm_osal_co_buf,
"s_btdm_osal_co_pool");
if (rc) {
return -6;
}
}
if (elem_num->sem_count) {
s_btdm_osal_sem_buf = btdm_osal_malloc(
BTDM_MEMPOOL_SIZE(elem_num->sem_count, sizeof(struct btdm_osal_sem_freertos)) *
sizeof(btdm_membuf_t),
BTDM_OSAL_MALLOC_F_INTERNAL);
if (!s_btdm_osal_sem_buf) {
return -7;
}
rc = btdm_mempool_init(&s_btdm_osal_sem_pool, elem_num->sem_count,
sizeof(struct btdm_osal_sem_freertos),
s_btdm_osal_sem_buf, "s_btdm_osal_sem_pool");
if (rc) {
return -8;
}
}
if (elem_num->mutex_count) {
s_btdm_osal_mutex_buf = btdm_osal_malloc(
BTDM_MEMPOOL_SIZE(elem_num->mutex_count, sizeof(struct btdm_osal_mutex_freertos)) *
sizeof(btdm_membuf_t),
BTDM_OSAL_MALLOC_F_INTERNAL);
if (!s_btdm_osal_mutex_buf) {
return -9;
}
rc = btdm_mempool_init(&s_btdm_osal_mutex_pool, elem_num->mutex_count,
sizeof(struct btdm_osal_mutex_freertos), s_btdm_osal_mutex_buf,
"s_btdm_osal_mutex_pool");
if (rc) {
return -10;
return -4;
}
}
return 0;
#else
return 0;
#endif // BTDM_MEMPOOL_ALLOC
}
void
btdm_osal_elem_mempool_deinit(void)
{
#if BTDM_MEMPOOL_ALLOC
if (s_btdm_osal_ev_buf) {
BTDM_OSAL_ASSERT(s_btdm_osal_ev_pool.mp_num_free == s_btdm_osal_ev_pool.mp_num_blocks);
btdm_osal_free(s_btdm_osal_ev_buf);
s_btdm_osal_ev_buf = NULL;
}
if (s_btdm_osal_evq_buf) {
BTDM_OSAL_ASSERT(s_btdm_osal_evq_pool.mp_num_free == s_btdm_osal_evq_pool.mp_num_blocks);
btdm_osal_free(s_btdm_osal_evq_buf);
s_btdm_osal_evq_buf = NULL;
}
if (s_btdm_osal_co_buf) {
BTDM_OSAL_ASSERT(s_btdm_osal_co_pool.mp_num_free == s_btdm_osal_co_pool.mp_num_blocks);
btdm_osal_free(s_btdm_osal_co_buf);
s_btdm_osal_co_buf = NULL;
}
if (s_btdm_osal_sem_buf) {
BTDM_OSAL_ASSERT(s_btdm_osal_sem_pool.mp_num_free == s_btdm_osal_sem_pool.mp_num_blocks);
btdm_osal_free(s_btdm_osal_sem_buf);
s_btdm_osal_sem_buf = NULL;
}
if (s_btdm_osal_mutex_buf) {
BTDM_OSAL_ASSERT(s_btdm_osal_mutex_pool.mp_num_free == s_btdm_osal_mutex_pool.mp_num_blocks);
btdm_osal_free(s_btdm_osal_mutex_buf);
s_btdm_osal_mutex_buf = NULL;
}
#endif // BTDM_MEMPOOL_ALLOC
}

View File

@@ -119,6 +119,8 @@ int r_ble_hci_trans_reset(void);
//!TODO: Should we initialize the hci layer in IDF ?
void esp_ble_hci_trans_init(uint8_t);
int hci_cmd_proc_init(void);
// ********************************************************************************************
// btdm common
// ********************************************************************************************
@@ -126,7 +128,9 @@ void esp_ble_hci_trans_init(uint8_t);
typedef int (*btdm_hci_trans_tx_func_t)(hci_driver_packet_t *pkt);
#define HCI_INTERNAL_CONN_MASK (0x0fff)
#define HCI_INTERNAL_CONN_IS_BLE(conn_handle) (!(conn_handle & 0x0800))
#define HCI_INTERNAL_CONN_IS_BLE(conn_handle) ((conn_handle & 0x0800) == 0x0000)
#define HCI_INTERNAL_CONN_IS_BLE_ACL(conn_handle) ((conn_handle & 0x0e00) == 0x0000)
#define HCI_INTERNAL_CONN_IS_BLE_ISO(conn_handle) ((conn_handle & 0x0e00) == 0x0200)
#define HCI_INTERNAL_CONN_IS_BREDR(conn_handle) (conn_handle & 0x0800)
#define HCI_INTERNAL_CONN_IS_BREDR_ACL(conn_handle) ((conn_handle & 0x0800) && (conn_handle & 0x000f))
#define HCI_INTERNAL_CONN_IS_BREDR_SYNC(conn_handle) ((conn_handle & 0x0800) && (conn_handle & 0x00f0))

File diff suppressed because it is too large Load Diff

View File

@@ -245,6 +245,8 @@ hci_transport_init(uint8_t hci_transport_mode)
goto error;
}
hci_cmd_proc_init();
s_hci_transport_env.driver_ops = ops;
#if UC_BT_CTRL_BLE_IS_ENABLE
r_ble_hci_trans_cfg_hs((esp_hci_internal_rx_cmd_fn *)hci_transport_controller_le_evt_tx, NULL,
@@ -271,21 +273,21 @@ hci_transport_deinit(void)
{
hci_driver_ops_t *ops;
btdm_hci_trans_register_tx((btdm_hci_trans_tx_func_t *)hci_transport_controller_tx_dummy, false);
ops = s_hci_transport_env.driver_ops;
if (ops) {
btdm_hci_trans_register_tx((btdm_hci_trans_tx_func_t *)hci_transport_controller_tx_dummy, false);
#if UC_BT_CTRL_BLE_IS_ENABLE
r_ble_hci_trans_cfg_hs((esp_hci_internal_rx_cmd_fn *)hci_transport_controller_le_tx_dummy, NULL,
r_ble_hci_trans_cfg_hs((esp_hci_internal_rx_cmd_fn *)hci_transport_controller_le_tx_dummy, NULL,
(esp_hci_internal_rx_acl_fn *)hci_transport_controller_le_tx_dummy, NULL);
#if CONFIG_BT_LE_ISO_SUPPORT
ble_iso_trans_cfg_hs((esp_hci_internal_rx_iso_fn *)hci_transport_controller_le_iso_tx_dummy, NULL);
ble_iso_trans_cfg_hs((esp_hci_internal_rx_iso_fn *)hci_transport_controller_le_iso_tx_dummy, NULL);
#endif // CONFIG_BT_LE_ISO_SUPPORT
#endif // UC_BT_CTRL_BLE_IS_ENABLE
#if UC_BT_CTRL_BR_EDR_IS_ENABLE
bredr_hci_trans_register_tx((btdm_hci_trans_tx_func_t *)hci_transport_controller_bredr_tx_dummy,
(btdm_hci_trans_tx_func_t *)hci_transport_controller_bredr_tx_dummy,
(btdm_hci_trans_tx_func_t *)hci_transport_controller_bredr_tx_dummy);
bredr_hci_trans_register_tx((btdm_hci_trans_tx_func_t *)hci_transport_controller_bredr_tx_dummy,
(btdm_hci_trans_tx_func_t *)hci_transport_controller_bredr_tx_dummy,
(btdm_hci_trans_tx_func_t *)hci_transport_controller_bredr_tx_dummy);
#endif // UC_BT_CTRL_BR_EDR_IS_ENABLE
ops = s_hci_transport_env.driver_ops;
if (ops) {
ops->hci_driver_deinit();
}
memset(&s_hci_transport_env, 0, sizeof(hci_transport_env_t));

View File

@@ -1,6 +1,8 @@
INPUT += \
$(PROJECT_PATH)/components/bt/include/$(IDF_TARGET)/include/esp_bt.h \
$(PROJECT_PATH)/components/bt/include/$(IDF_TARGET)/include/esp_bt_vs.h \
$(PROJECT_PATH)/components/bt/include/common/btdm_le_vs.h \
$(PROJECT_PATH)/components/bt/include/common/btdm_le.h \
$(PROJECT_PATH)/components/esp_phy/include/esp_phy_init.h \
$(PROJECT_PATH)/components/esp_phy/include/esp_phy_cert_test.h \
$(PROJECT_PATH)/components/esp_driver_touch_sens/hw_ver3/include/driver/touch_version_types.h \

View File

@@ -15,6 +15,9 @@ INPUT += \
$(PROJECT_PATH)/components/esp_hal_security/include/hal/key_mgr_types.h \
$(PROJECT_PATH)/components/bt/include/esp32s31/include/esp_bt.h \
$(PROJECT_PATH)/components/bt/include/esp32s31/include/esp_bt_vs.h \
$(PROJECT_PATH)/components/bt/include/common/btdm_le_vs.h \
$(PROJECT_PATH)/components/bt/include/common/btdm_le.h \
$(PROJECT_PATH)/components/bt/include/common/btdm_bredr.h \
$(PROJECT_PATH)/components/ulp/lp_core/include/lp_core_i2c.h \
$(PROJECT_PATH)/components/ulp/lp_core/include/lp_core_etm.h \
$(PROJECT_PATH)/components/ulp/lp_core/include/lp_core_uart.h \