diff --git a/V1/switch.c b/V1/switch.c index 3527208..3b3ac1e 100644 --- a/V1/switch.c +++ b/V1/switch.c @@ -7,9 +7,32 @@ * * */ -//Source: http://elinux.org/RPi_GPIO_Code_Samples: -#define BCM2837_PERIPHERIAL_BASE 0x3F000000 -#define GPIO_BASE (BCM2837_PERIPHERIAL_BASE + 0x3F000000) - +#include +#include + +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"); + return EXIT_SUCCESS; +} +int main() +{ + + return 0; +}