Skip to content

Commit f02e274

Browse files
committed
zephyr-sys: Export irq_lock/unlock
These are macros in Zephyr, so write explicit wrappers for them, that bindgen will be able to directly use. Signed-off-by: David Brown <[email protected]>
1 parent e3518de commit f02e274

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

zephyr-sys/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ fn main() -> Result<()> {
7777
.allowlist_function("k_.*")
7878
.allowlist_function("gpio_.*")
7979
.allowlist_function("flash_.*")
80+
.allowlist_function("zr_.*")
8081
.allowlist_item("GPIO_.*")
8182
.allowlist_item("FLASH_.*")
8283
.allowlist_item("Z_.*")

zephyr-sys/wrapper.h

+13
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ extern int errno;
4242
#include <zephyr/logging/log.h>
4343
#include <zephyr/bluetooth/bluetooth.h>
4444
#include <zephyr/drivers/flash.h>
45+
#include <zephyr/irq.h>
4546

4647
/*
4748
* bindgen will only output #defined constants that resolve to simple numbers. These are some
@@ -61,3 +62,15 @@ const uint32_t ZR_POLL_TYPE_DATA_AVAILABLE = K_POLL_TYPE_DATA_AVAILABLE;
6162
const uint32_t ZR_GPIO_INT_MODE_DISABLE_ONLY = GPIO_INT_MODE_DISABLE_ONLY;
6263
const uint32_t ZR_GPIO_INT_MODE_ENABLE_ONLY = GPIO_INT_MODE_ENABLE_ONLY;
6364
#endif
65+
66+
/*
67+
* Zephyr's irq_lock() and irq_unlock() are macros not inline functions, so we need some inlines to
68+
* access them.
69+
*/
70+
static inline int zr_irq_lock(void) {
71+
return irq_lock();
72+
}
73+
74+
static inline void zr_irq_unlock(int key) {
75+
irq_unlock(key);
76+
}

0 commit comments

Comments
 (0)