-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathwrapper.h
76 lines (65 loc) · 2.34 KB
/
wrapper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* Copyright (c) 2024 Linaro LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* This file is the seed point for bindgen. This determines every header that will be visited for
* binding generation. It should include any Zephyr headers we need bindings for. The driver in
* build.rs will also select which functions need generation, which will determine the types that
* are output.
*/
/*
* This is getting built with KERNEL defined, which causes syscalls to not be implemented. Work
* around this by just undefining this symbol.
*/
#undef KERNEL
#ifdef RUST_BINDGEN
/* errno is coming from somewhere in Zephyr's build. Add the symbol when running bindgen so that it
* is defined here.
*/
extern int errno;
#endif
/* First, make sure we have all of our config settings. */
#include <zephyr/autoconf.h>
/* Gcc defines __SOFT_FP__ when the target uses software floating point, and the CMSIS headers get
* confused without this.
*/
#if defined(CONFIG_CPU_CORTEX_M)
#if !defined(CONFIG_FP_HARDABI) && !defined(FORCE_FP_HARDABI) && !defined(__SOFTFP__)
#define __SOFTFP__
#endif
#endif
#include <zephyr/kernel.h>
#include <zephyr/kernel/thread_stack.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/logging/log.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/drivers/flash.h>
#include <zephyr/irq.h>
/*
* bindgen will only output #defined constants that resolve to simple numbers. These are some
* symbols that we want exported that, at least in some situations, are more complex, usually with a
* type cast.
*
* We'll use the prefix "ZR_" to avoid conflicts with other symbols.
*/
const uintptr_t ZR_STACK_ALIGN = Z_KERNEL_STACK_OBJ_ALIGN;
const uintptr_t ZR_STACK_RESERVED = K_KERNEL_STACK_RESERVED;
const uint32_t ZR_POLL_TYPE_SEM_AVAILABLE = K_POLL_TYPE_SEM_AVAILABLE;
const uint32_t ZR_POLL_TYPE_SIGNAL = K_POLL_TYPE_SIGNAL;
const uint32_t ZR_POLL_TYPE_DATA_AVAILABLE = K_POLL_TYPE_DATA_AVAILABLE;
#ifdef CONFIG_GPIO_ENABLE_DISABLE_INTERRUPT
const uint32_t ZR_GPIO_INT_MODE_DISABLE_ONLY = GPIO_INT_MODE_DISABLE_ONLY;
const uint32_t ZR_GPIO_INT_MODE_ENABLE_ONLY = GPIO_INT_MODE_ENABLE_ONLY;
#endif
/*
* Zephyr's irq_lock() and irq_unlock() are macros not inline functions, so we need some inlines to
* access them.
*/
static inline int zr_irq_lock(void) {
return irq_lock();
}
static inline void zr_irq_unlock(int key) {
irq_unlock(key);
}