From 52757cb8a4ac0ab07c3fb123bc7cf608135bd1df Mon Sep 17 00:00:00 2001 From: Norbert Richter Date: Wed, 27 Apr 2022 08:32:09 +0200 Subject: [PATCH] Refactor ISR --- tasmota/xsns_96_flowmeter.ino | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tasmota/xsns_96_flowmeter.ino b/tasmota/xsns_96_flowmeter.ino index f30feb7f7..f57675b6e 100644 --- a/tasmota/xsns_96_flowmeter.ino +++ b/tasmota/xsns_96_flowmeter.ino @@ -51,17 +51,16 @@ bool flowmeter_valuesread = false; void IRAM_ATTR FlowMeterIR(uint16_t irq) { uint32_t gpio_status = GPIO_REG_READ(GPIO_STATUS_ADDRESS); - GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, gpio_status); uint32_t time = micros(); - uint32_t i = irq; + GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, gpio_status); if (irq < MAX_FLOWMETER) { - if ((time - flowmeter_last_irq[i]) < (1000000 / FLOWMETER_MIN_FREQ)) { - flowmeter_period[i] = time - flowmeter_last_irq[i]; + if ((time - flowmeter_last_irq[irq]) < (1000000 / FLOWMETER_MIN_FREQ)) { + flowmeter_period[irq] = time - flowmeter_last_irq[irq]; } else { - flowmeter_period[i] = 0; + flowmeter_period[irq] = 0; } flowmeter_valuesread = true; - flowmeter_last_irq[i] = time; + flowmeter_last_irq[irq] = time; } } // GPIO_STATUS is always 0 (?), so can only determine the IR source using this way: