feat(nodes): adding window status reading
This commit is contained in:
11
nodes/app.overlay
Normal file
11
nodes/app.overlay
Normal file
@@ -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";
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -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";
|
||||
};
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef WINDOW_STATUS_H
|
||||
#define WINDOW_STATUS_H
|
||||
|
||||
#include <zephyr/drivers/gpio.h>
|
||||
|
||||
#include "error_code.h"
|
||||
|
||||
enum window_status{
|
||||
|
||||
Reference in New Issue
Block a user