diff --git a/main.c b/main.c index f09b1d1..7660808 100644 --- a/main.c +++ b/main.c @@ -15,17 +15,10 @@ int gpio_write(int gpio, int value); int main (int argc, char *argv[]){ int fd; - char pin[] = "17"; - + char pin[] = "17"; gpio_export(pin); + char direction[] = "out"; //pin direction - fd = open("/sys/class/gpio/chip0/gpio17/direction", O_WRONLY); - if (fd < 0){ - perror("Error opening the GPIO path"); - return -1; - } - write(fd,"out", 3); - close(fd); //pin value @@ -79,7 +72,25 @@ int gpio_export(const char *gpio){ perror("Error opening the GPIO path"); return -1; } - write(fd,gpio, strlen(gpio)); + write(fd, gpio, strlen(gpio)); close(fd); return(0); } +//pin_directions + +int gpio_direction(int gpio, const char *direction){ + + int fd; + + fd = open("/sys/class/gpio/chip0/gpio17/direction", O_WRONLY); + if (fd < 0){ + perror("Error opening the GPIO path"); + return -1; + } + write(fd, direction, 3); + close(fd); + return (0); +} +//pin_value + +