add volatile, as they are ISR-written outside the main loop

This commit is contained in:
proddy
2026-06-06 16:40:23 +02:00
parent 2d0bb34d17
commit b85085790a
2 changed files with 4 additions and 4 deletions

View File

@@ -26,8 +26,8 @@ std::vector<uint8_t> AnalogSensor::exclude_types_;
#ifndef EMSESP_STANDALONE
portMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED;
unsigned long AnalogSensor::edge[] = {0, 0, 0};
unsigned long AnalogSensor::edgecnt[] = {0, 0, 0};
volatile unsigned long AnalogSensor::edge[] = {0, 0, 0};
volatile unsigned long AnalogSensor::edgecnt[] = {0, 0, 0};
void IRAM_ATTR AnalogSensor::freqIrq0() {
portENTER_CRITICAL_ISR(&mux);

View File

@@ -210,8 +210,8 @@ class AnalogSensor {
static void IRAM_ATTR freqIrq0();
static void IRAM_ATTR freqIrq1();
static void IRAM_ATTR freqIrq2();
static unsigned long edge[3];
static unsigned long edgecnt[3];
static volatile unsigned long edge[3]; // written from freqIrqN() ISRs, read from the main measure() loop (partly outside the critical section)
static volatile unsigned long edgecnt[3]; // written from freqIrqN() ISRs, read from the main measure() loop (partly outside the critical section)
unsigned long lastedge[3] = {0, 0, 0};
#endif
};