diff options
| author | jacqueline <me@jacqueline.id.au> | 2025-07-25 13:33:07 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2025-07-25 13:33:07 +1000 |
| commit | c8e79a926620e48830778714cfe4b2ea2453fcaf (patch) | |
| tree | 8c756e08e01b8e147cf72bec128026f46bd854c5 /lib/bt/include/esp32c2 | |
| parent | 237136f3e93cb6b5be24670d7520adb17cc0fa36 (diff) | |
| download | tangara-fw-c8e79a926620e48830778714cfe4b2ea2453fcaf.tar.gz | |
Update forked idf components
Diffstat (limited to 'lib/bt/include/esp32c2')
| -rw-r--r-- | lib/bt/include/esp32c2/include/esp_bt.h | 69 | ||||
| -rw-r--r-- | lib/bt/include/esp32c2/include/esp_bt_vs.h | 214 |
2 files changed, 254 insertions, 29 deletions
diff --git a/lib/bt/include/esp32c2/include/esp_bt.h b/lib/bt/include/esp32c2/include/esp_bt.h index ee1bede7..de161b08 100644 --- a/lib/bt/include/esp32c2/include/esp_bt.h +++ b/lib/bt/include/esp32c2/include/esp_bt.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -16,6 +16,7 @@ #include "nimble/nimble_npl.h" #include "../../../../controller/esp32c2/esp_bt_cfg.h" #include "hal/efuse_hal.h" +#include "esp_private/esp_modem_clock.h" #ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART #include "driver/uart.h" @@ -72,26 +73,26 @@ typedef enum { } esp_ble_power_type_t; /** - * @brief Bluetooth TX power level(index), it's just a index corresponding to power(dbm). + * @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_P18 = 14, /*!< Corresponding to +18dbm */ - ESP_PWR_LVL_P20 = 15, /*!< Corresponding to +20dbm */ - ESP_PWR_LVL_P21 = 15, /*!< Corresponding to +20dbm, this enum variable has been deprecated */ + ESP_PWR_LVL_N24 = 0, /*!< Corresponding to -24 dBm */ + ESP_PWR_LVL_N21 = 1, /*!< Corresponding to -21 dBm */ + ESP_PWR_LVL_N18 = 2, /*!< Corresponding to -18 dBm */ + ESP_PWR_LVL_N15 = 3, /*!< Corresponding to -15 dBm */ + ESP_PWR_LVL_N12 = 4, /*!< Corresponding to -12 dBm */ + ESP_PWR_LVL_N9 = 5, /*!< Corresponding to -9 dBm */ + ESP_PWR_LVL_N6 = 6, /*!< Corresponding to -6 dBm */ + ESP_PWR_LVL_N3 = 7, /*!< Corresponding to -3 dBm */ + ESP_PWR_LVL_N0 = 8, /*!< Corresponding to 0 dBm */ + ESP_PWR_LVL_P3 = 9, /*!< Corresponding to +3 dBm */ + ESP_PWR_LVL_P6 = 10, /*!< Corresponding to +6 dBm */ + ESP_PWR_LVL_P9 = 11, /*!< Corresponding to +9 dBm */ + ESP_PWR_LVL_P12 = 12, /*!< Corresponding to +12 dBm */ + ESP_PWR_LVL_P15 = 13, /*!< Corresponding to +15 dBm */ + ESP_PWR_LVL_P18 = 14, /*!< Corresponding to +18 dBm */ + ESP_PWR_LVL_P20 = 15, /*!< Corresponding to +20 dBm */ + ESP_PWR_LVL_P21 = 15, /*!< Corresponding to +20 dBm, this enum variable has been deprecated */ ESP_PWR_LVL_INVALID = 0xFF, /*!< Indicates an invalid value */ } esp_power_level_t; @@ -127,7 +128,7 @@ typedef struct { * @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) + * @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); @@ -145,7 +146,7 @@ esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type); * 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) + * @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); @@ -166,7 +167,7 @@ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t po */ uint8_t esp_ble_get_chip_rev_version(void); -#define CONFIG_VERSION 0x20231124 +#define CONFIG_VERSION 0x20250310 #define CONFIG_MAGIC 0x5A5AA5A5 /** @@ -226,6 +227,11 @@ typedef struct { uint8_t version_num; /*!< Version number */ uint8_t ignore_wl_for_direct_adv; /*!< Ignore the white list for directed advertising */ uint8_t csa2_select; /*!< Select CSA#2 */ + 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 vhci_enabled; /*!< VHCI mode is enabled */ uint32_t config_magic; /*!< Configuration magic value */ } esp_bt_controller_config_t; @@ -262,13 +268,6 @@ typedef struct { .controller_run_cpu = 0, \ .enable_qa_test = RUN_QA_TEST, \ .enable_bqb_test = RUN_BQB_TEST, \ - .enable_uart_hci = HCI_UART_EN, \ - .ble_hci_uart_port = DEFAULT_BT_LE_HCI_UART_PORT, \ - .ble_hci_uart_baud = DEFAULT_BT_LE_HCI_UART_BAUD, \ - .ble_hci_uart_data_bits = DEFAULT_BT_LE_HCI_UART_DATA_BITS, \ - .ble_hci_uart_stop_bits = DEFAULT_BT_LE_HCI_UART_STOP_BITS, \ - .ble_hci_uart_flow_ctrl = DEFAULT_BT_LE_HCI_UART_FLOW_CTRL, \ - .ble_hci_uart_uart_parity = DEFAULT_BT_LE_HCI_UART_PARITY, \ .enable_tx_cca = DEFAULT_BT_LE_TX_CCA_ENABLED, \ .cca_rssi_thresh = 256 - DEFAULT_BT_LE_CCA_RSSI_THRESH, \ .sleep_en = NIMBLE_SLEEP_ENABLE, \ @@ -279,6 +278,10 @@ typedef struct { .version_num = esp_ble_get_chip_rev_version(), \ .ignore_wl_for_direct_adv = 0, \ .csa2_select = DEFAULT_BT_LE_50_FEATURE_SUPPORT, \ + .ble_aa_check = DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS, \ + .ble_llcp_disc_flag = BT_LE_CTRL_LLCP_DISC_FLAG, \ + .scan_backoff_upperlimitmax = BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX, \ + .vhci_enabled = DEFAULT_BT_LE_VHCI_ENABLED, \ .config_magic = CONFIG_MAGIC, \ } @@ -435,6 +438,14 @@ extern int esp_ble_hw_get_static_addr(esp_ble_addr_t *addr); void esp_ble_controller_log_dump_all(bool output); #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED +modem_clock_lpclk_src_t esp_bt_get_lpclk_src(void); + +void esp_bt_set_lpclk_src(modem_clock_lpclk_src_t clk_src); + +uint32_t esp_bt_get_lpclk_freq(void); + +void esp_bt_set_lpclk_freq(uint32_t clk_freq); + #ifdef __cplusplus } #endif diff --git a/lib/bt/include/esp32c2/include/esp_bt_vs.h b/lib/bt/include/esp32c2/include/esp_bt_vs.h new file mode 100644 index 00000000..1010073b --- /dev/null +++ b/lib/bt/include/esp32c2/include/esp_bt_vs.h @@ -0,0 +1,214 @@ +/* + * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#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 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 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 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 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_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_GET_BACKOFF_UPLIMIT_SUBCMD (0X2d) + #define ESP_BT_VS_CFG_TEST_GET_RXED_ADV_ADI_SUBCMD (0X2f) + #define ESP_BT_VS_CFG_TEST_SET_RX_SENS_THRESH_SUBCMD (0X31) + #define ESP_BT_VS_CFG_TEST_SET_AGC_MAX_GAIN_SUBCMD (0X39) + #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. +// + + +#ifdef __cplusplus +} +#endif |
