From 9c2fa9db3702f891eb490b9152f5ce4b41e355b7 Mon Sep 17 00:00:00 2001 From: schneider <schneider@blinkenlichts.net> Date: Sat, 4 May 2019 00:07:56 +0200 Subject: [PATCH] fix(testapp): Use GPIO interrupt --- testapp/main.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/testapp/main.c b/testapp/main.c index 0c7b11a2d..e03aedd6f 100644 --- a/testapp/main.c +++ b/testapp/main.c @@ -54,6 +54,7 @@ #include "spi.h" #include "MAX30003.h" #include "oled96.h" +#include "stdbool.h" /***** Definitions *****/ @@ -233,6 +234,11 @@ void add_sample(int16_t sample) } } +volatile bool ecgFIFOIntFlag = false; +void ecgFIFO_callback(void *data) { + ecgFIFOIntFlag = true; +} + // ***************************************************************************** int main(void) { @@ -300,22 +306,21 @@ int main(void) const int FIFO_VALID_SAMPLE_MASK = 0x0; const int FIFO_FAST_SAMPLE_MASK = 0x1; const int ETAG_BITS_MASK = 0x7; - uint8_t ecgFIFOIntFlag = 0; const gpio_cfg_t interrupt_pin = {PORT_1, PIN_12, GPIO_FUNC_IN, GPIO_PAD_PULL_UP}; GPIO_Config(&interrupt_pin); + GPIO_RegisterCallback(&interrupt_pin, ecgFIFO_callback, NULL); + GPIO_IntConfig(&interrupt_pin, GPIO_INT_EDGE, GPIO_INT_FALLING); + GPIO_IntEnable(&interrupt_pin); + NVIC_EnableIRQ(MXC_GPIO_GET_IRQ(PORT_1)); + while(1) { #if 1 - if(GPIO_InGet(&interrupt_pin) == 0) { - ecgFIFOIntFlag = 1; - } - // Read back ECG samples from the FIFO if( ecgFIFOIntFlag ) { - - ecgFIFOIntFlag = 0; + ecgFIFOIntFlag = false; //printf("Int\n"); status = ecg_read_reg( STATUS ); // Read the STATUS register -- GitLab