mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-23 17:17:14 +00:00
esp_wifi: refactor wifi code in order to adapter to new chips
This commit is contained in:
@@ -51,6 +51,11 @@
|
||||
|
||||
#define TAG "esp_adapter"
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
extern void wifi_apb80m_request(void);
|
||||
extern void wifi_apb80m_release(void);
|
||||
#endif
|
||||
|
||||
static void IRAM_ATTR s_esp_dport_access_stall_other_cpu_start(void)
|
||||
{
|
||||
DPORT_STALL_OTHER_CPU_START();
|
||||
@@ -174,6 +179,25 @@ static void wifi_delete_queue_wrapper(void *queue)
|
||||
wifi_delete_queue(queue);
|
||||
}
|
||||
|
||||
static bool IRAM_ATTR env_is_chip_wrapper(void)
|
||||
{
|
||||
#ifdef CONFIG_IDF_ENV_FPGA
|
||||
return false;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void set_intr_wrapper(int32_t cpu_no, uint32_t intr_source, uint32_t intr_num, int32_t intr_prio)
|
||||
{
|
||||
intr_matrix_set(cpu_no, intr_source, intr_num);
|
||||
}
|
||||
|
||||
static void clear_intr_wrapper(uint32_t intr_source, uint32_t intr_num)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void set_isr_wrapper(int32_t n, void *f, void *arg)
|
||||
{
|
||||
xt_set_interrupt_handler(n, (xt_handler)f, arg);
|
||||
@@ -213,7 +237,7 @@ static void IRAM_ATTR wifi_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp)
|
||||
|
||||
static bool IRAM_ATTR is_from_isr_wrapper(void)
|
||||
{
|
||||
return xPortInIsrContext();
|
||||
return !xPortCanYield();
|
||||
}
|
||||
|
||||
static void IRAM_ATTR task_yield_from_isr_wrapper(void)
|
||||
@@ -391,6 +415,20 @@ static int32_t esp_event_post_wrapper(const char* event_base, int32_t event_id,
|
||||
}
|
||||
}
|
||||
|
||||
static void IRAM_ATTR wifi_apb80m_request_wrapper(void)
|
||||
{
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
wifi_apb80m_request();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void IRAM_ATTR wifi_apb80m_release_wrapper(void)
|
||||
{
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
wifi_apb80m_release();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void IRAM_ATTR timer_arm_wrapper(void *timer, uint32_t tmout, bool repeat)
|
||||
{
|
||||
ets_timer_arm(timer, tmout, repeat);
|
||||
@@ -463,7 +501,7 @@ static void * IRAM_ATTR zalloc_internal_wrapper(size_t size)
|
||||
|
||||
static int coex_init_wrapper(void)
|
||||
{
|
||||
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_init();
|
||||
#else
|
||||
return 0;
|
||||
@@ -472,14 +510,30 @@ static int coex_init_wrapper(void)
|
||||
|
||||
static void coex_deinit_wrapper(void)
|
||||
{
|
||||
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_deinit();
|
||||
#endif
|
||||
}
|
||||
|
||||
static uint32_t coex_status_get_wrapper(void)
|
||||
static int coex_enable_wrapper(void)
|
||||
{
|
||||
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_enable();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void coex_disable_wrapper(void)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_disable();
|
||||
#endif
|
||||
}
|
||||
|
||||
static IRAM_ATTR uint32_t coex_status_get_wrapper(void)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_status_get();
|
||||
#else
|
||||
return 0;
|
||||
@@ -495,65 +549,118 @@ static void coex_condition_set_wrapper(uint32_t type, bool dissatisfy)
|
||||
|
||||
static int coex_wifi_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration)
|
||||
{
|
||||
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_wifi_request(event, latency, duration);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int coex_wifi_release_wrapper(uint32_t event)
|
||||
static IRAM_ATTR int coex_wifi_release_wrapper(uint32_t event)
|
||||
{
|
||||
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_wifi_release(event);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int IRAM_ATTR coex_bt_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration)
|
||||
static int coex_wifi_channel_set_wrapper(uint8_t primary, uint8_t secondary)
|
||||
{
|
||||
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
|
||||
return coex_bt_request(event, latency, duration);
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_wifi_channel_set(primary, secondary);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int IRAM_ATTR coex_bt_release_wrapper(uint32_t event)
|
||||
static IRAM_ATTR int coex_event_duration_get_wrapper(uint32_t event, uint32_t *duration)
|
||||
{
|
||||
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
|
||||
return coex_bt_release(event);
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_event_duration_get(event, duration);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int coex_register_bt_cb_wrapper(coex_func_cb_t cb)
|
||||
static int coex_pti_get_wrapper(uint32_t event, uint8_t *pti)
|
||||
{
|
||||
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
|
||||
return coex_register_bt_cb(cb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
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 IRAM_ATTR int coex_schm_interval_set_wrapper(uint32_t interval)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_schm_interval_set(interval);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t IRAM_ATTR coex_bb_reset_lock_wrapper(void)
|
||||
static uint32_t coex_schm_interval_get_wrapper(void)
|
||||
{
|
||||
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
|
||||
return coex_bb_reset_lock();
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_schm_interval_get();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void IRAM_ATTR coex_bb_reset_unlock_wrapper(uint32_t restore)
|
||||
static uint8_t coex_schm_curr_period_get_wrapper(void)
|
||||
{
|
||||
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
|
||||
coex_bb_reset_unlock(restore);
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_schm_curr_period_get();
|
||||
#else
|
||||
return 0;
|
||||
#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
|
||||
}
|
||||
|
||||
static int coex_schm_curr_phase_idx_set_wrapper(int idx)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_schm_curr_phase_idx_set(idx);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int coex_schm_curr_phase_idx_get_wrapper(void)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_schm_curr_phase_idx_get();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void IRAM_ATTR esp_empty_wrapper(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int32_t IRAM_ATTR coex_is_in_isr_wrapper(void)
|
||||
{
|
||||
return !xPortCanYield();
|
||||
@@ -561,9 +668,13 @@ int32_t IRAM_ATTR coex_is_in_isr_wrapper(void)
|
||||
|
||||
wifi_osi_funcs_t g_wifi_osi_funcs = {
|
||||
._version = ESP_WIFI_OS_ADAPTER_VERSION,
|
||||
._env_is_chip = env_is_chip_wrapper,
|
||||
._set_intr = set_intr_wrapper,
|
||||
._clear_intr = clear_intr_wrapper,
|
||||
._set_isr = set_isr_wrapper,
|
||||
._ints_on = xt_ints_on,
|
||||
._ints_off = xt_ints_off,
|
||||
._is_from_isr = is_from_isr_wrapper,
|
||||
._spin_lock_create = spin_lock_create_wrapper,
|
||||
._spin_lock_delete = free,
|
||||
._wifi_int_disable = wifi_int_disable_wrapper,
|
||||
@@ -606,6 +717,8 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
|
||||
._rand = esp_random,
|
||||
._dport_access_stall_other_cpu_start_wrap = s_esp_dport_access_stall_other_cpu_start,
|
||||
._dport_access_stall_other_cpu_end_wrap = s_esp_dport_access_stall_other_cpu_end,
|
||||
._wifi_apb80m_request = wifi_apb80m_request_wrapper,
|
||||
._wifi_apb80m_release = wifi_apb80m_release_wrapper,
|
||||
._phy_disable = esp_phy_disable,
|
||||
._phy_enable = esp_phy_enable,
|
||||
._phy_common_clock_enable = esp_phy_common_clock_enable,
|
||||
@@ -620,6 +733,8 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
|
||||
._wifi_reset_mac = wifi_reset_mac_wrapper,
|
||||
._wifi_clock_enable = wifi_clock_enable_wrapper,
|
||||
._wifi_clock_disable = wifi_clock_disable_wrapper,
|
||||
._wifi_rtc_enable_iso = esp_empty_wrapper,
|
||||
._wifi_rtc_disable_iso = esp_empty_wrapper,
|
||||
._esp_timer_get_time = esp_timer_get_time,
|
||||
._nvs_set_i8 = nvs_set_i8,
|
||||
._nvs_get_i8 = nvs_get_i8,
|
||||
@@ -651,11 +766,23 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
|
||||
._wifi_delete_queue = wifi_delete_queue_wrapper,
|
||||
._coex_init = coex_init_wrapper,
|
||||
._coex_deinit = coex_deinit_wrapper,
|
||||
._coex_enable = coex_enable_wrapper,
|
||||
._coex_disable = coex_disable_wrapper,
|
||||
._coex_status_get = coex_status_get_wrapper,
|
||||
._coex_condition_set = coex_condition_set_wrapper,
|
||||
._coex_wifi_request = coex_wifi_request_wrapper,
|
||||
._coex_wifi_release = coex_wifi_release_wrapper,
|
||||
._is_from_isr = is_from_isr_wrapper,
|
||||
._coex_wifi_channel_set = coex_wifi_channel_set_wrapper,
|
||||
._coex_event_duration_get = coex_event_duration_get_wrapper,
|
||||
._coex_pti_get = coex_pti_get_wrapper,
|
||||
._coex_schm_status_bit_clear = coex_schm_status_bit_clear_wrapper,
|
||||
._coex_schm_status_bit_set = coex_schm_status_bit_set_wrapper,
|
||||
._coex_schm_interval_set = coex_schm_interval_set_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,
|
||||
._coex_schm_curr_phase_idx_set = coex_schm_curr_phase_idx_set_wrapper,
|
||||
._coex_schm_curr_phase_idx_get = coex_schm_curr_phase_idx_get_wrapper,
|
||||
._magic = ESP_WIFI_OS_ADAPTER_MAGIC,
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user