From a2335a9d746133ff653bf7bfa3ffa69b06c72992 Mon Sep 17 00:00:00 2001 From: Amy Gale Ruth Bowersox Date: Fri, 29 Nov 2019 02:05:30 -0700 Subject: [PATCH] ready to test GPIO code --- src/Makefile | 8 ++++++++ src/gpio.c | 1 + src/gpio.h | 8 ++++++++ src/main.c | 16 ++++++++++++++++ 4 files changed, 33 insertions(+) create mode 100644 src/Makefile create mode 100644 src/gpio.h create mode 100644 src/main.c diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..ca829a2 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,8 @@ +OBJS=main.o log.o gpio.o +LIBS= + +upiwin: $(OBJS) + gcc -o upiwin $(OBJS) $(LIBS) + +.c.o: + gcc -c $(CFLAGS) $< diff --git a/src/gpio.c b/src/gpio.c index 65df20f..76f2cc1 100644 --- a/src/gpio.c +++ b/src/gpio.c @@ -3,6 +3,7 @@ #include #include #include "log.h" +#include "gpio.h" #define GLINE_BUTTON1 17 #define GLINE_BUTTON2 22 diff --git a/src/gpio.h b/src/gpio.h new file mode 100644 index 0000000..a1d48b7 --- /dev/null +++ b/src/gpio.h @@ -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 */ diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..8275d52 --- /dev/null +++ b/src/main.c @@ -0,0 +1,16 @@ +#include +#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(); + } +}