Compare commits

..

No commits in common. 'ab7b0e927bc663b7d8932decc3d8f75b80bb1fbf' and '0166182ba354784e25c9a4c3cb50a058dec610b5' have entirely different histories.

1
.gitignore vendored

@ -1 +0,0 @@
hello

@ -1,10 +1,6 @@
# Introduction
How to compile
```bash
gcc main.c -o hello
```
# Issues
- [ ] Error Catching

@ -7,61 +7,30 @@ int main(int argc, char *argv[])
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
fd = open("/sys/class/gpio/chip0/gpio17/direction", O_WRONLY);
if(fd<0)
{
perror("Error opening GPIO path");
return -1;
}
write(fd, "out",3);
close(fd);
// VALUE
fd = open("/sys/class/gpio/chip0/gpio17/value", O_WRONLY);
if(fd<0)
{
perror("Error opening GPIO path");
return -1;
}
write(fd, "1", 1);
close(fd);
sleep(1);
// Unexport
fd = open("/sys/class/gpio/chip0/gpio17/value", O_WRONLY);
if(fd<0)
{
perror("Error opening GPIO path");
return -1;
}
write(fd, "0", 1);
close(fd);
sleep(1);
fd = open("/sys/class/gpio/chip0/gpio17/value", O_WRONLY);
if(fd<0)
{
perror("Error opening GPIO path");
return -1;
}
write(fd, "1", 1);
close(fd);
sleep(1);
fd = open("/sys/class/gpio/chip0/gpio17/unexport", O_WRONLY);
if(fd<0)
{
perror("Error opening GPIO path");
return -1;
}
write(fd, "17", 2);
close(fd);

Loading…
Cancel
Save