ready to test GPIO code

This commit is contained in:
Amy G. Bowersox 2019-11-29 02:05:30 -07:00
parent 2da798238b
commit a2335a9d74
4 changed files with 33 additions and 0 deletions

8
src/Makefile Normal file
View File

@ -0,0 +1,8 @@
OBJS=main.o log.o gpio.o
LIBS=
upiwin: $(OBJS)
gcc -o upiwin $(OBJS) $(LIBS)
.c.o:
gcc -c $(CFLAGS) $<

View File

@ -3,6 +3,7 @@
#include <fcntl.h>
#include <sys/mman.h>
#include "log.h"
#include "gpio.h"
#define GLINE_BUTTON1 17
#define GLINE_BUTTON2 22

8
src/gpio.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef __GPIO_H_INCLUDED
#define __GPIO_H_INCLUDED
extern int Gpio_setup(void);
extern void Gpio_cleanup(void);
extern int Gpio_poll_buttons(void);
#endif /* __GPIO_H_INCLUDED */

16
src/main.c Normal file
View File

@ -0,0 +1,16 @@
#include <stdlib.h>
#include "gpio.h"
#include "log.h"
int main(int argc, char *argv[])
{
if (Gpio_setup() != 0)
return EXIT_FAILURE;
atexit(Gpio_cleanup);
log(LINFO, "System ready.");
for (;;) {
Gpio_poll_buttons();
}
}