1 // Copyright 2019 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 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef __ESP_COEXIST_ADAPTER_H__
16 #define __ESP_COEXIST_ADAPTER_H__
17 
18 #include <stdarg.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 #define COEX_ADAPTER_VERSION  0x00000002
25 #define COEX_ADAPTER_MAGIC    0xDEADBEAF
26 
27 #define COEX_ADAPTER_FUNCS_TIME_BLOCKING      0xffffffff
28 
29 typedef struct {
30     int32_t _version;
31 #if CONFIG_IDF_TARGET_ESP32
32     void *(* _spin_lock_create)(void);
33     void (* _spin_lock_delete)(void *lock);
34     uint32_t (*_int_disable)(void *mux);
35     void (*_int_enable)(void *mux, uint32_t tmp);
36 #endif
37     void (*_task_yield_from_isr)(void);
38     void *(*_semphr_create)(uint32_t max, uint32_t init);
39     void (*_semphr_delete)(void *semphr);
40     int32_t (*_semphr_take_from_isr)(void *semphr, void *hptw);
41     int32_t (*_semphr_give_from_isr)(void *semphr, void *hptw);
42     int32_t (*_semphr_take)(void *semphr, uint32_t block_time_tick);
43     int32_t (*_semphr_give)(void *semphr);
44     int (* _is_in_isr)(void);
45     void * (* _malloc_internal)(size_t size);
46     void (* _free)(void *p);
47 #if CONFIG_IDF_TARGET_ESP32
48     void (* _timer_disarm)(void *timer);
49     void (* _timer_done)(void *ptimer);
50     void (* _timer_setfn)(void *ptimer, void *pfunction, void *parg);
51     void (* _timer_arm_us)(void *ptimer, uint32_t us, bool repeat);
52 #endif
53     int64_t (* _esp_timer_get_time)(void);
54     int32_t _magic;
55 } coex_adapter_funcs_t;
56 
57 extern coex_adapter_funcs_t g_coex_adapter_funcs;
58 
59 #ifdef __cplusplus
60 }
61 #endif
62 
63 #endif /* __ESP_COEXIST_ADAPTER_H__ */
64