| | |
| | | int i; |
| | | gpio_info_t *gpioinfo; |
| | | |
| | | |
| | | s_gpio = gpio; |
| | | |
| | | |
| | | if( !gpio ) |
| | | { |
| | |
| | | log_warn("WARNNING: No GPIO pins configured\n"); |
| | | return 0; |
| | | } |
| | | |
| | | |
| | | /* gpiod open chip */ |
| | | s_chip = gpiod_chip_open_by_name(RPI_GPIONAME); |
| | |
| | | } |
| | | |
| | | |
| | | #if 0 |
| | | /* Return value: 1(HIGH): Sombody detected 0(LOW): Nobody detected */ |
| | | int infrared_detect(void) |
| | | { |
| | | int i; |
| | | int rv; |
| | | struct gpiod_line_event event; |
| | | |
| | | /* This function will block, must call it to setup */ |
| | | if( gpiod_line_event_wait(s_infrared_lines, NULL) < 0 ) |
| | | for(i=0; i<s_gpio->incnt; i++) |
| | | { |
| | | //log_err("infrared gpiod line wait event failure!\n"); |
| | | if( strstr(s_gpio->input[i].name, "infrared")) |
| | | { |
| | | log_dbg("Start detect '%s' on pin[#%d]\n", s_gpio->input[i].name, s_gpio->input[i].pin); |
| | | |
| | | /* This function will block, must call it to setup */ |
| | | rv = gpiod_line_event_wait(s_gpio->input[i].line, NULL) ; |
| | | if( rv< 0 ) |
| | | { |
| | | log_err("infrared gpiod line wait event failure!\n"); |
| | | return 0; |
| | | } |
| | | log_err("infrared gpiod line wait event rv=%d!\n", rv); |
| | | |
| | | /* This function will block, must read to clear the event */ |
| | | if (gpiod_line_event_read(s_infrared_lines, &event) < 0) |
| | | if (gpiod_line_event_read(s_gpio->input[i].line, &event) < 0) |
| | | { |
| | | log_err("gpiod line event read failure!\n"); |
| | | return 0; |
| | |
| | | else |
| | | return 0; |
| | | } |
| | | } |
| | | } |
| | | |
| | | #endif |