Add HW external coexist api.

Simplify the external coex flow.

And replace gpio of driver interface with hal one.
This commit is contained in:
alex.li
2021-01-18 15:55:14 +08:00
committed by Jack
parent b96b76fc10
commit 26d8b7ee17
12 changed files with 281 additions and 67 deletions

View File

@@ -48,6 +48,8 @@
#include "nvs.h"
#include "os.h"
#include "esp_smartconfig.h"
#include "esp_coexist_internal.h"
#include "esp_coexist_adapter.h"
#define TAG "esp_adapter"
@@ -277,6 +279,16 @@ static void * wifi_thread_semphr_get_wrapper(void)
return (void*)sem;
}
static int32_t IRAM_ATTR semphr_take_from_isr_wrapper(void *semphr, void *hptw)
{
return (int32_t)xSemaphoreTakeFromISR(semphr, hptw);
}
static int32_t IRAM_ATTR semphr_give_from_isr_wrapper(void *semphr, void *hptw)
{
return (int32_t)xSemaphoreGiveFromISR(semphr, hptw);
}
static int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
{
if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
@@ -483,7 +495,7 @@ static void * IRAM_ATTR zalloc_internal_wrapper(size_t size)
static int coex_init_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_init();
#else
return 0;
@@ -492,14 +504,14 @@ static int coex_init_wrapper(void)
static void coex_deinit_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
coex_deinit();
#endif
}
static int coex_enable_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_enable();
#else
return 0;
@@ -508,14 +520,14 @@ static int coex_enable_wrapper(void)
static void coex_disable_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
coex_disable();
#endif
}
static IRAM_ATTR uint32_t coex_status_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_status_get();
#else
return 0;
@@ -524,14 +536,14 @@ static IRAM_ATTR uint32_t coex_status_get_wrapper(void)
static void coex_condition_set_wrapper(uint32_t type, bool dissatisfy)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
coex_condition_set(type, dissatisfy);
#endif
}
static int coex_wifi_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_wifi_request(event, latency, duration);
#else
return 0;
@@ -540,7 +552,7 @@ static int coex_wifi_request_wrapper(uint32_t event, uint32_t latency, uint32_t
static IRAM_ATTR int coex_wifi_release_wrapper(uint32_t event)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_wifi_release(event);
#else
return 0;
@@ -549,7 +561,7 @@ static IRAM_ATTR int coex_wifi_release_wrapper(uint32_t event)
static int coex_wifi_channel_set_wrapper(uint8_t primary, uint8_t secondary)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_wifi_channel_set(primary, secondary);
#else
return 0;
@@ -558,7 +570,7 @@ static int coex_wifi_channel_set_wrapper(uint8_t primary, uint8_t secondary)
static IRAM_ATTR int coex_event_duration_get_wrapper(uint32_t event, uint32_t *duration)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_event_duration_get(event, duration);
#else
return 0;
@@ -567,26 +579,30 @@ static IRAM_ATTR int coex_event_duration_get_wrapper(uint32_t event, uint32_t *d
static int coex_pti_get_wrapper(uint32_t event, uint8_t *pti)
{
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_pti_get(event, pti);
#else
return 0;
#endif
}
static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_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
#if CONFIG_EXTERNAL_COEX_ENABLE
coex_schm_status_bit_set(type, status);
#endif
}
static IRAM_ATTR int coex_schm_interval_set_wrapper(uint32_t interval)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_schm_interval_set(interval);
#else
return 0;
@@ -595,7 +611,7 @@ static IRAM_ATTR int coex_schm_interval_set_wrapper(uint32_t interval)
static uint32_t coex_schm_interval_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_schm_interval_get();
#else
return 0;
@@ -604,7 +620,7 @@ static uint32_t coex_schm_interval_get_wrapper(void)
static uint8_t coex_schm_curr_period_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_schm_curr_period_get();
#else
return 0;
@@ -613,7 +629,7 @@ static uint8_t coex_schm_curr_period_get_wrapper(void)
static void * coex_schm_curr_phase_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_schm_curr_phase_get();
#else
return NULL;
@@ -622,7 +638,7 @@ static void * coex_schm_curr_phase_get_wrapper(void)
static int coex_schm_curr_phase_idx_set_wrapper(int idx)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_schm_curr_phase_idx_set(idx);
#else
return 0;
@@ -631,7 +647,7 @@ static int coex_schm_curr_phase_idx_set_wrapper(int idx)
static int coex_schm_curr_phase_idx_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_schm_curr_phase_idx_get();
#else
return 0;
@@ -643,6 +659,11 @@ static void IRAM_ATTR esp_empty_wrapper(void)
}
int32_t IRAM_ATTR coex_is_in_isr_wrapper(void)
{
return !xPortCanYield();
}
wifi_osi_funcs_t g_wifi_osi_funcs = {
._version = ESP_WIFI_OS_ADAPTER_VERSION,
._env_is_chip = env_is_chip_wrapper,
@@ -761,3 +782,19 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
._coex_schm_curr_phase_idx_get = coex_schm_curr_phase_idx_get_wrapper,
._magic = ESP_WIFI_OS_ADAPTER_MAGIC,
};
coex_adapter_funcs_t g_coex_adapter_funcs = {
._version = COEX_ADAPTER_VERSION,
._task_yield_from_isr = task_yield_from_isr_wrapper,
._semphr_create = semphr_create_wrapper,
._semphr_delete = semphr_delete_wrapper,
._semphr_take_from_isr = semphr_take_from_isr_wrapper,
._semphr_give_from_isr = semphr_give_from_isr_wrapper,
._semphr_take = semphr_take_wrapper,
._semphr_give = semphr_give_wrapper,
._is_in_isr = coex_is_in_isr_wrapper,
._malloc_internal = malloc_internal_wrapper,
._free = free,
._esp_timer_get_time = esp_timer_get_time,
._magic = COEX_ADAPTER_MAGIC,
};