export function ok

arguments
Gerardo Marx 2 weeks ago
parent 276fb40fb6
commit 45749112f7

@ -8,16 +8,16 @@
// prototype functions
int gpio_export(const char *gpio);
int gpio_direction(int gpio, const char *direction);
int gpio_direction(int gpio, const char *direction); // this function
int gpio_write(int gpio, int value);
int main(int argc, char *argv[]){
int fd;
char pin[] = "17";
char pin[] = "17"; // get gpio number from argument
gpio_export(pin);
// pin direction
// pin direction - convert into functions
fd = open("/sys/class/gpio/chip0/gpio17/direction", O_WRONLY);
if(fd<0)
{
@ -77,7 +77,7 @@ int gpio_export(const char *gpio){
perror("Error opening the GPIO path");
return -1;
}
write(fd,"17",2);
write(fd,gpio,strlen(gpio));
close(fd);
return 0;
}

Loading…
Cancel
Save