diff options
author | fishsoupisgood <github@madingley.org> | 2020-07-10 11:08:51 +0100 |
---|---|---|
committer | fishsoupisgood <github@madingley.org> | 2020-07-10 11:08:51 +0100 |
commit | 623a7e73cf79ecdda28fe5d3ff429090dbae359d (patch) | |
tree | bd35f492e210fe788500b98e41a8f4e733c2f563 | |
parent | 93dbd25f15d4fb7e8b43411471c1e50f7ea77f6b (diff) | |
download | pingid-623a7e73cf79ecdda28fe5d3ff429090dbae359d.tar.gz pingid-623a7e73cf79ecdda28fe5d3ff429090dbae359d.tar.bz2 pingid-623a7e73cf79ecdda28fe5d3ff429090dbae359d.zip |
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | out-of-tree.mk | 6 | ||||
-rw-r--r-- | pingid.c | 19 |
3 files changed, 23 insertions, 7 deletions
@@ -1,3 +1,8 @@ + +ifneq (${GPIO},) + CFLAGS+=-DGPIO=${GPIO} +endif + pingid:pingid.o ${CC} ${CFLAGS} ${LDFLAGS} -o $@ $< ${LIBS} diff --git a/out-of-tree.mk b/out-of-tree.mk index 524fdb6..9a65f7d 100644 --- a/out-of-tree.mk +++ b/out-of-tree.mk @@ -1,6 +1,8 @@ -STAGING_DIR=/home/openwrt/gl-inet-mt300n-v2/master-d20f4fc/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl +#STAGING_DIR=/home/openwrt/gl-inet-mt300n-v2/master-d20f4fc/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl +STAGING_DIR=/home//openwrt/gl-inet-ar300m/master-fa83455/staging_dir/toolchain-mips_24kc_gcc-8.3.0_musl/ export STAGING_DIR -CROSS=${STAGING_DIR}/bin/mipsel-openwrt-linux-musl- +#CROSS=${STAGING_DIR}/bin/mipsel-openwrt-linux-musl- +CROSS=${STAGING_DIR}/bin/mips-openwrt-linux- CC=${CROSS}gcc @@ -6,6 +6,14 @@ #include <sys/types.h> #include <linux/input.h> +#ifndef GPIO +#define GPIO 4 +#endif + +#define STRINGIFY(a) #a +#define STRINGIFY_HARDER(a) STRINGIFY(a) +#define GPIO_STR STRINGIFY_HARDER(GPIO) + char *names[KEY_MAX + 1] = { "", "", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "", @@ -132,16 +140,17 @@ main (int argc, char *argv[]) struct timeval tv; char ret[128]; - squirt ("/sys/class/gpio/export", "4"); - squirt ("/sys/class/gpio/gpio4/direction", "out"); - squirt ("/sys/class/gpio/gpio4/value", "0"); + + squirt ("/sys/class/gpio/export", GPIO_STR); + squirt ("/sys/class/gpio/gpio" GPIO_STR "/direction", "out"); + squirt ("/sys/class/gpio/gpio" GPIO_STR "/value", "0"); tv.tv_sec = 0; tv.tv_usec = 100; get_string_with_timeout (fd, &tv, NULL, 0); - squirt ("/sys/class/gpio/gpio4/value", "1"); + squirt ("/sys/class/gpio/gpio" GPIO_STR "/value", "1"); tv.tv_sec = 2; @@ -149,7 +158,7 @@ main (int argc, char *argv[]) get_string_with_timeout (fd, &tv, ret, sizeof (ret)); - squirt ("/sys/class/gpio/gpio4/value", "0"); + squirt ("/sys/class/gpio/gpio" GPIO_STR "/value", "0"); printf ("Access-Control-Allow-Origin: *\n"); printf ("Content-Type: text/plain\n\n%s\n", ret); |