irqhandler.cpp polished

This commit is contained in:
cyberman54 2022-01-08 18:01:28 +01:00
parent 87d47a7e80
commit adb7f93944

View File

@ -10,20 +10,20 @@ void irqHandler(void *pvParameters) {
_ASSERT((uint32_t)pvParameters == 1); // FreeRTOS check _ASSERT((uint32_t)pvParameters == 1); // FreeRTOS check
uint32_t InterruptStatus; uint32_t irqSource;
// 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 (;;) {
xTaskNotifyWait(0x00, // Don't clear any bits on entry xTaskNotifyWait(0x00, // Don't clear any bits on entry
ULONG_MAX, // Clear all bits on exit ULONG_MAX, // Clear all bits on exit
&InterruptStatus, // Receives the notification value &irqSource, // Receives the notification value
portMAX_DELAY); // wait forever portMAX_DELAY); // wait forever
if (InterruptStatus & UNMASK_IRQ) // interrupt handler to be enabled? if (irqSource & UNMASK_IRQ) // interrupt handler to be enabled?
InterruptStatus &= ~MASK_IRQ; // then clear irq mask flag irqSource &= ~MASK_IRQ; // then clear irq mask flag
// else suppress processing if interrupt handler is disabled // else suppress processing if interrupt handler is disabled
// or time critical lmic jobs are pending in next 100ms // or time critical lmic jobs are pending in next 100ms
else if ((InterruptStatus & MASK_IRQ) else if ((irqSource & MASK_IRQ)
#if (HAS_LORA) #if (HAS_LORA)
|| os_queryTimeCriticalJobs(ms2osticks(100)) || os_queryTimeCriticalJobs(ms2osticks(100))
#endif #endif
@ -32,63 +32,49 @@ void irqHandler(void *pvParameters) {
// button pressed? // button pressed?
#ifdef HAS_BUTTON #ifdef HAS_BUTTON
if (InterruptStatus & BUTTON_IRQ) { if (irqSource & BUTTON_IRQ)
readButton(); readButton();
InterruptStatus &= ~BUTTON_IRQ;
}
#endif #endif
// display needs refresh? // display needs refresh?
#ifdef HAS_DISPLAY #ifdef HAS_DISPLAY
if (InterruptStatus & DISPLAY_IRQ) { if (irqSource & DISPLAY_IRQ)
dp_refresh(); dp_refresh();
InterruptStatus &= ~DISPLAY_IRQ;
}
#endif #endif
// LED Matrix display needs refresh? // LED Matrix display needs refresh?
#ifdef HAS_MATRIX_DISPLAY #ifdef HAS_MATRIX_DISPLAY
if (InterruptStatus & MATRIX_DISPLAY_IRQ) { if (irqSource & MATRIX_DISPLAY_IRQ)
refreshTheMatrixDisplay(); refreshTheMatrixDisplay();
InterruptStatus &= ~MATRIX_DISPLAY_IRQ;
}
#endif #endif
#if (TIME_SYNC_INTERVAL) #if (TIME_SYNC_INTERVAL)
// is time to be synced? // is time to be synced?
if (InterruptStatus & TIMESYNC_IRQ) { if (irqSource & TIMESYNC_IRQ) {
now(); // ensure sysTime is recent now(); // ensure sysTime is recent
calibrateTime(); calibrateTime();
InterruptStatus &= ~TIMESYNC_IRQ;
} }
#endif #endif
// BME sensor data to be read? // BME sensor data to be read?
#if (HAS_BME) #if (HAS_BME)
if (InterruptStatus & BME_IRQ) { if (irqSource & BME_IRQ)
bme_storedata(&bme_status); bme_storedata(&bme_status);
InterruptStatus &= ~BME_IRQ;
}
#endif #endif
// are cyclic tasks due? // are cyclic tasks due?
if (InterruptStatus & CYCLIC_IRQ) { if (irqSource & CYCLIC_IRQ)
doHousekeeping(); doHousekeeping();
InterruptStatus &= ~CYCLIC_IRQ;
}
// do we have a power event? // do we have a power event?
#ifdef HAS_PMU #ifdef HAS_PMU
if (InterruptStatus & PMU_IRQ) { if (irqSource & PMU_IRQ)
AXP192_powerevent_IRQ(); AXP192_powerevent_IRQ();
InterruptStatus &= ~PMU_IRQ;
}
#endif #endif
// is time to send the payload? // is time to send the payload?
if (InterruptStatus & SENDCYCLE_IRQ) { if (irqSource & SENDCYCLE_IRQ) {
sendData(); sendData();
InterruptStatus &= ~SENDCYCLE_IRQ;
// goto sleep if we have a sleep cycle // goto sleep if we have a sleep cycle
if (cfg.sleepcycle) if (cfg.sleepcycle)
#ifdef HAS_BUTTON #ifdef HAS_BUTTON