2018-10-04 22:08:54 +02:00
|
|
|
#include "irqhandler.h"
|
|
|
|
|
|
|
|
// Local logging tag
|
2019-02-27 00:52:27 +01:00
|
|
|
static const char TAG[] = __FILE__;
|
2018-10-04 22:08:54 +02:00
|
|
|
|
|
|
|
// irq handler task, handles all our application level interrupts
|
|
|
|
void irqHandler(void *pvParameters) {
|
|
|
|
|
|
|
|
configASSERT(((uint32_t)pvParameters) == 1); // FreeRTOS check
|
|
|
|
|
|
|
|
uint32_t InterruptStatus;
|
|
|
|
|
|
|
|
// task remains in blocked state until it is notified by an irq
|
|
|
|
for (;;) {
|
2019-02-27 00:52:27 +01:00
|
|
|
xTaskNotifyWait(0x00, // Don't clear any bits on entry
|
|
|
|
ULONG_MAX, // Clear all bits on exit
|
|
|
|
&InterruptStatus, // Receives the notification value
|
|
|
|
portMAX_DELAY); // wait forever
|
2018-10-04 22:08:54 +02:00
|
|
|
|
|
|
|
// button pressed?
|
|
|
|
#ifdef HAS_BUTTON
|
|
|
|
if (InterruptStatus & BUTTON_IRQ)
|
|
|
|
readButton();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// display needs refresh?
|
|
|
|
#ifdef HAS_DISPLAY
|
|
|
|
if (InterruptStatus & DISPLAY_IRQ)
|
|
|
|
refreshtheDisplay();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// are cyclic tasks due?
|
2019-03-03 12:57:00 +01:00
|
|
|
if (InterruptStatus & CYCLIC_IRQ)
|
2018-10-04 22:08:54 +02:00
|
|
|
doHousekeeping();
|
|
|
|
|
2019-03-03 12:57:00 +01:00
|
|
|
#ifdef TIME_SYNC_INTERVAL
|
|
|
|
// is time to be synced?
|
|
|
|
if (InterruptStatus & TIMESYNC_IRQ)
|
2019-03-03 00:30:57 +01:00
|
|
|
setTime(timeProvider());
|
2019-03-03 12:57:00 +01:00
|
|
|
#endif
|
2019-03-03 00:30:57 +01:00
|
|
|
|
2018-10-04 22:08:54 +02:00
|
|
|
// is time to send the payload?
|
2019-03-03 12:57:00 +01:00
|
|
|
if (InterruptStatus & SENDCYCLE_IRQ)
|
2018-11-18 15:50:57 +01:00
|
|
|
sendCounter();
|
2018-10-04 22:08:54 +02:00
|
|
|
}
|
|
|
|
vTaskDelete(NULL); // shoud never be reached
|
|
|
|
}
|
|
|
|
|
|
|
|
// esp32 hardware timer triggered interrupt service routines
|
|
|
|
// they notify the irq handler task
|
|
|
|
|
|
|
|
#ifdef HAS_DISPLAY
|
|
|
|
void IRAM_ATTR DisplayIRQ() {
|
2019-03-03 12:57:00 +01:00
|
|
|
BaseType_t xHigherPriorityTaskWoken;
|
|
|
|
xHigherPriorityTaskWoken = pdFALSE;
|
|
|
|
|
|
|
|
xTaskNotifyFromISR(irqHandlerTask, DISPLAY_IRQ, eSetBits,
|
|
|
|
&xHigherPriorityTaskWoken);
|
|
|
|
|
|
|
|
if (xHigherPriorityTaskWoken)
|
|
|
|
portYIELD_FROM_ISR();
|
2018-10-04 22:08:54 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAS_BUTTON
|
|
|
|
void IRAM_ATTR ButtonIRQ() {
|
2019-03-03 12:57:00 +01:00
|
|
|
BaseType_t xHigherPriorityTaskWoken;
|
|
|
|
xHigherPriorityTaskWoken = pdFALSE;
|
|
|
|
|
|
|
|
xTaskNotifyFromISR(irqHandlerTask, BUTTON_IRQ, eSetBits,
|
|
|
|
&xHigherPriorityTaskWoken);
|
|
|
|
|
|
|
|
if (xHigherPriorityTaskWoken)
|
|
|
|
portYIELD_FROM_ISR();
|
2018-10-04 22:08:54 +02:00
|
|
|
}
|
|
|
|
#endif
|