support 727 esp32s3 BLE

This commit is contained in:
zwj 2021-03-19 14:59:30 +08:00
parent 9d093d3a04
commit facadc86d8
4 changed files with 955 additions and 549 deletions

View File

@ -65,6 +65,8 @@ config BT_CTRL_HCI_TL
default 0 if BT_CTRL_HCI_MODE_UART_H4
default 1 if BT_CTRL_HCI_M0DE_VHCI
default 1
help
HCI mode as VHCI or UART(H4)
config BT_CTRL_ADV_DUP_FILT_MAX
int "The maxinum number of 5.0 extend duplicate scan filter"
@ -75,7 +77,7 @@ config BT_CTRL_ADV_DUP_FILT_MAX
config BT_CTRL_HW_CCA
bool "HW CCA check enable"
default y
default n
help
It enables HW CCA feature in controller
@ -83,13 +85,9 @@ config BT_CTRL_HW_CCA_EFF
int
default 1 if BT_CTRL_HW_CCA
default 0
config BT_CTRL_COEX_PARAMETERS_ENABLE
bool "Allow Bluetooth preemption in the use of RF to support coexistence with Wi-Fi"
default n
help
Use pre-determined parameter set to control the use of RF by Bluetooth,s
so that Bluetooth can compete for RF with Wi-fi to support coexistence.
If other devices are sending packets in the air and the signal is strong,
the packet hw to be sent this time is cancelled.
choice BT_CTRL_CE_LENGTH_TYPE
prompt "Connection event length determination method"
@ -144,10 +142,20 @@ config BT_CTRL_RX_ANTENNA_INDEX_EFF
choice BT_CTRL_DFT_TX_POWER_LEVEL
prompt "BLE default Tx power level"
default BT_CTRL_DFT_TX_POWER_LEVEL_P9
default BT_CTRL_DFT_TX_POWER_LEVEL_P3
help
Specify default Tx power level
config BT_CTRL_DFT_TX_POWER_LEVEL_N27
bool "-27dBm"
config BT_CTRL_DFT_TX_POWER_LEVEL_N24
bool "-24dBm"
config BT_CTRL_DFT_TX_POWER_LEVEL_N21
bool "-21dBm"
config BT_CTRL_DFT_TX_POWER_LEVEL_N18
bool "-18dBm"
config BT_CTRL_DFT_TX_POWER_LEVEL_N15
bool "-15dBm"
config BT_CTRL_DFT_TX_POWER_LEVEL_N12
bool "-12dBm"
config BT_CTRL_DFT_TX_POWER_LEVEL_N9
@ -164,25 +172,164 @@ choice BT_CTRL_DFT_TX_POWER_LEVEL
bool "+6dBm"
config BT_CTRL_DFT_TX_POWER_LEVEL_P9
bool "+9dBm"
config BT_CTRL_DFT_TX_POWER_LEVEL_P12
bool "+12dBm"
config BT_CTRL_DFT_TX_POWER_LEVEL_P15
bool "+15dBm"
config BT_CTRL_DFT_TX_POWER_LEVEL_P18
bool "+18dBm"
endchoice
config BT_CTRL_DFT_TX_POWER_LEVEL_EFF
int
default 0 if BT_CTRL_DFT_TX_POWER_LEVEL_N12
default 1 if BT_CTRL_DFT_TX_POWER_LEVEL_N9
default 2 if BT_CTRL_DFT_TX_POWER_LEVEL_N6
default 3 if BT_CTRL_DFT_TX_POWER_LEVEL_N3
default 4 if BT_CTRL_DFT_TX_POWER_LEVEL_N0
default 5 if BT_CTRL_DFT_TX_POWER_LEVEL_P3
default 6 if BT_CTRL_DFT_TX_POWER_LEVEL_P6
default 7 if BT_CTRL_DFT_TX_POWER_LEVEL_P9
default 0 if BT_CTRL_DFT_TX_POWER_LEVEL_N27
default 1 if BT_CTRL_DFT_TX_POWER_LEVEL_N24
default 2 if BT_CTRL_DFT_TX_POWER_LEVEL_N21
default 3 if BT_CTRL_DFT_TX_POWER_LEVEL_N18
default 4 if BT_CTRL_DFT_TX_POWER_LEVEL_N15
default 5 if BT_CTRL_DFT_TX_POWER_LEVEL_N12
default 6 if BT_CTRL_DFT_TX_POWER_LEVEL_N9
default 7 if BT_CTRL_DFT_TX_POWER_LEVEL_N6
default 8 if BT_CTRL_DFT_TX_POWER_LEVEL_N3
default 9 if BT_CTRL_DFT_TX_POWER_LEVEL_N0
default 10 if BT_CTRL_DFT_TX_POWER_LEVEL_P3
default 11 if BT_CTRL_DFT_TX_POWER_LEVEL_P6
default 12 if BT_CTRL_DFT_TX_POWER_LEVEL_P9
default 13 if BT_CTRL_DFT_TX_POWER_LEVEL_P12
default 14 if BT_CTRL_DFT_TX_POWER_LEVEL_P15
default 15 if BT_CTRL_DFT_TX_POWER_LEVEL_P18
default 0
config BT_CTRL_COEX_USE_HOOKS
bool "Communicate Bluetooth working status with Wi-Fi to support coexistence"
config BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP
bool "BLE adv report flow control supported"
default y
help
The function is mainly used to enable flow control for advertising reports. When it is enabled,
advertising reports will be discarded by the controller if the number of unprocessed advertising
reports exceeds the size of BLE adv report flow control.
config BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM
int "BLE adv report flow control number"
depends on BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP
range 50 1000
default 100
help
The number of unprocessed advertising report that bluetooth host can save.If you set
`BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM` to a small value, this may cause adv packets lost.
If you set `BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM` to a large value, bluetooth host may cache a
lot of adv packets and this may cause system memory run out. For example, if you set
it to 50, the maximum memory consumed by host is 35 * 50 bytes. Please set
`BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM` according to your system free memory and handle adv
packets as fast as possible, otherwise it will cause adv packets lost.
config BT_CTRL_BLE_ADV_REPORT_DISCARD_THRSHOLD
int "BLE adv lost event threshold value"
depends on BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP
range 1 1000
default 20
help
When adv report flow control is enabled, The ADV lost event will be generated when the number
of ADV packets lost in the controller reaches this threshold. It is better to set a larger value.
If you set `BT_CTRL_BLE_ADV_REPORT_DISCARD_THRSHOLD` to a small value or printf every adv lost event, it
may cause adv packets lost more.
config BT_CTRL_BLE_SCAN_DUPL
bool "BLE Scan Duplicate Options"
default y
help
This select enables parameters setting of BLE scan duplicate.
choice BT_CTRL_SCAN_DUPL_TYPE
prompt "Scan Duplicate Type"
default BT_CTRL_SCAN_DUPL_TYPE_DEVICE
depends on BT_CTRL_BLE_SCAN_DUPL
help
Scan duplicate have three ways. one is "Scan Duplicate By Device Address", This way is to use
advertiser address filtering. The adv packet of the same address is only allowed to be reported once.
Another way is "Scan Duplicate By Device Address And Advertising Data". This way is to use advertising
data and device address filtering. All different adv packets with the same address are allowed to be
reported. The last way is "Scan Duplicate By Advertising Data". This way is to use advertising data
filtering. All same advertising data only allow to be reported once even though they are from
different devices.
config BT_CTRL_SCAN_DUPL_TYPE_DEVICE
bool "Scan Duplicate By Device Address"
help
This way is to use advertiser address filtering. The adv packet of the same address is only
allowed to be reported once
config BT_CTRL_SCAN_DUPL_TYPE_DATA
bool "Scan Duplicate By Advertising Data"
help
This way is to use advertising data filtering. All same advertising data only allow to be reported
once even though they are from different devices.
config BT_CTRL_SCAN_DUPL_TYPE_DATA_DEVICE
bool "Scan Duplicate By Device Address And Advertising Data"
help
This way is to use advertising data and device address filtering. All different adv packets with
the same address are allowed to be reported.
endchoice
config BT_CTRL_SCAN_DUPL_TYPE
int
depends on BT_CTRL_BLE_SCAN_DUPL
default 0 if BT_CTRL_SCAN_DUPL_TYPE_DEVICE
default 1 if BT_CTRL_SCAN_DUPL_TYPE_DATA
default 2 if BT_CTRL_SCAN_DUPL_TYPE_DATA_DEVICE
default 0
config BT_CTRL_SCAN_DUPL_CACHE_SIZE
int "Maximum number of devices in scan duplicate filter"
depends on BT_CTRL_BLE_SCAN_DUPL
range 10 1000
default 100
help
Maximum number of devices which can be recorded in scan duplicate filter.
When the maximum amount of device in the filter is reached, the cache will be refreshed.
config BT_CTRL_BLE_MESH_SCAN_DUPL_EN
bool "Special duplicate scan mechanism for BLE Mesh scan"
depends on BT_CTRL_BLE_SCAN_DUPL
default n
help
Send notifications of Bluetooth working status to support coexistence with Wi-Fi.
This enables the BLE scan duplicate for special BLE Mesh scan.
config BT_CTRL_MESH_DUPL_SCAN_CACHE_SIZE
int "Maximum number of Mesh adv packets in scan duplicate filter"
depends on BT_CTRL_BLE_MESH_SCAN_DUPL_EN
range 10 1000
default 100
help
Maximum number of adv packets which can be recorded in duplicate scan cache for BLE Mesh.
When the maximum amount of device in the filter is reached, the cache will be refreshed.
choice BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM
prompt "Coexistence: limit on MAX Tx/Rx time for coded-PHY connection"
default BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_DIS
depends on ESP32_WIFI_SW_COEXIST_ENABLE
help
When using PHY-Coded in BLE connection, limitation on max tx/rx time can be applied to
better avoid dramatic performance deterioration of Wi-Fi.
config BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_EN
bool "Force Enable"
help
Always enable the limitation on max tx/rx time for Coded-PHY connection
config BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_DIS
bool "Force Disable"
help
Disable the limitation on max tx/rx time for Coded-PHY connection
endchoice
config BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_EFF
int
default 0 if (!ESP32_WIFI_SW_COEXIST_ENABLE)
default 1 if BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_EN
default 0 if BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_DIS
menu "MODEM SLEEP Options"
visible if BT_ENABLED
@ -217,8 +364,22 @@ menu "MODEM SLEEP Options"
selected, bluetooth modem sleep can work under Dynamic Frequency Scaling(DFS) enabled, but
cannot work when light sleep is enabled. Main crystal has a relatively better performance than
other bluetooth low power clock sources.
endchoice
config BT_CTRL_LPCLK_SEL_EXT_32K_XTAL
bool "External 32kHz crystal"
depends on ESP32S3_RTC_CLK_SRC_EXT_CRYS
help
External 32kHz crystal has a nominal frequency of 32.768kHz and provides good frequency
stability. If used as Bluetooth low power clock, External 32kHz can support Bluetooth
modem sleep to be used with both DFS and light sleep.
config BT_CTRL_LPCLK_SEL_RTC_SLOW
bool "Internal 90kHz RC oscillator"
depends on ESP32S3_RTC_CLK_SRC_INT_RC
help
Internal 90kHz RC oscillator.
endchoice
endmenu
config BT_CTRL_SLEEP_MODE_EFF
@ -229,6 +390,8 @@ config BT_CTRL_SLEEP_MODE_EFF
config BT_CTRL_SLEEP_CLOCK_EFF
int
default 1 if BT_CTRL_LPCLK_SEL_MAIN_XTAL
default 2 if BT_CTRL_LPCLK_SEL_EXT_32K_XTAL
default 3 if BT_CTRL_LPCLK_SEL_RTC_SLOW
default 0

File diff suppressed because it is too large Load Diff

@ -1 +1 @@
Subproject commit 2b7816260ecd12710b983b7c859d42fce4f7d979
Subproject commit a7d76980fe7687053bebaa145095e4e3584f6150

View File

@ -25,8 +25,8 @@
extern "C" {
#endif
#define ESP_BT_CTRL_CONFIG_MAGIC_VAL 0x5A5AA5A5
#define ESP_BT_CTRL_CONFIG_VERSION 0x02004260
#define ESP_BT_CTRL_CONFIG_MAGIC_VAL 0x5A5AA5A5
#define ESP_BT_CTRL_CONFIG_VERSION 0x02103080
#define ESP_BT_HCI_TL_MAGIC_VALUE 0xfadebead
#define ESP_BT_HCI_TL_VERSION 0x00010000
@ -73,7 +73,8 @@ typedef enum {
ESP_BT_SLEEP_CLOCK_NONE = 0, /*!< Sleep clock not configured */
ESP_BT_SLEEP_CLOCK_MAIN_XTAL = 1, /*!< SoC main crystal */
ESP_BT_SLEEP_CLOCK_EXT_32K_XTAL = 2, /*!< External 32.768kHz crystal */
ESP_BT_SLEEP_CLOCK_FPGA_32K = 3, /*!< Hardwired 32KHz clock temporarily used for FPGA */
ESP_BT_SLEEP_CLOCK_RTC_SLOW = 3, /*!< Internal 90kHz RC oscillator */
ESP_BT_SLEEP_CLOCK_FPGA_32K = 4, /*!< Hardwired 32KHz clock temporarily used for FPGA */
} esp_bt_sleep_clock_t;
/**
@ -84,22 +85,55 @@ enum {
ESP_BT_ANT_IDX_1 = 1, /*!< anntena NO 1 */
};
/**
* @brief Maximum Tx/Rx time limit on Coded-PHY connection
*/
enum {
ESP_BT_COEX_PHY_CODED_TX_RX_TIME_LIMIT_FORCE_DISABLE = 0, /*!< Disable the limit */
ESP_BT_COEX_PHY_CODED_TX_RX_TIME_LIMIT_FORCE_ENABLE, /*!< Always Enable the limit */
};
#ifdef CONFIG_BT_ENABLED
#ifdef CONFIG_BT_CTRL_COEX_PARAMETERS_ENABLE
#define BT_CTRL_COEX_PARAMETERS_ENABLE true
#else
#define BT_CTRL_COEX_PARAMETERS_ENABLE false
#endif
#ifdef CONFIG_BT_CTRL_COEX_USE_HOOKS
#define BT_CTRL_COEX_USE_HOOKS true
#else
#define BT_CTRL_COEX_USE_HOOKS false
#endif
#define BT_CTRL_BLE_MAX_ACT_LIMIT 10 //Maximum BLE activity limitation
#ifdef CONFIG_BT_CTRL_SCAN_DUPL_TYPE
#define SCAN_DUPLICATE_TYPE_VALUE CONFIG_BT_CTRL_SCAN_DUPL_TYPE
#else
#define SCAN_DUPLICATE_TYPE_VALUE 0
#endif
/* normal adv cache size */
#ifdef CONFIG_BT_CTRL_SCAN_DUPL_CACHE_SIZE
#define NORMAL_SCAN_DUPLICATE_CACHE_SIZE CONFIG_BT_CTRL_SCAN_DUPL_CACHE_SIZE
#else
#define NORMAL_SCAN_DUPLICATE_CACHE_SIZE 20
#endif
#ifndef CONFIG_BT_CTRL_BLE_MESH_SCAN_DUPL_EN
#define CONFIG_BT_CTRL_BLE_MESH_SCAN_DUPL_EN FALSE
#endif
#define SCAN_DUPLICATE_MODE_NORMAL_ADV_ONLY 0
#define SCAN_DUPLICATE_MODE_NORMAL_ADV_MESH_ADV 1
#if CONFIG_BT_CTRL_BLE_MESH_SCAN_DUPL_EN
#define SCAN_DUPLICATE_MODE SCAN_DUPLICATE_MODE_NORMAL_ADV_MESH_ADV
#ifdef CONFIG_BT_CTRL_MESH_DUPL_SCAN_CACHE_SIZE
#define MESH_DUPLICATE_SCAN_CACHE_SIZE CONFIG_BT_CTRL_MESH_DUPL_SCAN_CACHE_SIZE
#else
#define MESH_DUPLICATE_SCAN_CACHE_SIZE 50
#endif
#else
#define SCAN_DUPLICATE_MODE SCAN_DUPLICATE_MODE_NORMAL_ADV_ONLY
#define MESH_DUPLICATE_SCAN_CACHE_SIZE 0
#endif
#define CFG_MASK_BIT_SCAN_DUPLICATE_OPTION (1<<0)
#define CFG_MASK CFG_MASK_BIT_SCAN_DUPLICATE_OPTION
#define BLE_HW_TARGET_CODE_ESP32S3_CHIP_ECO0 (0x02010000)
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() { \
.magic = ESP_BT_CTRL_CONFIG_MAGIC_VAL, \
@ -114,17 +148,21 @@ enum {
.ble_st_acl_tx_buf_nb = CONFIG_BT_CTRL_BLE_STATIC_ACL_TX_BUF_NB, \
.ble_hw_cca_check = CONFIG_BT_CTRL_HW_CCA_EFF, \
.ble_adv_dup_filt_max = CONFIG_BT_CTRL_ADV_DUP_FILT_MAX, \
.coex_param_en = BT_CTRL_COEX_PARAMETERS_ENABLE, \
.ce_len_type = CONFIG_BT_CTRL_CE_LENGTH_TYPE_EFF, \
.coex_use_hooks = BT_CTRL_COEX_USE_HOOKS, \
.hci_tl_type = CONFIG_BT_CTRL_HCI_TL_EFF, \
.hci_tl_funcs = NULL, \
.txant_dft = CONFIG_BT_CTRL_TX_ANTENNA_INDEX_EFF, \
.rxant_dft = CONFIG_BT_CTRL_RX_ANTENNA_INDEX_EFF, \
.txpwr_dft = CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_EFF, \
.cfg_mask = CFG_MASK, \
.scan_duplicate_mode = SCAN_DUPLICATE_MODE, \
.scan_duplicate_type = SCAN_DUPLICATE_TYPE_VALUE, \
.normal_adv_size = NORMAL_SCAN_DUPLICATE_CACHE_SIZE, \
.mesh_adv_size = MESH_DUPLICATE_SCAN_CACHE_SIZE, \
.coex_phy_coded_tx_rx_time_limit = CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_EFF, \
.hw_target_code = BLE_HW_TARGET_CODE_ESP32S3_CHIP_ECO0, \
};
#else
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() {0}; _Static_assert(0, "please enable bluetooth in menuconfig to use bt.h");
#endif
@ -172,14 +210,21 @@ typedef struct {
uint8_t ble_st_acl_tx_buf_nb; /*!< controller static ACL TX BUFFER number */
uint8_t ble_hw_cca_check; /*!< controller hardware triggered CCA check */
uint16_t ble_adv_dup_filt_max; /*!< maxinum number of duplicate scan filter */
bool coex_param_en; /*!< init coex parameters*/
bool coex_param_en; /*!< deprecated */
uint8_t ce_len_type; /*!< connection event length computation method */
bool coex_use_hooks; /*!< use hooks in bluetooth to assist WiFi behavouir determination */
bool coex_use_hooks; /*!< deprecated */
uint8_t hci_tl_type; /*!< HCI transport layer, UART, VHCI, etc */
esp_bt_hci_tl_t *hci_tl_funcs; /*!< hci transport functions used, must be set when hci_tl_type is UART */
uint8_t txant_dft; /*!< default Tx antenna */
uint8_t rxant_dft; /*!< default Rx antenna */
uint8_t txpwr_dft; /*!< default Tx power */
uint32_t cfg_mask;
uint8_t scan_duplicate_mode; /*!< scan duplicate mode */
uint8_t scan_duplicate_type; /*!< scan duplicate type */
uint16_t normal_adv_size; /*!< Normal adv size for scan duplicate */
uint16_t mesh_adv_size; /*!< Mesh adv size for scan duplicate */
uint8_t coex_phy_coded_tx_rx_time_limit; /*!< limit on max tx/rx time in case of connection using CODED-PHY with Wi-Fi coexistence */
uint32_t hw_target_code; /*!< hardware target */
} esp_bt_controller_config_t;
/**
@ -222,14 +267,23 @@ typedef enum {
* @brief Bluetooth TX power level(index), it's just a index corresponding to power(dbm).
*/
typedef enum {
ESP_PWR_LVL_N12 = 0, /*!< Corresponding to -12dbm */
ESP_PWR_LVL_N9 = 1, /*!< Corresponding to -9dbm */
ESP_PWR_LVL_N6 = 2, /*!< Corresponding to -6dbm */
ESP_PWR_LVL_N3 = 3, /*!< Corresponding to -3dbm */
ESP_PWR_LVL_N0 = 4, /*!< Corresponding to 0dbm */
ESP_PWR_LVL_P3 = 5, /*!< Corresponding to +3dbm */
ESP_PWR_LVL_P6 = 6, /*!< Corresponding to +6dbm */
ESP_PWR_LVL_P9 = 7, /*!< Corresponding to +9dbm */
ESP_PWR_LVL_N27 = 0, /*!< Corresponding to -27dbm */
ESP_PWR_LVL_N24 = 1, /*!< Corresponding to -24dbm */
ESP_PWR_LVL_N21 = 2, /*!< Corresponding to -21dbm */
ESP_PWR_LVL_N18 = 3, /*!< Corresponding to -18dbm */
ESP_PWR_LVL_N15 = 4, /*!< Corresponding to -15dbm */
ESP_PWR_LVL_N12 = 5, /*!< Corresponding to -12dbm */
ESP_PWR_LVL_N9 = 6, /*!< Corresponding to -9dbm */
ESP_PWR_LVL_N6 = 7, /*!< Corresponding to -6dbm */
ESP_PWR_LVL_N3 = 8, /*!< Corresponding to -3dbm */
ESP_PWR_LVL_N0 = 9, /*!< Corresponding to 0dbm */
ESP_PWR_LVL_P3 = 10, /*!< Corresponding to +3dbm */
ESP_PWR_LVL_P6 = 11, /*!< Corresponding to +6dbm */
ESP_PWR_LVL_P9 = 12, /*!< Corresponding to +9dbm */
ESP_PWR_LVL_P12 = 13, /*!< Corresponding to +12dbm */
ESP_PWR_LVL_P15 = 14, /*!< Corresponding to +15dbm */
ESP_PWR_LVL_P18 = 15, /*!< Corresponding to +18dbm */
ESP_PWR_LVL_INVALID = 0xFF, /*!< Indicates an invalid value */
} esp_power_level_t;
/**