irqhandler.cpp: mask/unmask added

This commit is contained in:
Verkehrsrot 2019-03-24 16:15:29 +01:00
parent 9931591a1f
commit c84063aa6d
2 changed files with 14 additions and 2 deletions

View File

@ -6,6 +6,9 @@
#define SENDCYCLE_IRQ 0x04 #define SENDCYCLE_IRQ 0x04
#define CYCLIC_IRQ 0x08 #define CYCLIC_IRQ 0x08
#define TIMESYNC_IRQ 0x10 #define TIMESYNC_IRQ 0x10
#define MASK_IRQ 0x20
#define UNMASK_IRQ 0x40
#define RESERVED_IRQ 0x80
#include "globals.h" #include "globals.h"
#include "cyclic.h" #include "cyclic.h"

View File

@ -3,14 +3,13 @@
// Local logging tag // Local logging tag
static const char TAG[] = __FILE__; static const char TAG[] = __FILE__;
static portMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED;
// irq handler task, handles all our application level interrupts // irq handler task, handles all our application level interrupts
void irqHandler(void *pvParameters) { void irqHandler(void *pvParameters) {
configASSERT(((uint32_t)pvParameters) == 1); // FreeRTOS check configASSERT(((uint32_t)pvParameters) == 1); // FreeRTOS check
uint32_t InterruptStatus; uint32_t InterruptStatus;
static bool mask_irq = false;
// task remains in blocked state until it is notified by an irq // task remains in blocked state until it is notified by an irq
for (;;) { for (;;) {
@ -19,6 +18,16 @@ void irqHandler(void *pvParameters) {
&InterruptStatus, // Receives the notification value &InterruptStatus, // Receives the notification value
portMAX_DELAY); // wait forever 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? // button pressed?
#ifdef HAS_BUTTON #ifdef HAS_BUTTON
if (InterruptStatus & BUTTON_IRQ) if (InterruptStatus & BUTTON_IRQ)