mirror of
https://github.com/arendst/Tasmota.git
synced 2025-04-25 07:17:16 +00:00
Second try to fix counter interrupt storm
Second try to fix counter interrupt storm during OTA (#8928)
This commit is contained in:
parent
25dcf447f3
commit
8dbe3c90da
@ -2874,6 +2874,9 @@ void HandleUploadLoop(void)
|
||||
} else if (UPLOAD_FILE_ABORTED == upload.status) {
|
||||
restart_flag = 0;
|
||||
MqttRetryCounter(0);
|
||||
#ifdef USE_COUNTER
|
||||
CounterInterruptDisable(false);
|
||||
#endif
|
||||
Web.upload_error = 7; // Upload aborted
|
||||
if (UPL_TASMOTA == Web.upload_file_type) { Update.end(); }
|
||||
}
|
||||
|
@ -44,7 +44,6 @@ struct COUNTER {
|
||||
uint8_t no_pullup = 0; // Counter input pullup flag (1 = No pullup)
|
||||
uint8_t pin_state = 0; // LSB0..3 Last state of counter pin; LSB7==0 IRQ is FALLING, LSB7==1 IRQ is CHANGE
|
||||
bool any_counter = false;
|
||||
bool disable = false;
|
||||
} Counter;
|
||||
|
||||
uint32_t last_cycle;
|
||||
@ -52,8 +51,6 @@ uint32_t cycle_time;
|
||||
|
||||
//void ICACHE_RAM_ATTR CounterUpdate(uint8_t index) {
|
||||
void ICACHE_RAM_ATTR CounterIsrArg(void *arg) {
|
||||
if (Counter.disable) { return; }
|
||||
|
||||
uint32_t index = *static_cast<uint8_t*>(arg);
|
||||
|
||||
uint32_t time = micros();
|
||||
@ -147,7 +144,20 @@ void ICACHE_RAM_ATTR CounterUpdate4(void)
|
||||
/********************************************************************************************/
|
||||
|
||||
void CounterInterruptDisable(bool state) {
|
||||
Counter.disable = state;
|
||||
if (state) { // Disable interrupts
|
||||
if (Counter.any_counter) {
|
||||
for (uint32_t i = 0; i < MAX_COUNTERS; i++) {
|
||||
if (PinUsed(GPIO_CNTR1, i)) {
|
||||
detachInterrupt(Pin(GPIO_CNTR1, i));
|
||||
}
|
||||
}
|
||||
Counter.any_counter = false;
|
||||
}
|
||||
} else { // Enable interrupts
|
||||
if (!Counter.any_counter) {
|
||||
CounterInit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CounterPinState(void)
|
||||
|
Loading…
x
Reference in New Issue
Block a user