esp_adapter.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. /*
  2. * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include <stddef.h>
  7. #include <stdlib.h>
  8. #include <stdio.h>
  9. #include <string.h>
  10. #include <assert.h>
  11. #include <pthread.h>
  12. #include "freertos/FreeRTOS.h"
  13. #include "freertos/task.h"
  14. #include "freertos/queue.h"
  15. #include "freertos/semphr.h"
  16. #include "freertos/event_groups.h"
  17. #include "freertos/portmacro.h"
  18. #include "freertos/xtensa_api.h"
  19. #include "esp_types.h"
  20. #include "esp_random.h"
  21. #include "esp_mac.h"
  22. #include "esp_task.h"
  23. #include "esp_intr_alloc.h"
  24. #include "esp_attr.h"
  25. #include "esp_log.h"
  26. #include "esp_event.h"
  27. #include "esp_heap_caps.h"
  28. #include "esp_timer.h"
  29. #include "esp_cpu.h"
  30. #include "esp_private/wifi_os_adapter.h"
  31. #include "esp_private/wifi.h"
  32. #include "esp_phy_init.h"
  33. #include "soc/rtc_cntl_reg.h"
  34. #include "soc/rtc.h"
  35. #include "soc/syscon_reg.h"
  36. #include "soc/system_reg.h"
  37. #include "phy_init_data.h"
  38. #include "esp_private/periph_ctrl.h"
  39. #include "esp_private/esp_clk.h"
  40. #include "nvs.h"
  41. #include "os.h"
  42. #include "esp_smartconfig.h"
  43. #include "private/esp_coexist_internal.h"
  44. #include "esp_rom_sys.h"
  45. #include "esp32s3/rom/ets_sys.h"
  46. #include "private/esp_modem_wrapper.h"
  47. #define TAG "esp_adapter"
  48. #define MHZ (1000000)
  49. #ifdef CONFIG_PM_ENABLE
  50. extern void wifi_apb80m_request(void);
  51. extern void wifi_apb80m_release(void);
  52. #endif
  53. /*
  54. If CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP is enabled. Prefer to allocate a chunk of memory in SPIRAM firstly.
  55. If failed, try to allocate it in internal memory then.
  56. */
  57. IRAM_ATTR void *wifi_malloc( size_t size )
  58. {
  59. #if CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP
  60. return heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL);
  61. #else
  62. return malloc(size);
  63. #endif
  64. }
  65. /*
  66. If CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP is enabled. Prefer to allocate a chunk of memory in SPIRAM firstly.
  67. If failed, try to allocate it in internal memory then.
  68. */
  69. IRAM_ATTR void *wifi_realloc( void *ptr, size_t size )
  70. {
  71. #if CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP
  72. return heap_caps_realloc_prefer(ptr, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL);
  73. #else
  74. return realloc(ptr, size);
  75. #endif
  76. }
  77. /*
  78. If CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP is enabled. Prefer to allocate a chunk of memory in SPIRAM firstly.
  79. If failed, try to allocate it in internal memory then.
  80. */
  81. IRAM_ATTR void *wifi_calloc( size_t n, size_t size )
  82. {
  83. #if CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP
  84. return heap_caps_calloc_prefer(n, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL);
  85. #else
  86. return calloc(n, size);
  87. #endif
  88. }
  89. static void * IRAM_ATTR wifi_zalloc_wrapper(size_t size)
  90. {
  91. void *ptr = wifi_calloc(1, size);
  92. return ptr;
  93. }
  94. wifi_static_queue_t* wifi_create_queue( int queue_len, int item_size)
  95. {
  96. wifi_static_queue_t *queue = NULL;
  97. queue = (wifi_static_queue_t*)heap_caps_malloc(sizeof(wifi_static_queue_t), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
  98. if (!queue) {
  99. return NULL;
  100. }
  101. #if CONFIG_SPIRAM_USE_MALLOC
  102. queue->storage = heap_caps_calloc(1, sizeof(StaticQueue_t) + (queue_len*item_size), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
  103. if (!queue->storage) {
  104. goto _error;
  105. }
  106. queue->handle = xQueueCreateStatic( queue_len, item_size, ((uint8_t*)(queue->storage)) + sizeof(StaticQueue_t), (StaticQueue_t*)(queue->storage));
  107. if (!queue->handle) {
  108. goto _error;
  109. }
  110. return queue;
  111. _error:
  112. if (queue) {
  113. if (queue->storage) {
  114. free(queue->storage);
  115. }
  116. free(queue);
  117. }
  118. return NULL;
  119. #else
  120. queue->handle = xQueueCreate( queue_len, item_size);
  121. return queue;
  122. #endif
  123. }
  124. void wifi_delete_queue(wifi_static_queue_t *queue)
  125. {
  126. if (queue) {
  127. vQueueDelete(queue->handle);
  128. #if CONFIG_SPIRAM_USE_MALLOC
  129. if (queue->storage) {
  130. free(queue->storage);
  131. }
  132. #endif
  133. free(queue);
  134. }
  135. }
  136. static void * wifi_create_queue_wrapper(int queue_len, int item_size)
  137. {
  138. return wifi_create_queue(queue_len, item_size);
  139. }
  140. static void wifi_delete_queue_wrapper(void *queue)
  141. {
  142. wifi_delete_queue(queue);
  143. }
  144. static void set_intr_wrapper(int32_t cpu_no, uint32_t intr_source, uint32_t intr_num, int32_t intr_prio)
  145. {
  146. esp_rom_route_intr_matrix(cpu_no, intr_source, intr_num);
  147. }
  148. static void clear_intr_wrapper(uint32_t intr_source, uint32_t intr_num)
  149. {
  150. }
  151. static void set_isr_wrapper(int32_t n, void *f, void *arg)
  152. {
  153. xt_set_interrupt_handler(n, (xt_handler)f, arg);
  154. }
  155. static bool IRAM_ATTR is_from_isr_wrapper(void)
  156. {
  157. return !xPortCanYield();
  158. }
  159. static void wifi_thread_semphr_free(void* data)
  160. {
  161. SemaphoreHandle_t *sem = (SemaphoreHandle_t*)(data);
  162. if (sem) {
  163. vSemaphoreDelete(sem);
  164. }
  165. }
  166. static void * wifi_thread_semphr_get_wrapper(void)
  167. {
  168. static bool s_wifi_thread_sem_key_init = false;
  169. static pthread_key_t s_wifi_thread_sem_key;
  170. SemaphoreHandle_t sem = NULL;
  171. if (s_wifi_thread_sem_key_init == false) {
  172. if (0 != pthread_key_create(&s_wifi_thread_sem_key, wifi_thread_semphr_free)) {
  173. return NULL;
  174. }
  175. s_wifi_thread_sem_key_init = true;
  176. }
  177. sem = pthread_getspecific(s_wifi_thread_sem_key);
  178. if (!sem) {
  179. sem = xSemaphoreCreateCounting(1, 0);
  180. if (sem) {
  181. pthread_setspecific(s_wifi_thread_sem_key, sem);
  182. ESP_LOGV(TAG, "thread sem create: sem=%p", sem);
  183. }
  184. }
  185. ESP_LOGV(TAG, "thread sem get: sem=%p", sem);
  186. return (void*)sem;
  187. }
  188. static void * recursive_mutex_create_wrapper(void)
  189. {
  190. return (void *)xSemaphoreCreateRecursiveMutex();
  191. }
  192. static void * mutex_create_wrapper(void)
  193. {
  194. return (void *)xSemaphoreCreateMutex();
  195. }
  196. static void mutex_delete_wrapper(void *mutex)
  197. {
  198. vSemaphoreDelete(mutex);
  199. }
  200. static int32_t IRAM_ATTR mutex_lock_wrapper(void *mutex)
  201. {
  202. return (int32_t)xSemaphoreTakeRecursive(mutex, portMAX_DELAY);
  203. }
  204. static int32_t IRAM_ATTR mutex_unlock_wrapper(void *mutex)
  205. {
  206. return (int32_t)xSemaphoreGiveRecursive(mutex);
  207. }
  208. static void * queue_create_wrapper(uint32_t queue_len, uint32_t item_size)
  209. {
  210. return (void *)xQueueCreate(queue_len, item_size);
  211. }
  212. static int32_t queue_send_wrapper(void *queue, void *item, uint32_t block_time_tick)
  213. {
  214. if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
  215. return (int32_t)xQueueSend(queue, item, portMAX_DELAY);
  216. } else {
  217. return (int32_t)xQueueSend(queue, item, block_time_tick);
  218. }
  219. }
  220. static int32_t IRAM_ATTR queue_send_from_isr_wrapper(void *queue, void *item, void *hptw)
  221. {
  222. return (int32_t)xQueueSendFromISR(queue, item, hptw);
  223. }
  224. static int32_t queue_send_to_back_wrapper(void *queue, void *item, uint32_t block_time_tick)
  225. {
  226. return (int32_t)xQueueGenericSend(queue, item, block_time_tick, queueSEND_TO_BACK);
  227. }
  228. static int32_t queue_send_to_front_wrapper(void *queue, void *item, uint32_t block_time_tick)
  229. {
  230. return (int32_t)xQueueGenericSend(queue, item, block_time_tick, queueSEND_TO_FRONT);
  231. }
  232. static int32_t queue_recv_wrapper(void *queue, void *item, uint32_t block_time_tick)
  233. {
  234. if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
  235. return (int32_t)xQueueReceive(queue, item, portMAX_DELAY);
  236. } else {
  237. return (int32_t)xQueueReceive(queue, item, block_time_tick);
  238. }
  239. }
  240. static uint32_t event_group_wait_bits_wrapper(void *event, uint32_t bits_to_wait_for, int clear_on_exit, int wait_for_all_bits, uint32_t block_time_tick)
  241. {
  242. if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
  243. return (uint32_t)xEventGroupWaitBits(event, bits_to_wait_for, clear_on_exit, wait_for_all_bits, portMAX_DELAY);
  244. } else {
  245. return (uint32_t)xEventGroupWaitBits(event, bits_to_wait_for, clear_on_exit, wait_for_all_bits, block_time_tick);
  246. }
  247. }
  248. static int32_t task_create_pinned_to_core_wrapper(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle, uint32_t core_id)
  249. {
  250. return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle, (core_id < portNUM_PROCESSORS ? core_id : tskNO_AFFINITY));
  251. }
  252. static int32_t task_create_wrapper(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle)
  253. {
  254. return (uint32_t)xTaskCreate(task_func, name, stack_depth, param, prio, task_handle);
  255. }
  256. static int32_t IRAM_ATTR task_ms_to_tick_wrapper(uint32_t ms)
  257. {
  258. return (int32_t)(ms / portTICK_PERIOD_MS);
  259. }
  260. static int32_t task_get_max_priority_wrapper(void)
  261. {
  262. return (int32_t)(configMAX_PRIORITIES);
  263. }
  264. static int32_t esp_event_post_wrapper(const char* event_base, int32_t event_id, void* event_data, size_t event_data_size, uint32_t ticks_to_wait)
  265. {
  266. if (ticks_to_wait == OSI_FUNCS_TIME_BLOCKING) {
  267. return (int32_t)esp_event_post(event_base, event_id, event_data, event_data_size, portMAX_DELAY);
  268. } else {
  269. return (int32_t)esp_event_post(event_base, event_id, event_data, event_data_size, ticks_to_wait);
  270. }
  271. }
  272. static void IRAM_ATTR wifi_apb80m_request_wrapper(void)
  273. {
  274. #ifdef CONFIG_PM_ENABLE
  275. wifi_apb80m_request();
  276. #endif
  277. }
  278. static void IRAM_ATTR wifi_apb80m_release_wrapper(void)
  279. {
  280. #ifdef CONFIG_PM_ENABLE
  281. wifi_apb80m_release();
  282. #endif
  283. }
  284. static void IRAM_ATTR timer_arm_wrapper(void *timer, uint32_t tmout, bool repeat)
  285. {
  286. ets_timer_arm(timer, tmout, repeat);
  287. }
  288. static void wifi_reset_mac_wrapper(void)
  289. {
  290. periph_module_reset(PERIPH_WIFI_MODULE);
  291. }
  292. static void IRAM_ATTR wifi_rtc_enable_iso_wrapper(void)
  293. {
  294. #if CONFIG_MAC_BB_PD
  295. esp_mac_bb_power_down();
  296. #endif
  297. }
  298. static void IRAM_ATTR wifi_rtc_disable_iso_wrapper(void)
  299. {
  300. #if CONFIG_MAC_BB_PD
  301. esp_mac_bb_power_up();
  302. #endif
  303. }
  304. static void wifi_clock_enable_wrapper(void)
  305. {
  306. wifi_module_enable();
  307. }
  308. static void wifi_clock_disable_wrapper(void)
  309. {
  310. wifi_module_disable();
  311. }
  312. static int get_time_wrapper(void *t)
  313. {
  314. return os_get_time(t);
  315. }
  316. static void * IRAM_ATTR realloc_internal_wrapper(void *ptr, size_t size)
  317. {
  318. return heap_caps_realloc(ptr, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
  319. }
  320. static void * IRAM_ATTR calloc_internal_wrapper(size_t n, size_t size)
  321. {
  322. return heap_caps_calloc(n, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
  323. }
  324. static void * IRAM_ATTR zalloc_internal_wrapper(size_t size)
  325. {
  326. void *ptr = heap_caps_calloc(1, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
  327. return ptr;
  328. }
  329. static int coex_init_wrapper(void)
  330. {
  331. #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
  332. return coex_init();
  333. #else
  334. return 0;
  335. #endif
  336. }
  337. static void coex_deinit_wrapper(void)
  338. {
  339. #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
  340. coex_deinit();
  341. #endif
  342. }
  343. static int coex_enable_wrapper(void)
  344. {
  345. #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
  346. return coex_enable();
  347. #else
  348. return 0;
  349. #endif
  350. }
  351. static void coex_disable_wrapper(void)
  352. {
  353. #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
  354. coex_disable();
  355. #endif
  356. }
  357. static IRAM_ATTR uint32_t coex_status_get_wrapper(void)
  358. {
  359. #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
  360. return coex_status_get();
  361. #else
  362. return 0;
  363. #endif
  364. }
  365. static int coex_wifi_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration)
  366. {
  367. #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
  368. return coex_wifi_request(event, latency, duration);
  369. #else
  370. return 0;
  371. #endif
  372. }
  373. static IRAM_ATTR int coex_wifi_release_wrapper(uint32_t event)
  374. {
  375. #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
  376. return coex_wifi_release(event);
  377. #else
  378. return 0;
  379. #endif
  380. }
  381. static int coex_wifi_channel_set_wrapper(uint8_t primary, uint8_t secondary)
  382. {
  383. #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
  384. return coex_wifi_channel_set(primary, secondary);
  385. #else
  386. return 0;
  387. #endif
  388. }
  389. static IRAM_ATTR int coex_event_duration_get_wrapper(uint32_t event, uint32_t *duration)
  390. {
  391. #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
  392. return coex_event_duration_get(event, duration);
  393. #else
  394. return 0;
  395. #endif
  396. }
  397. static int coex_pti_get_wrapper(uint32_t event, uint8_t *pti)
  398. {
  399. #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
  400. return coex_pti_get(event, pti);
  401. #else
  402. return 0;
  403. #endif
  404. }
  405. static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status)
  406. {
  407. #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
  408. coex_schm_status_bit_clear(type, status);
  409. #endif
  410. }
  411. static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status)
  412. {
  413. #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
  414. coex_schm_status_bit_set(type, status);
  415. #endif
  416. }
  417. static IRAM_ATTR int coex_schm_interval_set_wrapper(uint32_t interval)
  418. {
  419. #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
  420. return coex_schm_interval_set(interval);
  421. #else
  422. return 0;
  423. #endif
  424. }
  425. static uint32_t coex_schm_interval_get_wrapper(void)
  426. {
  427. #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
  428. return coex_schm_interval_get();
  429. #else
  430. return 0;
  431. #endif
  432. }
  433. static uint8_t coex_schm_curr_period_get_wrapper(void)
  434. {
  435. #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
  436. return coex_schm_curr_period_get();
  437. #else
  438. return 0;
  439. #endif
  440. }
  441. static void * coex_schm_curr_phase_get_wrapper(void)
  442. {
  443. #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
  444. return coex_schm_curr_phase_get();
  445. #else
  446. return NULL;
  447. #endif
  448. }
  449. static int coex_register_start_cb_wrapper(int (* cb)(void))
  450. {
  451. #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
  452. return coex_register_start_cb(cb);
  453. #else
  454. return 0;
  455. #endif
  456. }
  457. static int coex_schm_process_restart_wrapper(void)
  458. {
  459. #if CONFIG_SW_COEXIST_ENABLE
  460. return coex_schm_process_restart();
  461. #else
  462. return 0;
  463. #endif
  464. }
  465. static int coex_schm_register_cb_wrapper(int type, int(*cb)(int))
  466. {
  467. #if CONFIG_SW_COEXIST_ENABLE
  468. return coex_schm_register_callback(type, cb);
  469. #else
  470. return 0;
  471. #endif
  472. }
  473. static void IRAM_ATTR esp_empty_wrapper(void)
  474. {
  475. }
  476. static void esp_phy_enable_wrapper(void)
  477. {
  478. esp_phy_enable(PHY_MODEM_WIFI);
  479. phy_wifi_enable_set(1);
  480. }
  481. static void esp_phy_disable_wrapper(void)
  482. {
  483. phy_wifi_enable_set(0);
  484. esp_phy_disable(PHY_MODEM_WIFI);
  485. }
  486. wifi_osi_funcs_t g_wifi_osi_funcs = {
  487. ._version = ESP_WIFI_OS_ADAPTER_VERSION,
  488. ._env_is_chip = esp_coex_common_env_is_chip_wrapper,
  489. ._set_intr = set_intr_wrapper,
  490. ._clear_intr = clear_intr_wrapper,
  491. ._set_isr = set_isr_wrapper,
  492. ._ints_on = esp_cpu_intr_enable,
  493. ._ints_off = esp_cpu_intr_disable,
  494. ._is_from_isr = is_from_isr_wrapper,
  495. ._spin_lock_create = esp_coex_common_spin_lock_create_wrapper,
  496. ._spin_lock_delete = free,
  497. ._wifi_int_disable = esp_coex_common_int_disable_wrapper,
  498. ._wifi_int_restore = esp_coex_common_int_restore_wrapper,
  499. ._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper,
  500. ._semphr_create = esp_coex_common_semphr_create_wrapper,
  501. ._semphr_delete = esp_coex_common_semphr_delete_wrapper,
  502. ._semphr_take = esp_coex_common_semphr_take_wrapper,
  503. ._semphr_give = esp_coex_common_semphr_give_wrapper,
  504. ._wifi_thread_semphr_get = wifi_thread_semphr_get_wrapper,
  505. ._mutex_create = mutex_create_wrapper,
  506. ._recursive_mutex_create = recursive_mutex_create_wrapper,
  507. ._mutex_delete = mutex_delete_wrapper,
  508. ._mutex_lock = mutex_lock_wrapper,
  509. ._mutex_unlock = mutex_unlock_wrapper,
  510. ._queue_create = queue_create_wrapper,
  511. ._queue_delete = (void(*)(void *))vQueueDelete,
  512. ._queue_send = queue_send_wrapper,
  513. ._queue_send_from_isr = queue_send_from_isr_wrapper,
  514. ._queue_send_to_back = queue_send_to_back_wrapper,
  515. ._queue_send_to_front = queue_send_to_front_wrapper,
  516. ._queue_recv = queue_recv_wrapper,
  517. ._queue_msg_waiting = (uint32_t(*)(void *))uxQueueMessagesWaiting,
  518. ._event_group_create = (void *(*)(void))xEventGroupCreate,
  519. ._event_group_delete = (void(*)(void *))vEventGroupDelete,
  520. ._event_group_set_bits = (uint32_t(*)(void *,uint32_t))xEventGroupSetBits,
  521. ._event_group_clear_bits = (uint32_t(*)(void *,uint32_t))xEventGroupClearBits,
  522. ._event_group_wait_bits = event_group_wait_bits_wrapper,
  523. ._task_create_pinned_to_core = task_create_pinned_to_core_wrapper,
  524. ._task_create = task_create_wrapper,
  525. ._task_delete = (void(*)(void *))vTaskDelete,
  526. ._task_delay = vTaskDelay,
  527. ._task_ms_to_tick = task_ms_to_tick_wrapper,
  528. ._task_get_current_task = (void *(*)(void))xTaskGetCurrentTaskHandle,
  529. ._task_get_max_priority = task_get_max_priority_wrapper,
  530. ._malloc = malloc,
  531. ._free = free,
  532. ._event_post = esp_event_post_wrapper,
  533. ._get_free_heap_size = esp_get_free_internal_heap_size,
  534. ._rand = esp_random,
  535. ._dport_access_stall_other_cpu_start_wrap = esp_empty_wrapper,
  536. ._dport_access_stall_other_cpu_end_wrap = esp_empty_wrapper,
  537. ._wifi_apb80m_request = wifi_apb80m_request_wrapper,
  538. ._wifi_apb80m_release = wifi_apb80m_release_wrapper,
  539. ._phy_disable = esp_phy_disable_wrapper,
  540. ._phy_enable = esp_phy_enable_wrapper,
  541. ._phy_update_country_info = esp_phy_update_country_info,
  542. ._read_mac = esp_read_mac,
  543. ._timer_arm = timer_arm_wrapper,
  544. ._timer_disarm = esp_coex_common_timer_disarm_wrapper,
  545. ._timer_done = esp_coex_common_timer_done_wrapper,
  546. ._timer_setfn = esp_coex_common_timer_setfn_wrapper,
  547. ._timer_arm_us = esp_coex_common_timer_arm_us_wrapper,
  548. ._wifi_reset_mac = wifi_reset_mac_wrapper,
  549. ._wifi_clock_enable = wifi_clock_enable_wrapper,
  550. ._wifi_clock_disable = wifi_clock_disable_wrapper,
  551. ._wifi_rtc_enable_iso = wifi_rtc_enable_iso_wrapper,
  552. ._wifi_rtc_disable_iso = wifi_rtc_disable_iso_wrapper,
  553. ._esp_timer_get_time = esp_timer_get_time,
  554. ._nvs_set_i8 = nvs_set_i8,
  555. ._nvs_get_i8 = nvs_get_i8,
  556. ._nvs_set_u8 = nvs_set_u8,
  557. ._nvs_get_u8 = nvs_get_u8,
  558. ._nvs_set_u16 = nvs_set_u16,
  559. ._nvs_get_u16 = nvs_get_u16,
  560. ._nvs_open = nvs_open,
  561. ._nvs_close = nvs_close,
  562. ._nvs_commit = nvs_commit,
  563. ._nvs_set_blob = nvs_set_blob,
  564. ._nvs_get_blob = nvs_get_blob,
  565. ._nvs_erase_key = nvs_erase_key,
  566. ._get_random = os_get_random,
  567. ._get_time = get_time_wrapper,
  568. ._random = os_random,
  569. ._slowclk_cal_get = esp_coex_common_clk_slowclk_cal_get_wrapper,
  570. ._log_write = esp_log_write,
  571. ._log_writev = esp_log_writev,
  572. ._log_timestamp = esp_log_timestamp,
  573. ._malloc_internal = esp_coex_common_malloc_internal_wrapper,
  574. ._realloc_internal = realloc_internal_wrapper,
  575. ._calloc_internal = calloc_internal_wrapper,
  576. ._zalloc_internal = zalloc_internal_wrapper,
  577. ._wifi_malloc = wifi_malloc,
  578. ._wifi_realloc = wifi_realloc,
  579. ._wifi_calloc = wifi_calloc,
  580. ._wifi_zalloc = wifi_zalloc_wrapper,
  581. ._wifi_create_queue = wifi_create_queue_wrapper,
  582. ._wifi_delete_queue = wifi_delete_queue_wrapper,
  583. ._coex_init = coex_init_wrapper,
  584. ._coex_deinit = coex_deinit_wrapper,
  585. ._coex_enable = coex_enable_wrapper,
  586. ._coex_disable = coex_disable_wrapper,
  587. ._coex_status_get = coex_status_get_wrapper,
  588. ._coex_wifi_request = coex_wifi_request_wrapper,
  589. ._coex_wifi_release = coex_wifi_release_wrapper,
  590. ._coex_wifi_channel_set = coex_wifi_channel_set_wrapper,
  591. ._coex_event_duration_get = coex_event_duration_get_wrapper,
  592. ._coex_pti_get = coex_pti_get_wrapper,
  593. ._coex_schm_status_bit_clear = coex_schm_status_bit_clear_wrapper,
  594. ._coex_schm_status_bit_set = coex_schm_status_bit_set_wrapper,
  595. ._coex_schm_interval_set = coex_schm_interval_set_wrapper,
  596. ._coex_schm_interval_get = coex_schm_interval_get_wrapper,
  597. ._coex_schm_curr_period_get = coex_schm_curr_period_get_wrapper,
  598. ._coex_schm_curr_phase_get = coex_schm_curr_phase_get_wrapper,
  599. ._coex_register_start_cb = coex_register_start_cb_wrapper,
  600. ._coex_schm_process_restart = coex_schm_process_restart_wrapper,
  601. ._coex_schm_register_cb = coex_schm_register_cb_wrapper,
  602. ._magic = ESP_WIFI_OS_ADAPTER_MAGIC,
  603. };