did your source code includes them? I find an example, you can refer it
Libgpiod Programing Examples
Following section provides examples how to use in Libgpiod
- How to read the state of an input GPIO pin?
Following example shows how to get the state of a GPIO pin:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "gpiod.h"
int main(int argc, char * argv[]) {
struct gpiod_chip *chip;
struct gpiod_line *line;
char *dev;
int gpio_line;
int i, req, value = 0;
if (argc != 3)
{
printf("Wrong parameters \n \
Usage:\n \
./gpio_read_example <gpio_dev> <line>\n \
Example:\n \
./gpio_read_example /dev/gpiochip4 9 \n"
);
return -1;
}
dev = strdup(argv[1]);
if(!dev)
{
printf("Wrong CharDev Name\n");
return -1;
}
if (argv[2])
{
gpio_line = atoi(strdup(argv[2]));
}
chip = gpiod_chip_open(dev);
if (!chip)
return -1;
line = gpiod_chip_get_line(chip, gpio_line);
if (!line) {
gpiod_chip_close(chip);
return -1;
}
req = gpiod_line_request_input(line, "button");
if (req < 0) {
gpiod_chip_close(chip);
return -1;
}
value = gpiod_line_get_value(line);
printf("GPIO value of %s on line %d is: %d\n", dev, gpio_line, value);
gpiod_chip_close(chip);
}
./gpio_toggle_example /dev/gpiochip4 9