mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
esp_wifi: port coex adapter for esp32c6
This commit is contained in:
parent
38316b38b5
commit
5e59276ddf
@ -20,7 +20,7 @@ endif()
|
||||
|
||||
idf_component_register(SRCS "${srcs}"
|
||||
INCLUDE_DIRS "include"
|
||||
PRIV_REQUIRES esp_timer driver
|
||||
PRIV_REQUIRES esp_timer driver esp_event
|
||||
LDFRAGMENTS "${ldfragments}")
|
||||
|
||||
if(CONFIG_SW_COEXIST_ENABLE OR CONFIG_EXTERNAL_COEX_ENABLE)
|
||||
|
131
components/esp_coex/esp32c6/esp_coex_adapter.c
Normal file
131
components/esp_coex/esp32c6/esp_coex_adapter.c
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/portmacro.h"
|
||||
#include "esp_heap_caps.h"
|
||||
#include "esp_timer.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "esp_private/esp_clk.h"
|
||||
#include "esp_coexist_adapter.h"
|
||||
#include "esp32c6/rom/ets_sys.h"
|
||||
|
||||
#define TAG "esp_coex_adapter"
|
||||
|
||||
#define OSI_FUNCS_TIME_BLOCKING 0xffffffff
|
||||
|
||||
bool IRAM_ATTR env_is_chip_wrapper(void)
|
||||
{
|
||||
#ifdef CONFIG_IDF_ENV_FPGA
|
||||
return false;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void IRAM_ATTR task_yield_from_isr_wrapper(void)
|
||||
{
|
||||
portYIELD_FROM_ISR();
|
||||
}
|
||||
|
||||
void *semphr_create_wrapper(uint32_t max, uint32_t init)
|
||||
{
|
||||
return (void *)xSemaphoreCreateCounting(max, init);
|
||||
}
|
||||
|
||||
void semphr_delete_wrapper(void *semphr)
|
||||
{
|
||||
vSemaphoreDelete(semphr);
|
||||
}
|
||||
|
||||
int32_t IRAM_ATTR semphr_take_from_isr_wrapper(void *semphr, void *hptw)
|
||||
{
|
||||
return (int32_t)xSemaphoreTakeFromISR(semphr, hptw);
|
||||
}
|
||||
|
||||
int32_t IRAM_ATTR semphr_give_from_isr_wrapper(void *semphr, void *hptw)
|
||||
{
|
||||
return (int32_t)xSemaphoreGiveFromISR(semphr, hptw);
|
||||
}
|
||||
|
||||
int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
|
||||
{
|
||||
if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
|
||||
return (int32_t)xSemaphoreTake(semphr, portMAX_DELAY);
|
||||
} else {
|
||||
return (int32_t)xSemaphoreTake(semphr, block_time_tick);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t semphr_give_wrapper(void *semphr)
|
||||
{
|
||||
return (int32_t)xSemaphoreGive(semphr);
|
||||
}
|
||||
|
||||
void IRAM_ATTR timer_disarm_wrapper(void *timer)
|
||||
{
|
||||
ets_timer_disarm(timer);
|
||||
}
|
||||
|
||||
void timer_done_wrapper(void *ptimer)
|
||||
{
|
||||
ets_timer_done(ptimer);
|
||||
}
|
||||
|
||||
void timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg)
|
||||
{
|
||||
ets_timer_setfn(ptimer, pfunction, parg);
|
||||
}
|
||||
|
||||
void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat)
|
||||
{
|
||||
ets_timer_arm_us(ptimer, us, repeat);
|
||||
}
|
||||
|
||||
uint32_t esp_clk_slowclk_cal_get_wrapper(void)
|
||||
{
|
||||
/* The bit width of WiFi light sleep clock calibration is 12 while the one of
|
||||
* system is 19. It should shift 19 - 12 = 7.
|
||||
*/
|
||||
return (esp_clk_slowclk_cal_get() >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH));
|
||||
}
|
||||
|
||||
void *IRAM_ATTR malloc_internal_wrapper(size_t size)
|
||||
{
|
||||
return heap_caps_malloc(size, MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
|
||||
}
|
||||
|
||||
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 = xPortInIsrContext,
|
||||
._malloc_internal = malloc_internal_wrapper,
|
||||
._free = free,
|
||||
._esp_timer_get_time = esp_timer_get_time,
|
||||
._env_is_chip = env_is_chip_wrapper,
|
||||
._slowclk_cal_get = esp_clk_slowclk_cal_get_wrapper,
|
||||
._timer_disarm = timer_disarm_wrapper,
|
||||
._timer_done = timer_done_wrapper,
|
||||
._timer_setfn = timer_setfn_wrapper,
|
||||
._timer_arm_us = timer_arm_us_wrapper,
|
||||
._magic = COEX_ADAPTER_MAGIC,
|
||||
};
|
@ -65,7 +65,7 @@ void timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat);
|
||||
|
||||
void * malloc_internal_wrapper(size_t size);
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32C2
|
||||
#if CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C6
|
||||
bool env_is_chip_wrapper(void);
|
||||
|
||||
uint32_t esp_clk_slowclk_cal_get_wrapper(void);
|
||||
|
@ -40,8 +40,8 @@
|
||||
#include "os.h"
|
||||
#include "esp_smartconfig.h"
|
||||
#include "esp_coexist_internal.h"
|
||||
#include "esp_coexist_adapter.h"
|
||||
#include "esp32c6/rom/ets_sys.h"
|
||||
#include "esp_modem_wrapper.h"
|
||||
|
||||
#define TAG "esp_adapter"
|
||||
|
||||
@ -102,15 +102,6 @@ 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_route(intr_source, intr_num);
|
||||
@ -175,21 +166,6 @@ static bool IRAM_ATTR is_from_isr_wrapper(void)
|
||||
return !xPortCanYield();
|
||||
}
|
||||
|
||||
static void IRAM_ATTR task_yield_from_isr_wrapper(void)
|
||||
{
|
||||
portYIELD_FROM_ISR();
|
||||
}
|
||||
|
||||
static void *semphr_create_wrapper(uint32_t max, uint32_t init)
|
||||
{
|
||||
return (void *)xSemaphoreCreateCounting(max, init);
|
||||
}
|
||||
|
||||
static void semphr_delete_wrapper(void *semphr)
|
||||
{
|
||||
vSemaphoreDelete(semphr);
|
||||
}
|
||||
|
||||
static void wifi_thread_semphr_free(void *data)
|
||||
{
|
||||
SemaphoreHandle_t *sem = (SemaphoreHandle_t *)(data);
|
||||
@ -225,30 +201,6 @@ 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) {
|
||||
return (int32_t)xSemaphoreTake(semphr, portMAX_DELAY);
|
||||
} else {
|
||||
return (int32_t)xSemaphoreTake(semphr, block_time_tick);
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t semphr_give_wrapper(void *semphr)
|
||||
{
|
||||
return (int32_t)xSemaphoreGive(semphr);
|
||||
}
|
||||
|
||||
static void *recursive_mutex_create_wrapper(void)
|
||||
{
|
||||
return (void *)xSemaphoreCreateRecursiveMutex();
|
||||
@ -369,26 +321,6 @@ static void IRAM_ATTR timer_arm_wrapper(void *timer, uint32_t tmout, bool repeat
|
||||
ets_timer_arm(timer, tmout, repeat);
|
||||
}
|
||||
|
||||
static void IRAM_ATTR timer_disarm_wrapper(void *timer)
|
||||
{
|
||||
ets_timer_disarm(timer);
|
||||
}
|
||||
|
||||
static void timer_done_wrapper(void *ptimer)
|
||||
{
|
||||
ets_timer_done(ptimer);
|
||||
}
|
||||
|
||||
static void timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg)
|
||||
{
|
||||
ets_timer_setfn(ptimer, pfunction, parg);
|
||||
}
|
||||
|
||||
static void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat)
|
||||
{
|
||||
ets_timer_arm_us(ptimer, us, repeat);
|
||||
}
|
||||
|
||||
static void wifi_reset_mac_wrapper(void)
|
||||
{
|
||||
// TODO: IDF-5713
|
||||
@ -422,19 +354,6 @@ static int get_time_wrapper(void *t)
|
||||
return os_get_time(t);
|
||||
}
|
||||
|
||||
static uint32_t esp_clk_slowclk_cal_get_wrapper(void)
|
||||
{
|
||||
/* The bit width of WiFi light sleep clock calibration is 12 while the one of
|
||||
* system is 19. It should shift 19 - 12 = 7.
|
||||
*/
|
||||
return (esp_clk_slowclk_cal_get() >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH));
|
||||
}
|
||||
|
||||
static void *IRAM_ATTR malloc_internal_wrapper(size_t size)
|
||||
{
|
||||
return heap_caps_malloc(size, MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
|
||||
}
|
||||
|
||||
static void *IRAM_ATTR realloc_internal_wrapper(void *ptr, size_t size)
|
||||
{
|
||||
return heap_caps_realloc(ptr, size, MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
|
||||
@ -617,24 +536,6 @@ static void *coex_schm_curr_phase_get_wrapper(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static int coex_schm_curr_phase_idx_set_wrapper(int idx)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_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 || CONFIG_EXTERNAL_COEX_ENABLE
|
||||
return coex_schm_curr_phase_idx_get();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int coex_register_start_cb_wrapper(int (* cb)(void))
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
@ -644,6 +545,24 @@ static int coex_register_start_cb_wrapper(int (* cb)(void))
|
||||
#endif
|
||||
}
|
||||
|
||||
static int coex_schm_process_restart_wrapper(void)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_schm_process_restart();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int coex_schm_register_cb_wrapper(int type, void(*cb)(int))
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_schm_register_callback(type, cb);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void IRAM_ATTR esp_empty_wrapper(void)
|
||||
{
|
||||
|
||||
@ -763,8 +682,6 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
|
||||
._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,
|
||||
._coex_register_start_cb = coex_register_start_cb_wrapper,
|
||||
#if 0//CONFIG_IDF_TARGET_ESP32C6
|
||||
// TODO: WIFI-5150
|
||||
@ -773,23 +690,7 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
|
||||
._sleep_retention_entries_create = (int (*)(const void *, int, int, int))sleep_retention_entries_create,
|
||||
._sleep_retention_entries_destroy = sleep_retention_entries_destroy,
|
||||
#endif
|
||||
._coex_schm_process_restart = coex_schm_process_restart_wrapper,
|
||||
._coex_schm_register_cb = coex_schm_register_cb_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 = xPortInIsrContext,
|
||||
._malloc_internal = malloc_internal_wrapper,
|
||||
._free = free,
|
||||
._esp_timer_get_time = esp_timer_get_time,
|
||||
._env_is_chip = env_is_chip_wrapper,
|
||||
._slowclk_cal_get = esp_clk_slowclk_cal_get_wrapper,
|
||||
._magic = COEX_ADAPTER_MAGIC,
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user