Skip to content

Fix CMake PATH parser for Windows #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,14 @@ endfunction()

function(get_include_dirs target dirs)
get_target_property(include_dirs ${target} INTERFACE_INCLUDE_DIRECTORIES)
# normalited this path "/../"
if(include_dirs)
foreach(dir IN LISTS include_dirs)
file(TO_CMAKE_PATH "${dir}" normalized_dir)
file(REAL_PATH "${normalized_dir}" resolved_dir BASE_DIRECTORY "${CMAKE_SOURCE_DIR}")
list(APPEND normalized_dirs "${resolved_dir}")
endforeach()
string(REPLACE ";" " " include_dirs "${normalized_dirs}")
set(${dirs} "${include_dirs}" PARENT_SCOPE)
else()
set(${dirs} "" PARENT_SCOPE)
Expand Down
1 change: 1 addition & 0 deletions dt-rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
- "nordic,nrf51-flash-controller"
- "raspberrypi,pico-flash-controller"
- "zephyr,sim-flash"
- "espressif,esp32-flash-controller"
level: 0
actions:
- !Instance
Expand Down
1 change: 1 addition & 0 deletions zephyr-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ fn main() -> Result<()> {
.derive_copy(false)
.allowlist_function("k_.*")
.allowlist_function("gpio_.*")
.allowlist_function("auxdisplay_.*")
.allowlist_function("flash_.*")
.allowlist_function("zr_.*")
.allowlist_item("GPIO_.*")
Expand Down
1 change: 1 addition & 0 deletions zephyr-sys/wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ extern int errno;
#include <zephyr/logging/log.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/drivers/flash.h>
#include <zephyr/drivers/auxdisplay.h>
#include <zephyr/irq.h>

/*
Expand Down
11 changes: 8 additions & 3 deletions zephyr/src/device/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ mod async_io {
use embassy_sync::waitqueue::AtomicWaker;
use zephyr_sys::{
device, gpio_add_callback, gpio_callback, gpio_init_callback, gpio_pin_interrupt_configure,
gpio_pin_interrupt_configure_dt, gpio_port_pins_t, GPIO_INT_LEVEL_HIGH, GPIO_INT_LEVEL_LOW,
gpio_pin_interrupt_configure_dt, gpio_port_pins_t, GPIO_INT_EDGE_FALLING, GPIO_INT_EDGE_RISING,
ZR_GPIO_INT_MODE_DISABLE_ONLY,
};

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

let mode = match self.level {
0 => GPIO_INT_LEVEL_LOW,
1 => GPIO_INT_LEVEL_HIGH,
0 => GPIO_INT_EDGE_FALLING/*GPIO_INT_LEVEL_LOW*/,
1 => GPIO_INT_EDGE_RISING/*GPIO_INT_LEVEL_HIGH*/,
_ => unreachable!(),
};

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

if self.level == zephyr_sys::gpio_pin_get_raw(self.pin.pin.port,self.pin.pin.pin) as u8 {
let cb = self.pin.data.callback.get();
GpioStatic::callback_handler(self.pin.pin.port, cb, 1 << self.pin.pin.pin);
}

// Before sleeping, check if it fired, to avoid having to pend if it already
// happened.
if self.pin.data.has_fired(self.pin.pin.pin) {
Expand Down
Loading