esp_adapter.c 19 KB

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