mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge ESP32C3 and ESP32S3 BLE bt.c files to one
This commit is contained in:
parent
d013bedbbe
commit
a5e43a7d43
@ -14,8 +14,8 @@ if(CONFIG_BT_ENABLED)
|
||||
list(APPEND include_dirs include/esp32c3/include)
|
||||
|
||||
elseif(CONFIG_IDF_TARGET_ESP32S3)
|
||||
list(APPEND srcs "controller/esp32s3/bt.c")
|
||||
list(APPEND include_dirs include/esp32s3/include)
|
||||
list(APPEND srcs "controller/esp32c3/bt.c")
|
||||
list(APPEND include_dirs include/esp32c3/include)
|
||||
|
||||
elseif(CONFIG_IDF_TARGET_ESP32H4)
|
||||
list(APPEND srcs "controller/esp32h4/bt.c")
|
||||
|
@ -24,8 +24,24 @@ config BT_CTRL_BLE_STATIC_ACL_TX_BUF_NB
|
||||
(alloate when controller initialise, never free until controller de-initialise)
|
||||
another is dynamically allocating (allocate before TX and free after TX).
|
||||
|
||||
choice BT_CTRL_PINNED_TO_CORE_CHOICE
|
||||
prompt "The cpu core which bluetooth controller run"
|
||||
depends on !FREERTOS_UNICORE
|
||||
help
|
||||
Specify the cpu core to run bluetooth controller.
|
||||
Can not specify no-affinity.
|
||||
|
||||
config BT_CTRL_PINNED_TO_CORE_0
|
||||
bool "Core 0 (PRO CPU)"
|
||||
config BT_CTRL_PINNED_TO_CORE_1
|
||||
bool "Core 1 (APP CPU)"
|
||||
depends on !FREERTOS_UNICORE
|
||||
endchoice
|
||||
|
||||
config BT_CTRL_PINNED_TO_CORE
|
||||
int
|
||||
default 0 if BT_CTRL_PINNED_TO_CORE_0
|
||||
default 1 if BT_CTRL_PINNED_TO_CORE_1
|
||||
default 0
|
||||
|
||||
choice BT_CTRL_HCI_MODE_CHOICE
|
||||
@ -36,7 +52,7 @@ choice BT_CTRL_HCI_MODE_CHOICE
|
||||
config BT_CTRL_HCI_MODE_VHCI
|
||||
bool "VHCI"
|
||||
help
|
||||
Normal option. Mostly, choose this VHCI when bluetooth host run on ESP32C3, too.
|
||||
Normal option. Mostly, choose this VHCI when bluetooth host run on ESP32S3 or ESP32C3.
|
||||
|
||||
config BT_CTRL_HCI_MODE_UART_H4
|
||||
bool "UART(H4)"
|
||||
@ -395,7 +411,6 @@ menu "MODEM SLEEP Options"
|
||||
selects an external 32kHz crystal but the external 32kHz crystal does not exist or the low power clock
|
||||
selects the main crystal.
|
||||
|
||||
|
||||
endmenu
|
||||
|
||||
config BT_CTRL_SLEEP_MODE_EFF
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "esp_mac.h"
|
||||
#include "esp_random.h"
|
||||
#include "esp_task.h"
|
||||
#include "riscv/interrupt.h"
|
||||
#include "esp_attr.h"
|
||||
#include "esp_phy_init.h"
|
||||
#include "esp_bt.h"
|
||||
@ -35,18 +34,25 @@
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
#include "soc/soc_memory_layout.h"
|
||||
#include "esp_coexist_internal.h"
|
||||
#include "esp32c3/rom/rom_layout.h"
|
||||
#include "esp_timer.h"
|
||||
#include "esp_sleep.h"
|
||||
#include "esp_rom_sys.h"
|
||||
#include "esp_private/phy.h"
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "riscv/interrupt.h"
|
||||
#include "esp32c3/rom/rom_layout.h"
|
||||
#else //CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "freertos/xtensa_api.h"
|
||||
#include "xtensa/core-macros.h"
|
||||
#include "esp32s3/rom/rom_layout.h"
|
||||
#endif
|
||||
#if CONFIG_BT_ENABLED
|
||||
|
||||
/* Macro definition
|
||||
************************************************************************
|
||||
*/
|
||||
|
||||
#define BTDM_LOG_TAG "BTDM_INIT"
|
||||
#define BT_LOG_TAG "BLE_INIT"
|
||||
|
||||
#define BTDM_INIT_PERIOD (5000) /* ms */
|
||||
|
||||
@ -126,12 +132,10 @@ typedef struct vhci_host_callback {
|
||||
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*/
|
||||
} vhci_host_callback_t;
|
||||
|
||||
/* Dram region */
|
||||
typedef struct {
|
||||
esp_bt_mode_t mode;
|
||||
intptr_t start;
|
||||
intptr_t end;
|
||||
} btdm_dram_available_region_t;
|
||||
void *handle;
|
||||
void *storage;
|
||||
} btdm_queue_item_t;
|
||||
|
||||
typedef void (* osi_intr_handler)(void);
|
||||
|
||||
@ -207,7 +211,6 @@ extern void btdm_controller_disable(void);
|
||||
extern uint8_t btdm_controller_get_mode(void);
|
||||
extern const char *btdm_controller_get_compile_version(void);
|
||||
extern void btdm_rf_bb_init_phase2(void); // shall be called after PHY/RF is enabled
|
||||
|
||||
/* Sleep */
|
||||
extern void btdm_controller_enable_sleep(bool enable);
|
||||
extern uint8_t btdm_controller_get_sleep_mode(void);
|
||||
@ -261,7 +264,6 @@ extern uint32_t _btdm_data_end;
|
||||
extern uint32_t _nimble_data_start;
|
||||
extern uint32_t _nimble_data_end;
|
||||
|
||||
|
||||
/* Local Function Declare
|
||||
*********************************************************************
|
||||
*/
|
||||
@ -403,10 +405,11 @@ static DRAM_ATTR esp_pm_lock_handle_t s_light_sleep_pm_lock;
|
||||
void IRAM_ATTR btdm_hw_mac_power_down_wrapper(void)
|
||||
{
|
||||
#if CONFIG_MAC_BB_PD
|
||||
#if CONFIG_IDF_TARGET_ESP32C3
|
||||
// Bluetooth module power down
|
||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_BT_FORCE_ISO);
|
||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_PWC_REG, RTC_CNTL_BT_FORCE_PD);
|
||||
|
||||
#endif
|
||||
esp_mac_bb_power_down();
|
||||
#endif
|
||||
}
|
||||
@ -414,30 +417,15 @@ void IRAM_ATTR btdm_hw_mac_power_down_wrapper(void)
|
||||
void IRAM_ATTR btdm_hw_mac_power_up_wrapper(void)
|
||||
{
|
||||
#if CONFIG_MAC_BB_PD
|
||||
#if CONFIG_IDF_TARGET_ESP32C3
|
||||
// Bluetooth module power up
|
||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_PWC_REG, RTC_CNTL_BT_FORCE_PD);
|
||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_BT_FORCE_ISO);
|
||||
|
||||
#endif
|
||||
esp_mac_bb_power_up();
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void esp_bt_power_domain_on(void)
|
||||
{
|
||||
// Bluetooth module power up
|
||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_PWC_REG, RTC_CNTL_BT_FORCE_PD);
|
||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_BT_FORCE_ISO);
|
||||
esp_wifi_bt_power_domain_on();
|
||||
}
|
||||
|
||||
static inline void esp_bt_power_domain_off(void)
|
||||
{
|
||||
// Bluetooth module power down
|
||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_BT_FORCE_ISO);
|
||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_PWC_REG, RTC_CNTL_BT_FORCE_PD);
|
||||
esp_wifi_bt_power_domain_off();
|
||||
}
|
||||
|
||||
void IRAM_ATTR btdm_backup_dma_copy_wrapper(uint32_t reg, uint32_t mem_addr, uint32_t num, bool to_mem)
|
||||
{
|
||||
#if CONFIG_MAC_BB_PD
|
||||
@ -445,12 +433,34 @@ void IRAM_ATTR btdm_backup_dma_copy_wrapper(uint32_t reg, uint32_t mem_addr, uin
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void esp_bt_power_domain_on(void)
|
||||
{
|
||||
// Bluetooth module power up
|
||||
#if CONFIG_IDF_TARGET_ESP32C3
|
||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_PWC_REG, RTC_CNTL_BT_FORCE_PD);
|
||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_BT_FORCE_ISO);
|
||||
#endif
|
||||
esp_wifi_bt_power_domain_on();
|
||||
}
|
||||
|
||||
static inline void esp_bt_power_domain_off(void)
|
||||
{
|
||||
// Bluetooth module power down
|
||||
#if CONFIG_IDF_TARGET_ESP32C3
|
||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_BT_FORCE_ISO);
|
||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_PWC_REG, RTC_CNTL_BT_FORCE_PD);
|
||||
#endif
|
||||
esp_wifi_bt_power_domain_off();
|
||||
}
|
||||
|
||||
static void interrupt_set_wrapper(int cpu_no, int intr_source, int intr_num, int intr_prio)
|
||||
{
|
||||
intr_matrix_route(intr_source, intr_num);
|
||||
esp_rom_route_intr_matrix(cpu_no, intr_source, intr_num);
|
||||
#if __riscv
|
||||
esprv_intc_int_set_priority(intr_num, intr_prio);
|
||||
//esprv_intc_int_enable_level(1 << intr_num);
|
||||
esprv_intc_int_set_type(intr_num, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void interrupt_clear_wrapper(int intr_source, int intr_num)
|
||||
@ -459,17 +469,17 @@ static void interrupt_clear_wrapper(int intr_source, int intr_num)
|
||||
|
||||
static void interrupt_handler_set_wrapper(int n, intr_handler_t fn, void *arg)
|
||||
{
|
||||
intr_handler_set(n, fn, arg);
|
||||
esp_cpu_intr_set_handler(n, fn, arg);
|
||||
}
|
||||
|
||||
static void interrupt_on_wrapper(int intr_num)
|
||||
{
|
||||
esprv_intc_int_enable(1 << intr_num);
|
||||
esp_cpu_intr_enable(1 << intr_num);
|
||||
}
|
||||
|
||||
static void interrupt_off_wrapper(int intr_num)
|
||||
{
|
||||
esprv_intc_int_disable(1<<intr_num);
|
||||
esp_cpu_intr_disable(1<<intr_num);
|
||||
}
|
||||
|
||||
static void IRAM_ATTR interrupt_disable(void)
|
||||
@ -497,36 +507,64 @@ static void IRAM_ATTR task_yield_from_isr(void)
|
||||
|
||||
static void *semphr_create_wrapper(uint32_t max, uint32_t init)
|
||||
{
|
||||
return (void *)xSemaphoreCreateCounting(max, init);
|
||||
btdm_queue_item_t *semphr = heap_caps_calloc(1, sizeof(btdm_queue_item_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
|
||||
assert(semphr);
|
||||
|
||||
#if !CONFIG_SPIRAM_USE_MALLOC
|
||||
semphr->handle = (void *)xSemaphoreCreateCounting(max, init);
|
||||
#else
|
||||
|
||||
semphr->storage = heap_caps_malloc(sizeof(StaticQueue_t), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
assert(semphr->storage);
|
||||
|
||||
semphr->handle = (void *)xSemaphoreCreateCountingStatic(max, init, semphr->storage);
|
||||
#endif
|
||||
assert(semphr->handle);
|
||||
return semphr;
|
||||
}
|
||||
|
||||
static void semphr_delete_wrapper(void *semphr)
|
||||
{
|
||||
vSemaphoreDelete(semphr);
|
||||
if (semphr == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
btdm_queue_item_t *semphr_item = (btdm_queue_item_t *)semphr;
|
||||
|
||||
if (semphr_item->handle) {
|
||||
vSemaphoreDelete(semphr_item->handle);
|
||||
}
|
||||
#ifdef CONFIG_SPIRAM_USE_MALLOC
|
||||
if (semphr_item->storage) {
|
||||
free(semphr_item->storage);
|
||||
}
|
||||
#endif
|
||||
|
||||
free(semphr);
|
||||
}
|
||||
|
||||
static int IRAM_ATTR semphr_take_from_isr_wrapper(void *semphr, void *hptw)
|
||||
{
|
||||
return (int)xSemaphoreTakeFromISR(semphr, hptw);
|
||||
return (int)xSemaphoreTakeFromISR(((btdm_queue_item_t *)semphr)->handle, hptw);
|
||||
}
|
||||
|
||||
static int IRAM_ATTR semphr_give_from_isr_wrapper(void *semphr, void *hptw)
|
||||
{
|
||||
return (int)xSemaphoreGiveFromISR(semphr, hptw);
|
||||
return (int)xSemaphoreGiveFromISR(((btdm_queue_item_t *)semphr)->handle, hptw);
|
||||
}
|
||||
|
||||
static int semphr_take_wrapper(void *semphr, uint32_t block_time_ms)
|
||||
{
|
||||
if (block_time_ms == OSI_FUNCS_TIME_BLOCKING) {
|
||||
return (int)xSemaphoreTake(semphr, portMAX_DELAY);
|
||||
return (int)xSemaphoreTake(((btdm_queue_item_t *)semphr)->handle, portMAX_DELAY);
|
||||
} else {
|
||||
return (int)xSemaphoreTake(semphr, block_time_ms / portTICK_PERIOD_MS);
|
||||
return (int)xSemaphoreTake(((btdm_queue_item_t *)semphr)->handle, block_time_ms / portTICK_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
|
||||
static int semphr_give_wrapper(void *semphr)
|
||||
{
|
||||
return (int)xSemaphoreGive(semphr);
|
||||
return (int)xSemaphoreGive(((btdm_queue_item_t *)semphr)->handle);
|
||||
}
|
||||
|
||||
static void *mutex_create_wrapper(void)
|
||||
@ -551,40 +589,71 @@ static int mutex_unlock_wrapper(void *mutex)
|
||||
|
||||
static void *queue_create_wrapper(uint32_t queue_len, uint32_t item_size)
|
||||
{
|
||||
return (void *)xQueueCreate(queue_len, item_size);
|
||||
btdm_queue_item_t *queue = NULL;
|
||||
|
||||
queue = (btdm_queue_item_t*)heap_caps_malloc(sizeof(btdm_queue_item_t), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
assert(queue);
|
||||
|
||||
#if CONFIG_SPIRAM_USE_MALLOC
|
||||
|
||||
queue->storage = heap_caps_calloc(1, sizeof(StaticQueue_t) + (queue_len*item_size), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
assert(queue->storage);
|
||||
|
||||
queue->handle = xQueueCreateStatic( queue_len, item_size, ((uint8_t*)(queue->storage)) + sizeof(StaticQueue_t), (StaticQueue_t*)(queue->storage));
|
||||
assert(queue->handle);
|
||||
|
||||
#else
|
||||
queue->handle = xQueueCreate( queue_len, item_size);
|
||||
assert(queue->handle);
|
||||
#endif
|
||||
|
||||
return queue;
|
||||
}
|
||||
|
||||
static void queue_delete_wrapper(void *queue)
|
||||
{
|
||||
vQueueDelete(queue);
|
||||
btdm_queue_item_t *queue_item = (btdm_queue_item_t *)queue;
|
||||
if (queue_item) {
|
||||
if(queue_item->handle){
|
||||
vQueueDelete(queue_item->handle);
|
||||
}
|
||||
|
||||
#if CONFIG_SPIRAM_USE_MALLOC
|
||||
if (queue_item->storage) {
|
||||
free(queue_item->storage);
|
||||
}
|
||||
#endif
|
||||
|
||||
free(queue_item);
|
||||
}
|
||||
}
|
||||
|
||||
static int queue_send_wrapper(void *queue, void *item, uint32_t block_time_ms)
|
||||
{
|
||||
if (block_time_ms == OSI_FUNCS_TIME_BLOCKING) {
|
||||
return (int)xQueueSend(queue, item, portMAX_DELAY);
|
||||
return (int)xQueueSend(((btdm_queue_item_t*)queue)->handle, item, portMAX_DELAY);
|
||||
} else {
|
||||
return (int)xQueueSend(queue, item, block_time_ms / portTICK_PERIOD_MS);
|
||||
return (int)xQueueSend(((btdm_queue_item_t*)queue)->handle, item, block_time_ms / portTICK_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
|
||||
static int IRAM_ATTR queue_send_from_isr_wrapper(void *queue, void *item, void *hptw)
|
||||
{
|
||||
return (int)xQueueSendFromISR(queue, item, hptw);
|
||||
return (int)xQueueSendFromISR(((btdm_queue_item_t*)queue)->handle, item, hptw);
|
||||
}
|
||||
|
||||
static int queue_recv_wrapper(void *queue, void *item, uint32_t block_time_ms)
|
||||
{
|
||||
if (block_time_ms == OSI_FUNCS_TIME_BLOCKING) {
|
||||
return (int)xQueueReceive(queue, item, portMAX_DELAY);
|
||||
return (int)xQueueReceive(((btdm_queue_item_t*)queue)->handle, item, portMAX_DELAY);
|
||||
} else {
|
||||
return (int)xQueueReceive(queue, item, block_time_ms / portTICK_PERIOD_MS);
|
||||
return (int)xQueueReceive(((btdm_queue_item_t*)queue)->handle, item, block_time_ms / portTICK_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
|
||||
static int IRAM_ATTR queue_recv_from_isr_wrapper(void *queue, void *item, void *hptw)
|
||||
{
|
||||
return (int)xQueueReceiveFromISR(queue, item, hptw);
|
||||
return (int)xQueueReceiveFromISR(((btdm_queue_item_t*)queue)->handle, item, hptw);
|
||||
}
|
||||
|
||||
static int task_create_wrapper(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle, uint32_t core_id)
|
||||
@ -604,13 +673,17 @@ static bool IRAM_ATTR is_in_isr_wrapper(void)
|
||||
|
||||
static void *malloc_internal_wrapper(size_t size)
|
||||
{
|
||||
return heap_caps_malloc(size, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL|MALLOC_CAP_DMA);
|
||||
void *p = heap_caps_malloc(size, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL|MALLOC_CAP_DMA);
|
||||
if(p == NULL) {
|
||||
ESP_LOGE(BT_LOG_TAG, "Malloc failed");
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
static int IRAM_ATTR read_mac_wrapper(uint8_t mac[6])
|
||||
{
|
||||
int ret = esp_read_mac(mac, ESP_MAC_BT);
|
||||
ESP_LOGI(BTDM_LOG_TAG, "Bluetooth MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
ESP_LOGI(BT_LOG_TAG, "Bluetooth MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
|
||||
return ret;
|
||||
@ -685,7 +758,7 @@ static void btdm_sleep_enter_phase1_wrapper(uint32_t lpcycles)
|
||||
if (esp_timer_start_once(s_btdm_slp_tmr, us_to_sleep - uncertainty) == ESP_OK) {
|
||||
s_lp_stat.wakeup_timer_started = 1;
|
||||
} else {
|
||||
ESP_LOGE(BTDM_LOG_TAG, "timer start failed");
|
||||
ESP_LOGE(BT_LOG_TAG, "timer start failed");
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
@ -888,21 +961,21 @@ esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode)
|
||||
mem_start = (intptr_t)ets_rom_layout_p->data_start_btdm;
|
||||
mem_end = (intptr_t)ets_rom_layout_p->bss_end_btdm;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release rom btdm [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_LOGD(BT_LOG_TAG, "Release rom btdm [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
} else {
|
||||
mem_start = (intptr_t)ets_rom_layout_p->bss_start_btdm;
|
||||
mem_end = (intptr_t)ets_rom_layout_p->bss_end_btdm;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release rom btdm BSS [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_LOGD(BT_LOG_TAG, "Release rom btdm BSS [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
|
||||
mem_start = (intptr_t)ets_rom_layout_p->data_start_btdm;
|
||||
mem_end = (intptr_t)ets_rom_layout_p->data_end_btdm;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release rom btdm Data [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_LOGD(BT_LOG_TAG, "Release rom btdm Data [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
}
|
||||
@ -913,21 +986,21 @@ esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode)
|
||||
mem_start = (intptr_t)ets_rom_layout_p->data_start_interface_btdm;
|
||||
mem_end = (intptr_t)ets_rom_layout_p->bss_end_interface_btdm;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release rom interface btdm [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_LOGD(BT_LOG_TAG, "Release rom interface btdm [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
} else {
|
||||
mem_start = (intptr_t)ets_rom_layout_p->data_start_interface_btdm;
|
||||
mem_end = (intptr_t)ets_rom_layout_p->data_end_interface_btdm;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release rom interface btdm Data [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_LOGD(BT_LOG_TAG, "Release rom interface btdm Data [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
|
||||
mem_start = (intptr_t)ets_rom_layout_p->bss_start_interface_btdm;
|
||||
mem_end = (intptr_t)ets_rom_layout_p->bss_end_interface_btdm;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release rom interface btdm BSS [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_LOGD(BT_LOG_TAG, "Release rom interface btdm BSS [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
}
|
||||
@ -954,21 +1027,21 @@ esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
||||
mem_start = (intptr_t)&_bt_bss_start;
|
||||
mem_end = (intptr_t)&_btdm_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release BSS [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_LOGD(BT_LOG_TAG, "Release BSS [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
} else {
|
||||
mem_start = (intptr_t)&_bt_bss_start;
|
||||
mem_end = (intptr_t)&_bt_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release BT BSS [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_LOGD(BT_LOG_TAG, "Release BT BSS [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
|
||||
mem_start = (intptr_t)&_btdm_bss_start;
|
||||
mem_end = (intptr_t)&_btdm_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release BTDM BSS [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_LOGD(BT_LOG_TAG, "Release BTDM BSS [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
}
|
||||
@ -979,21 +1052,21 @@ esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
||||
mem_start = (intptr_t)&_bt_data_start;
|
||||
mem_end = (intptr_t)&_btdm_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release data [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_LOGD(BT_LOG_TAG, "Release data [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
} else {
|
||||
mem_start = (intptr_t)&_bt_data_start;
|
||||
mem_end = (intptr_t)&_bt_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release BT Data [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_LOGD(BT_LOG_TAG, "Release BT Data [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
|
||||
mem_start = (intptr_t)&_btdm_data_start;
|
||||
mem_end = (intptr_t)&_btdm_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release BTDM Data [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_LOGD(BT_LOG_TAG, "Release BTDM Data [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
}
|
||||
@ -1001,13 +1074,13 @@ esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
||||
mem_start = (intptr_t)&_nimble_bss_start;
|
||||
mem_end = (intptr_t)&_nimble_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release NimBLE BSS [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_LOGD(BT_LOG_TAG, "Release NimBLE BSS [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
mem_start = (intptr_t)&_nimble_data_start;
|
||||
mem_end = (intptr_t)&_nimble_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release NimBLE Data [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_LOGD(BT_LOG_TAG, "Release NimBLE Data [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
}
|
||||
@ -1021,19 +1094,13 @@ static esp_err_t try_heap_caps_add_region(intptr_t start, intptr_t end)
|
||||
* is too small to fit a heap. This cannot be termed as a fatal error and hence
|
||||
* we replace it by ESP_OK
|
||||
*/
|
||||
|
||||
if (ret == ESP_ERR_INVALID_SIZE) {
|
||||
return ESP_OK;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// release wifi and coex memory, free about 720 bytes,
|
||||
void esp_release_wifi_and_coex_mem(void)
|
||||
{
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region((intptr_t)ets_rom_layout_p->dram_start_coexist, (intptr_t)ets_rom_layout_p->dram_end_pp));
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region((intptr_t)ets_rom_layout_p->data_start_interface_coexist,(intptr_t)ets_rom_layout_p->bss_end_interface_pp));
|
||||
}
|
||||
|
||||
#if CONFIG_MAC_BB_PD
|
||||
static void IRAM_ATTR btdm_mac_bb_power_down_cb(void)
|
||||
{
|
||||
@ -1066,25 +1133,25 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
|
||||
if (cfg->controller_task_prio != ESP_TASK_BT_CONTROLLER_PRIO
|
||||
|| cfg->controller_task_stack_size < ESP_TASK_BT_CONTROLLER_STACK) {
|
||||
ESP_LOGE(BTDM_LOG_TAG, "Invalid controller task prioriy or stack size");
|
||||
ESP_LOGE(BT_LOG_TAG, "Invalid controller task prioriy or stack size");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (cfg->bluetooth_mode != ESP_BT_MODE_BLE) {
|
||||
ESP_LOGE(BTDM_LOG_TAG, "%s controller only support BLE only mode", __func__);
|
||||
ESP_LOGE(BT_LOG_TAG, "%s controller only support BLE only mode", __func__);
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
if (cfg->bluetooth_mode & ESP_BT_MODE_BLE) {
|
||||
if ((cfg->ble_max_act <= 0) || (cfg->ble_max_act > BT_CTRL_BLE_MAX_ACT_LIMIT)) {
|
||||
ESP_LOGE(BTDM_LOG_TAG, "Invalid value of ble_max_act");
|
||||
ESP_LOGE(BT_LOG_TAG, "Invalid value of ble_max_act");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
|
||||
if (cfg->sleep_mode == ESP_BT_SLEEP_MODE_1) {
|
||||
if (cfg->sleep_clock == ESP_BT_SLEEP_CLOCK_NONE) {
|
||||
ESP_LOGE(BTDM_LOG_TAG, "SLEEP_MODE_1 enabled but sleep clock not configured");
|
||||
ESP_LOGE(BT_LOG_TAG, "SLEEP_MODE_1 enabled but sleep clock not configured");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
@ -1122,7 +1189,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_LOGI(BTDM_LOG_TAG, "BT controller compile version [%s]", btdm_controller_get_compile_version());
|
||||
ESP_LOGI(BT_LOG_TAG, "BT controller compile version [%s]", btdm_controller_get_compile_version());
|
||||
|
||||
// init low-power control resources
|
||||
do {
|
||||
@ -1173,19 +1240,19 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac);
|
||||
|
||||
// set default bluetooth sleep clock source
|
||||
s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value
|
||||
s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value
|
||||
#if CONFIG_BT_CTRL_LPCLK_SEL_EXT_32K_XTAL
|
||||
// check whether or not EXT_CRYS is working
|
||||
if (rtc_clk_slow_src_get() == SOC_RTC_SLOW_CLK_SRC_XTAL32K) {
|
||||
s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_XTAL32K; // External 32 kHz XTAL
|
||||
} else {
|
||||
ESP_LOGW(BTDM_LOG_TAG, "32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock.");
|
||||
ESP_LOGW(BT_LOG_TAG, "32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock");
|
||||
#if !CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP
|
||||
s_lp_cntl.no_light_sleep = 1;
|
||||
#endif
|
||||
}
|
||||
#elif (CONFIG_BT_CTRL_LPCLK_SEL_MAIN_XTAL)
|
||||
ESP_LOGI(BTDM_LOG_TAG, "Bluetooth will use main XTAL as Bluetooth sleep clock.");
|
||||
ESP_LOGI(BT_LOG_TAG, "Bluetooth will use main XTAL as Bluetooth sleep clock.");
|
||||
#if !CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP
|
||||
s_lp_cntl.no_light_sleep = 1;
|
||||
#endif
|
||||
@ -1193,10 +1260,10 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
// check whether or not internal 150 kHz RC oscillator is working
|
||||
if (rtc_clk_slow_src_get() == SOC_RTC_SLOW_CLK_SRC_RC_SLOW) {
|
||||
s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_RTC_SLOW; // Internal 150 kHz RC oscillator
|
||||
ESP_LOGW(BTDM_LOG_TAG, "Internal 150kHz RC osciallator. The accuracy of this clock is a lot larger than 500ppm which is "
|
||||
ESP_LOGW(BT_LOG_TAG, "Internal 150kHz RC osciallator. The accuracy of this clock is a lot larger than 500ppm which is "
|
||||
"required in Bluetooth communication, so don't select this option in scenarios such as BLE connection state.");
|
||||
} else {
|
||||
ESP_LOGW(BTDM_LOG_TAG, "Internal 150kHz RC oscillator not detected.");
|
||||
ESP_LOGW(BT_LOG_TAG, "Internal 150kHz RC oscillator not detected.");
|
||||
assert(0);
|
||||
}
|
||||
#endif
|
||||
@ -1241,7 +1308,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
err = ESP_ERR_NO_MEM;
|
||||
goto error;
|
||||
}
|
||||
ESP_LOGW(BTDM_LOG_TAG, "Light sleep mode will not be able to apply when bluetooth is enabled.");
|
||||
ESP_LOGW(BT_LOG_TAG, "light sleep mode will not be able to apply when bluetooth is enabled.");
|
||||
}
|
||||
if ((err = esp_pm_lock_create(ESP_PM_APB_FREQ_MAX, 0, "bt", &s_pm_lock)) != ESP_OK) {
|
||||
err = ESP_ERR_NO_MEM;
|
||||
@ -1390,7 +1457,7 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
|
||||
//As the history reason, mode should be equal to the mode which set in esp_bt_controller_init()
|
||||
if (mode != btdm_controller_get_mode()) {
|
||||
ESP_LOGE(BTDM_LOG_TAG, "invalid mode %d, controller support mode is %d", mode, btdm_controller_get_mode());
|
||||
ESP_LOGE(BT_LOG_TAG, "invalid mode %d, controller support mode is %d", mode, btdm_controller_get_mode());
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
|
@ -1,455 +1 @@
|
||||
config BT_CTRL_MODE_EFF
|
||||
int
|
||||
default 1
|
||||
|
||||
config BT_CTRL_BLE_MAX_ACT
|
||||
int "BLE Max Instances"
|
||||
default 10
|
||||
range 1 10
|
||||
help
|
||||
BLE maximum instances of bluetooth controller.
|
||||
|
||||
config BT_CTRL_BLE_MAX_ACT_EFF
|
||||
int
|
||||
default BT_CTRL_BLE_MAX_ACT
|
||||
default 0
|
||||
|
||||
config BT_CTRL_BLE_STATIC_ACL_TX_BUF_NB
|
||||
int "BLE static ACL TX buffer numbers"
|
||||
range 0 12
|
||||
default 0
|
||||
help
|
||||
BLE ACL buffer have two methods to be allocated. One is persistent allocating
|
||||
(alloate when controller initialise, never free until controller de-initialise)
|
||||
another is dynamically allocating (allocate before TX and free after TX).
|
||||
|
||||
choice BT_CTRL_PINNED_TO_CORE_CHOICE
|
||||
prompt "The cpu core which bluetooth controller run"
|
||||
depends on !FREERTOS_UNICORE
|
||||
help
|
||||
Specify the cpu core to run bluetooth controller.
|
||||
Can not specify no-affinity.
|
||||
|
||||
config BT_CTRL_PINNED_TO_CORE_0
|
||||
bool "Core 0 (PRO CPU)"
|
||||
config BT_CTRL_PINNED_TO_CORE_1
|
||||
bool "Core 1 (APP CPU)"
|
||||
depends on !FREERTOS_UNICORE
|
||||
endchoice
|
||||
|
||||
config BT_CTRL_PINNED_TO_CORE
|
||||
int
|
||||
default 0 if BT_CTRL_PINNED_TO_CORE_0
|
||||
default 1 if BT_CTRL_PINNED_TO_CORE_1
|
||||
default 0
|
||||
|
||||
choice BT_CTRL_HCI_MODE_CHOICE
|
||||
prompt "HCI mode"
|
||||
help
|
||||
Specify HCI mode as VHCI or UART(H4)
|
||||
|
||||
config BT_CTRL_HCI_MODE_VHCI
|
||||
bool "VHCI"
|
||||
help
|
||||
Normal option. Mostly, choose this VHCI when bluetooth host run on ESP32S3, too.
|
||||
|
||||
config BT_CTRL_HCI_MODE_UART_H4
|
||||
bool "UART(H4)"
|
||||
help
|
||||
If use external bluetooth host which run on other hardware and use UART as the HCI interface,
|
||||
choose this option.
|
||||
endchoice
|
||||
|
||||
config BT_CTRL_HCI_TL
|
||||
int
|
||||
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"
|
||||
range 1 500
|
||||
default 30
|
||||
help
|
||||
The maxinum number of suplicate scan filter
|
||||
|
||||
config BT_CTRL_HW_CCA
|
||||
bool "HW CCA check enable"
|
||||
default n
|
||||
help
|
||||
It enables HW CCA feature in controller
|
||||
|
||||
config BT_CTRL_HW_CCA_VAL
|
||||
int "CCA threshold value"
|
||||
range 20 60
|
||||
default 20
|
||||
help
|
||||
It is the threshold value of HW CCA, if the value is 30, it means CCA threshold is -30 dBm.
|
||||
|
||||
config BT_CTRL_HW_CCA_EFF
|
||||
int
|
||||
default 1 if BT_CTRL_HW_CCA
|
||||
default 0
|
||||
help
|
||||
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"
|
||||
help
|
||||
Specify connection event length determination
|
||||
|
||||
config BT_CTRL_CE_LENGTH_TYPE_ORIG
|
||||
bool "ORIGINAL"
|
||||
config BT_CTRL_CE_LENGTH_TYPE_CE
|
||||
bool "Use CE parameter for HCI command"
|
||||
config BT_CTRL_CE_LENGTH_TYPE_SD
|
||||
bool "Use Espressif self-defined method"
|
||||
endchoice
|
||||
|
||||
config BT_CTRL_CE_LENGTH_TYPE_EFF
|
||||
int
|
||||
default 0 if BT_CTRL_CE_LENGTH_TYPE_ORIG
|
||||
default 1 if BT_CTRL_CE_LENGTH_TYPE_CE
|
||||
default 2 if BT_CTRL_CE_LENGTH_TYPE_SD
|
||||
|
||||
choice BT_CTRL_TX_ANTENNA_INDEX
|
||||
prompt "default Tx anntena used"
|
||||
help
|
||||
Specify default Tx antenna used for bluetooth
|
||||
|
||||
config BT_CTRL_TX_ANTENNA_INDEX_0
|
||||
bool "Antenna 0"
|
||||
config BT_CTRL_TX_ANTENNA_INDEX_1
|
||||
bool "Antenna 1"
|
||||
endchoice
|
||||
|
||||
config BT_CTRL_TX_ANTENNA_INDEX_EFF
|
||||
int
|
||||
default 0 if BT_CTRL_TX_ANTENNA_INDEX_0
|
||||
default 1 if BT_CTRL_TX_ANTENNA_INDEX_1
|
||||
|
||||
choice BT_CTRL_RX_ANTENNA_INDEX
|
||||
prompt "default Rx anntena used"
|
||||
help
|
||||
Specify default Rx antenna used for bluetooth
|
||||
|
||||
config BT_CTRL_RX_ANTENNA_INDEX_0
|
||||
bool "Antenna 0"
|
||||
config BT_CTRL_RX_ANTENNA_INDEX_1
|
||||
bool "Antenna 1"
|
||||
endchoice
|
||||
|
||||
config BT_CTRL_RX_ANTENNA_INDEX_EFF
|
||||
int
|
||||
default 0 if BT_CTRL_RX_ANTENNA_INDEX_0
|
||||
default 1 if BT_CTRL_RX_ANTENNA_INDEX_1
|
||||
|
||||
choice BT_CTRL_DFT_TX_POWER_LEVEL
|
||||
prompt "BLE default Tx power level"
|
||||
default BT_CTRL_DFT_TX_POWER_LEVEL_P9
|
||||
help
|
||||
Specify default Tx power level
|
||||
|
||||
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
|
||||
bool "-9dBm"
|
||||
config BT_CTRL_DFT_TX_POWER_LEVEL_N6
|
||||
bool "-6dBm"
|
||||
config BT_CTRL_DFT_TX_POWER_LEVEL_N3
|
||||
bool "-3dBm"
|
||||
config BT_CTRL_DFT_TX_POWER_LEVEL_N0
|
||||
bool "0dBm"
|
||||
config BT_CTRL_DFT_TX_POWER_LEVEL_P3
|
||||
bool "+3dBm"
|
||||
config BT_CTRL_DFT_TX_POWER_LEVEL_P6
|
||||
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"
|
||||
config BT_CTRL_DFT_TX_POWER_LEVEL_P18
|
||||
bool "+21dBm"
|
||||
|
||||
endchoice
|
||||
|
||||
config BT_CTRL_DFT_TX_POWER_LEVEL_EFF
|
||||
int
|
||||
default 0 if BT_CTRL_DFT_TX_POWER_LEVEL_N24
|
||||
default 1 if BT_CTRL_DFT_TX_POWER_LEVEL_N21
|
||||
default 2 if BT_CTRL_DFT_TX_POWER_LEVEL_N18
|
||||
default 3 if BT_CTRL_DFT_TX_POWER_LEVEL_N15
|
||||
default 4 if BT_CTRL_DFT_TX_POWER_LEVEL_N12
|
||||
default 5 if BT_CTRL_DFT_TX_POWER_LEVEL_N9
|
||||
default 6 if BT_CTRL_DFT_TX_POWER_LEVEL_N6
|
||||
default 7 if BT_CTRL_DFT_TX_POWER_LEVEL_N3
|
||||
default 8 if BT_CTRL_DFT_TX_POWER_LEVEL_N0
|
||||
default 9 if BT_CTRL_DFT_TX_POWER_LEVEL_P3
|
||||
default 10 if BT_CTRL_DFT_TX_POWER_LEVEL_P6
|
||||
default 11 if BT_CTRL_DFT_TX_POWER_LEVEL_P9
|
||||
default 12 if BT_CTRL_DFT_TX_POWER_LEVEL_P12
|
||||
default 13 if BT_CTRL_DFT_TX_POWER_LEVEL_P15
|
||||
default 14 if BT_CTRL_DFT_TX_POWER_LEVEL_P18
|
||||
default 15 if BT_CTRL_DFT_TX_POWER_LEVEL_P21
|
||||
|
||||
default 0
|
||||
|
||||
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_DUPL_SCAN_CACHE_REFRESH_PERIOD
|
||||
int "Duplicate scan list refresh period (seconds)"
|
||||
depends on BT_CTRL_BLE_SCAN_DUPL
|
||||
range 0 1000
|
||||
default 0
|
||||
help
|
||||
If the period value is non-zero, the controller will periodically clear the device information
|
||||
stored in the scan duuplicate filter. If it is 0, the scan duuplicate filter will not be cleared
|
||||
until the scanning is disabled. Duplicate advertisements for this period should not be sent to the
|
||||
Host in advertising report events.
|
||||
There are two scenarios where the ADV packet will be repeatedly reported:
|
||||
1. The duplicate scan cache is full, the controller will delete the oldest device information and
|
||||
add new device information.
|
||||
2. When the refresh period is up, the controller will clear all device information and start filtering
|
||||
again.
|
||||
|
||||
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
|
||||
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 ESP_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 (!ESP_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
|
||||
|
||||
config BT_CTRL_MODEM_SLEEP
|
||||
bool "Bluetooth modem sleep"
|
||||
depends on !BT_CTRL_HCI_MODE_UART_H4
|
||||
default n
|
||||
help
|
||||
Enable/disable bluetooth controller low power mode.
|
||||
Modem sleep is not supported to be used with UART HCI.
|
||||
|
||||
config BT_CTRL_MODEM_SLEEP_MODE_1
|
||||
bool "Bluetooth Modem sleep Mode 1"
|
||||
depends on BT_CTRL_MODEM_SLEEP
|
||||
default y
|
||||
help
|
||||
Mode 1 is the currently supported sleep mode. In this mode,
|
||||
bluetooth controller sleeps between and BLE events. A low
|
||||
power clock is used to maintain bluetooth reference clock.
|
||||
|
||||
choice BT_CTRL_LOW_POWER_CLOCK
|
||||
prompt "Bluetooth low power clock"
|
||||
depends on BT_CTRL_MODEM_SLEEP_MODE_1
|
||||
help
|
||||
Select the low power clock source for bluetooth controller
|
||||
|
||||
config BT_CTRL_LPCLK_SEL_MAIN_XTAL
|
||||
bool "Main crystal"
|
||||
help
|
||||
Main crystal can be used as low power clock for bluetooth modem sleep. If this option is
|
||||
selected, bluetooth modem sleep can work under Dynamic Frequency Scaling(DFS) enabled, and
|
||||
bluetooth can work under light sleep enabled. Main crystal has a relatively better performance
|
||||
than other bluetooth low power clock sources.
|
||||
config BT_CTRL_LPCLK_SEL_EXT_32K_XTAL
|
||||
bool "External 32kHz crystal"
|
||||
depends on 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 150kHz RC oscillator"
|
||||
depends on RTC_CLK_SRC_INT_RC
|
||||
help
|
||||
Internal 150kHz RC oscillator. The accuracy of this clock is a lot larger than 500ppm which is required
|
||||
in Bluetooth communication, so don't select this option in scenarios such as BLE connection state.
|
||||
endchoice
|
||||
|
||||
config BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP
|
||||
bool "power up main XTAL during light sleep"
|
||||
depends on (BT_CTRL_LPCLK_SEL_MAIN_XTAL || BT_CTRL_LPCLK_SEL_EXT_32K_XTAL) && FREERTOS_USE_TICKLESS_IDLE
|
||||
default n
|
||||
help
|
||||
If this option is selected, the main crystal will power up during light sleep when the low power clock
|
||||
selects an external 32kHz crystal but the external 32kHz crystal does not exist or the low power clock
|
||||
selects the main crystal.
|
||||
|
||||
endmenu
|
||||
|
||||
config BT_CTRL_SLEEP_MODE_EFF
|
||||
int
|
||||
default 1 if BT_CTRL_MODEM_SLEEP_MODE_1
|
||||
default 0
|
||||
|
||||
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
|
||||
|
||||
config BT_CTRL_HCI_TL_EFF
|
||||
int
|
||||
default 0 if BT_CTRL_HCI_MODE_UART_H4
|
||||
default 1 if BT_CTRL_HCI_M0DE_VHCI
|
||||
default 1
|
||||
|
||||
config BT_CTRL_AGC_RECORRECT_EN
|
||||
bool "Enable HW AGC recorrect"
|
||||
default n
|
||||
help
|
||||
Enable uncoded phy AGC recorrect
|
||||
|
||||
config BT_CTRL_CODED_AGC_RECORRECT_EN
|
||||
bool "Enable coded phy AGC recorrect"
|
||||
depends on BT_CTRL_AGC_RECORRECT_EN
|
||||
default n
|
||||
help
|
||||
Enable coded phy AGC recorrect
|
||||
|
||||
config BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
|
||||
bool "Disable active scan backoff"
|
||||
default n
|
||||
help
|
||||
Disable active scan backoff. The bluetooth spec requires that scanners should run a backoff procedure to
|
||||
minimize collision of scan request PDUs from nultiple scanners. If scan backoff is disabled, in active
|
||||
scanning, scan request PDU will be sent every time when HW receives scannable ADV PDU.
|
||||
source "$IDF_PATH/components/bt/controller/esp32c3/Kconfig.in"
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -66,7 +66,7 @@ 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_RTC_SLOW = 3, /*!< Internal 150kHz RC oscillator */
|
||||
ESP_BT_SLEEP_CLOCK_RTC_SLOW = 3, /*!< Internal 136kHz RC oscillator */
|
||||
ESP_BT_SLEEP_CLOCK_FPGA_32K = 4, /*!< Hardwired 32KHz clock temporarily used for FPGA */
|
||||
} esp_bt_sleep_clock_t;
|
||||
|
||||
@ -136,6 +136,12 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status);
|
||||
#define DUPL_SCAN_CACHE_REFRESH_PERIOD CONFIG_BT_CTRL_DUPL_SCAN_CACHE_REFRESH_PERIOD
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
|
||||
#define BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
|
||||
#else
|
||||
#define BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_CTRL_AGC_RECORRECT_EN
|
||||
#define BT_CTRL_AGC_RECORRECT_EN CONFIG_BT_CTRL_AGC_RECORRECT_EN
|
||||
#else
|
||||
@ -148,20 +154,16 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status);
|
||||
#define BT_CTRL_CODED_AGC_RECORRECT 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
|
||||
#define BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
|
||||
#else
|
||||
#define BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX 0
|
||||
#endif
|
||||
|
||||
#define AGC_RECORRECT_EN ((BT_CTRL_AGC_RECORRECT_EN << 0) | (BT_CTRL_CODED_AGC_RECORRECT <<1))
|
||||
|
||||
|
||||
#define CFG_MASK_BIT_SCAN_DUPLICATE_OPTION (1<<0)
|
||||
|
||||
#define CFG_NASK CFG_MASK_BIT_SCAN_DUPLICATE_OPTION
|
||||
|
||||
#define BLE_HW_TARGET_CODE_ESP32C3_CHIP_ECO0 (0x01010000)
|
||||
#define CFG_MASK CFG_MASK_BIT_SCAN_DUPLICATE_OPTION
|
||||
#if CONFIG_IDF_TARGET_ESP32C3
|
||||
#define BLE_HW_TARGET_CODE_CHIP_ECO0 (0x01010000)
|
||||
#else // CONFIG_IDF_TARGET_ESP32S3
|
||||
#define BLE_HW_TARGET_CODE_CHIP_ECO0 (0x02010000)
|
||||
#endif
|
||||
|
||||
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() { \
|
||||
.magic = ESP_BT_CTRL_CONFIG_MAGIC_VAL, \
|
||||
@ -184,13 +186,13 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status);
|
||||
.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_NASK, \
|
||||
.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_ESP32C3_CHIP_ECO0, \
|
||||
.hw_target_code = BLE_HW_TARGET_CODE_CHIP_ECO0, \
|
||||
.slave_ce_len_min = SLAVE_CE_LEN_MIN_DEFAULT, \
|
||||
.hw_recorrect_en = AGC_RECORRECT_EN, \
|
||||
.cca_thresh = CONFIG_BT_CTRL_HW_CCA_VAL, \
|
||||
@ -260,7 +262,7 @@ typedef struct {
|
||||
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 */
|
||||
uint8_t slave_ce_len_min;
|
||||
uint8_t slave_ce_len_min; /*!< slave minimum ce length*/
|
||||
uint8_t hw_recorrect_en;
|
||||
uint8_t cca_thresh; /*!< cca threshold*/
|
||||
uint16_t scan_backoff_upperlimitmax; /*!< scan backoff upperlimitmax value */
|
||||
|
@ -1,558 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#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"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_BT_CTRL_CONFIG_MAGIC_VAL 0x5A5AA5A5
|
||||
#define ESP_BT_CTRL_CONFIG_VERSION 0x02212090
|
||||
|
||||
#define ESP_BT_HCI_TL_MAGIC_VALUE 0xfadebead
|
||||
#define ESP_BT_HCI_TL_VERSION 0x00010000
|
||||
|
||||
/**
|
||||
* @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 Type of controller HCI transport layer
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_BT_CTRL_HCI_TL_UART = 0, /*!< HCI UART h4 transport layer */
|
||||
ESP_BT_CTRL_HCI_TL_VHCI = 1, /*!< VHCI interface */
|
||||
} esp_bt_ctrl_hci_tl_t;
|
||||
|
||||
/**
|
||||
* @breif type of BLE connection event length computation
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_BLE_CE_LEN_TYPE_ORIG = 0, /*!< original */
|
||||
ESP_BLE_CE_LEN_TYPE_CE = 1, /*!< use CE_LEN parameter from HCI commands */
|
||||
ESP_BLE_CE_LEN_TYPE_SD = 1, /*!< Espressif vendor defined */
|
||||
} esp_ble_ce_len_t;
|
||||
|
||||
/**
|
||||
* @brief Bluetooth sleep mode
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_BT_SLEEP_MODE_NONE = 0, /*!< Bluetooth sleep mode disabled */
|
||||
ESP_BT_SLEEP_MODE_1 = 1, /*!< Bluetooth sleep mode 1 */
|
||||
} esp_bt_sleep_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Bluetooth sleep clock
|
||||
*/
|
||||
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_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;
|
||||
|
||||
/**
|
||||
* @brief antenna index used for bluetooth
|
||||
*/
|
||||
enum {
|
||||
ESP_BT_ANT_IDX_0 = 0, /*!< anntena NO 0 */
|
||||
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 */
|
||||
};
|
||||
|
||||
#define ESP_BT_HCI_TL_STATUS_OK (0) /*!< HCI_TL Tx/Rx operation status OK */
|
||||
|
||||
/**
|
||||
* @brief callback function for HCI Transport Layer send/receive operations
|
||||
*/
|
||||
typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status);
|
||||
|
||||
#ifdef CONFIG_BT_ENABLED
|
||||
|
||||
#define BT_CTRL_BLE_MAX_ACT_LIMIT 10 //Maximum BLE activity limitation
|
||||
#define SLAVE_CE_LEN_MIN_DEFAULT 5
|
||||
|
||||
#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
|
||||
|
||||
#ifndef CONFIG_BT_CTRL_DUPL_SCAN_CACHE_REFRESH_PERIOD
|
||||
#define DUPL_SCAN_CACHE_REFRESH_PERIOD 0
|
||||
#else
|
||||
#define DUPL_SCAN_CACHE_REFRESH_PERIOD CONFIG_BT_CTRL_DUPL_SCAN_CACHE_REFRESH_PERIOD
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
|
||||
#define BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
|
||||
#else
|
||||
#define BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_CTRL_AGC_RECORRECT_EN
|
||||
#define BT_CTRL_AGC_RECORRECT_EN CONFIG_BT_CTRL_AGC_RECORRECT_EN
|
||||
#else
|
||||
#define BT_CTRL_AGC_RECORRECT_EN 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_CTRL_CODED_AGC_RECORRECT_EN
|
||||
#define BT_CTRL_CODED_AGC_RECORRECT CONFIG_BT_CTRL_CODED_AGC_RECORRECT_EN
|
||||
#else
|
||||
#define BT_CTRL_CODED_AGC_RECORRECT 0
|
||||
#endif
|
||||
|
||||
#define AGC_RECORRECT_EN ((BT_CTRL_AGC_RECORRECT_EN << 0) | (BT_CTRL_CODED_AGC_RECORRECT <<1))
|
||||
|
||||
#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, \
|
||||
.version = ESP_BT_CTRL_CONFIG_VERSION, \
|
||||
.controller_task_stack_size = ESP_TASK_BT_CONTROLLER_STACK, \
|
||||
.controller_task_prio = ESP_TASK_BT_CONTROLLER_PRIO, \
|
||||
.controller_task_run_cpu = CONFIG_BT_CTRL_PINNED_TO_CORE, \
|
||||
.bluetooth_mode = CONFIG_BT_CTRL_MODE_EFF, \
|
||||
.ble_max_act = CONFIG_BT_CTRL_BLE_MAX_ACT_EFF, \
|
||||
.sleep_mode = CONFIG_BT_CTRL_SLEEP_MODE_EFF, \
|
||||
.sleep_clock = CONFIG_BT_CTRL_SLEEP_CLOCK_EFF, \
|
||||
.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 = false, \
|
||||
.ce_len_type = CONFIG_BT_CTRL_CE_LENGTH_TYPE_EFF, \
|
||||
.coex_use_hooks = false, \
|
||||
.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, \
|
||||
.slave_ce_len_min = SLAVE_CE_LEN_MIN_DEFAULT, \
|
||||
.hw_recorrect_en = AGC_RECORRECT_EN, \
|
||||
.cca_thresh = CONFIG_BT_CTRL_HW_CCA_VAL, \
|
||||
.scan_backoff_upperlimitmax = BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX, \
|
||||
.dup_list_refresh_period = DUPL_SCAN_CACHE_REFRESH_PERIOD, \
|
||||
}
|
||||
|
||||
#else
|
||||
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() {0}; ESP_STATIC_ASSERT(0, "please enable bluetooth in menuconfig to use esp_bt.h");
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Controller HCI transport layer function structure
|
||||
* This structure shall be registered when HCI transport layer is UART
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t _magic; /* Magic number */
|
||||
uint32_t _version; /* version number of the defined structure */
|
||||
uint32_t _reserved; /* reserved for future use */
|
||||
int (* _open)(void); /* hci tl open */
|
||||
void (* _close)(void); /* hci tl close */
|
||||
void (* _finish_transfers)(void); /* hci tl finish trasnfers */
|
||||
void (* _recv)(uint8_t *buf, uint32_t len, esp_bt_hci_tl_callback_t callback, void* arg); /* hci tl recv */
|
||||
void (* _send)(uint8_t *buf, uint32_t len, esp_bt_hci_tl_callback_t callback, void* arg); /* hci tl send */
|
||||
bool (* _flow_off)(void); /* hci tl flow off */
|
||||
void (* _flow_on)(void); /* hci tl flow on */
|
||||
} esp_bt_hci_tl_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 {
|
||||
/*
|
||||
* 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 magic; /*!< Magic number */
|
||||
uint32_t version; /*!< version number of the defined structure */
|
||||
/*
|
||||
* Following parameters can be configured runtime, when call esp_bt_controller_init()
|
||||
*/
|
||||
uint16_t controller_task_stack_size; /*!< Bluetooth controller task stack size */
|
||||
uint8_t controller_task_prio; /*!< Bluetooth controller task priority */
|
||||
uint8_t controller_task_run_cpu; /*!< CPU num that Bluetooth controller task runs on */
|
||||
uint8_t bluetooth_mode; /*!< Controller mode: BR/EDR, BLE or Dual Mode */
|
||||
uint8_t ble_max_act; /*!< BLE maximum number of air activities */
|
||||
uint8_t sleep_mode; /*!< controller sleep mode */
|
||||
uint8_t sleep_clock; /*!< controller sleep clock */
|
||||
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; /*!< deprecated */
|
||||
uint8_t ce_len_type; /*!< connection event length computation method */
|
||||
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 */
|
||||
uint8_t slave_ce_len_min; /*!< slave minimum ce length*/
|
||||
uint8_t hw_recorrect_en;
|
||||
uint8_t cca_thresh; /*!< cca threshold*/
|
||||
uint16_t scan_backoff_upperlimitmax; /*!< scan backoff upperlimitmax value */
|
||||
uint16_t dup_list_refresh_period; /*!< duplicate scan list refresh time */
|
||||
} esp_bt_controller_config_t;
|
||||
|
||||
/**
|
||||
* @brief Bluetooth controller enable/disable/initialised/de-initialised status
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_BT_CONTROLLER_STATUS_IDLE = 0,
|
||||
ESP_BT_CONTROLLER_STATUS_INITED,
|
||||
ESP_BT_CONTROLLER_STATUS_ENABLED,
|
||||
ESP_BT_CONTROLLER_STATUS_NUM,
|
||||
} esp_bt_controller_status_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 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_P21 = 15, /*!< Corresponding to +21dbm */
|
||||
ESP_PWR_LVL_INVALID = 0xFF, /*!< Indicates an invalid value */
|
||||
} esp_power_level_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 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 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 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 Disable BT controller
|
||||
* @return ESP_OK - success, other - failed
|
||||
*/
|
||||
esp_err_t esp_bt_controller_disable(void);
|
||||
|
||||
/**
|
||||
* @brief Get BT controller is initialised/de-initialised/enabled/disabled
|
||||
* @return status value
|
||||
*/
|
||||
esp_bt_controller_status_t esp_bt_controller_get_status(void);
|
||||
|
||||
uint16_t esp_bt_get_tx_buf_num(void);
|
||||
|
||||
/** @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 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 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 enable bluetooth to enter modem sleep
|
||||
*
|
||||
* Note that this function shall not be invoked before esp_bt_controller_enable()
|
||||
*
|
||||
* There are currently two options for bluetooth modem sleep, one is ORIG mode, and another is EVED Mode. EVED Mode is intended for BLE only.
|
||||
*
|
||||
* For ORIG mode:
|
||||
* Bluetooth modem sleep is enabled in controller start up by default if CONFIG_BTDM_CONTROLLER_MODEM_SLEEP is set and "ORIG mode" is selected. In ORIG modem sleep mode, bluetooth controller will switch off some components and pause to work every now and then, if there is no event to process; and wakeup according to the scheduled interval and resume the work. It can also wakeup earlier upon external request using function "esp_bt_controller_wakeup_request".
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*/
|
||||
esp_err_t esp_bt_sleep_enable(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief disable bluetooth modem sleep
|
||||
*
|
||||
* Note that this function shall not be invoked before esp_bt_controller_enable()
|
||||
*
|
||||
* If esp_bt_sleep_disable() is called, bluetooth controller will not be allowed to enter modem sleep;
|
||||
*
|
||||
* If ORIG modem sleep mode is in use, if this function is called, bluetooth controller may not immediately wake up if it is dormant then.
|
||||
* In this case, esp_bt_controller_wakeup_request() can be used to shorten the time for wakeup.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*/
|
||||
esp_err_t esp_bt_sleep_disable(void);
|
||||
|
||||
/**
|
||||
* @brief to check whether bluetooth controller is sleeping at the instant, if modem sleep is enabled
|
||||
*
|
||||
* Note that this function shall not be invoked before esp_bt_controller_enable()
|
||||
* This function is supposed to be used ORIG mode of modem sleep
|
||||
*
|
||||
* @return true if in modem sleep state, false otherwise
|
||||
*/
|
||||
bool esp_bt_controller_is_sleeping(void);
|
||||
|
||||
/**
|
||||
* @brief request controller to wakeup from sleeping state during sleep mode
|
||||
*
|
||||
* Note that this function shall not be invoked before esp_bt_controller_enable()
|
||||
* Note that this function is supposed to be used ORIG mode of modem sleep
|
||||
* Note that after this request, bluetooth controller may again enter sleep as long as the modem sleep is enabled
|
||||
*
|
||||
* Profiling shows that it takes several milliseconds to wakeup from modem sleep after this request.
|
||||
* Generally it takes longer if 32kHz XTAL is used than the main XTAL, due to the lower frequency of the former as the bluetooth low power clock source.
|
||||
*/
|
||||
void esp_bt_controller_wakeup_request(void);
|
||||
|
||||
/**
|
||||
* @brief notify bluetooth controller task to process the event upon Tx or Rx done
|
||||
*
|
||||
* Note that this function shall not be invoked before esp_bt_controller_enable()
|
||||
* This function can be called in both ISR and non-ISR context
|
||||
*
|
||||
*/
|
||||
int esp_bt_h4tl_eif_io_event_notify(int event);
|
||||
|
||||
/**
|
||||
* @brief bt Wi-Fi power domain power on
|
||||
*/
|
||||
void esp_wifi_bt_power_domain_on(void);
|
||||
|
||||
/**
|
||||
* @brief bt Wi-Fi power domain power off
|
||||
*/
|
||||
void esp_wifi_bt_power_domain_off(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_BT_H__ */
|
Loading…
Reference in New Issue
Block a user