diff --git a/nodes/app.overlay b/nodes/app.overlay new file mode 100644 index 0000000..f61dff1 --- /dev/null +++ b/nodes/app.overlay @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: Apache-2.0 */ + +/ { + buttons{ + compatible = "gpio-keys"; + window_switch: window_switch { + gpios = <&gpio0 7 GPIO_ACTIVE_HIGH>; + label = "Window Switch"; + }; + }; +}; diff --git a/nodes/boards/nrf54h20dk_nrf54h20_cpuppr.overlay b/nodes/boards/nrf54h20dk_nrf54h20_cpuppr.overlay deleted file mode 100644 index cbc7b67..0000000 --- a/nodes/boards/nrf54h20dk_nrf54h20_cpuppr.overlay +++ /dev/null @@ -1,23 +0,0 @@ -/* SPDX-License-Identifier: Apache-2.0 */ - -/ { - aliases { - led0 = &led0; - }; - - leds { - compatible = "gpio-leds"; - led0: led_0 { - gpios = <&gpio9 0 GPIO_ACTIVE_HIGH>; - label = "Green LED 0"; - }; - }; -}; - -&gpiote130 { - status = "okay"; -}; - -&gpio9 { - status = "okay"; -}; diff --git a/nodes/src/window_status.c b/nodes/src/window_status.c index 27b2208..3f49374 100644 --- a/nodes/src/window_status.c +++ b/nodes/src/window_status.c @@ -1,9 +1,17 @@ #include "window_status.h" +static const struct gpio_dt_spec window_switch = GPIO_DT_SPEC_GET(DT_NODELABEL(window_switch), gpios); + enum error_code window_init(){ - return success; + enum error_code ret = init_failed; + if(gpio_is_ready_dt(&window_switch) && gpio_pin_configure_dt(&window_switch, GPIO_INPUT)){ + ret = success; + }else{} + return ret; } enum error_code window_get_value(enum window_status* holder){ - return 0; + // active high + *holder = (gpio_pin_get_dt(&window_switch) ? open : closed); + return success; } diff --git a/nodes/src/window_status.h b/nodes/src/window_status.h index 104e0c4..401dfd7 100644 --- a/nodes/src/window_status.h +++ b/nodes/src/window_status.h @@ -1,6 +1,8 @@ #ifndef WINDOW_STATUS_H #define WINDOW_STATUS_H +#include + #include "error_code.h" enum window_status{