irqhandler code optimized
This commit is contained in:
parent
ed1b06dd2e
commit
fac48ed9c4
@ -8,8 +8,7 @@ void irqHandler(void *pvParameters) {
|
|||||||
|
|
||||||
configASSERT(((uint32_t)pvParameters) == 1); // FreeRTOS check
|
configASSERT(((uint32_t)pvParameters) == 1); // FreeRTOS check
|
||||||
|
|
||||||
static uint32_t InterruptStatus = 0x00;
|
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,22 +18,17 @@ void irqHandler(void *pvParameters) {
|
|||||||
portMAX_DELAY); // wait forever
|
portMAX_DELAY); // wait forever
|
||||||
|
|
||||||
if (InterruptStatus & UNMASK_IRQ) // interrupt handler to be enabled?
|
if (InterruptStatus & UNMASK_IRQ) // interrupt handler to be enabled?
|
||||||
mask_irq = false;
|
InterruptStatus &= ~MASK_IRQ; // then clear irq mask flag
|
||||||
|
// else suppress processing if interrupt handler is disabled
|
||||||
// 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
|
||||||
#if (HAS_LORA)
|
#if (HAS_LORA)
|
||||||
else if (mask_irq || os_queryTimeCriticalJobs(ms2osticks(100)))
|
else if ((InterruptStatus & MASK_IRQ) ||
|
||||||
|
os_queryTimeCriticalJobs(ms2osticks(100)))
|
||||||
#else
|
#else
|
||||||
else if (mask_irq)
|
else if ((InterruptStatus & MASK_IRQ)
|
||||||
#endif
|
#endif
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
else if (InterruptStatus & MASK_IRQ) { // interrupt handler to be disabled?
|
|
||||||
mask_irq = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// button pressed?
|
// button pressed?
|
||||||
#ifdef HAS_BUTTON
|
#ifdef HAS_BUTTON
|
||||||
if (InterruptStatus & BUTTON_IRQ) {
|
if (InterruptStatus & BUTTON_IRQ) {
|
||||||
@ -59,21 +53,6 @@ void irqHandler(void *pvParameters) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// BME sensor data to be read?
|
|
||||||
#if (HAS_BME)
|
|
||||||
if (InterruptStatus & BME_IRQ) {
|
|
||||||
bme_storedata(&bme_status);
|
|
||||||
InterruptStatus &= ~BME_IRQ;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// are cyclic tasks due?
|
|
||||||
if (InterruptStatus & CYCLIC_IRQ) {
|
|
||||||
doHousekeeping();
|
|
||||||
InterruptStatus &= ~CYCLIC_IRQ;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if (TIME_SYNC_INTERVAL)
|
#if (TIME_SYNC_INTERVAL)
|
||||||
// is time to be synced?
|
// is time to be synced?
|
||||||
if (InterruptStatus & TIMESYNC_IRQ) {
|
if (InterruptStatus & TIMESYNC_IRQ) {
|
||||||
@ -83,6 +62,20 @@ void irqHandler(void *pvParameters) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// BME sensor data to be read?
|
||||||
|
#if (HAS_BME)
|
||||||
|
if (InterruptStatus & BME_IRQ) {
|
||||||
|
bme_storedata(&bme_status);
|
||||||
|
InterruptStatus &= ~BME_IRQ;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// are cyclic tasks due?
|
||||||
|
if (InterruptStatus & CYCLIC_IRQ) {
|
||||||
|
doHousekeeping();
|
||||||
|
InterruptStatus &= ~CYCLIC_IRQ;
|
||||||
|
}
|
||||||
|
|
||||||
// do we have a power event?
|
// do we have a power event?
|
||||||
#if (HAS_PMU)
|
#if (HAS_PMU)
|
||||||
if (InterruptStatus & PMU_IRQ) {
|
if (InterruptStatus & PMU_IRQ) {
|
||||||
@ -96,8 +89,8 @@ void irqHandler(void *pvParameters) {
|
|||||||
sendData();
|
sendData();
|
||||||
InterruptStatus &= ~SENDCYCLE_IRQ;
|
InterruptStatus &= ~SENDCYCLE_IRQ;
|
||||||
}
|
}
|
||||||
}
|
} // for
|
||||||
}
|
} // irqHandler()
|
||||||
|
|
||||||
// esp32 hardware timer triggered interrupt service routines
|
// esp32 hardware timer triggered interrupt service routines
|
||||||
// they notify the irq handler task
|
// they notify the irq handler task
|
||||||
|
Loading…
Reference in New Issue
Block a user