Skip to content

Commit 830b748

Browse files
committed
zephyr-build: add aux_display support and fixed the gpio interrupt for stm32 series.
The zephyr-build parser was missing aux_display support, which was included and used in a demo; https://github.com/coskunergan/zephyr_rust_demo Signed-off-by: coskun ergan <[email protected]>
1 parent 0fc7432 commit 830b748

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

zephyr-sys/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ fn main() -> Result<()> {
7676
.derive_copy(false)
7777
.allowlist_function("k_.*")
7878
.allowlist_function("gpio_.*")
79+
.allowlist_function("auxdisplay_.*")
7980
.allowlist_function("flash_.*")
8081
.allowlist_item("GPIO_.*")
8182
.allowlist_item("FLASH_.*")

zephyr-sys/wrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ extern int errno;
4242
#include <zephyr/logging/log.h>
4343
#include <zephyr/bluetooth/bluetooth.h>
4444
#include <zephyr/drivers/flash.h>
45-
45+
#include <zephyr/drivers/auxdisplay.h>
4646
/*
4747
* bindgen will only output #defined constants that resolve to simple numbers. These are some
4848
* symbols that we want exported that, at least in some situations, are more complex, usually with a

zephyr/src/device/gpio.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ mod async_io {
3131
use embassy_sync::waitqueue::AtomicWaker;
3232
use zephyr_sys::{
3333
device, gpio_add_callback, gpio_callback, gpio_init_callback, gpio_pin_interrupt_configure,
34-
gpio_pin_interrupt_configure_dt, gpio_port_pins_t, GPIO_INT_LEVEL_HIGH, GPIO_INT_LEVEL_LOW,
34+
gpio_pin_interrupt_configure_dt, gpio_port_pins_t, GPIO_INT_EDGE_FALLING, GPIO_INT_EDGE_RISING,
3535
ZR_GPIO_INT_MODE_DISABLE_ONLY,
3636
};
3737

@@ -212,14 +212,19 @@ mod async_io {
212212
self.pin.data.register(self.pin.pin.pin, cx.waker());
213213

214214
let mode = match self.level {
215-
0 => GPIO_INT_LEVEL_LOW,
216-
1 => GPIO_INT_LEVEL_HIGH,
215+
0 => GPIO_INT_EDGE_FALLING/*GPIO_INT_LEVEL_LOW*/,
216+
1 => GPIO_INT_EDGE_RISING/*GPIO_INT_LEVEL_HIGH*/,
217217
_ => unreachable!(),
218218
};
219219

220220
unsafe {
221221
gpio_pin_interrupt_configure_dt(&self.pin.pin, mode);
222222

223+
if self.level == zephyr_sys::gpio_pin_get_raw(self.pin.pin.port,self.pin.pin.pin) as u8 {
224+
let cb = self.pin.data.callback.get();
225+
GpioStatic::callback_handler(self.pin.pin.port, cb, 1 << self.pin.pin.pin);
226+
}
227+
223228
// Before sleeping, check if it fired, to avoid having to pend if it already
224229
// happened.
225230
if self.pin.data.has_fired(self.pin.pin.pin) {

0 commit comments

Comments
 (0)