Compare commits

..

No commits in common. 'arguments' and 'main' have entirely different histories.

@ -1,21 +1,20 @@
//Leonardo Mendoza 26-sep-2026
#include <stdio.h> #include <stdio.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <string.h>
//Prototypes
int gpio_export(const char *gpio);
int gpio_direction(int gpio, const char *direction);
int gpio_write(int gpio, int value);
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
char pin[] = "17";
gpio_export(pin);
int fd; int fd;
// EXPORT
fd = open("/sys/class/gpio/chip0/export", O_WRONLY);
if(fd<0)
{
perror("Error opening GPIO export path");
return -1;
}
write(fd, "17", 2);
close(fd);
// DIRECTION // DIRECTION
fd = open("/sys/class/gpio/chip0/gpio17/direction", O_WRONLY); fd = open("/sys/class/gpio/chip0/gpio17/direction", O_WRONLY);
if(fd<0) if(fd<0)
@ -77,20 +76,3 @@ int main(int argc, char *argv[])
return 0; return 0;
} }
//Full functions
int gpio_export(const char *gpio)
{
int fd;
// EXPORT
fd = open("/sys/class/gpio/chip0/export", O_WRONLY);
if(fd<0)
{
perror("Error opening GPIO export path");
return -1;
}
write(fd, gpio, strlen(gpio));
close(fd);
return 0;
}

Loading…
Cancel
Save