forked from espressif/esp-idf
esp_coex: correct wrapper names
This commit is contained in:
@@ -30,7 +30,16 @@ typedef struct {
|
|||||||
void *storage; /**< storage for FreeRTOS queue */
|
void *storage; /**< storage for FreeRTOS queue */
|
||||||
} modem_static_queue_t;
|
} modem_static_queue_t;
|
||||||
|
|
||||||
void * spin_lock_create_wrapper(void)
|
bool IRAM_ATTR esp_coex_common_env_is_chip_wrapper(void)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_IDF_ENV_FPGA
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void * esp_coex_common_spin_lock_create_wrapper(void)
|
||||||
{
|
{
|
||||||
portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED;
|
portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED;
|
||||||
void *mux = heap_caps_malloc(sizeof(portMUX_TYPE), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
|
void *mux = heap_caps_malloc(sizeof(portMUX_TYPE), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
|
||||||
@@ -42,7 +51,7 @@ void * spin_lock_create_wrapper(void)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t IRAM_ATTR wifi_int_disable_wrapper(void *wifi_int_mux)
|
uint32_t IRAM_ATTR esp_coex_common_int_disable_wrapper(void *wifi_int_mux)
|
||||||
{
|
{
|
||||||
if (xPortInIsrContext()) {
|
if (xPortInIsrContext()) {
|
||||||
portENTER_CRITICAL_ISR(wifi_int_mux);
|
portENTER_CRITICAL_ISR(wifi_int_mux);
|
||||||
@@ -53,7 +62,7 @@ uint32_t IRAM_ATTR wifi_int_disable_wrapper(void *wifi_int_mux)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR wifi_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp)
|
void IRAM_ATTR esp_coex_common_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp)
|
||||||
{
|
{
|
||||||
if (xPortInIsrContext()) {
|
if (xPortInIsrContext()) {
|
||||||
portEXIT_CRITICAL_ISR(wifi_int_mux);
|
portEXIT_CRITICAL_ISR(wifi_int_mux);
|
||||||
@@ -62,12 +71,68 @@ void IRAM_ATTR wifi_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR task_yield_from_isr_wrapper(void)
|
void IRAM_ATTR esp_coex_common_task_yield_from_isr_wrapper(void)
|
||||||
{
|
{
|
||||||
portYIELD_FROM_ISR();
|
portYIELD_FROM_ISR();
|
||||||
}
|
}
|
||||||
|
|
||||||
void *internal_semphr_create_wrapper(uint32_t max, uint32_t init)
|
void * esp_coex_common_semphr_create_wrapper(uint32_t max, uint32_t init)
|
||||||
|
{
|
||||||
|
return (void *)xSemaphoreCreateCounting(max, init);
|
||||||
|
}
|
||||||
|
|
||||||
|
void esp_coex_common_semphr_delete_wrapper(void *semphr)
|
||||||
|
{
|
||||||
|
vSemaphoreDelete(semphr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t esp_coex_common_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 esp_coex_common_semphr_give_wrapper(void *semphr)
|
||||||
|
{
|
||||||
|
return (int32_t)xSemaphoreGive(semphr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRAM_ATTR esp_coex_common_timer_disarm_wrapper(void *timer)
|
||||||
|
{
|
||||||
|
ets_timer_disarm(timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void esp_coex_common_timer_done_wrapper(void *ptimer)
|
||||||
|
{
|
||||||
|
ets_timer_done(ptimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void esp_coex_common_timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg)
|
||||||
|
{
|
||||||
|
ets_timer_setfn(ptimer, pfunction, parg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRAM_ATTR esp_coex_common_timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat)
|
||||||
|
{
|
||||||
|
ets_timer_arm_us(ptimer, us, repeat);
|
||||||
|
}
|
||||||
|
|
||||||
|
void * IRAM_ATTR esp_coex_common_malloc_internal_wrapper(size_t size)
|
||||||
|
{
|
||||||
|
return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* static wrapper */
|
||||||
|
|
||||||
|
static int IRAM_ATTR esp_coex_is_in_isr_wrapper(void)
|
||||||
|
{
|
||||||
|
return !xPortCanYield();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *esp_coex_internal_semphr_create_wrapper(uint32_t max, uint32_t init)
|
||||||
{
|
{
|
||||||
modem_static_queue_t *semphr = heap_caps_calloc(1, sizeof(modem_static_queue_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
|
modem_static_queue_t *semphr = heap_caps_calloc(1, sizeof(modem_static_queue_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
|
||||||
if (!semphr) {
|
if (!semphr) {
|
||||||
@@ -101,7 +166,7 @@ _error:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void internal_semphr_delete_wrapper(void *semphr)
|
static void esp_coex_internal_semphr_delete_wrapper(void *semphr)
|
||||||
{
|
{
|
||||||
modem_static_queue_t *semphr_item = (modem_static_queue_t *)semphr;
|
modem_static_queue_t *semphr_item = (modem_static_queue_t *)semphr;
|
||||||
if (semphr_item) {
|
if (semphr_item) {
|
||||||
@@ -117,17 +182,17 @@ void internal_semphr_delete_wrapper(void *semphr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t IRAM_ATTR internal_semphr_take_from_isr_wrapper(void *semphr, void *hptw)
|
static int32_t IRAM_ATTR esp_coex_internal_semphr_take_from_isr_wrapper(void *semphr, void *hptw)
|
||||||
{
|
{
|
||||||
return (int32_t)xSemaphoreTakeFromISR(((modem_static_queue_t *)semphr)->handle, hptw);
|
return (int32_t)xSemaphoreTakeFromISR(((modem_static_queue_t *)semphr)->handle, hptw);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t IRAM_ATTR internal_semphr_give_from_isr_wrapper(void *semphr, void *hptw)
|
static int32_t IRAM_ATTR esp_coex_internal_semphr_give_from_isr_wrapper(void *semphr, void *hptw)
|
||||||
{
|
{
|
||||||
return (int32_t)xSemaphoreGiveFromISR(((modem_static_queue_t *)semphr)->handle, hptw);
|
return (int32_t)xSemaphoreGiveFromISR(((modem_static_queue_t *)semphr)->handle, hptw);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
|
static int32_t esp_coex_internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
|
||||||
{
|
{
|
||||||
if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
|
if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
|
||||||
return (int32_t)xSemaphoreTake(((modem_static_queue_t *)semphr)->handle, portMAX_DELAY);
|
return (int32_t)xSemaphoreTake(((modem_static_queue_t *)semphr)->handle, portMAX_DELAY);
|
||||||
@@ -136,61 +201,31 @@ int32_t internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t internal_semphr_give_wrapper(void *semphr)
|
static int32_t esp_coex_internal_semphr_give_wrapper(void *semphr)
|
||||||
{
|
{
|
||||||
return (int32_t)xSemaphoreGive(((modem_static_queue_t *)semphr)->handle);
|
return (int32_t)xSemaphoreGive(((modem_static_queue_t *)semphr)->handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
void * IRAM_ATTR malloc_internal_wrapper(size_t size)
|
|
||||||
{
|
|
||||||
return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int IRAM_ATTR coex_is_in_isr_wrapper(void)
|
|
||||||
{
|
|
||||||
return !xPortCanYield();
|
|
||||||
}
|
|
||||||
|
|
||||||
coex_adapter_funcs_t g_coex_adapter_funcs = {
|
coex_adapter_funcs_t g_coex_adapter_funcs = {
|
||||||
._version = COEX_ADAPTER_VERSION,
|
._version = COEX_ADAPTER_VERSION,
|
||||||
._spin_lock_create = spin_lock_create_wrapper,
|
._spin_lock_create = esp_coex_common_spin_lock_create_wrapper,
|
||||||
._spin_lock_delete = free,
|
._spin_lock_delete = free,
|
||||||
._int_disable = wifi_int_disable_wrapper,
|
._int_disable = esp_coex_common_int_disable_wrapper,
|
||||||
._int_enable = wifi_int_restore_wrapper,
|
._int_enable = esp_coex_common_int_restore_wrapper,
|
||||||
._task_yield_from_isr = task_yield_from_isr_wrapper,
|
._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper,
|
||||||
._semphr_create = internal_semphr_create_wrapper,
|
._semphr_create = esp_coex_internal_semphr_create_wrapper,
|
||||||
._semphr_delete = internal_semphr_delete_wrapper,
|
._semphr_delete = esp_coex_internal_semphr_delete_wrapper,
|
||||||
._semphr_take_from_isr = internal_semphr_take_from_isr_wrapper,
|
._semphr_take_from_isr = esp_coex_internal_semphr_take_from_isr_wrapper,
|
||||||
._semphr_give_from_isr = internal_semphr_give_from_isr_wrapper,
|
._semphr_give_from_isr = esp_coex_internal_semphr_give_from_isr_wrapper,
|
||||||
._semphr_take = internal_semphr_take_wrapper,
|
._semphr_take = esp_coex_internal_semphr_take_wrapper,
|
||||||
._semphr_give = internal_semphr_give_wrapper,
|
._semphr_give = esp_coex_internal_semphr_give_wrapper,
|
||||||
._is_in_isr = coex_is_in_isr_wrapper,
|
._is_in_isr = esp_coex_is_in_isr_wrapper,
|
||||||
._malloc_internal = malloc_internal_wrapper,
|
._malloc_internal = esp_coex_common_malloc_internal_wrapper,
|
||||||
._free = free,
|
._free = free,
|
||||||
._esp_timer_get_time = esp_timer_get_time,
|
._esp_timer_get_time = esp_timer_get_time,
|
||||||
._timer_disarm = timer_disarm_wrapper,
|
._timer_disarm = esp_coex_common_timer_disarm_wrapper,
|
||||||
._timer_done = timer_done_wrapper,
|
._timer_done = esp_coex_common_timer_done_wrapper,
|
||||||
._timer_setfn = timer_setfn_wrapper,
|
._timer_setfn = esp_coex_common_timer_setfn_wrapper,
|
||||||
._timer_arm_us = timer_arm_us_wrapper,
|
._timer_arm_us = esp_coex_common_timer_arm_us_wrapper,
|
||||||
._magic = COEX_ADAPTER_MAGIC,
|
._magic = COEX_ADAPTER_MAGIC,
|
||||||
};
|
};
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#define OSI_FUNCS_TIME_BLOCKING 0xffffffff
|
#define OSI_FUNCS_TIME_BLOCKING 0xffffffff
|
||||||
|
|
||||||
bool IRAM_ATTR env_is_chip_wrapper(void)
|
bool IRAM_ATTR esp_coex_common_env_is_chip_wrapper(void)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_IDF_ENV_FPGA
|
#ifdef CONFIG_IDF_ENV_FPGA
|
||||||
return false;
|
return false;
|
||||||
@@ -36,32 +36,54 @@ bool IRAM_ATTR env_is_chip_wrapper(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR task_yield_from_isr_wrapper(void)
|
void * esp_coex_common_spin_lock_create_wrapper(void)
|
||||||
|
{
|
||||||
|
portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED;
|
||||||
|
void *mux = malloc(sizeof(portMUX_TYPE));
|
||||||
|
|
||||||
|
if (mux) {
|
||||||
|
memcpy(mux,&tmp,sizeof(portMUX_TYPE));
|
||||||
|
return mux;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t IRAM_ATTR esp_coex_common_int_disable_wrapper(void *wifi_int_mux)
|
||||||
|
{
|
||||||
|
if (xPortInIsrContext()) {
|
||||||
|
portENTER_CRITICAL_ISR(wifi_int_mux);
|
||||||
|
} else {
|
||||||
|
portENTER_CRITICAL(wifi_int_mux);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRAM_ATTR esp_coex_common_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp)
|
||||||
|
{
|
||||||
|
if (xPortInIsrContext()) {
|
||||||
|
portEXIT_CRITICAL_ISR(wifi_int_mux);
|
||||||
|
} else {
|
||||||
|
portEXIT_CRITICAL(wifi_int_mux);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRAM_ATTR esp_coex_common_task_yield_from_isr_wrapper(void)
|
||||||
{
|
{
|
||||||
portYIELD_FROM_ISR();
|
portYIELD_FROM_ISR();
|
||||||
}
|
}
|
||||||
|
|
||||||
void * semphr_create_wrapper(uint32_t max, uint32_t init)
|
void * esp_coex_common_semphr_create_wrapper(uint32_t max, uint32_t init)
|
||||||
{
|
{
|
||||||
return (void *)xSemaphoreCreateCounting(max, init);
|
return (void *)xSemaphoreCreateCounting(max, init);
|
||||||
}
|
}
|
||||||
|
|
||||||
void semphr_delete_wrapper(void *semphr)
|
void esp_coex_common_semphr_delete_wrapper(void *semphr)
|
||||||
{
|
{
|
||||||
vSemaphoreDelete(semphr);
|
vSemaphoreDelete(semphr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t IRAM_ATTR semphr_take_from_isr_wrapper(void *semphr, void *hptw)
|
int32_t esp_coex_common_semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
|
||||||
{
|
|
||||||
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) {
|
if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
|
||||||
return (int32_t)xSemaphoreTake(semphr, portMAX_DELAY);
|
return (int32_t)xSemaphoreTake(semphr, portMAX_DELAY);
|
||||||
@@ -70,32 +92,37 @@ int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t semphr_give_wrapper(void *semphr)
|
int32_t esp_coex_common_semphr_give_wrapper(void *semphr)
|
||||||
{
|
{
|
||||||
return (int32_t)xSemaphoreGive(semphr);
|
return (int32_t)xSemaphoreGive(semphr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR timer_disarm_wrapper(void *timer)
|
void IRAM_ATTR esp_coex_common_timer_disarm_wrapper(void *timer)
|
||||||
{
|
{
|
||||||
ets_timer_disarm(timer);
|
ets_timer_disarm(timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void timer_done_wrapper(void *ptimer)
|
void esp_coex_common_timer_done_wrapper(void *ptimer)
|
||||||
{
|
{
|
||||||
ets_timer_done(ptimer);
|
ets_timer_done(ptimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg)
|
void esp_coex_common_timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg)
|
||||||
{
|
{
|
||||||
ets_timer_setfn(ptimer, pfunction, parg);
|
ets_timer_setfn(ptimer, pfunction, parg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat)
|
void IRAM_ATTR esp_coex_common_timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat)
|
||||||
{
|
{
|
||||||
ets_timer_arm_us(ptimer, us, repeat);
|
ets_timer_arm_us(ptimer, us, repeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t esp_clk_slowclk_cal_get_wrapper(void)
|
void * IRAM_ATTR esp_coex_common_malloc_internal_wrapper(size_t size)
|
||||||
|
{
|
||||||
|
return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t esp_coex_common_clk_slowclk_cal_get_wrapper(void)
|
||||||
{
|
{
|
||||||
/* The bit width of WiFi light sleep clock calibration is 12 while the one of
|
/* The bit width of WiFi light sleep clock calibration is 12 while the one of
|
||||||
* system is 19. It should shift 19 - 12 = 7.
|
* system is 19. It should shift 19 - 12 = 7.
|
||||||
@@ -103,29 +130,36 @@ uint32_t esp_clk_slowclk_cal_get_wrapper(void)
|
|||||||
return (esp_clk_slowclk_cal_get() >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH));
|
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)
|
/* static wrapper */
|
||||||
|
|
||||||
|
static int32_t IRAM_ATTR esp_coex_semphr_take_from_isr_wrapper(void *semphr, void *hptw)
|
||||||
{
|
{
|
||||||
return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
|
return (int32_t)xSemaphoreTakeFromISR(semphr, hptw);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t IRAM_ATTR esp_coex_semphr_give_from_isr_wrapper(void *semphr, void *hptw)
|
||||||
|
{
|
||||||
|
return (int32_t)xSemaphoreGiveFromISR(semphr, hptw);
|
||||||
}
|
}
|
||||||
|
|
||||||
coex_adapter_funcs_t g_coex_adapter_funcs = {
|
coex_adapter_funcs_t g_coex_adapter_funcs = {
|
||||||
._version = COEX_ADAPTER_VERSION,
|
._version = COEX_ADAPTER_VERSION,
|
||||||
._task_yield_from_isr = task_yield_from_isr_wrapper,
|
._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper,
|
||||||
._semphr_create = semphr_create_wrapper,
|
._semphr_create = esp_coex_common_semphr_create_wrapper,
|
||||||
._semphr_delete = semphr_delete_wrapper,
|
._semphr_delete = esp_coex_common_semphr_delete_wrapper,
|
||||||
._semphr_take_from_isr = semphr_take_from_isr_wrapper,
|
._semphr_take_from_isr = esp_coex_semphr_take_from_isr_wrapper,
|
||||||
._semphr_give_from_isr = semphr_give_from_isr_wrapper,
|
._semphr_give_from_isr = esp_coex_semphr_give_from_isr_wrapper,
|
||||||
._semphr_take = semphr_take_wrapper,
|
._semphr_take = esp_coex_common_semphr_take_wrapper,
|
||||||
._semphr_give = semphr_give_wrapper,
|
._semphr_give = esp_coex_common_semphr_give_wrapper,
|
||||||
._is_in_isr = xPortInIsrContext,
|
._is_in_isr = xPortInIsrContext,
|
||||||
._malloc_internal = malloc_internal_wrapper,
|
._malloc_internal = esp_coex_common_malloc_internal_wrapper,
|
||||||
._free = free,
|
._free = free,
|
||||||
._esp_timer_get_time = esp_timer_get_time,
|
._esp_timer_get_time = esp_timer_get_time,
|
||||||
._env_is_chip = env_is_chip_wrapper,
|
._env_is_chip = esp_coex_common_env_is_chip_wrapper,
|
||||||
._slowclk_cal_get = esp_clk_slowclk_cal_get_wrapper,
|
._slowclk_cal_get = esp_coex_common_clk_slowclk_cal_get_wrapper,
|
||||||
._timer_disarm = timer_disarm_wrapper,
|
._timer_disarm = esp_coex_common_timer_disarm_wrapper,
|
||||||
._timer_done = timer_done_wrapper,
|
._timer_done = esp_coex_common_timer_done_wrapper,
|
||||||
._timer_setfn = timer_setfn_wrapper,
|
._timer_setfn = esp_coex_common_timer_setfn_wrapper,
|
||||||
._timer_arm_us = timer_arm_us_wrapper,
|
._timer_arm_us = esp_coex_common_timer_arm_us_wrapper,
|
||||||
._magic = COEX_ADAPTER_MAGIC,
|
._magic = COEX_ADAPTER_MAGIC,
|
||||||
};
|
};
|
||||||
|
@@ -18,39 +18,73 @@
|
|||||||
#include "freertos/portmacro.h"
|
#include "freertos/portmacro.h"
|
||||||
#include "esp_heap_caps.h"
|
#include "esp_heap_caps.h"
|
||||||
#include "esp_timer.h"
|
#include "esp_timer.h"
|
||||||
|
#include "soc/rtc.h"
|
||||||
|
#include "esp_private/esp_clk.h"
|
||||||
#include "esp_coexist_adapter.h"
|
#include "esp_coexist_adapter.h"
|
||||||
#include "esp32c3/rom/ets_sys.h"
|
#include "esp32c3/rom/ets_sys.h"
|
||||||
|
#include "soc/system_reg.h"
|
||||||
|
|
||||||
#define TAG "esp_coex_adapter"
|
#define TAG "esp_coex_adapter"
|
||||||
|
|
||||||
#define OSI_FUNCS_TIME_BLOCKING 0xffffffff
|
#define OSI_FUNCS_TIME_BLOCKING 0xffffffff
|
||||||
|
|
||||||
void IRAM_ATTR task_yield_from_isr_wrapper(void)
|
bool IRAM_ATTR esp_coex_common_env_is_chip_wrapper(void)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_IDF_ENV_FPGA
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void * esp_coex_common_spin_lock_create_wrapper(void)
|
||||||
|
{
|
||||||
|
portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED;
|
||||||
|
void *mux = malloc(sizeof(portMUX_TYPE));
|
||||||
|
|
||||||
|
if (mux) {
|
||||||
|
memcpy(mux,&tmp,sizeof(portMUX_TYPE));
|
||||||
|
return mux;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t IRAM_ATTR esp_coex_common_int_disable_wrapper(void *wifi_int_mux)
|
||||||
|
{
|
||||||
|
if (xPortInIsrContext()) {
|
||||||
|
portENTER_CRITICAL_ISR(wifi_int_mux);
|
||||||
|
} else {
|
||||||
|
portENTER_CRITICAL(wifi_int_mux);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRAM_ATTR esp_coex_common_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp)
|
||||||
|
{
|
||||||
|
if (xPortInIsrContext()) {
|
||||||
|
portEXIT_CRITICAL_ISR(wifi_int_mux);
|
||||||
|
} else {
|
||||||
|
portEXIT_CRITICAL(wifi_int_mux);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRAM_ATTR esp_coex_common_task_yield_from_isr_wrapper(void)
|
||||||
{
|
{
|
||||||
portYIELD_FROM_ISR();
|
portYIELD_FROM_ISR();
|
||||||
}
|
}
|
||||||
|
|
||||||
void * semphr_create_wrapper(uint32_t max, uint32_t init)
|
void * esp_coex_common_semphr_create_wrapper(uint32_t max, uint32_t init)
|
||||||
{
|
{
|
||||||
return (void *)xSemaphoreCreateCounting(max, init);
|
return (void *)xSemaphoreCreateCounting(max, init);
|
||||||
}
|
}
|
||||||
|
|
||||||
void semphr_delete_wrapper(void *semphr)
|
void esp_coex_common_semphr_delete_wrapper(void *semphr)
|
||||||
{
|
{
|
||||||
vSemaphoreDelete(semphr);
|
vSemaphoreDelete(semphr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t IRAM_ATTR semphr_take_from_isr_wrapper(void *semphr, void *hptw)
|
int32_t esp_coex_common_semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
|
||||||
{
|
|
||||||
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) {
|
if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
|
||||||
return (int32_t)xSemaphoreTake(semphr, portMAX_DELAY);
|
return (int32_t)xSemaphoreTake(semphr, portMAX_DELAY);
|
||||||
@@ -59,52 +93,77 @@ int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t semphr_give_wrapper(void *semphr)
|
int32_t esp_coex_common_semphr_give_wrapper(void *semphr)
|
||||||
{
|
{
|
||||||
return (int32_t)xSemaphoreGive(semphr);
|
return (int32_t)xSemaphoreGive(semphr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR timer_disarm_wrapper(void *timer)
|
void IRAM_ATTR esp_coex_common_timer_disarm_wrapper(void *timer)
|
||||||
{
|
{
|
||||||
ets_timer_disarm(timer);
|
ets_timer_disarm(timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void timer_done_wrapper(void *ptimer)
|
void esp_coex_common_timer_done_wrapper(void *ptimer)
|
||||||
{
|
{
|
||||||
ets_timer_done(ptimer);
|
ets_timer_done(ptimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg)
|
void esp_coex_common_timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg)
|
||||||
{
|
{
|
||||||
ets_timer_setfn(ptimer, pfunction, parg);
|
ets_timer_setfn(ptimer, pfunction, parg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat)
|
void IRAM_ATTR esp_coex_common_timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat)
|
||||||
{
|
{
|
||||||
ets_timer_arm_us(ptimer, us, repeat);
|
ets_timer_arm_us(ptimer, us, repeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void * IRAM_ATTR malloc_internal_wrapper(size_t size)
|
void * IRAM_ATTR esp_coex_common_malloc_internal_wrapper(size_t size)
|
||||||
{
|
{
|
||||||
return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
|
return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t esp_coex_common_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.
|
||||||
|
*/
|
||||||
|
if (GET_PERI_REG_MASK(SYSTEM_BT_LPCK_DIV_FRAC_REG, SYSTEM_LPCLK_SEL_XTAL)) {
|
||||||
|
uint64_t time_per_us = 1000000ULL;
|
||||||
|
return (((time_per_us << RTC_CLK_CAL_FRACT) / (MHZ)) >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH));
|
||||||
|
} else {
|
||||||
|
return (esp_clk_slowclk_cal_get() >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* static wrapper */
|
||||||
|
|
||||||
|
static int32_t IRAM_ATTR esp_coex_semphr_take_from_isr_wrapper(void *semphr, void *hptw)
|
||||||
|
{
|
||||||
|
return (int32_t)xSemaphoreTakeFromISR(semphr, hptw);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t IRAM_ATTR esp_coex_semphr_give_from_isr_wrapper(void *semphr, void *hptw)
|
||||||
|
{
|
||||||
|
return (int32_t)xSemaphoreGiveFromISR(semphr, hptw);
|
||||||
|
}
|
||||||
|
|
||||||
coex_adapter_funcs_t g_coex_adapter_funcs = {
|
coex_adapter_funcs_t g_coex_adapter_funcs = {
|
||||||
._version = COEX_ADAPTER_VERSION,
|
._version = COEX_ADAPTER_VERSION,
|
||||||
._task_yield_from_isr = task_yield_from_isr_wrapper,
|
._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper,
|
||||||
._semphr_create = semphr_create_wrapper,
|
._semphr_create = esp_coex_common_semphr_create_wrapper,
|
||||||
._semphr_delete = semphr_delete_wrapper,
|
._semphr_delete = esp_coex_common_semphr_delete_wrapper,
|
||||||
._semphr_take_from_isr = semphr_take_from_isr_wrapper,
|
._semphr_take_from_isr = esp_coex_semphr_take_from_isr_wrapper,
|
||||||
._semphr_give_from_isr = semphr_give_from_isr_wrapper,
|
._semphr_give_from_isr = esp_coex_semphr_give_from_isr_wrapper,
|
||||||
._semphr_take = semphr_take_wrapper,
|
._semphr_take = esp_coex_common_semphr_take_wrapper,
|
||||||
._semphr_give = semphr_give_wrapper,
|
._semphr_give = esp_coex_common_semphr_give_wrapper,
|
||||||
._is_in_isr = xPortInIsrContext,
|
._is_in_isr = xPortInIsrContext,
|
||||||
._malloc_internal = malloc_internal_wrapper,
|
._malloc_internal = esp_coex_common_malloc_internal_wrapper,
|
||||||
._free = free,
|
._free = free,
|
||||||
._esp_timer_get_time = esp_timer_get_time,
|
._esp_timer_get_time = esp_timer_get_time,
|
||||||
._timer_disarm = timer_disarm_wrapper,
|
._timer_disarm = esp_coex_common_timer_disarm_wrapper,
|
||||||
._timer_done = timer_done_wrapper,
|
._timer_done = esp_coex_common_timer_done_wrapper,
|
||||||
._timer_setfn = timer_setfn_wrapper,
|
._timer_setfn = esp_coex_common_timer_setfn_wrapper,
|
||||||
._timer_arm_us = timer_arm_us_wrapper,
|
._timer_arm_us = esp_coex_common_timer_arm_us_wrapper,
|
||||||
._magic = COEX_ADAPTER_MAGIC,
|
._magic = COEX_ADAPTER_MAGIC,
|
||||||
};
|
};
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#define OSI_FUNCS_TIME_BLOCKING 0xffffffff
|
#define OSI_FUNCS_TIME_BLOCKING 0xffffffff
|
||||||
|
|
||||||
bool IRAM_ATTR env_is_chip_wrapper(void)
|
bool IRAM_ATTR esp_coex_common_env_is_chip_wrapper(void)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_IDF_ENV_FPGA
|
#ifdef CONFIG_IDF_ENV_FPGA
|
||||||
return false;
|
return false;
|
||||||
@@ -36,32 +36,54 @@ bool IRAM_ATTR env_is_chip_wrapper(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR task_yield_from_isr_wrapper(void)
|
void *esp_coex_common_spin_lock_create_wrapper(void)
|
||||||
|
{
|
||||||
|
portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED;
|
||||||
|
void *mux = malloc(sizeof(portMUX_TYPE));
|
||||||
|
|
||||||
|
if (mux) {
|
||||||
|
memcpy(mux, &tmp, sizeof(portMUX_TYPE));
|
||||||
|
return mux;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t IRAM_ATTR esp_coex_common_int_disable_wrapper(void *wifi_int_mux)
|
||||||
|
{
|
||||||
|
if (xPortInIsrContext()) {
|
||||||
|
portENTER_CRITICAL_ISR(wifi_int_mux);
|
||||||
|
} else {
|
||||||
|
portENTER_CRITICAL(wifi_int_mux);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRAM_ATTR esp_coex_common_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp)
|
||||||
|
{
|
||||||
|
if (xPortInIsrContext()) {
|
||||||
|
portEXIT_CRITICAL_ISR(wifi_int_mux);
|
||||||
|
} else {
|
||||||
|
portEXIT_CRITICAL(wifi_int_mux);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRAM_ATTR esp_coex_common_task_yield_from_isr_wrapper(void)
|
||||||
{
|
{
|
||||||
portYIELD_FROM_ISR();
|
portYIELD_FROM_ISR();
|
||||||
}
|
}
|
||||||
|
|
||||||
void *semphr_create_wrapper(uint32_t max, uint32_t init)
|
void *esp_coex_common_semphr_create_wrapper(uint32_t max, uint32_t init)
|
||||||
{
|
{
|
||||||
return (void *)xSemaphoreCreateCounting(max, init);
|
return (void *)xSemaphoreCreateCounting(max, init);
|
||||||
}
|
}
|
||||||
|
|
||||||
void semphr_delete_wrapper(void *semphr)
|
void esp_coex_common_semphr_delete_wrapper(void *semphr)
|
||||||
{
|
{
|
||||||
vSemaphoreDelete(semphr);
|
vSemaphoreDelete(semphr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t IRAM_ATTR semphr_take_from_isr_wrapper(void *semphr, void *hptw)
|
int32_t esp_coex_common_semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
|
||||||
{
|
|
||||||
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) {
|
if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
|
||||||
return (int32_t)xSemaphoreTake(semphr, portMAX_DELAY);
|
return (int32_t)xSemaphoreTake(semphr, portMAX_DELAY);
|
||||||
@@ -70,32 +92,32 @@ int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t semphr_give_wrapper(void *semphr)
|
int32_t esp_coex_common_semphr_give_wrapper(void *semphr)
|
||||||
{
|
{
|
||||||
return (int32_t)xSemaphoreGive(semphr);
|
return (int32_t)xSemaphoreGive(semphr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR timer_disarm_wrapper(void *timer)
|
void IRAM_ATTR esp_coex_common_timer_disarm_wrapper(void *timer)
|
||||||
{
|
{
|
||||||
ets_timer_disarm(timer);
|
ets_timer_disarm(timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void timer_done_wrapper(void *ptimer)
|
void esp_coex_common_timer_done_wrapper(void *ptimer)
|
||||||
{
|
{
|
||||||
ets_timer_done(ptimer);
|
ets_timer_done(ptimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg)
|
void esp_coex_common_timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg)
|
||||||
{
|
{
|
||||||
ets_timer_setfn(ptimer, pfunction, parg);
|
ets_timer_setfn(ptimer, pfunction, parg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat)
|
void IRAM_ATTR esp_coex_common_timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat)
|
||||||
{
|
{
|
||||||
ets_timer_arm_us(ptimer, us, repeat);
|
ets_timer_arm_us(ptimer, us, repeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t esp_clk_slowclk_cal_get_wrapper(void)
|
uint32_t esp_coex_common_clk_slowclk_cal_get_wrapper(void)
|
||||||
{
|
{
|
||||||
/* The bit width of WiFi light sleep clock calibration is 12 while the one of
|
/* The bit width of WiFi light sleep clock calibration is 12 while the one of
|
||||||
* system is 19. It should shift 19 - 12 = 7.
|
* system is 19. It should shift 19 - 12 = 7.
|
||||||
@@ -103,29 +125,41 @@ uint32_t esp_clk_slowclk_cal_get_wrapper(void)
|
|||||||
return (esp_clk_slowclk_cal_get() >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH));
|
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)
|
void *IRAM_ATTR esp_coex_common_malloc_internal_wrapper(size_t size)
|
||||||
{
|
{
|
||||||
return heap_caps_malloc(size, MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
|
return heap_caps_malloc(size, MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* static wrapper */
|
||||||
|
|
||||||
|
static int32_t IRAM_ATTR esp_coex_semphr_take_from_isr_wrapper(void *semphr, void *hptw)
|
||||||
|
{
|
||||||
|
return (int32_t)xSemaphoreTakeFromISR(semphr, hptw);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t IRAM_ATTR esp_coex_semphr_give_from_isr_wrapper(void *semphr, void *hptw)
|
||||||
|
{
|
||||||
|
return (int32_t)xSemaphoreGiveFromISR(semphr, hptw);
|
||||||
|
}
|
||||||
|
|
||||||
coex_adapter_funcs_t g_coex_adapter_funcs = {
|
coex_adapter_funcs_t g_coex_adapter_funcs = {
|
||||||
._version = COEX_ADAPTER_VERSION,
|
._version = COEX_ADAPTER_VERSION,
|
||||||
._task_yield_from_isr = task_yield_from_isr_wrapper,
|
._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper,
|
||||||
._semphr_create = semphr_create_wrapper,
|
._semphr_create = esp_coex_common_semphr_create_wrapper,
|
||||||
._semphr_delete = semphr_delete_wrapper,
|
._semphr_delete = esp_coex_common_semphr_delete_wrapper,
|
||||||
._semphr_take_from_isr = semphr_take_from_isr_wrapper,
|
._semphr_take_from_isr = esp_coex_semphr_take_from_isr_wrapper,
|
||||||
._semphr_give_from_isr = semphr_give_from_isr_wrapper,
|
._semphr_give_from_isr = esp_coex_semphr_give_from_isr_wrapper,
|
||||||
._semphr_take = semphr_take_wrapper,
|
._semphr_take = esp_coex_common_semphr_take_wrapper,
|
||||||
._semphr_give = semphr_give_wrapper,
|
._semphr_give = esp_coex_common_semphr_give_wrapper,
|
||||||
._is_in_isr = xPortInIsrContext,
|
._is_in_isr = xPortInIsrContext,
|
||||||
._malloc_internal = malloc_internal_wrapper,
|
._malloc_internal = esp_coex_common_malloc_internal_wrapper,
|
||||||
._free = free,
|
._free = free,
|
||||||
._esp_timer_get_time = esp_timer_get_time,
|
._esp_timer_get_time = esp_timer_get_time,
|
||||||
._env_is_chip = env_is_chip_wrapper,
|
._env_is_chip = esp_coex_common_env_is_chip_wrapper,
|
||||||
._slowclk_cal_get = esp_clk_slowclk_cal_get_wrapper,
|
._slowclk_cal_get = esp_coex_common_clk_slowclk_cal_get_wrapper,
|
||||||
._timer_disarm = timer_disarm_wrapper,
|
._timer_disarm = esp_coex_common_timer_disarm_wrapper,
|
||||||
._timer_done = timer_done_wrapper,
|
._timer_done = esp_coex_common_timer_done_wrapper,
|
||||||
._timer_setfn = timer_setfn_wrapper,
|
._timer_setfn = esp_coex_common_timer_setfn_wrapper,
|
||||||
._timer_arm_us = timer_arm_us_wrapper,
|
._timer_arm_us = esp_coex_common_timer_arm_us_wrapper,
|
||||||
._magic = COEX_ADAPTER_MAGIC,
|
._magic = COEX_ADAPTER_MAGIC,
|
||||||
};
|
};
|
||||||
|
@@ -18,6 +18,8 @@
|
|||||||
#include "freertos/portmacro.h"
|
#include "freertos/portmacro.h"
|
||||||
#include "esp_heap_caps.h"
|
#include "esp_heap_caps.h"
|
||||||
#include "esp_timer.h"
|
#include "esp_timer.h"
|
||||||
|
#include "soc/rtc.h"
|
||||||
|
#include "esp_private/esp_clk.h"
|
||||||
#include "esp_coexist_adapter.h"
|
#include "esp_coexist_adapter.h"
|
||||||
#include "esp32s2/rom/ets_sys.h"
|
#include "esp32s2/rom/ets_sys.h"
|
||||||
|
|
||||||
@@ -30,12 +32,117 @@ typedef struct {
|
|||||||
void *storage; /**< storage for FreeRTOS queue */
|
void *storage; /**< storage for FreeRTOS queue */
|
||||||
} modem_static_queue_t;
|
} modem_static_queue_t;
|
||||||
|
|
||||||
void IRAM_ATTR task_yield_from_isr_wrapper(void)
|
bool IRAM_ATTR esp_coex_common_env_is_chip_wrapper(void)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_IDF_ENV_FPGA
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void * esp_coex_common_spin_lock_create_wrapper(void)
|
||||||
|
{
|
||||||
|
portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED;
|
||||||
|
void *mux = heap_caps_malloc(sizeof(portMUX_TYPE), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
|
||||||
|
|
||||||
|
if (mux) {
|
||||||
|
memcpy(mux,&tmp,sizeof(portMUX_TYPE));
|
||||||
|
return mux;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t IRAM_ATTR esp_coex_common_int_disable_wrapper(void *wifi_int_mux)
|
||||||
|
{
|
||||||
|
if (xPortInIsrContext()) {
|
||||||
|
portENTER_CRITICAL_ISR(wifi_int_mux);
|
||||||
|
} else {
|
||||||
|
portENTER_CRITICAL(wifi_int_mux);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRAM_ATTR esp_coex_common_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp)
|
||||||
|
{
|
||||||
|
if (xPortInIsrContext()) {
|
||||||
|
portEXIT_CRITICAL_ISR(wifi_int_mux);
|
||||||
|
} else {
|
||||||
|
portEXIT_CRITICAL(wifi_int_mux);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRAM_ATTR esp_coex_common_task_yield_from_isr_wrapper(void)
|
||||||
{
|
{
|
||||||
portYIELD_FROM_ISR();
|
portYIELD_FROM_ISR();
|
||||||
}
|
}
|
||||||
|
|
||||||
void *internal_semphr_create_wrapper(uint32_t max, uint32_t init)
|
void * esp_coex_common_semphr_create_wrapper(uint32_t max, uint32_t init)
|
||||||
|
{
|
||||||
|
return (void *)xSemaphoreCreateCounting(max, init);
|
||||||
|
}
|
||||||
|
|
||||||
|
void esp_coex_common_semphr_delete_wrapper(void *semphr)
|
||||||
|
{
|
||||||
|
vSemaphoreDelete(semphr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t esp_coex_common_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 esp_coex_common_semphr_give_wrapper(void *semphr)
|
||||||
|
{
|
||||||
|
return (int32_t)xSemaphoreGive(semphr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRAM_ATTR esp_coex_common_timer_disarm_wrapper(void *timer)
|
||||||
|
{
|
||||||
|
ets_timer_disarm(timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void esp_coex_common_timer_done_wrapper(void *ptimer)
|
||||||
|
{
|
||||||
|
ets_timer_done(ptimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void esp_coex_common_timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg)
|
||||||
|
{
|
||||||
|
ets_timer_setfn(ptimer, pfunction, parg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRAM_ATTR esp_coex_common_timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat)
|
||||||
|
{
|
||||||
|
ets_timer_arm_us(ptimer, us, repeat);
|
||||||
|
}
|
||||||
|
|
||||||
|
void * IRAM_ATTR esp_coex_common_malloc_internal_wrapper(size_t size)
|
||||||
|
{
|
||||||
|
return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t esp_coex_common_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 wrapper */
|
||||||
|
|
||||||
|
static int IRAM_ATTR esp_coex_is_in_isr_wrapper(void)
|
||||||
|
{
|
||||||
|
return !xPortCanYield();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *esp_coex_internal_semphr_create_wrapper(uint32_t max, uint32_t init)
|
||||||
{
|
{
|
||||||
modem_static_queue_t *semphr = heap_caps_calloc(1, sizeof(modem_static_queue_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
|
modem_static_queue_t *semphr = heap_caps_calloc(1, sizeof(modem_static_queue_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
|
||||||
if (!semphr) {
|
if (!semphr) {
|
||||||
@@ -69,7 +176,7 @@ _error:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void internal_semphr_delete_wrapper(void *semphr)
|
static void esp_coex_internal_semphr_delete_wrapper(void *semphr)
|
||||||
{
|
{
|
||||||
modem_static_queue_t *semphr_item = (modem_static_queue_t *)semphr;
|
modem_static_queue_t *semphr_item = (modem_static_queue_t *)semphr;
|
||||||
if (semphr_item) {
|
if (semphr_item) {
|
||||||
@@ -85,17 +192,17 @@ void internal_semphr_delete_wrapper(void *semphr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t IRAM_ATTR internal_semphr_take_from_isr_wrapper(void *semphr, void *hptw)
|
static int32_t IRAM_ATTR esp_coex_internal_semphr_take_from_isr_wrapper(void *semphr, void *hptw)
|
||||||
{
|
{
|
||||||
return (int32_t)xSemaphoreTakeFromISR(((modem_static_queue_t *)semphr)->handle, hptw);
|
return (int32_t)xSemaphoreTakeFromISR(((modem_static_queue_t *)semphr)->handle, hptw);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t IRAM_ATTR internal_semphr_give_from_isr_wrapper(void *semphr, void *hptw)
|
static int32_t IRAM_ATTR esp_coex_internal_semphr_give_from_isr_wrapper(void *semphr, void *hptw)
|
||||||
{
|
{
|
||||||
return (int32_t)xSemaphoreGiveFromISR(((modem_static_queue_t *)semphr)->handle, hptw);
|
return (int32_t)xSemaphoreGiveFromISR(((modem_static_queue_t *)semphr)->handle, hptw);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
|
static int32_t esp_coex_internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
|
||||||
{
|
{
|
||||||
if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
|
if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
|
||||||
return (int32_t)xSemaphoreTake(((modem_static_queue_t *)semphr)->handle, portMAX_DELAY);
|
return (int32_t)xSemaphoreTake(((modem_static_queue_t *)semphr)->handle, portMAX_DELAY);
|
||||||
@@ -104,57 +211,27 @@ int32_t internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t internal_semphr_give_wrapper(void *semphr)
|
static int32_t esp_coex_internal_semphr_give_wrapper(void *semphr)
|
||||||
{
|
{
|
||||||
return (int32_t)xSemaphoreGive(((modem_static_queue_t *)semphr)->handle);
|
return (int32_t)xSemaphoreGive(((modem_static_queue_t *)semphr)->handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
void * IRAM_ATTR malloc_internal_wrapper(size_t size)
|
|
||||||
{
|
|
||||||
return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int IRAM_ATTR coex_is_in_isr_wrapper(void)
|
|
||||||
{
|
|
||||||
return !xPortCanYield();
|
|
||||||
}
|
|
||||||
|
|
||||||
coex_adapter_funcs_t g_coex_adapter_funcs = {
|
coex_adapter_funcs_t g_coex_adapter_funcs = {
|
||||||
._version = COEX_ADAPTER_VERSION,
|
._version = COEX_ADAPTER_VERSION,
|
||||||
._task_yield_from_isr = task_yield_from_isr_wrapper,
|
._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper,
|
||||||
._semphr_create = internal_semphr_create_wrapper,
|
._semphr_create = esp_coex_internal_semphr_create_wrapper,
|
||||||
._semphr_delete = internal_semphr_delete_wrapper,
|
._semphr_delete = esp_coex_internal_semphr_delete_wrapper,
|
||||||
._semphr_take_from_isr = internal_semphr_take_from_isr_wrapper,
|
._semphr_take_from_isr = esp_coex_internal_semphr_take_from_isr_wrapper,
|
||||||
._semphr_give_from_isr = internal_semphr_give_from_isr_wrapper,
|
._semphr_give_from_isr = esp_coex_internal_semphr_give_from_isr_wrapper,
|
||||||
._semphr_take = internal_semphr_take_wrapper,
|
._semphr_take = esp_coex_internal_semphr_take_wrapper,
|
||||||
._semphr_give = internal_semphr_give_wrapper,
|
._semphr_give = esp_coex_internal_semphr_give_wrapper,
|
||||||
._is_in_isr = coex_is_in_isr_wrapper,
|
._is_in_isr = esp_coex_is_in_isr_wrapper,
|
||||||
._malloc_internal = malloc_internal_wrapper,
|
._malloc_internal = esp_coex_common_malloc_internal_wrapper,
|
||||||
._free = free,
|
._free = free,
|
||||||
._esp_timer_get_time = esp_timer_get_time,
|
._esp_timer_get_time = esp_timer_get_time,
|
||||||
._timer_disarm = timer_disarm_wrapper,
|
._timer_disarm = esp_coex_common_timer_disarm_wrapper,
|
||||||
._timer_done = timer_done_wrapper,
|
._timer_done = esp_coex_common_timer_done_wrapper,
|
||||||
._timer_setfn = timer_setfn_wrapper,
|
._timer_setfn = esp_coex_common_timer_setfn_wrapper,
|
||||||
._timer_arm_us = timer_arm_us_wrapper,
|
._timer_arm_us = esp_coex_common_timer_arm_us_wrapper,
|
||||||
._magic = COEX_ADAPTER_MAGIC,
|
._magic = COEX_ADAPTER_MAGIC,
|
||||||
};
|
};
|
||||||
|
@@ -18,8 +18,11 @@
|
|||||||
#include "freertos/portmacro.h"
|
#include "freertos/portmacro.h"
|
||||||
#include "esp_heap_caps.h"
|
#include "esp_heap_caps.h"
|
||||||
#include "esp_timer.h"
|
#include "esp_timer.h"
|
||||||
|
#include "soc/rtc.h"
|
||||||
|
#include "esp_private/esp_clk.h"
|
||||||
#include "esp_coexist_adapter.h"
|
#include "esp_coexist_adapter.h"
|
||||||
#include "esp32s3/rom/ets_sys.h"
|
#include "esp32s3/rom/ets_sys.h"
|
||||||
|
#include "soc/system_reg.h"
|
||||||
|
|
||||||
#define TAG "esp_coex_adapter"
|
#define TAG "esp_coex_adapter"
|
||||||
|
|
||||||
@@ -30,12 +33,122 @@ typedef struct {
|
|||||||
void *storage; /**< storage for FreeRTOS queue */
|
void *storage; /**< storage for FreeRTOS queue */
|
||||||
} modem_static_queue_t;
|
} modem_static_queue_t;
|
||||||
|
|
||||||
void IRAM_ATTR task_yield_from_isr_wrapper(void)
|
bool IRAM_ATTR esp_coex_common_env_is_chip_wrapper(void)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_IDF_ENV_FPGA
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void * esp_coex_common_spin_lock_create_wrapper(void)
|
||||||
|
{
|
||||||
|
portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED;
|
||||||
|
void *mux = heap_caps_malloc(sizeof(portMUX_TYPE), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
|
||||||
|
|
||||||
|
if (mux) {
|
||||||
|
memcpy(mux,&tmp,sizeof(portMUX_TYPE));
|
||||||
|
return mux;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t IRAM_ATTR esp_coex_common_int_disable_wrapper(void *wifi_int_mux)
|
||||||
|
{
|
||||||
|
if (xPortInIsrContext()) {
|
||||||
|
portENTER_CRITICAL_ISR(wifi_int_mux);
|
||||||
|
} else {
|
||||||
|
portENTER_CRITICAL(wifi_int_mux);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRAM_ATTR esp_coex_common_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp)
|
||||||
|
{
|
||||||
|
if (xPortInIsrContext()) {
|
||||||
|
portEXIT_CRITICAL_ISR(wifi_int_mux);
|
||||||
|
} else {
|
||||||
|
portEXIT_CRITICAL(wifi_int_mux);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRAM_ATTR esp_coex_common_task_yield_from_isr_wrapper(void)
|
||||||
{
|
{
|
||||||
portYIELD_FROM_ISR();
|
portYIELD_FROM_ISR();
|
||||||
}
|
}
|
||||||
|
|
||||||
void *internal_semphr_create_wrapper(uint32_t max, uint32_t init)
|
void * esp_coex_common_semphr_create_wrapper(uint32_t max, uint32_t init)
|
||||||
|
{
|
||||||
|
return (void *)xSemaphoreCreateCounting(max, init);
|
||||||
|
}
|
||||||
|
|
||||||
|
void esp_coex_common_semphr_delete_wrapper(void *semphr)
|
||||||
|
{
|
||||||
|
vSemaphoreDelete(semphr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t esp_coex_common_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 esp_coex_common_semphr_give_wrapper(void *semphr)
|
||||||
|
{
|
||||||
|
return (int32_t)xSemaphoreGive(semphr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRAM_ATTR esp_coex_common_timer_disarm_wrapper(void *timer)
|
||||||
|
{
|
||||||
|
ets_timer_disarm(timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void esp_coex_common_timer_done_wrapper(void *ptimer)
|
||||||
|
{
|
||||||
|
ets_timer_done(ptimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void esp_coex_common_timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg)
|
||||||
|
{
|
||||||
|
ets_timer_setfn(ptimer, pfunction, parg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRAM_ATTR esp_coex_common_timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat)
|
||||||
|
{
|
||||||
|
ets_timer_arm_us(ptimer, us, repeat);
|
||||||
|
}
|
||||||
|
|
||||||
|
void * IRAM_ATTR esp_coex_common_malloc_internal_wrapper(size_t size)
|
||||||
|
{
|
||||||
|
return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t esp_coex_common_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.
|
||||||
|
*/
|
||||||
|
if (GET_PERI_REG_MASK(SYSTEM_BT_LPCK_DIV_FRAC_REG, SYSTEM_LPCLK_SEL_XTAL)) {
|
||||||
|
uint64_t time_per_us = 1000000ULL;
|
||||||
|
return (((time_per_us << RTC_CLK_CAL_FRACT) / (MHZ)) >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH));
|
||||||
|
} else {
|
||||||
|
return (esp_clk_slowclk_cal_get() >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* static wrapper */
|
||||||
|
|
||||||
|
static int IRAM_ATTR esp_coex_is_in_isr_wrapper(void)
|
||||||
|
{
|
||||||
|
return !xPortCanYield();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *esp_coex_internal_semphr_create_wrapper(uint32_t max, uint32_t init)
|
||||||
{
|
{
|
||||||
modem_static_queue_t *semphr = heap_caps_calloc(1, sizeof(modem_static_queue_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
|
modem_static_queue_t *semphr = heap_caps_calloc(1, sizeof(modem_static_queue_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
|
||||||
if (!semphr) {
|
if (!semphr) {
|
||||||
@@ -69,7 +182,7 @@ _error:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void internal_semphr_delete_wrapper(void *semphr)
|
static void esp_coex_internal_semphr_delete_wrapper(void *semphr)
|
||||||
{
|
{
|
||||||
modem_static_queue_t *semphr_item = (modem_static_queue_t *)semphr;
|
modem_static_queue_t *semphr_item = (modem_static_queue_t *)semphr;
|
||||||
if (semphr_item) {
|
if (semphr_item) {
|
||||||
@@ -85,17 +198,17 @@ void internal_semphr_delete_wrapper(void *semphr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t IRAM_ATTR internal_semphr_take_from_isr_wrapper(void *semphr, void *hptw)
|
static int32_t IRAM_ATTR esp_coex_internal_semphr_take_from_isr_wrapper(void *semphr, void *hptw)
|
||||||
{
|
{
|
||||||
return (int32_t)xSemaphoreTakeFromISR(((modem_static_queue_t *)semphr)->handle, hptw);
|
return (int32_t)xSemaphoreTakeFromISR(((modem_static_queue_t *)semphr)->handle, hptw);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t IRAM_ATTR internal_semphr_give_from_isr_wrapper(void *semphr, void *hptw)
|
static int32_t IRAM_ATTR esp_coex_internal_semphr_give_from_isr_wrapper(void *semphr, void *hptw)
|
||||||
{
|
{
|
||||||
return (int32_t)xSemaphoreGiveFromISR(((modem_static_queue_t *)semphr)->handle, hptw);
|
return (int32_t)xSemaphoreGiveFromISR(((modem_static_queue_t *)semphr)->handle, hptw);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
|
static int32_t esp_coex_internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
|
||||||
{
|
{
|
||||||
if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
|
if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
|
||||||
return (int32_t)xSemaphoreTake(((modem_static_queue_t *)semphr)->handle, portMAX_DELAY);
|
return (int32_t)xSemaphoreTake(((modem_static_queue_t *)semphr)->handle, portMAX_DELAY);
|
||||||
@@ -104,57 +217,27 @@ int32_t internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t internal_semphr_give_wrapper(void *semphr)
|
static int32_t esp_coex_internal_semphr_give_wrapper(void *semphr)
|
||||||
{
|
{
|
||||||
return (int32_t)xSemaphoreGive(((modem_static_queue_t *)semphr)->handle);
|
return (int32_t)xSemaphoreGive(((modem_static_queue_t *)semphr)->handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
void * IRAM_ATTR malloc_internal_wrapper(size_t size)
|
|
||||||
{
|
|
||||||
return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int IRAM_ATTR coex_is_in_isr_wrapper(void)
|
|
||||||
{
|
|
||||||
return !xPortCanYield();
|
|
||||||
}
|
|
||||||
|
|
||||||
coex_adapter_funcs_t g_coex_adapter_funcs = {
|
coex_adapter_funcs_t g_coex_adapter_funcs = {
|
||||||
._version = COEX_ADAPTER_VERSION,
|
._version = COEX_ADAPTER_VERSION,
|
||||||
._task_yield_from_isr = task_yield_from_isr_wrapper,
|
._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper,
|
||||||
._semphr_create = internal_semphr_create_wrapper,
|
._semphr_create = esp_coex_internal_semphr_create_wrapper,
|
||||||
._semphr_delete = internal_semphr_delete_wrapper,
|
._semphr_delete = esp_coex_internal_semphr_delete_wrapper,
|
||||||
._semphr_take_from_isr = internal_semphr_take_from_isr_wrapper,
|
._semphr_take_from_isr = esp_coex_internal_semphr_take_from_isr_wrapper,
|
||||||
._semphr_give_from_isr = internal_semphr_give_from_isr_wrapper,
|
._semphr_give_from_isr = esp_coex_internal_semphr_give_from_isr_wrapper,
|
||||||
._semphr_take = internal_semphr_take_wrapper,
|
._semphr_take = esp_coex_internal_semphr_take_wrapper,
|
||||||
._semphr_give = internal_semphr_give_wrapper,
|
._semphr_give = esp_coex_internal_semphr_give_wrapper,
|
||||||
._is_in_isr = coex_is_in_isr_wrapper,
|
._is_in_isr = esp_coex_is_in_isr_wrapper,
|
||||||
._malloc_internal = malloc_internal_wrapper,
|
._malloc_internal = esp_coex_common_malloc_internal_wrapper,
|
||||||
._free = free,
|
._free = free,
|
||||||
._esp_timer_get_time = esp_timer_get_time,
|
._esp_timer_get_time = esp_timer_get_time,
|
||||||
._timer_disarm = timer_disarm_wrapper,
|
._timer_disarm = esp_coex_common_timer_disarm_wrapper,
|
||||||
._timer_done = timer_done_wrapper,
|
._timer_done = esp_coex_common_timer_done_wrapper,
|
||||||
._timer_setfn = timer_setfn_wrapper,
|
._timer_setfn = esp_coex_common_timer_setfn_wrapper,
|
||||||
._timer_arm_us = timer_arm_us_wrapper,
|
._timer_arm_us = esp_coex_common_timer_arm_us_wrapper,
|
||||||
._magic = COEX_ADAPTER_MAGIC,
|
._magic = COEX_ADAPTER_MAGIC,
|
||||||
};
|
};
|
||||||
|
@@ -15,44 +15,36 @@ extern "C" {
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
bool esp_coex_common_env_is_chip_wrapper(void);
|
||||||
void * spin_lock_create_wrapper(void);
|
|
||||||
|
|
||||||
uint32_t wifi_int_disable_wrapper(void *wifi_int_mux);
|
void * esp_coex_common_spin_lock_create_wrapper(void);
|
||||||
|
|
||||||
void wifi_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp);
|
uint32_t esp_coex_common_int_disable_wrapper(void *wifi_int_mux);
|
||||||
#endif
|
|
||||||
|
|
||||||
void task_yield_from_isr_wrapper(void);
|
void esp_coex_common_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp);
|
||||||
|
|
||||||
#if !defined(CONFIG_IDF_TARGET_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32S3)
|
void esp_coex_common_task_yield_from_isr_wrapper(void);
|
||||||
void * semphr_create_wrapper(uint32_t max, uint32_t init);
|
|
||||||
|
|
||||||
void semphr_delete_wrapper(void *semphr);
|
void * esp_coex_common_semphr_create_wrapper(uint32_t max, uint32_t init);
|
||||||
|
|
||||||
int32_t semphr_take_from_isr_wrapper(void *semphr, void *hptw);
|
void esp_coex_common_semphr_delete_wrapper(void *semphr);
|
||||||
|
|
||||||
int32_t semphr_give_from_isr_wrapper(void *semphr, void *hptw);
|
int32_t esp_coex_common_semphr_take_wrapper(void *semphr, uint32_t block_time_tick);
|
||||||
|
|
||||||
int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick);
|
int32_t esp_coex_common_semphr_give_wrapper(void *semphr);
|
||||||
|
|
||||||
int32_t semphr_give_wrapper(void *semphr);
|
void esp_coex_common_timer_disarm_wrapper(void *timer);
|
||||||
#endif
|
|
||||||
|
|
||||||
void timer_disarm_wrapper(void *timer);
|
void esp_coex_common_timer_done_wrapper(void *ptimer);
|
||||||
|
|
||||||
void timer_done_wrapper(void *ptimer);
|
void esp_coex_common_timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg);
|
||||||
|
|
||||||
void timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg);
|
void esp_coex_common_timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat);
|
||||||
|
|
||||||
void timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat);
|
void * esp_coex_common_malloc_internal_wrapper(size_t size);
|
||||||
|
|
||||||
void * malloc_internal_wrapper(size_t size);
|
#ifndef CONFIG_IDF_TARGET_ESP32
|
||||||
|
uint32_t esp_coex_common_clk_slowclk_cal_get_wrapper(void);
|
||||||
#if CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C6
|
|
||||||
bool env_is_chip_wrapper(void);
|
|
||||||
|
|
||||||
uint32_t esp_clk_slowclk_cal_get_wrapper(void);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@@ -172,15 +172,6 @@ static void wifi_delete_queue_wrapper(void *queue)
|
|||||||
wifi_delete_queue(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)
|
static void set_intr_wrapper(int32_t cpu_no, uint32_t intr_source, uint32_t intr_num, int32_t intr_prio)
|
||||||
{
|
{
|
||||||
esp_rom_route_intr_matrix(cpu_no, intr_source, intr_num);
|
esp_rom_route_intr_matrix(cpu_no, intr_source, intr_num);
|
||||||
@@ -201,16 +192,6 @@ static bool IRAM_ATTR is_from_isr_wrapper(void)
|
|||||||
return !xPortCanYield();
|
return !xPortCanYield();
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
static void wifi_thread_semphr_free(void* data)
|
||||||
{
|
{
|
||||||
SemaphoreHandle_t *sem = (SemaphoreHandle_t*)(data);
|
SemaphoreHandle_t *sem = (SemaphoreHandle_t*)(data);
|
||||||
@@ -246,20 +227,6 @@ static void * wifi_thread_semphr_get_wrapper(void)
|
|||||||
return (void*)sem;
|
return (void*)sem;
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
static void * recursive_mutex_create_wrapper(void)
|
||||||
{
|
{
|
||||||
return (void *)xSemaphoreCreateRecursiveMutex();
|
return (void *)xSemaphoreCreateRecursiveMutex();
|
||||||
@@ -589,22 +556,22 @@ static void IRAM_ATTR esp_empty_wrapper(void)
|
|||||||
|
|
||||||
wifi_osi_funcs_t g_wifi_osi_funcs = {
|
wifi_osi_funcs_t g_wifi_osi_funcs = {
|
||||||
._version = ESP_WIFI_OS_ADAPTER_VERSION,
|
._version = ESP_WIFI_OS_ADAPTER_VERSION,
|
||||||
._env_is_chip = env_is_chip_wrapper,
|
._env_is_chip = esp_coex_common_env_is_chip_wrapper,
|
||||||
._set_intr = set_intr_wrapper,
|
._set_intr = set_intr_wrapper,
|
||||||
._clear_intr = clear_intr_wrapper,
|
._clear_intr = clear_intr_wrapper,
|
||||||
._set_isr = set_isr_wrapper,
|
._set_isr = set_isr_wrapper,
|
||||||
._ints_on = esp_cpu_intr_enable,
|
._ints_on = esp_cpu_intr_enable,
|
||||||
._ints_off = esp_cpu_intr_disable,
|
._ints_off = esp_cpu_intr_disable,
|
||||||
._is_from_isr = is_from_isr_wrapper,
|
._is_from_isr = is_from_isr_wrapper,
|
||||||
._spin_lock_create = spin_lock_create_wrapper,
|
._spin_lock_create = esp_coex_common_spin_lock_create_wrapper,
|
||||||
._spin_lock_delete = free,
|
._spin_lock_delete = free,
|
||||||
._wifi_int_disable = wifi_int_disable_wrapper,
|
._wifi_int_disable = esp_coex_common_int_disable_wrapper,
|
||||||
._wifi_int_restore = wifi_int_restore_wrapper,
|
._wifi_int_restore = esp_coex_common_int_restore_wrapper,
|
||||||
._task_yield_from_isr = task_yield_from_isr_wrapper,
|
._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper,
|
||||||
._semphr_create = semphr_create_wrapper,
|
._semphr_create = esp_coex_common_semphr_create_wrapper,
|
||||||
._semphr_delete = semphr_delete_wrapper,
|
._semphr_delete = esp_coex_common_semphr_delete_wrapper,
|
||||||
._semphr_take = semphr_take_wrapper,
|
._semphr_take = esp_coex_common_semphr_take_wrapper,
|
||||||
._semphr_give = semphr_give_wrapper,
|
._semphr_give = esp_coex_common_semphr_give_wrapper,
|
||||||
._wifi_thread_semphr_get = wifi_thread_semphr_get_wrapper,
|
._wifi_thread_semphr_get = wifi_thread_semphr_get_wrapper,
|
||||||
._mutex_create = mutex_create_wrapper,
|
._mutex_create = mutex_create_wrapper,
|
||||||
._recursive_mutex_create = recursive_mutex_create_wrapper,
|
._recursive_mutex_create = recursive_mutex_create_wrapper,
|
||||||
@@ -647,10 +614,10 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
|
|||||||
._phy_update_country_info = esp_phy_update_country_info,
|
._phy_update_country_info = esp_phy_update_country_info,
|
||||||
._read_mac = esp_read_mac,
|
._read_mac = esp_read_mac,
|
||||||
._timer_arm = timer_arm_wrapper,
|
._timer_arm = timer_arm_wrapper,
|
||||||
._timer_disarm = timer_disarm_wrapper,
|
._timer_disarm = esp_coex_common_timer_disarm_wrapper,
|
||||||
._timer_done = timer_done_wrapper,
|
._timer_done = esp_coex_common_timer_done_wrapper,
|
||||||
._timer_setfn = timer_setfn_wrapper,
|
._timer_setfn = esp_coex_common_timer_setfn_wrapper,
|
||||||
._timer_arm_us = timer_arm_us_wrapper,
|
._timer_arm_us = esp_coex_common_timer_arm_us_wrapper,
|
||||||
._wifi_reset_mac = wifi_reset_mac_wrapper,
|
._wifi_reset_mac = wifi_reset_mac_wrapper,
|
||||||
._wifi_clock_enable = wifi_clock_enable_wrapper,
|
._wifi_clock_enable = wifi_clock_enable_wrapper,
|
||||||
._wifi_clock_disable = wifi_clock_disable_wrapper,
|
._wifi_clock_disable = wifi_clock_disable_wrapper,
|
||||||
@@ -675,7 +642,7 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
|
|||||||
._log_write = esp_log_write,
|
._log_write = esp_log_write,
|
||||||
._log_writev = esp_log_writev,
|
._log_writev = esp_log_writev,
|
||||||
._log_timestamp = esp_log_timestamp,
|
._log_timestamp = esp_log_timestamp,
|
||||||
._malloc_internal = malloc_internal_wrapper,
|
._malloc_internal = esp_coex_common_malloc_internal_wrapper,
|
||||||
._realloc_internal = realloc_internal_wrapper,
|
._realloc_internal = realloc_internal_wrapper,
|
||||||
._calloc_internal = calloc_internal_wrapper,
|
._calloc_internal = calloc_internal_wrapper,
|
||||||
._zalloc_internal = zalloc_internal_wrapper,
|
._zalloc_internal = zalloc_internal_wrapper,
|
||||||
|
@@ -130,38 +130,6 @@ static void disable_intr_wrapper(uint32_t intr_mask)
|
|||||||
esprv_intc_int_disable(intr_mask);
|
esprv_intc_int_disable(intr_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * spin_lock_create_wrapper(void)
|
|
||||||
{
|
|
||||||
portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED;
|
|
||||||
void *mux = malloc(sizeof(portMUX_TYPE));
|
|
||||||
|
|
||||||
if (mux) {
|
|
||||||
memcpy(mux,&tmp,sizeof(portMUX_TYPE));
|
|
||||||
return mux;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint32_t IRAM_ATTR wifi_int_disable_wrapper(void *wifi_int_mux)
|
|
||||||
{
|
|
||||||
if (xPortInIsrContext()) {
|
|
||||||
portENTER_CRITICAL_ISR(wifi_int_mux);
|
|
||||||
} else {
|
|
||||||
portENTER_CRITICAL(wifi_int_mux);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void IRAM_ATTR wifi_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp)
|
|
||||||
{
|
|
||||||
if (xPortInIsrContext()) {
|
|
||||||
portEXIT_CRITICAL_ISR(wifi_int_mux);
|
|
||||||
} else {
|
|
||||||
portEXIT_CRITICAL(wifi_int_mux);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool IRAM_ATTR is_from_isr_wrapper(void)
|
static bool IRAM_ATTR is_from_isr_wrapper(void)
|
||||||
{
|
{
|
||||||
return !xPortCanYield();
|
return !xPortCanYield();
|
||||||
@@ -572,22 +540,22 @@ static void IRAM_ATTR esp_empty_wrapper(void)
|
|||||||
|
|
||||||
wifi_osi_funcs_t g_wifi_osi_funcs = {
|
wifi_osi_funcs_t g_wifi_osi_funcs = {
|
||||||
._version = ESP_WIFI_OS_ADAPTER_VERSION,
|
._version = ESP_WIFI_OS_ADAPTER_VERSION,
|
||||||
._env_is_chip = env_is_chip_wrapper,
|
._env_is_chip = esp_coex_common_env_is_chip_wrapper,
|
||||||
._set_intr = set_intr_wrapper,
|
._set_intr = set_intr_wrapper,
|
||||||
._clear_intr = clear_intr_wrapper,
|
._clear_intr = clear_intr_wrapper,
|
||||||
._set_isr = set_isr_wrapper,
|
._set_isr = set_isr_wrapper,
|
||||||
._ints_on = enable_intr_wrapper,
|
._ints_on = enable_intr_wrapper,
|
||||||
._ints_off = disable_intr_wrapper,
|
._ints_off = disable_intr_wrapper,
|
||||||
._is_from_isr = is_from_isr_wrapper,
|
._is_from_isr = is_from_isr_wrapper,
|
||||||
._spin_lock_create = spin_lock_create_wrapper,
|
._spin_lock_create = esp_coex_common_spin_lock_create_wrapper,
|
||||||
._spin_lock_delete = free,
|
._spin_lock_delete = free,
|
||||||
._wifi_int_disable = wifi_int_disable_wrapper,
|
._wifi_int_disable = esp_coex_common_int_disable_wrapper,
|
||||||
._wifi_int_restore = wifi_int_restore_wrapper,
|
._wifi_int_restore = esp_coex_common_int_restore_wrapper,
|
||||||
._task_yield_from_isr = task_yield_from_isr_wrapper,
|
._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper,
|
||||||
._semphr_create = semphr_create_wrapper,
|
._semphr_create = esp_coex_common_semphr_create_wrapper,
|
||||||
._semphr_delete = semphr_delete_wrapper,
|
._semphr_delete = esp_coex_common_semphr_delete_wrapper,
|
||||||
._semphr_take = semphr_take_wrapper,
|
._semphr_take = esp_coex_common_semphr_take_wrapper,
|
||||||
._semphr_give = semphr_give_wrapper,
|
._semphr_give = esp_coex_common_semphr_give_wrapper,
|
||||||
._wifi_thread_semphr_get = wifi_thread_semphr_get_wrapper,
|
._wifi_thread_semphr_get = wifi_thread_semphr_get_wrapper,
|
||||||
._mutex_create = mutex_create_wrapper,
|
._mutex_create = mutex_create_wrapper,
|
||||||
._recursive_mutex_create = recursive_mutex_create_wrapper,
|
._recursive_mutex_create = recursive_mutex_create_wrapper,
|
||||||
@@ -628,10 +596,10 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
|
|||||||
._phy_update_country_info = esp_phy_update_country_info,
|
._phy_update_country_info = esp_phy_update_country_info,
|
||||||
._read_mac = esp_read_mac_wrapper,
|
._read_mac = esp_read_mac_wrapper,
|
||||||
._timer_arm = timer_arm_wrapper,
|
._timer_arm = timer_arm_wrapper,
|
||||||
._timer_disarm = timer_disarm_wrapper,
|
._timer_disarm = esp_coex_common_timer_disarm_wrapper,
|
||||||
._timer_done = timer_done_wrapper,
|
._timer_done = esp_coex_common_timer_done_wrapper,
|
||||||
._timer_setfn = timer_setfn_wrapper,
|
._timer_setfn = esp_coex_common_timer_setfn_wrapper,
|
||||||
._timer_arm_us = timer_arm_us_wrapper,
|
._timer_arm_us = esp_coex_common_timer_arm_us_wrapper,
|
||||||
._wifi_reset_mac = wifi_reset_mac_wrapper,
|
._wifi_reset_mac = wifi_reset_mac_wrapper,
|
||||||
._wifi_clock_enable = wifi_clock_enable_wrapper,
|
._wifi_clock_enable = wifi_clock_enable_wrapper,
|
||||||
._wifi_clock_disable = wifi_clock_disable_wrapper,
|
._wifi_clock_disable = wifi_clock_disable_wrapper,
|
||||||
@@ -653,11 +621,11 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
|
|||||||
._get_random = os_get_random,
|
._get_random = os_get_random,
|
||||||
._get_time = get_time_wrapper,
|
._get_time = get_time_wrapper,
|
||||||
._random = os_random,
|
._random = os_random,
|
||||||
._slowclk_cal_get = esp_clk_slowclk_cal_get_wrapper,
|
._slowclk_cal_get = esp_coex_common_clk_slowclk_cal_get_wrapper,
|
||||||
._log_write = esp_log_write_wrapper,
|
._log_write = esp_log_write_wrapper,
|
||||||
._log_writev = esp_log_writev_wrapper,
|
._log_writev = esp_log_writev_wrapper,
|
||||||
._log_timestamp = esp_log_timestamp,
|
._log_timestamp = esp_log_timestamp,
|
||||||
._malloc_internal = malloc_internal_wrapper,
|
._malloc_internal = esp_coex_common_malloc_internal_wrapper,
|
||||||
._realloc_internal = realloc_internal_wrapper,
|
._realloc_internal = realloc_internal_wrapper,
|
||||||
._calloc_internal = calloc_internal_wrapper,
|
._calloc_internal = calloc_internal_wrapper,
|
||||||
._zalloc_internal = zalloc_internal_wrapper,
|
._zalloc_internal = zalloc_internal_wrapper,
|
||||||
|
@@ -106,15 +106,6 @@ static void wifi_delete_queue_wrapper(void *queue)
|
|||||||
wifi_delete_queue(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)
|
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);
|
intr_matrix_route(intr_source, intr_num);
|
||||||
@@ -142,38 +133,6 @@ static void disable_intr_wrapper(uint32_t intr_mask)
|
|||||||
esprv_intc_int_disable(intr_mask);
|
esprv_intc_int_disable(intr_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * spin_lock_create_wrapper(void)
|
|
||||||
{
|
|
||||||
portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED;
|
|
||||||
void *mux = malloc(sizeof(portMUX_TYPE));
|
|
||||||
|
|
||||||
if (mux) {
|
|
||||||
memcpy(mux,&tmp,sizeof(portMUX_TYPE));
|
|
||||||
return mux;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint32_t IRAM_ATTR wifi_int_disable_wrapper(void *wifi_int_mux)
|
|
||||||
{
|
|
||||||
if (xPortInIsrContext()) {
|
|
||||||
portENTER_CRITICAL_ISR(wifi_int_mux);
|
|
||||||
} else {
|
|
||||||
portENTER_CRITICAL(wifi_int_mux);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void IRAM_ATTR wifi_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp)
|
|
||||||
{
|
|
||||||
if (xPortInIsrContext()) {
|
|
||||||
portEXIT_CRITICAL_ISR(wifi_int_mux);
|
|
||||||
} else {
|
|
||||||
portEXIT_CRITICAL(wifi_int_mux);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool IRAM_ATTR is_from_isr_wrapper(void)
|
static bool IRAM_ATTR is_from_isr_wrapper(void)
|
||||||
{
|
{
|
||||||
return !xPortCanYield();
|
return !xPortCanYield();
|
||||||
@@ -368,19 +327,6 @@ static int get_time_wrapper(void *t)
|
|||||||
return os_get_time(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.
|
|
||||||
*/
|
|
||||||
if (GET_PERI_REG_MASK(SYSTEM_BT_LPCK_DIV_FRAC_REG, SYSTEM_LPCLK_SEL_XTAL)) {
|
|
||||||
uint64_t time_per_us = 1000000ULL;
|
|
||||||
return (((time_per_us << RTC_CLK_CAL_FRACT) / (MHZ)) >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH));
|
|
||||||
} else {
|
|
||||||
return (esp_clk_slowclk_cal_get() >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void * IRAM_ATTR realloc_internal_wrapper(void *ptr, size_t size)
|
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);
|
return heap_caps_realloc(ptr, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
|
||||||
@@ -597,22 +543,22 @@ static void IRAM_ATTR esp_empty_wrapper(void)
|
|||||||
|
|
||||||
wifi_osi_funcs_t g_wifi_osi_funcs = {
|
wifi_osi_funcs_t g_wifi_osi_funcs = {
|
||||||
._version = ESP_WIFI_OS_ADAPTER_VERSION,
|
._version = ESP_WIFI_OS_ADAPTER_VERSION,
|
||||||
._env_is_chip = env_is_chip_wrapper,
|
._env_is_chip = esp_coex_common_env_is_chip_wrapper,
|
||||||
._set_intr = set_intr_wrapper,
|
._set_intr = set_intr_wrapper,
|
||||||
._clear_intr = clear_intr_wrapper,
|
._clear_intr = clear_intr_wrapper,
|
||||||
._set_isr = set_isr_wrapper,
|
._set_isr = set_isr_wrapper,
|
||||||
._ints_on = enable_intr_wrapper,
|
._ints_on = enable_intr_wrapper,
|
||||||
._ints_off = disable_intr_wrapper,
|
._ints_off = disable_intr_wrapper,
|
||||||
._is_from_isr = is_from_isr_wrapper,
|
._is_from_isr = is_from_isr_wrapper,
|
||||||
._spin_lock_create = spin_lock_create_wrapper,
|
._spin_lock_create = esp_coex_common_spin_lock_create_wrapper,
|
||||||
._spin_lock_delete = free,
|
._spin_lock_delete = free,
|
||||||
._wifi_int_disable = wifi_int_disable_wrapper,
|
._wifi_int_disable = esp_coex_common_int_disable_wrapper,
|
||||||
._wifi_int_restore = wifi_int_restore_wrapper,
|
._wifi_int_restore = esp_coex_common_int_restore_wrapper,
|
||||||
._task_yield_from_isr = task_yield_from_isr_wrapper,
|
._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper,
|
||||||
._semphr_create = semphr_create_wrapper,
|
._semphr_create = esp_coex_common_semphr_create_wrapper,
|
||||||
._semphr_delete = semphr_delete_wrapper,
|
._semphr_delete = esp_coex_common_semphr_delete_wrapper,
|
||||||
._semphr_take = semphr_take_wrapper,
|
._semphr_take = esp_coex_common_semphr_take_wrapper,
|
||||||
._semphr_give = semphr_give_wrapper,
|
._semphr_give = esp_coex_common_semphr_give_wrapper,
|
||||||
._wifi_thread_semphr_get = wifi_thread_semphr_get_wrapper,
|
._wifi_thread_semphr_get = wifi_thread_semphr_get_wrapper,
|
||||||
._mutex_create = mutex_create_wrapper,
|
._mutex_create = mutex_create_wrapper,
|
||||||
._recursive_mutex_create = recursive_mutex_create_wrapper,
|
._recursive_mutex_create = recursive_mutex_create_wrapper,
|
||||||
@@ -653,10 +599,10 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
|
|||||||
._phy_update_country_info = esp_phy_update_country_info,
|
._phy_update_country_info = esp_phy_update_country_info,
|
||||||
._read_mac = esp_read_mac_wrapper,
|
._read_mac = esp_read_mac_wrapper,
|
||||||
._timer_arm = timer_arm_wrapper,
|
._timer_arm = timer_arm_wrapper,
|
||||||
._timer_disarm = timer_disarm_wrapper,
|
._timer_disarm = esp_coex_common_timer_disarm_wrapper,
|
||||||
._timer_done = timer_done_wrapper,
|
._timer_done = esp_coex_common_timer_done_wrapper,
|
||||||
._timer_setfn = timer_setfn_wrapper,
|
._timer_setfn = esp_coex_common_timer_setfn_wrapper,
|
||||||
._timer_arm_us = timer_arm_us_wrapper,
|
._timer_arm_us = esp_coex_common_timer_arm_us_wrapper,
|
||||||
._wifi_reset_mac = wifi_reset_mac_wrapper,
|
._wifi_reset_mac = wifi_reset_mac_wrapper,
|
||||||
._wifi_clock_enable = wifi_clock_enable_wrapper,
|
._wifi_clock_enable = wifi_clock_enable_wrapper,
|
||||||
._wifi_clock_disable = wifi_clock_disable_wrapper,
|
._wifi_clock_disable = wifi_clock_disable_wrapper,
|
||||||
@@ -678,11 +624,11 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
|
|||||||
._get_random = os_get_random,
|
._get_random = os_get_random,
|
||||||
._get_time = get_time_wrapper,
|
._get_time = get_time_wrapper,
|
||||||
._random = os_random,
|
._random = os_random,
|
||||||
._slowclk_cal_get = esp_clk_slowclk_cal_get_wrapper,
|
._slowclk_cal_get = esp_coex_common_clk_slowclk_cal_get_wrapper,
|
||||||
._log_write = esp_log_write_wrapper,
|
._log_write = esp_log_write_wrapper,
|
||||||
._log_writev = esp_log_writev_wrapper,
|
._log_writev = esp_log_writev_wrapper,
|
||||||
._log_timestamp = esp_log_timestamp,
|
._log_timestamp = esp_log_timestamp,
|
||||||
._malloc_internal = malloc_internal_wrapper,
|
._malloc_internal = esp_coex_common_malloc_internal_wrapper,
|
||||||
._realloc_internal = realloc_internal_wrapper,
|
._realloc_internal = realloc_internal_wrapper,
|
||||||
._calloc_internal = calloc_internal_wrapper,
|
._calloc_internal = calloc_internal_wrapper,
|
||||||
._zalloc_internal = zalloc_internal_wrapper,
|
._zalloc_internal = zalloc_internal_wrapper,
|
||||||
|
@@ -129,38 +129,6 @@ static void disable_intr_wrapper(uint32_t intr_mask)
|
|||||||
esprv_intc_int_disable(intr_mask);
|
esprv_intc_int_disable(intr_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *spin_lock_create_wrapper(void)
|
|
||||||
{
|
|
||||||
portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED;
|
|
||||||
void *mux = malloc(sizeof(portMUX_TYPE));
|
|
||||||
|
|
||||||
if (mux) {
|
|
||||||
memcpy(mux, &tmp, sizeof(portMUX_TYPE));
|
|
||||||
return mux;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint32_t IRAM_ATTR wifi_int_disable_wrapper(void *wifi_int_mux)
|
|
||||||
{
|
|
||||||
if (xPortInIsrContext()) {
|
|
||||||
portENTER_CRITICAL_ISR(wifi_int_mux);
|
|
||||||
} else {
|
|
||||||
portENTER_CRITICAL(wifi_int_mux);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void IRAM_ATTR wifi_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp)
|
|
||||||
{
|
|
||||||
if (xPortInIsrContext()) {
|
|
||||||
portEXIT_CRITICAL_ISR(wifi_int_mux);
|
|
||||||
} else {
|
|
||||||
portEXIT_CRITICAL(wifi_int_mux);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool IRAM_ATTR is_from_isr_wrapper(void)
|
static bool IRAM_ATTR is_from_isr_wrapper(void)
|
||||||
{
|
{
|
||||||
return !xPortCanYield();
|
return !xPortCanYield();
|
||||||
@@ -570,22 +538,22 @@ static void IRAM_ATTR esp_empty_wrapper(void)
|
|||||||
|
|
||||||
wifi_osi_funcs_t g_wifi_osi_funcs = {
|
wifi_osi_funcs_t g_wifi_osi_funcs = {
|
||||||
._version = ESP_WIFI_OS_ADAPTER_VERSION,
|
._version = ESP_WIFI_OS_ADAPTER_VERSION,
|
||||||
._env_is_chip = env_is_chip_wrapper,
|
._env_is_chip = esp_coex_common_env_is_chip_wrapper,
|
||||||
._set_intr = set_intr_wrapper,
|
._set_intr = set_intr_wrapper,
|
||||||
._clear_intr = clear_intr_wrapper,
|
._clear_intr = clear_intr_wrapper,
|
||||||
._set_isr = set_isr_wrapper,
|
._set_isr = set_isr_wrapper,
|
||||||
._ints_on = enable_intr_wrapper,
|
._ints_on = enable_intr_wrapper,
|
||||||
._ints_off = disable_intr_wrapper,
|
._ints_off = disable_intr_wrapper,
|
||||||
._is_from_isr = is_from_isr_wrapper,
|
._is_from_isr = is_from_isr_wrapper,
|
||||||
._spin_lock_create = spin_lock_create_wrapper,
|
._spin_lock_create = esp_coex_common_spin_lock_create_wrapper,
|
||||||
._spin_lock_delete = free,
|
._spin_lock_delete = free,
|
||||||
._wifi_int_disable = wifi_int_disable_wrapper,
|
._wifi_int_disable = esp_coex_common_int_disable_wrapper,
|
||||||
._wifi_int_restore = wifi_int_restore_wrapper,
|
._wifi_int_restore = esp_coex_common_int_restore_wrapper,
|
||||||
._task_yield_from_isr = task_yield_from_isr_wrapper,
|
._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper,
|
||||||
._semphr_create = semphr_create_wrapper,
|
._semphr_create = esp_coex_common_semphr_create_wrapper,
|
||||||
._semphr_delete = semphr_delete_wrapper,
|
._semphr_delete = esp_coex_common_semphr_delete_wrapper,
|
||||||
._semphr_take = semphr_take_wrapper,
|
._semphr_take = esp_coex_common_semphr_take_wrapper,
|
||||||
._semphr_give = semphr_give_wrapper,
|
._semphr_give = esp_coex_common_semphr_give_wrapper,
|
||||||
._wifi_thread_semphr_get = wifi_thread_semphr_get_wrapper,
|
._wifi_thread_semphr_get = wifi_thread_semphr_get_wrapper,
|
||||||
._mutex_create = mutex_create_wrapper,
|
._mutex_create = mutex_create_wrapper,
|
||||||
._recursive_mutex_create = recursive_mutex_create_wrapper,
|
._recursive_mutex_create = recursive_mutex_create_wrapper,
|
||||||
@@ -626,10 +594,10 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
|
|||||||
._phy_update_country_info = esp_phy_update_country_info,
|
._phy_update_country_info = esp_phy_update_country_info,
|
||||||
._read_mac = esp_read_mac_wrapper,
|
._read_mac = esp_read_mac_wrapper,
|
||||||
._timer_arm = timer_arm_wrapper,
|
._timer_arm = timer_arm_wrapper,
|
||||||
._timer_disarm = timer_disarm_wrapper,
|
._timer_disarm = esp_coex_common_timer_disarm_wrapper,
|
||||||
._timer_done = timer_done_wrapper,
|
._timer_done = esp_coex_common_timer_done_wrapper,
|
||||||
._timer_setfn = timer_setfn_wrapper,
|
._timer_setfn = esp_coex_common_timer_setfn_wrapper,
|
||||||
._timer_arm_us = timer_arm_us_wrapper,
|
._timer_arm_us = esp_coex_common_timer_arm_us_wrapper,
|
||||||
._wifi_reset_mac = wifi_reset_mac_wrapper,
|
._wifi_reset_mac = wifi_reset_mac_wrapper,
|
||||||
._wifi_clock_enable = wifi_clock_enable_wrapper,
|
._wifi_clock_enable = wifi_clock_enable_wrapper,
|
||||||
._wifi_clock_disable = wifi_clock_disable_wrapper,
|
._wifi_clock_disable = wifi_clock_disable_wrapper,
|
||||||
@@ -651,11 +619,11 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
|
|||||||
._get_random = os_get_random,
|
._get_random = os_get_random,
|
||||||
._get_time = get_time_wrapper,
|
._get_time = get_time_wrapper,
|
||||||
._random = os_random,
|
._random = os_random,
|
||||||
._slowclk_cal_get = esp_clk_slowclk_cal_get_wrapper,
|
._slowclk_cal_get = esp_coex_common_clk_slowclk_cal_get_wrapper,
|
||||||
._log_write = esp_log_write_wrapper,
|
._log_write = esp_log_write_wrapper,
|
||||||
._log_writev = esp_log_writev_wrapper,
|
._log_writev = esp_log_writev_wrapper,
|
||||||
._log_timestamp = esp_log_timestamp,
|
._log_timestamp = esp_log_timestamp,
|
||||||
._malloc_internal = malloc_internal_wrapper,
|
._malloc_internal = esp_coex_common_malloc_internal_wrapper,
|
||||||
._realloc_internal = realloc_internal_wrapper,
|
._realloc_internal = realloc_internal_wrapper,
|
||||||
._calloc_internal = calloc_internal_wrapper,
|
._calloc_internal = calloc_internal_wrapper,
|
||||||
._zalloc_internal = zalloc_internal_wrapper,
|
._zalloc_internal = zalloc_internal_wrapper,
|
||||||
|
@@ -163,15 +163,6 @@ static void wifi_delete_queue_wrapper(void *queue)
|
|||||||
wifi_delete_queue(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)
|
static void set_intr_wrapper(int32_t cpu_no, uint32_t intr_source, uint32_t intr_num, int32_t intr_prio)
|
||||||
{
|
{
|
||||||
esp_rom_route_intr_matrix(cpu_no, intr_source, intr_num);
|
esp_rom_route_intr_matrix(cpu_no, intr_source, intr_num);
|
||||||
@@ -187,53 +178,11 @@ static void set_isr_wrapper(int32_t n, void *f, void *arg)
|
|||||||
xt_set_interrupt_handler(n, (xt_handler)f, arg);
|
xt_set_interrupt_handler(n, (xt_handler)f, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * spin_lock_create_wrapper(void)
|
|
||||||
{
|
|
||||||
portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED;
|
|
||||||
void *mux = heap_caps_malloc(sizeof(portMUX_TYPE), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
|
|
||||||
|
|
||||||
if (mux) {
|
|
||||||
memcpy(mux,&tmp,sizeof(portMUX_TYPE));
|
|
||||||
return mux;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint32_t IRAM_ATTR wifi_int_disable_wrapper(void *wifi_int_mux)
|
|
||||||
{
|
|
||||||
if (xPortInIsrContext()) {
|
|
||||||
portENTER_CRITICAL_ISR(wifi_int_mux);
|
|
||||||
} else {
|
|
||||||
portENTER_CRITICAL(wifi_int_mux);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void IRAM_ATTR wifi_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp)
|
|
||||||
{
|
|
||||||
if (xPortInIsrContext()) {
|
|
||||||
portEXIT_CRITICAL_ISR(wifi_int_mux);
|
|
||||||
} else {
|
|
||||||
portEXIT_CRITICAL(wifi_int_mux);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool IRAM_ATTR is_from_isr_wrapper(void)
|
static bool IRAM_ATTR is_from_isr_wrapper(void)
|
||||||
{
|
{
|
||||||
return !xPortCanYield();
|
return !xPortCanYield();
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
static void wifi_thread_semphr_free(void* data)
|
||||||
{
|
{
|
||||||
SemaphoreHandle_t *sem = (SemaphoreHandle_t*)(data);
|
SemaphoreHandle_t *sem = (SemaphoreHandle_t*)(data);
|
||||||
@@ -269,20 +218,6 @@ static void * wifi_thread_semphr_get_wrapper(void)
|
|||||||
return (void*)sem;
|
return (void*)sem;
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
static void * recursive_mutex_create_wrapper(void)
|
||||||
{
|
{
|
||||||
return (void *)xSemaphoreCreateRecursiveMutex();
|
return (void *)xSemaphoreCreateRecursiveMutex();
|
||||||
@@ -423,14 +358,6 @@ static int get_time_wrapper(void *t)
|
|||||||
return os_get_time(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 realloc_internal_wrapper(void *ptr, size_t size)
|
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);
|
return heap_caps_realloc(ptr, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
|
||||||
@@ -624,22 +551,22 @@ static void IRAM_ATTR esp_empty_wrapper(void)
|
|||||||
|
|
||||||
wifi_osi_funcs_t g_wifi_osi_funcs = {
|
wifi_osi_funcs_t g_wifi_osi_funcs = {
|
||||||
._version = ESP_WIFI_OS_ADAPTER_VERSION,
|
._version = ESP_WIFI_OS_ADAPTER_VERSION,
|
||||||
._env_is_chip = env_is_chip_wrapper,
|
._env_is_chip = esp_coex_common_env_is_chip_wrapper,
|
||||||
._set_intr = set_intr_wrapper,
|
._set_intr = set_intr_wrapper,
|
||||||
._clear_intr = clear_intr_wrapper,
|
._clear_intr = clear_intr_wrapper,
|
||||||
._set_isr = set_isr_wrapper,
|
._set_isr = set_isr_wrapper,
|
||||||
._ints_on = esp_cpu_intr_enable,
|
._ints_on = esp_cpu_intr_enable,
|
||||||
._ints_off = esp_cpu_intr_disable,
|
._ints_off = esp_cpu_intr_disable,
|
||||||
._is_from_isr = is_from_isr_wrapper,
|
._is_from_isr = is_from_isr_wrapper,
|
||||||
._spin_lock_create = spin_lock_create_wrapper,
|
._spin_lock_create = esp_coex_common_spin_lock_create_wrapper,
|
||||||
._spin_lock_delete = free,
|
._spin_lock_delete = free,
|
||||||
._wifi_int_disable = wifi_int_disable_wrapper,
|
._wifi_int_disable = esp_coex_common_int_disable_wrapper,
|
||||||
._wifi_int_restore = wifi_int_restore_wrapper,
|
._wifi_int_restore = esp_coex_common_int_restore_wrapper,
|
||||||
._task_yield_from_isr = task_yield_from_isr_wrapper,
|
._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper,
|
||||||
._semphr_create = semphr_create_wrapper,
|
._semphr_create = esp_coex_common_semphr_create_wrapper,
|
||||||
._semphr_delete = semphr_delete_wrapper,
|
._semphr_delete = esp_coex_common_semphr_delete_wrapper,
|
||||||
._semphr_take = semphr_take_wrapper,
|
._semphr_take = esp_coex_common_semphr_take_wrapper,
|
||||||
._semphr_give = semphr_give_wrapper,
|
._semphr_give = esp_coex_common_semphr_give_wrapper,
|
||||||
._wifi_thread_semphr_get = wifi_thread_semphr_get_wrapper,
|
._wifi_thread_semphr_get = wifi_thread_semphr_get_wrapper,
|
||||||
._mutex_create = mutex_create_wrapper,
|
._mutex_create = mutex_create_wrapper,
|
||||||
._recursive_mutex_create = recursive_mutex_create_wrapper,
|
._recursive_mutex_create = recursive_mutex_create_wrapper,
|
||||||
@@ -682,10 +609,10 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
|
|||||||
._phy_update_country_info = esp_phy_update_country_info,
|
._phy_update_country_info = esp_phy_update_country_info,
|
||||||
._read_mac = esp_read_mac,
|
._read_mac = esp_read_mac,
|
||||||
._timer_arm = timer_arm_wrapper,
|
._timer_arm = timer_arm_wrapper,
|
||||||
._timer_disarm = timer_disarm_wrapper,
|
._timer_disarm = esp_coex_common_timer_disarm_wrapper,
|
||||||
._timer_done = timer_done_wrapper,
|
._timer_done = esp_coex_common_timer_done_wrapper,
|
||||||
._timer_setfn = timer_setfn_wrapper,
|
._timer_setfn = esp_coex_common_timer_setfn_wrapper,
|
||||||
._timer_arm_us = timer_arm_us_wrapper,
|
._timer_arm_us = esp_coex_common_timer_arm_us_wrapper,
|
||||||
._wifi_reset_mac = wifi_reset_mac_wrapper,
|
._wifi_reset_mac = wifi_reset_mac_wrapper,
|
||||||
._wifi_clock_enable = wifi_clock_enable_wrapper,
|
._wifi_clock_enable = wifi_clock_enable_wrapper,
|
||||||
._wifi_clock_disable = wifi_clock_disable_wrapper,
|
._wifi_clock_disable = wifi_clock_disable_wrapper,
|
||||||
@@ -707,11 +634,11 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
|
|||||||
._get_random = os_get_random,
|
._get_random = os_get_random,
|
||||||
._get_time = get_time_wrapper,
|
._get_time = get_time_wrapper,
|
||||||
._random = os_random,
|
._random = os_random,
|
||||||
._slowclk_cal_get = esp_clk_slowclk_cal_get_wrapper,
|
._slowclk_cal_get = esp_coex_common_clk_slowclk_cal_get_wrapper,
|
||||||
._log_write = esp_log_write,
|
._log_write = esp_log_write,
|
||||||
._log_writev = esp_log_writev,
|
._log_writev = esp_log_writev,
|
||||||
._log_timestamp = esp_log_timestamp,
|
._log_timestamp = esp_log_timestamp,
|
||||||
._malloc_internal = malloc_internal_wrapper,
|
._malloc_internal = esp_coex_common_malloc_internal_wrapper,
|
||||||
._realloc_internal = realloc_internal_wrapper,
|
._realloc_internal = realloc_internal_wrapper,
|
||||||
._calloc_internal = calloc_internal_wrapper,
|
._calloc_internal = calloc_internal_wrapper,
|
||||||
._zalloc_internal = zalloc_internal_wrapper,
|
._zalloc_internal = zalloc_internal_wrapper,
|
||||||
|
@@ -166,15 +166,6 @@ static void wifi_delete_queue_wrapper(void *queue)
|
|||||||
wifi_delete_queue(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)
|
static void set_intr_wrapper(int32_t cpu_no, uint32_t intr_source, uint32_t intr_num, int32_t intr_prio)
|
||||||
{
|
{
|
||||||
esp_rom_route_intr_matrix(cpu_no, intr_source, intr_num);
|
esp_rom_route_intr_matrix(cpu_no, intr_source, intr_num);
|
||||||
@@ -190,53 +181,11 @@ static void set_isr_wrapper(int32_t n, void *f, void *arg)
|
|||||||
xt_set_interrupt_handler(n, (xt_handler)f, arg);
|
xt_set_interrupt_handler(n, (xt_handler)f, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * spin_lock_create_wrapper(void)
|
|
||||||
{
|
|
||||||
portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED;
|
|
||||||
void *mux = heap_caps_malloc(sizeof(portMUX_TYPE), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
|
|
||||||
|
|
||||||
if (mux) {
|
|
||||||
memcpy(mux,&tmp,sizeof(portMUX_TYPE));
|
|
||||||
return mux;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint32_t IRAM_ATTR wifi_int_disable_wrapper(void *wifi_int_mux)
|
|
||||||
{
|
|
||||||
if (xPortInIsrContext()) {
|
|
||||||
portENTER_CRITICAL_ISR(wifi_int_mux);
|
|
||||||
} else {
|
|
||||||
portENTER_CRITICAL(wifi_int_mux);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void IRAM_ATTR wifi_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp)
|
|
||||||
{
|
|
||||||
if (xPortInIsrContext()) {
|
|
||||||
portEXIT_CRITICAL_ISR(wifi_int_mux);
|
|
||||||
} else {
|
|
||||||
portEXIT_CRITICAL(wifi_int_mux);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool IRAM_ATTR is_from_isr_wrapper(void)
|
static bool IRAM_ATTR is_from_isr_wrapper(void)
|
||||||
{
|
{
|
||||||
return !xPortCanYield();
|
return !xPortCanYield();
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
static void wifi_thread_semphr_free(void* data)
|
||||||
{
|
{
|
||||||
SemaphoreHandle_t *sem = (SemaphoreHandle_t*)(data);
|
SemaphoreHandle_t *sem = (SemaphoreHandle_t*)(data);
|
||||||
@@ -272,20 +221,6 @@ static void * wifi_thread_semphr_get_wrapper(void)
|
|||||||
return (void*)sem;
|
return (void*)sem;
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
static void * recursive_mutex_create_wrapper(void)
|
||||||
{
|
{
|
||||||
return (void *)xSemaphoreCreateRecursiveMutex();
|
return (void *)xSemaphoreCreateRecursiveMutex();
|
||||||
@@ -440,19 +375,6 @@ static int get_time_wrapper(void *t)
|
|||||||
return os_get_time(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.
|
|
||||||
*/
|
|
||||||
if (GET_PERI_REG_MASK(SYSTEM_BT_LPCK_DIV_FRAC_REG, SYSTEM_LPCLK_SEL_XTAL)) {
|
|
||||||
uint64_t time_per_us = 1000000ULL;
|
|
||||||
return (((time_per_us << RTC_CLK_CAL_FRACT) / (MHZ)) >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH));
|
|
||||||
} else {
|
|
||||||
return (esp_clk_slowclk_cal_get() >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void * IRAM_ATTR realloc_internal_wrapper(void *ptr, size_t size)
|
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);
|
return heap_caps_realloc(ptr, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
|
||||||
@@ -646,22 +568,22 @@ static void IRAM_ATTR esp_empty_wrapper(void)
|
|||||||
|
|
||||||
wifi_osi_funcs_t g_wifi_osi_funcs = {
|
wifi_osi_funcs_t g_wifi_osi_funcs = {
|
||||||
._version = ESP_WIFI_OS_ADAPTER_VERSION,
|
._version = ESP_WIFI_OS_ADAPTER_VERSION,
|
||||||
._env_is_chip = env_is_chip_wrapper,
|
._env_is_chip = esp_coex_common_env_is_chip_wrapper,
|
||||||
._set_intr = set_intr_wrapper,
|
._set_intr = set_intr_wrapper,
|
||||||
._clear_intr = clear_intr_wrapper,
|
._clear_intr = clear_intr_wrapper,
|
||||||
._set_isr = set_isr_wrapper,
|
._set_isr = set_isr_wrapper,
|
||||||
._ints_on = esp_cpu_intr_enable,
|
._ints_on = esp_cpu_intr_enable,
|
||||||
._ints_off = esp_cpu_intr_disable,
|
._ints_off = esp_cpu_intr_disable,
|
||||||
._is_from_isr = is_from_isr_wrapper,
|
._is_from_isr = is_from_isr_wrapper,
|
||||||
._spin_lock_create = spin_lock_create_wrapper,
|
._spin_lock_create = esp_coex_common_spin_lock_create_wrapper,
|
||||||
._spin_lock_delete = free,
|
._spin_lock_delete = free,
|
||||||
._wifi_int_disable = wifi_int_disable_wrapper,
|
._wifi_int_disable = esp_coex_common_int_disable_wrapper,
|
||||||
._wifi_int_restore = wifi_int_restore_wrapper,
|
._wifi_int_restore = esp_coex_common_int_restore_wrapper,
|
||||||
._task_yield_from_isr = task_yield_from_isr_wrapper,
|
._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper,
|
||||||
._semphr_create = semphr_create_wrapper,
|
._semphr_create = esp_coex_common_semphr_create_wrapper,
|
||||||
._semphr_delete = semphr_delete_wrapper,
|
._semphr_delete = esp_coex_common_semphr_delete_wrapper,
|
||||||
._semphr_take = semphr_take_wrapper,
|
._semphr_take = esp_coex_common_semphr_take_wrapper,
|
||||||
._semphr_give = semphr_give_wrapper,
|
._semphr_give = esp_coex_common_semphr_give_wrapper,
|
||||||
._wifi_thread_semphr_get = wifi_thread_semphr_get_wrapper,
|
._wifi_thread_semphr_get = wifi_thread_semphr_get_wrapper,
|
||||||
._mutex_create = mutex_create_wrapper,
|
._mutex_create = mutex_create_wrapper,
|
||||||
._recursive_mutex_create = recursive_mutex_create_wrapper,
|
._recursive_mutex_create = recursive_mutex_create_wrapper,
|
||||||
@@ -702,10 +624,10 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
|
|||||||
._phy_update_country_info = esp_phy_update_country_info,
|
._phy_update_country_info = esp_phy_update_country_info,
|
||||||
._read_mac = esp_read_mac,
|
._read_mac = esp_read_mac,
|
||||||
._timer_arm = timer_arm_wrapper,
|
._timer_arm = timer_arm_wrapper,
|
||||||
._timer_disarm = timer_disarm_wrapper,
|
._timer_disarm = esp_coex_common_timer_disarm_wrapper,
|
||||||
._timer_done = timer_done_wrapper,
|
._timer_done = esp_coex_common_timer_done_wrapper,
|
||||||
._timer_setfn = timer_setfn_wrapper,
|
._timer_setfn = esp_coex_common_timer_setfn_wrapper,
|
||||||
._timer_arm_us = timer_arm_us_wrapper,
|
._timer_arm_us = esp_coex_common_timer_arm_us_wrapper,
|
||||||
._wifi_reset_mac = wifi_reset_mac_wrapper,
|
._wifi_reset_mac = wifi_reset_mac_wrapper,
|
||||||
._wifi_clock_enable = wifi_clock_enable_wrapper,
|
._wifi_clock_enable = wifi_clock_enable_wrapper,
|
||||||
._wifi_clock_disable = wifi_clock_disable_wrapper,
|
._wifi_clock_disable = wifi_clock_disable_wrapper,
|
||||||
@@ -727,11 +649,11 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
|
|||||||
._get_random = os_get_random,
|
._get_random = os_get_random,
|
||||||
._get_time = get_time_wrapper,
|
._get_time = get_time_wrapper,
|
||||||
._random = os_random,
|
._random = os_random,
|
||||||
._slowclk_cal_get = esp_clk_slowclk_cal_get_wrapper,
|
._slowclk_cal_get = esp_coex_common_clk_slowclk_cal_get_wrapper,
|
||||||
._log_write = esp_log_write,
|
._log_write = esp_log_write,
|
||||||
._log_writev = esp_log_writev,
|
._log_writev = esp_log_writev,
|
||||||
._log_timestamp = esp_log_timestamp,
|
._log_timestamp = esp_log_timestamp,
|
||||||
._malloc_internal = malloc_internal_wrapper,
|
._malloc_internal = esp_coex_common_malloc_internal_wrapper,
|
||||||
._realloc_internal = realloc_internal_wrapper,
|
._realloc_internal = realloc_internal_wrapper,
|
||||||
._calloc_internal = calloc_internal_wrapper,
|
._calloc_internal = calloc_internal_wrapper,
|
||||||
._zalloc_internal = zalloc_internal_wrapper,
|
._zalloc_internal = zalloc_internal_wrapper,
|
||||||
|
Reference in New Issue
Block a user