51 lines
811 B
C
51 lines
811 B
C
/*
|
|
* switch.c
|
|
* How to register an button and count this
|
|
* author: Simon Wörner, Manuel Vögele,
|
|
* Siegfried Kienzle
|
|
* 24-March-2017
|
|
*
|
|
* */
|
|
|
|
#define PIN01 1
|
|
#define PIN12 12
|
|
#define PIN11 11
|
|
#define PIN06 6
|
|
#define IN ((const unsigned char *)"in\n")
|
|
#define OUT ((const unsigned char *)"out\n")
|
|
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
|
|
int reserve(char gpioPort)
|
|
{
|
|
int fd;
|
|
char buffer[2];
|
|
|
|
strcpy(buffer, gpioPort + "\n");
|
|
|
|
if((fd=open("/sys/class/gpio/export", O_RDWR | O_CREAT | O_TRUNC) == -1) {
|
|
perror(NULL);
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
if(write(fd, &buffer, sizeof(buffer)) == -1) {
|
|
perror("Cannot write into file");
|
|
return EXIT_FAILURE;
|
|
}
|
|
printf("Success");
|
|
close(fd);
|
|
return EXIT_SUCCESS;
|
|
}
|
|
|
|
int inOut(char gpioPort, char * inOut)
|
|
{
|
|
|
|
}
|
|
|
|
int main()
|
|
{
|
|
|
|
return 0;
|
|
}
|