esp_adapter.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. // Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #include <stddef.h>
  14. #include <stdlib.h>
  15. #include <stdio.h>
  16. #include <string.h>
  17. #include <assert.h>
  18. #include <pthread.h>
  19. #include "freertos/FreeRTOS.h"
  20. #include "freertos/task.h"
  21. #include "freertos/queue.h"
  22. #include "freertos/semphr.h"
  23. #include "freertos/event_groups.h"
  24. #include "freertos/xtensa_api.h"
  25. #include "freertos/portmacro.h"
  26. #include "freertos/xtensa_api.h"
  27. #include "esp_types.h"
  28. #include "esp_system.h"
  29. #include "esp_task.h"
  30. #include "esp_intr.h"
  31. #include "esp_attr.h"
  32. #include "esp_log.h"
  33. #include "esp_heap_caps.h"
  34. #include "esp_wifi_os_adapter.h"
  35. #include "esp_wifi_internal.h"
  36. #include "esp_phy_init.h"
  37. #include "crypto/md5.h"
  38. #include "crypto/sha1.h"
  39. #include "crypto/crypto.h"
  40. #include "crypto/aes.h"
  41. #include "crypto/dh_group5.h"
  42. #include "driver/periph_ctrl.h"
  43. #include "nvs.h"
  44. #include "os.h"
  45. #include "esp_smartconfig.h"
  46. #include "smartconfig_ack.h"
  47. #include "esp_coexist_internal.h"
  48. #include "esp_coexist_adapter.h"
  49. extern void esp_dport_access_stall_other_cpu_start_wrap(void);
  50. extern void esp_dport_access_stall_other_cpu_end_wrap(void);
  51. #define TAG "esp_adapter"
  52. /*
  53. If CONFIG_WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST is enabled. Prefer to allocate a chunk of memory in SPIRAM firstly.
  54. If failed, try to allocate it in internal memory then.
  55. */
  56. IRAM_ATTR void *wifi_malloc( size_t size )
  57. {
  58. #if CONFIG_WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST
  59. return heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL);
  60. #else
  61. return malloc(size);
  62. #endif
  63. }
  64. /*
  65. If CONFIG_WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST is enabled. Prefer to allocate a chunk of memory in SPIRAM firstly.
  66. If failed, try to allocate it in internal memory then.
  67. */
  68. IRAM_ATTR void *wifi_realloc( void *ptr, size_t size )
  69. {
  70. #if CONFIG_WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST
  71. return heap_caps_realloc_prefer(ptr, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL);
  72. #else
  73. return realloc(ptr, size);
  74. #endif
  75. }
  76. /*
  77. If CONFIG_WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST is enabled. Prefer to allocate a chunk of memory in SPIRAM firstly.
  78. If failed, try to allocate it in internal memory then.
  79. */
  80. IRAM_ATTR void *wifi_calloc( size_t n, size_t size )
  81. {
  82. #if CONFIG_WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST
  83. return heap_caps_calloc_prefer(n, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL);
  84. #else
  85. return calloc(n, size);
  86. #endif
  87. }
  88. static void * IRAM_ATTR wifi_zalloc_wrapper(size_t size)
  89. {
  90. void *ptr = wifi_calloc(1, size);
  91. if (ptr) {
  92. memset(ptr, 0, size);
  93. }
  94. return ptr;
  95. }
  96. wifi_static_queue_t* wifi_create_queue( int queue_len, int item_size)
  97. {
  98. wifi_static_queue_t *queue = NULL;
  99. queue = (wifi_static_queue_t*)heap_caps_malloc(sizeof(wifi_static_queue_t), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
  100. if (!queue) {
  101. return NULL;
  102. }
  103. #if CONFIG_SPIRAM_USE_MALLOC
  104. queue->storage = heap_caps_calloc(1, sizeof(StaticQueue_t) + (queue_len*item_size), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
  105. if (!queue->storage) {
  106. goto _error;
  107. }
  108. queue->handle = xQueueCreateStatic( queue_len, item_size, ((uint8_t*)(queue->storage)) + sizeof(StaticQueue_t), (StaticQueue_t*)(queue->storage));
  109. if (!queue->handle) {
  110. goto _error;
  111. }
  112. return queue;
  113. _error:
  114. if (queue) {
  115. if (queue->storage) {
  116. free(queue->storage);
  117. }
  118. free(queue);
  119. }
  120. return NULL;
  121. #else
  122. queue->handle = xQueueCreate( queue_len, item_size);
  123. return queue;
  124. #endif
  125. }
  126. void wifi_delete_queue(wifi_static_queue_t *queue)
  127. {
  128. if (queue) {
  129. vQueueDelete(queue->handle);
  130. #if CONFIG_SPIRAM_USE_MALLOC
  131. if (queue->storage) {
  132. free(queue->storage);
  133. }
  134. #endif
  135. free(queue);
  136. }
  137. }
  138. static void * wifi_create_queue_wrapper(int queue_len, int item_size)
  139. {
  140. return wifi_create_queue(queue_len, item_size);
  141. }
  142. static void wifi_delete_queue_wrapper(void *queue)
  143. {
  144. wifi_delete_queue(queue);
  145. }
  146. static void set_isr_wrapper(int32_t n, void *f, void *arg)
  147. {
  148. xt_set_interrupt_handler(n, (xt_handler)f, arg);
  149. }
  150. static void * spin_lock_create_wrapper(void)
  151. {
  152. portMUX_TYPE tmp = portMUX_INITIALIZER_UNLOCKED;
  153. void *mux = heap_caps_malloc(sizeof(portMUX_TYPE), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
  154. if (mux) {
  155. memcpy(mux,&tmp,sizeof(portMUX_TYPE));
  156. return mux;
  157. }
  158. return NULL;
  159. }
  160. static uint32_t IRAM_ATTR wifi_int_disable_wrapper(void *wifi_int_mux)
  161. {
  162. if (xPortInIsrContext()) {
  163. portENTER_CRITICAL_ISR(wifi_int_mux);
  164. } else {
  165. portENTER_CRITICAL(wifi_int_mux);
  166. }
  167. return 0;
  168. }
  169. static void IRAM_ATTR wifi_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp)
  170. {
  171. if (xPortInIsrContext()) {
  172. portEXIT_CRITICAL_ISR(wifi_int_mux);
  173. } else {
  174. portEXIT_CRITICAL(wifi_int_mux);
  175. }
  176. }
  177. static void IRAM_ATTR task_yield_from_isr_wrapper(void)
  178. {
  179. portYIELD_FROM_ISR();
  180. }
  181. static void * semphr_create_wrapper(uint32_t max, uint32_t init)
  182. {
  183. return (void *)xSemaphoreCreateCounting(max, init);
  184. }
  185. static void semphr_delete_wrapper(void *semphr)
  186. {
  187. vSemaphoreDelete(semphr);
  188. }
  189. static void wifi_thread_semphr_free(void* data)
  190. {
  191. xSemaphoreHandle *sem = (xSemaphoreHandle*)(data);
  192. if (sem) {
  193. vSemaphoreDelete(sem);
  194. }
  195. }
  196. static void * wifi_thread_semphr_get_wrapper(void)
  197. {
  198. static bool s_wifi_thread_sem_key_init = false;
  199. static pthread_key_t s_wifi_thread_sem_key;
  200. xSemaphoreHandle sem = NULL;
  201. if (s_wifi_thread_sem_key_init == false) {
  202. if (0 != pthread_key_create(&s_wifi_thread_sem_key, wifi_thread_semphr_free)) {
  203. return NULL;
  204. }
  205. s_wifi_thread_sem_key_init = true;
  206. }
  207. sem = pthread_getspecific(s_wifi_thread_sem_key);
  208. if (!sem) {
  209. sem = xSemaphoreCreateCounting(1, 0);
  210. if (sem) {
  211. pthread_setspecific(s_wifi_thread_sem_key, sem);
  212. ESP_LOGV(TAG, "thread sem create: sem=%p", sem);
  213. }
  214. }
  215. ESP_LOGV(TAG, "thread sem get: sem=%p", sem);
  216. return (void*)sem;
  217. }
  218. static int32_t IRAM_ATTR semphr_take_from_isr_wrapper(void *semphr, void *hptw)
  219. {
  220. return (int32_t)xSemaphoreTakeFromISR(semphr, hptw);
  221. }
  222. static int32_t IRAM_ATTR semphr_give_from_isr_wrapper(void *semphr, void *hptw)
  223. {
  224. return (int32_t)xSemaphoreGiveFromISR(semphr, hptw);
  225. }
  226. static int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
  227. {
  228. if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
  229. return (int32_t)xSemaphoreTake(semphr, portMAX_DELAY);
  230. } else {
  231. return (int32_t)xSemaphoreTake(semphr, block_time_tick);
  232. }
  233. }
  234. static int32_t semphr_give_wrapper(void *semphr)
  235. {
  236. return (int32_t)xSemaphoreGive(semphr);
  237. }
  238. static void * recursive_mutex_create_wrapper(void)
  239. {
  240. return (void *)xSemaphoreCreateRecursiveMutex();
  241. }
  242. static void * mutex_create_wrapper(void)
  243. {
  244. return (void *)xSemaphoreCreateMutex();
  245. }
  246. static void mutex_delete_wrapper(void *mutex)
  247. {
  248. vSemaphoreDelete(mutex);
  249. }
  250. static int32_t IRAM_ATTR mutex_lock_wrapper(void *mutex)
  251. {
  252. return (int32_t)xSemaphoreTakeRecursive(mutex, portMAX_DELAY);
  253. }
  254. static int32_t IRAM_ATTR mutex_unlock_wrapper(void *mutex)
  255. {
  256. return (int32_t)xSemaphoreGiveRecursive(mutex);
  257. }
  258. static void * queue_create_wrapper(uint32_t queue_len, uint32_t item_size)
  259. {
  260. return (void *)xQueueCreate(queue_len, item_size);
  261. }
  262. static int32_t queue_send_wrapper(void *queue, void *item, uint32_t block_time_tick)
  263. {
  264. if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
  265. return (int32_t)xQueueSend(queue, item, portMAX_DELAY);
  266. } else {
  267. return (int32_t)xQueueSend(queue, item, block_time_tick);
  268. }
  269. }
  270. static int32_t IRAM_ATTR queue_send_from_isr_wrapper(void *queue, void *item, void *hptw)
  271. {
  272. return (int32_t)xQueueSendFromISR(queue, item, hptw);
  273. }
  274. static int32_t queue_send_to_back_wrapper(void *queue, void *item, uint32_t block_time_tick)
  275. {
  276. return (int32_t)xQueueGenericSend(queue, item, block_time_tick, queueSEND_TO_BACK);
  277. }
  278. static int32_t queue_send_to_front_wrapper(void *queue, void *item, uint32_t block_time_tick)
  279. {
  280. return (int32_t)xQueueGenericSend(queue, item, block_time_tick, queueSEND_TO_FRONT);
  281. }
  282. static int32_t queue_recv_wrapper(void *queue, void *item, uint32_t block_time_tick)
  283. {
  284. if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
  285. return (int32_t)xQueueReceive(queue, item, portMAX_DELAY);
  286. } else {
  287. return (int32_t)xQueueReceive(queue, item, block_time_tick);
  288. }
  289. }
  290. 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)
  291. {
  292. if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
  293. return (uint32_t)xEventGroupWaitBits(event, bits_to_wait_for, clear_on_exit, wait_for_all_bits, portMAX_DELAY);
  294. } else {
  295. return (uint32_t)xEventGroupWaitBits(event, bits_to_wait_for, clear_on_exit, wait_for_all_bits, block_time_tick);
  296. }
  297. }
  298. 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)
  299. {
  300. return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle, (core_id < portNUM_PROCESSORS ? core_id : tskNO_AFFINITY));
  301. }
  302. static int32_t task_create_wrapper(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle)
  303. {
  304. return (uint32_t)xTaskCreate(task_func, name, stack_depth, param, prio, task_handle);
  305. }
  306. static int32_t IRAM_ATTR task_ms_to_tick_wrapper(uint32_t ms)
  307. {
  308. return (int32_t)(ms / portTICK_PERIOD_MS);
  309. }
  310. static int32_t task_get_max_priority_wrapper(void)
  311. {
  312. return (int32_t)(configMAX_PRIORITIES);
  313. }
  314. static void IRAM_ATTR timer_arm_wrapper(void *timer, uint32_t tmout, bool repeat)
  315. {
  316. ets_timer_arm(timer, tmout, repeat);
  317. }
  318. static void IRAM_ATTR timer_disarm_wrapper(void *timer)
  319. {
  320. ets_timer_disarm(timer);
  321. }
  322. static void timer_done_wrapper(void *ptimer)
  323. {
  324. ets_timer_done(ptimer);
  325. }
  326. static void timer_setfn_wrapper(void *ptimer, void *pfunction, void *parg)
  327. {
  328. ets_timer_setfn(ptimer, pfunction, parg);
  329. }
  330. static void IRAM_ATTR timer_arm_us_wrapper(void *ptimer, uint32_t us, bool repeat)
  331. {
  332. ets_timer_arm_us(ptimer, us, repeat);
  333. }
  334. static int get_time_wrapper(void *t)
  335. {
  336. return os_get_time(t);
  337. }
  338. static void * IRAM_ATTR malloc_internal_wrapper(size_t size)
  339. {
  340. return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
  341. }
  342. static void * IRAM_ATTR realloc_internal_wrapper(void *ptr, size_t size)
  343. {
  344. return heap_caps_realloc(ptr, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
  345. }
  346. static void * IRAM_ATTR calloc_internal_wrapper(size_t n, size_t size)
  347. {
  348. return heap_caps_calloc(n, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
  349. }
  350. static void * IRAM_ATTR zalloc_internal_wrapper(size_t size)
  351. {
  352. void *ptr = heap_caps_calloc(1, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
  353. if (ptr) {
  354. memset(ptr, 0, size);
  355. }
  356. return ptr;
  357. }
  358. static void sc_ack_send_wrapper(void *param)
  359. {
  360. return sc_ack_send((sc_ack_t *)param);
  361. }
  362. static uint32_t coex_status_get_wrapper(void)
  363. {
  364. #if CONFIG_SW_COEXIST_ENABLE
  365. return coex_status_get();
  366. #else
  367. return 0;
  368. #endif
  369. }
  370. static void coex_condition_set_wrapper(uint32_t type, bool dissatisfy)
  371. {
  372. #if CONFIG_SW_COEXIST_ENABLE
  373. coex_condition_set(type, dissatisfy);
  374. #endif
  375. }
  376. static int coex_wifi_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration)
  377. {
  378. #if CONFIG_SW_COEXIST_ENABLE
  379. return coex_wifi_request(event, latency, duration);
  380. #else
  381. return 0;
  382. #endif
  383. }
  384. static int coex_wifi_release_wrapper(uint32_t event)
  385. {
  386. #if CONFIG_SW_COEXIST_ENABLE
  387. return coex_wifi_release(event);
  388. #else
  389. return 0;
  390. #endif
  391. }
  392. static int coex_wifi_channel_set_wrapper(uint8_t primary, uint8_t secondary)
  393. {
  394. #if CONFIG_SW_COEXIST_ENABLE
  395. return coex_wifi_channel_set(primary, secondary);
  396. #else
  397. return 0;
  398. #endif
  399. }
  400. static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status)
  401. {
  402. #if CONFIG_SW_COEXIST_ENABLE
  403. coex_schm_status_bit_clear(type, status);
  404. #endif
  405. }
  406. static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status)
  407. {
  408. #if CONFIG_SW_COEXIST_ENABLE
  409. coex_schm_status_bit_set(type, status);
  410. #endif
  411. }
  412. static IRAM_ATTR int coex_schm_interval_set_wrapper(uint32_t interval)
  413. {
  414. #if CONFIG_SW_COEXIST_ENABLE
  415. return coex_schm_interval_set(interval);
  416. #else
  417. return 0;
  418. #endif
  419. }
  420. static uint32_t coex_schm_interval_get_wrapper(void)
  421. {
  422. #if CONFIG_SW_COEXIST_ENABLE
  423. return coex_schm_interval_get();
  424. #else
  425. return 0;
  426. #endif
  427. }
  428. static uint8_t coex_schm_curr_period_get_wrapper(void)
  429. {
  430. #if CONFIG_SW_COEXIST_ENABLE
  431. return coex_schm_curr_period_get();
  432. #else
  433. return 0;
  434. #endif
  435. }
  436. static void * coex_schm_curr_phase_get_wrapper(void)
  437. {
  438. #if CONFIG_SW_COEXIST_ENABLE
  439. return coex_schm_curr_phase_get();
  440. #else
  441. return NULL;
  442. #endif
  443. }
  444. static int coex_schm_curr_phase_idx_set_wrapper(int idx)
  445. {
  446. #if CONFIG_SW_COEXIST_ENABLE
  447. return coex_schm_curr_phase_idx_set(idx);
  448. #else
  449. return 0;
  450. #endif
  451. }
  452. static int coex_schm_curr_phase_idx_get_wrapper(void)
  453. {
  454. #if CONFIG_SW_COEXIST_ENABLE
  455. return coex_schm_curr_phase_idx_get();
  456. #else
  457. return 0;
  458. #endif
  459. }
  460. int32_t IRAM_ATTR coex_is_in_isr_wrapper(void)
  461. {
  462. return !xPortCanYield();
  463. }
  464. wifi_osi_funcs_t g_wifi_osi_funcs = {
  465. ._version = ESP_WIFI_OS_ADAPTER_VERSION,
  466. ._set_isr = set_isr_wrapper,
  467. ._ints_on = xt_ints_on,
  468. ._ints_off = xt_ints_off,
  469. ._spin_lock_create = spin_lock_create_wrapper,
  470. ._spin_lock_delete = free,
  471. ._wifi_int_disable = wifi_int_disable_wrapper,
  472. ._wifi_int_restore = wifi_int_restore_wrapper,
  473. ._task_yield_from_isr = task_yield_from_isr_wrapper,
  474. ._semphr_create = semphr_create_wrapper,
  475. ._semphr_delete = semphr_delete_wrapper,
  476. ._semphr_take = semphr_take_wrapper,
  477. ._semphr_give = semphr_give_wrapper,
  478. ._wifi_thread_semphr_get = wifi_thread_semphr_get_wrapper,
  479. ._mutex_create = mutex_create_wrapper,
  480. ._recursive_mutex_create = recursive_mutex_create_wrapper,
  481. ._mutex_delete = mutex_delete_wrapper,
  482. ._mutex_lock = mutex_lock_wrapper,
  483. ._mutex_unlock = mutex_unlock_wrapper,
  484. ._queue_create = queue_create_wrapper,
  485. ._queue_delete = (void(*)(void *))vQueueDelete,
  486. ._queue_send = queue_send_wrapper,
  487. ._queue_send_from_isr = queue_send_from_isr_wrapper,
  488. ._queue_send_to_back = queue_send_to_back_wrapper,
  489. ._queue_send_to_front = queue_send_to_front_wrapper,
  490. ._queue_recv = queue_recv_wrapper,
  491. ._queue_msg_waiting = (uint32_t(*)(void *))uxQueueMessagesWaiting,
  492. ._event_group_create = (void *(*)(void))xEventGroupCreate,
  493. ._event_group_delete = (void(*)(void *))vEventGroupDelete,
  494. ._event_group_set_bits = (uint32_t(*)(void *,uint32_t))xEventGroupSetBits,
  495. ._event_group_clear_bits = (uint32_t(*)(void *,uint32_t))xEventGroupClearBits,
  496. ._event_group_wait_bits = event_group_wait_bits_wrapper,
  497. ._task_create_pinned_to_core = task_create_pinned_to_core_wrapper,
  498. ._task_create = task_create_wrapper,
  499. ._task_delete = (void(*)(void *))vTaskDelete,
  500. ._task_delay = vTaskDelay,
  501. ._task_ms_to_tick = task_ms_to_tick_wrapper,
  502. ._task_get_current_task = (void *(*)(void))xTaskGetCurrentTaskHandle,
  503. ._task_get_max_priority = task_get_max_priority_wrapper,
  504. ._malloc = malloc,
  505. ._free = free,
  506. ._get_free_heap_size = esp_get_free_internal_heap_size,
  507. ._rand = esp_random,
  508. ._dport_access_stall_other_cpu_start_wrap = esp_dport_access_stall_other_cpu_start_wrap,
  509. ._dport_access_stall_other_cpu_end_wrap = esp_dport_access_stall_other_cpu_end_wrap,
  510. ._phy_rf_deinit = esp_phy_rf_deinit,
  511. ._phy_load_cal_and_init = esp_phy_load_cal_and_init,
  512. ._phy_common_clock_enable = esp_phy_common_clock_enable,
  513. ._phy_common_clock_disable = esp_phy_common_clock_disable,
  514. ._read_mac = esp_read_mac,
  515. ._timer_arm = timer_arm_wrapper,
  516. ._timer_disarm = timer_disarm_wrapper,
  517. ._timer_done = timer_done_wrapper,
  518. ._timer_setfn = timer_setfn_wrapper,
  519. ._timer_arm_us = timer_arm_us_wrapper,
  520. ._periph_module_enable = periph_module_enable,
  521. ._periph_module_disable = periph_module_disable,
  522. ._esp_timer_get_time = esp_timer_get_time,
  523. ._nvs_set_i8 = nvs_set_i8,
  524. ._nvs_get_i8 = nvs_get_i8,
  525. ._nvs_set_u8 = nvs_set_u8,
  526. ._nvs_get_u8 = nvs_get_u8,
  527. ._nvs_set_u16 = nvs_set_u16,
  528. ._nvs_get_u16 = nvs_get_u16,
  529. ._nvs_open = nvs_open,
  530. ._nvs_close = nvs_close,
  531. ._nvs_commit = nvs_commit,
  532. ._nvs_set_blob = nvs_set_blob,
  533. ._nvs_get_blob = nvs_get_blob,
  534. ._nvs_erase_key = nvs_erase_key,
  535. ._get_random = os_get_random,
  536. ._get_time = get_time_wrapper,
  537. ._random = os_random,
  538. ._log_write = esp_log_write,
  539. ._log_writev = esp_log_writev,
  540. ._log_timestamp = esp_log_timestamp,
  541. ._malloc_internal = malloc_internal_wrapper,
  542. ._realloc_internal = realloc_internal_wrapper,
  543. ._calloc_internal = calloc_internal_wrapper,
  544. ._zalloc_internal = zalloc_internal_wrapper,
  545. ._wifi_malloc = wifi_malloc,
  546. ._wifi_realloc = wifi_realloc,
  547. ._wifi_calloc = wifi_calloc,
  548. ._wifi_zalloc = wifi_zalloc_wrapper,
  549. ._wifi_create_queue = wifi_create_queue_wrapper,
  550. ._wifi_delete_queue = wifi_delete_queue_wrapper,
  551. ._modem_sleep_enter = esp_modem_sleep_enter,
  552. ._modem_sleep_exit = esp_modem_sleep_exit,
  553. ._modem_sleep_register = esp_modem_sleep_register,
  554. ._modem_sleep_deregister = esp_modem_sleep_deregister,
  555. ._sc_ack_send = sc_ack_send_wrapper,
  556. ._sc_ack_send_stop = sc_ack_send_stop,
  557. ._coex_status_get = coex_status_get_wrapper,
  558. ._coex_condition_set = coex_condition_set_wrapper,
  559. ._coex_wifi_request = coex_wifi_request_wrapper,
  560. ._coex_wifi_release = coex_wifi_release_wrapper,
  561. ._coex_wifi_channel_set = coex_wifi_channel_set_wrapper,
  562. ._coex_schm_status_bit_clear = coex_schm_status_bit_clear_wrapper,
  563. ._coex_schm_status_bit_set = coex_schm_status_bit_set_wrapper,
  564. ._coex_schm_interval_set = coex_schm_interval_set_wrapper,
  565. ._coex_schm_interval_get = coex_schm_interval_get_wrapper,
  566. ._coex_schm_curr_period_get = coex_schm_curr_period_get_wrapper,
  567. ._coex_schm_curr_phase_get = coex_schm_curr_phase_get_wrapper,
  568. ._coex_schm_curr_phase_idx_set = coex_schm_curr_phase_idx_set_wrapper,
  569. ._coex_schm_curr_phase_idx_get = coex_schm_curr_phase_idx_get_wrapper,
  570. ._magic = ESP_WIFI_OS_ADAPTER_MAGIC,
  571. };
  572. coex_adapter_funcs_t g_coex_adapter_funcs = {
  573. ._version = COEX_ADAPTER_VERSION,
  574. ._spin_lock_create = spin_lock_create_wrapper,
  575. ._spin_lock_delete = free,
  576. ._int_disable = wifi_int_disable_wrapper,
  577. ._int_enable = wifi_int_restore_wrapper,
  578. ._task_yield_from_isr = task_yield_from_isr_wrapper,
  579. ._semphr_create = semphr_create_wrapper,
  580. ._semphr_delete = semphr_delete_wrapper,
  581. ._semphr_take_from_isr = semphr_take_from_isr_wrapper,
  582. ._semphr_give_from_isr = semphr_give_from_isr_wrapper,
  583. ._semphr_take = semphr_take_wrapper,
  584. ._semphr_give = semphr_give_wrapper,
  585. ._is_in_isr = coex_is_in_isr_wrapper,
  586. ._malloc_internal = malloc_internal_wrapper,
  587. ._free = free,
  588. ._timer_disarm = timer_disarm_wrapper,
  589. ._timer_done = timer_done_wrapper,
  590. ._timer_setfn = timer_setfn_wrapper,
  591. ._timer_arm_us = timer_arm_us_wrapper,
  592. ._esp_timer_get_time = esp_timer_get_time,
  593. ._magic = COEX_ADAPTER_MAGIC,
  594. };