Skip to content
Snippets Groups Projects
Commit 2810886f authored by jdkruege's avatar jdkruege
Browse files
parents bb0cb553 b7c1632e
Branches master
No related tags found
No related merge requests found
/*
* buttonInterrupt.c
*
* Created on: Feb 10, 2016
* Author: Nik
*/
#include <stdio.h>
#include <stdlib.h>
#include <mraa.h>
static volatile int counter = 1;
void interrupt(void* args) {
fprintf(stdout, "%d\n", counter);
counter++;
}
int buttonInterrupt() {
//initialize mraa
mraa_init();
//create mraa context
mraa_gpio_context context;
//set context to GPIO 15 (J20:7)
context = mraa_gpio_init(15);
if (context == NULL) {
return -1;
} else {
fprintf(stdout, "GPIO Initialized\n");
}
mraa_gpio_dir(context, MRAA_GPIO_IN);
mraa_gpio_edge_t edge = MRAA_GPIO_EDGE_FALLING;
mraa_gpio_isr(context, edge, &interrupt, NULL);
// mraa_result_t result = mraa_gpio_isr_exit(context);
// return result;
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment