2018-10-04 22:08:54 +02:00
|
|
|
#include "irqhandler.h"
|
|
|
|
|
|
|
|
// Local logging tag
|
|
|
|
static const char TAG[] = "main";
|
|
|
|
|
|
|
|
// 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 (;;) {
|
|
|
|
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 (missing error handling here...)
|
|
|
|
|
|
|
|
// 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?
|
|
|
|
if (InterruptStatus & CYCLIC_IRQ)
|
|
|
|
doHousekeeping();
|
|
|
|
|
|
|
|
// is time to send the payload?
|
2018-11-18 15:50:57 +01:00
|
|
|
if (InterruptStatus & SENDCOUNTER_IRQ)
|
|
|
|
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
|
|
|
|
|
|
|
|
void IRAM_ATTR ChannelSwitchIRQ() {
|
|
|
|
xTaskNotifyGive(wifiSwitchTask);
|
|
|
|
portYIELD_FROM_ISR();
|
|
|
|
}
|
|
|
|
|
|
|
|
void IRAM_ATTR homeCycleIRQ() {
|
|
|
|
xTaskNotifyFromISR(irqHandlerTask, CYCLIC_IRQ, eSetBits, NULL);
|
|
|
|
portYIELD_FROM_ISR();
|
|
|
|
}
|
|
|
|
|
|
|
|
void IRAM_ATTR SendCycleIRQ() {
|
2018-11-18 15:50:57 +01:00
|
|
|
xTaskNotifyFromISR(irqHandlerTask, SENDCOUNTER_IRQ, eSetBits, NULL);
|
2018-10-04 22:08:54 +02:00
|
|
|
portYIELD_FROM_ISR();
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAS_DISPLAY
|
|
|
|
void IRAM_ATTR DisplayIRQ() {
|
2018-12-21 00:35:21 +01:00
|
|
|
xTaskNotifyFromISR(irqHandlerTask, DISPLAY_IRQ, eSetBits, NULL);
|
2018-10-04 22:08:54 +02:00
|
|
|
portYIELD_FROM_ISR();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAS_BUTTON
|
|
|
|
void IRAM_ATTR ButtonIRQ() {
|
|
|
|
xTaskNotifyFromISR(irqHandlerTask, BUTTON_IRQ, eSetBits, NULL);
|
|
|
|
portYIELD_FROM_ISR();
|
|
|
|
}
|
|
|
|
#endif
|