remove gpio.c and gpio.h
This commit is contained in:
@@ -1,57 +0,0 @@
|
|||||||
#include<stdio.h>
|
|
||||||
#include<fcntl.h>
|
|
||||||
#include<string.h>
|
|
||||||
#include<unistd.h>
|
|
||||||
#include<string.h>
|
|
||||||
#include "gpio.h"
|
|
||||||
|
|
||||||
#define BASEPATH "/sys/class/gpio/"
|
|
||||||
#define GPIO_FOLDER "gpio%s/"
|
|
||||||
|
|
||||||
void writeFile(char *filename, char *buffer, size_t count)
|
|
||||||
{
|
|
||||||
int fd = open(filename, O_WRONLY);
|
|
||||||
if(fd == -1) {
|
|
||||||
perror("Fehler bei open ");
|
|
||||||
}
|
|
||||||
write(fd, buffer, count);
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
void registerPin(char *pin)
|
|
||||||
{
|
|
||||||
writeFile(BASEPATH "export", pin, strlen(pin));
|
|
||||||
}
|
|
||||||
|
|
||||||
void freePin(char *pin)
|
|
||||||
{
|
|
||||||
writeFile(BASEPATH "unexport", pin, strlen(pin));
|
|
||||||
}
|
|
||||||
|
|
||||||
void setDirection(char *pin, char *direction, int dirlen)
|
|
||||||
{
|
|
||||||
char path[50];
|
|
||||||
sprintf(path, BASEPATH GPIO_FOLDER "direction", pin);
|
|
||||||
writeFile(path, direction, dirlen);
|
|
||||||
}
|
|
||||||
|
|
||||||
void registerOutput(char *pin)
|
|
||||||
{
|
|
||||||
registerPin(pin);
|
|
||||||
setDirection(pin, "out", 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
void registerInput(char *pin)
|
|
||||||
{
|
|
||||||
registerPin(pin);
|
|
||||||
setDirection(pin, "in", 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeOutput(char *pin, int state)
|
|
||||||
{
|
|
||||||
char path[50];
|
|
||||||
sprintf(path, BASEPATH GPIO_FOLDER "value", pin);
|
|
||||||
FILE *fd = fopen(path, "w");
|
|
||||||
fprintf(fd, "%i", state);
|
|
||||||
fclose(fd);
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#ifndef GPIO_H_
|
|
||||||
#define GPIO_H_
|
|
||||||
|
|
||||||
void writeFile(char *filename, char *buffer, size_t count);
|
|
||||||
void registerPin(char *pin);
|
|
||||||
void freePin(char *pin);
|
|
||||||
void setDirection(char *pin, char *direction, int dirlen);
|
|
||||||
void registerOutput(char *pin);
|
|
||||||
void registerInput(char *pin);
|
|
||||||
void writeOutput(char *pin, int state);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
Reference in New Issue
Block a user