mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-07 20:00:53 +00:00
feat(ble/controller): Add coexist schm for BLE
This commit is contained in:
@@ -64,6 +64,7 @@
|
||||
// wakeup request sources
|
||||
enum {
|
||||
BTDM_ASYNC_WAKEUP_SRC_VHCI = 0,
|
||||
BTDM_ASYNC_WAKEUP_REQ_COEX,
|
||||
BTDM_ASYNC_WAKEUP_SRC_DISA,
|
||||
BTDM_ASYNC_WAKEUP_SRC_TMR,
|
||||
BTDM_ASYNC_WAKEUP_SRC_MAX,
|
||||
@@ -110,7 +111,7 @@ do{\
|
||||
} while(0)
|
||||
|
||||
#define OSI_FUNCS_TIME_BLOCKING 0xffffffff
|
||||
#define OSI_VERSION 0x00010007
|
||||
#define OSI_VERSION 0x00010008
|
||||
#define OSI_MAGIC_VALUE 0xFADEBEAD
|
||||
|
||||
/* Types definition
|
||||
@@ -184,8 +185,12 @@ struct osi_funcs_t {
|
||||
void (* _btdm_sleep_exit_phase3)(void); /* called from task */
|
||||
void (* _coex_wifi_sleep_set)(bool sleep);
|
||||
int (* _coex_core_ble_conn_dyn_prio_get)(bool *low, bool *high);
|
||||
int (* _coex_schm_register_btdm_callback)(void *callback);
|
||||
void (* _coex_schm_status_bit_set)(uint32_t type, uint32_t status);
|
||||
void (* _coex_schm_status_bit_clear)(uint32_t type, uint32_t status);
|
||||
uint32_t (* _coex_schm_interval_get)(void);
|
||||
uint8_t (* _coex_schm_curr_period_get)(void);
|
||||
void *(* _coex_schm_curr_phase_get)(void);
|
||||
void (* _interrupt_on)(int intr_num);
|
||||
void (* _interrupt_off)(int intr_num);
|
||||
void (* _esp_hw_power_down)(void);
|
||||
@@ -193,6 +198,8 @@ struct osi_funcs_t {
|
||||
void (* _ets_backup_dma_copy)(uint32_t reg, uint32_t mem_addr, uint32_t num, bool to_rem);
|
||||
void (* _ets_delay_us)(uint32_t us);
|
||||
void (* _btdm_rom_table_ready)(void);
|
||||
bool (* _coex_bt_wakeup_request)(void);
|
||||
void (* _coex_bt_wakeup_request_end)(void);
|
||||
};
|
||||
|
||||
|
||||
@@ -306,14 +313,20 @@ static void btdm_sleep_enter_phase1_wrapper(uint32_t lpcycles);
|
||||
static void btdm_sleep_enter_phase2_wrapper(void);
|
||||
static void btdm_sleep_exit_phase3_wrapper(void);
|
||||
static void coex_wifi_sleep_set_hook(bool sleep);
|
||||
static int coex_schm_register_btdm_callback_wrapper(void *callback);
|
||||
static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status);
|
||||
static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status);
|
||||
static uint32_t coex_schm_interval_get_wrapper(void);
|
||||
static uint8_t coex_schm_curr_period_get_wrapper(void);
|
||||
static void * coex_schm_curr_phase_get_wrapper(void);
|
||||
static void interrupt_on_wrapper(int intr_num);
|
||||
static void interrupt_off_wrapper(int intr_num);
|
||||
static void btdm_hw_mac_power_up_wrapper(void);
|
||||
static void btdm_hw_mac_power_down_wrapper(void);
|
||||
static void btdm_backup_dma_copy_wrapper(uint32_t reg, uint32_t mem_addr, uint32_t num, bool to_mem);
|
||||
static void btdm_funcs_table_ready_wrapper(void);
|
||||
static bool coex_bt_wakeup_request(void);
|
||||
static void coex_bt_wakeup_request_end(void);
|
||||
|
||||
static void btdm_slp_tmr_callback(void *arg);
|
||||
|
||||
@@ -371,8 +384,12 @@ static const struct osi_funcs_t osi_funcs_ro = {
|
||||
._btdm_sleep_exit_phase3 = btdm_sleep_exit_phase3_wrapper,
|
||||
._coex_wifi_sleep_set = coex_wifi_sleep_set_hook,
|
||||
._coex_core_ble_conn_dyn_prio_get = NULL,
|
||||
._coex_schm_register_btdm_callback = coex_schm_register_btdm_callback_wrapper,
|
||||
._coex_schm_status_bit_set = coex_schm_status_bit_set_wrapper,
|
||||
._coex_schm_status_bit_clear = coex_schm_status_bit_clear_wrapper,
|
||||
._coex_schm_interval_get = coex_schm_interval_get_wrapper,
|
||||
._coex_schm_curr_period_get = coex_schm_curr_period_get_wrapper,
|
||||
._coex_schm_curr_phase_get = coex_schm_curr_phase_get_wrapper,
|
||||
._interrupt_on = interrupt_on_wrapper,
|
||||
._interrupt_off = interrupt_off_wrapper,
|
||||
._esp_hw_power_down = btdm_hw_mac_power_down_wrapper,
|
||||
@@ -380,6 +397,8 @@ static const struct osi_funcs_t osi_funcs_ro = {
|
||||
._ets_backup_dma_copy = btdm_backup_dma_copy_wrapper,
|
||||
._ets_delay_us = esp_rom_delay_us,
|
||||
._btdm_rom_table_ready = btdm_funcs_table_ready_wrapper,
|
||||
._coex_bt_wakeup_request = coex_bt_wakeup_request,
|
||||
._coex_bt_wakeup_request_end = coex_bt_wakeup_request_end,
|
||||
};
|
||||
|
||||
static DRAM_ATTR struct osi_funcs_t *osi_funcs_p;
|
||||
@@ -852,6 +871,22 @@ static bool async_wakeup_request(int event)
|
||||
semphr_take_wrapper(s_wakeup_req_sem, OSI_FUNCS_TIME_BLOCKING);
|
||||
}
|
||||
break;
|
||||
case BTDM_ASYNC_WAKEUP_REQ_COEX:
|
||||
if (!btdm_power_state_active()) {
|
||||
do_wakeup_request = true;
|
||||
#if CONFIG_PM_ENABLE
|
||||
if (s_lp_stat.pm_lock_released) {
|
||||
esp_pm_lock_acquire(s_pm_lock);
|
||||
s_lp_stat.pm_lock_released = 0;
|
||||
}
|
||||
#endif
|
||||
btdm_wakeup_request();
|
||||
|
||||
if (s_lp_cntl.wakeup_timer_required && s_lp_stat.wakeup_timer_started) {
|
||||
esp_timer_stop(s_btdm_slp_tmr);
|
||||
s_lp_stat.wakeup_timer_started = 0;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -871,6 +906,9 @@ static void async_wakeup_request_end(int event)
|
||||
case BTDM_ASYNC_WAKEUP_SRC_DISA:
|
||||
allow_to_sleep = true;
|
||||
break;
|
||||
case BTDM_ASYNC_WAKEUP_REQ_COEX:
|
||||
allow_to_sleep = false;
|
||||
break;
|
||||
default:
|
||||
allow_to_sleep = true;
|
||||
break;
|
||||
@@ -890,18 +928,25 @@ static void btdm_funcs_table_ready_wrapper(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status)
|
||||
bool bt_async_wakeup_request(void)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_schm_status_bit_set(type, status);
|
||||
#endif
|
||||
return async_wakeup_request(BTDM_ASYNC_WAKEUP_SRC_VHCI);
|
||||
}
|
||||
|
||||
static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status)
|
||||
void bt_wakeup_request_end(void)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_schm_status_bit_clear(type, status);
|
||||
#endif
|
||||
async_wakeup_request_end(BTDM_ASYNC_WAKEUP_SRC_VHCI);
|
||||
}
|
||||
|
||||
static bool coex_bt_wakeup_request(void)
|
||||
{
|
||||
return async_wakeup_request(BTDM_ASYNC_WAKEUP_REQ_COEX);
|
||||
}
|
||||
|
||||
static void coex_bt_wakeup_request_end(void)
|
||||
{
|
||||
async_wakeup_request_end(BTDM_ASYNC_WAKEUP_REQ_COEX);
|
||||
return;
|
||||
}
|
||||
|
||||
bool esp_vhci_host_check_send_available(void)
|
||||
@@ -1676,4 +1721,55 @@ static void coex_wifi_sleep_set_hook(bool sleep)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static int coex_schm_register_btdm_callback_wrapper(void *callback)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_schm_register_callback(COEX_SCHM_CALLBACK_TYPE_BT, callback);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_schm_status_bit_clear(type, status);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_schm_status_bit_set(type, status);
|
||||
#endif
|
||||
}
|
||||
|
||||
static uint32_t coex_schm_interval_get_wrapper(void)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_schm_interval_get();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static uint8_t coex_schm_curr_period_get_wrapper(void)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_schm_curr_period_get();
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void * coex_schm_curr_phase_get_wrapper(void)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_schm_curr_phase_get();
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BT_ENABLED */
|
||||
|
Reference in New Issue
Block a user