From c84063aa6dd71c04c3e8e2bbb36cd74a2e549db9 Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Sun, 24 Mar 2019 16:15:29 +0100 Subject: [PATCH] irqhandler.cpp: mask/unmask added --- include/irqhandler.h | 3 +++ src/irqhandler.cpp | 13 +++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/irqhandler.h b/include/irqhandler.h index ad74f700..61d1f347 100644 --- a/include/irqhandler.h +++ b/include/irqhandler.h @@ -6,6 +6,9 @@ #define SENDCYCLE_IRQ 0x04 #define CYCLIC_IRQ 0x08 #define TIMESYNC_IRQ 0x10 +#define MASK_IRQ 0x20 +#define UNMASK_IRQ 0x40 +#define RESERVED_IRQ 0x80 #include "globals.h" #include "cyclic.h" diff --git a/src/irqhandler.cpp b/src/irqhandler.cpp index 11bc50f0..08cc4431 100644 --- a/src/irqhandler.cpp +++ b/src/irqhandler.cpp @@ -3,14 +3,13 @@ // Local logging tag static const char TAG[] = __FILE__; -static portMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED; - // irq handler task, handles all our application level interrupts void irqHandler(void *pvParameters) { configASSERT(((uint32_t)pvParameters) == 1); // FreeRTOS check uint32_t InterruptStatus; + static bool mask_irq = false; // task remains in blocked state until it is notified by an irq for (;;) { @@ -19,6 +18,16 @@ void irqHandler(void *pvParameters) { &InterruptStatus, // Receives the notification value portMAX_DELAY); // wait forever + // interrupt handler to be enabled? + if (InterruptStatus & UNMASK_IRQ) + mask_irq = false; + else if (mask_irq) + continue; // suppress processing if interrupt handler is disabled + + // interrupt handler to be disabled? + if (InterruptStatus & MASK_IRQ) + mask_irq = true; + // button pressed? #ifdef HAS_BUTTON if (InterruptStatus & BUTTON_IRQ)