18 lines
526 B
C
18 lines
526 B
C
#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(){
|
|
enum error_code ret = init_failed;
|
|
if(gpio_is_ready_dt(&window_switch) && (0 == gpio_pin_configure_dt(&window_switch, GPIO_INPUT))){
|
|
ret = success;
|
|
}else{}
|
|
return ret;
|
|
}
|
|
|
|
enum error_code window_get_value(enum window_status* holder){
|
|
// active high
|
|
*holder = (gpio_pin_get_dt(&window_switch) ? closed : open);
|
|
return success;
|
|
}
|