Files
resy/V1/switch.c
Siegfried Kienzle b15d09216e remove some bugs
2017-03-24 16:34:06 +01:00

54 lines
936 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 ((char *) "1\n")
#define PIN12 ((char *) "12\n")
#define PIN11 ((char *) "11\n")
#define PIN06 ((char *) "6\n")
#define IN ((char *)"in\n")
#define OUT ((char *)"out\n")
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
int reserve(char* gpioPort)
{
int fd;
char buffer[2];
printf("%s", gpioPort);
strcpy(buffer, gpioPort );
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()
{
reserve(PIN06);
return 0;
}