/* Copyright (c) 2016 CurlyMo This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include #include #include #include #include #include #include #include "wiringx.h" char *usage = "Usage: %s platform GPIO GPIO\n" " first GPIO to write to = output\n" " second GPIO reacts on an interrupt = input\n" "Example: %s raspberrypi2 16 20\n"; void *interrupt(void *gpio_void_ptr) { int i = 0; int gpio = *(int *)gpio_void_ptr; while(++i < 20) { if(waitForInterrupt(gpio, 1000) > 0) { printf(">>Interrupt on GPIO %d\n", gpio); } else { printf(" Timeout on GPIO %d\n", gpio); } } return 0; } int main(int argc, char *argv[]) { pthread_t pth; char *str = NULL, *platform = NULL; char usagestr[190]; int gpio_out = 0, gpio_in = 0; int i = 0, err = 0, invalid = 0; memset(usagestr, '\0', 190); // expect 2 arguments => argc must be 3 if(argc != 4) { snprintf(usagestr, 189, usage, argv[0], argv[0]); puts(usagestr); return -1; } // check for valid, numeric arguments for(i=2; i