Open smr547 opened 7 months ago
The following code works perfectly (but does nothing) for a button press
struct Button {
const uint8_t PIN;
unsigned long last_interrupt_ms;
};
Button button = {BUTTON_PIN, 0U};
void BUTTON_ISR(void) {
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
unsigned long now_ms = millis();
if ((now_ms - button.last_interrupt_ms) > BUTTON_BOUNCE_SUPPRESS_MS) {
// not a bounce
button.last_interrupt_ms = now_ms;
//event publishing goes here
} else {
// key bounce, ignore
}
if(xHigherPriorityTaskWoken) {
portYIELD_FROM_ISR();
}
}
Don't put a Serial.println()
call in the ISR, the chip will reset randomly
Very interesting comments here from Miro and Andy (the author of the QP ESP32 port)
Victor Chavez QP/C++ port to ESP32 on GitHub
Further discussion about the QP/ESP32/FreeRTOS port -- experimental only and with questionable parentage.
It is not clear from the documentation how this should be done