Add comments explaining why latched interrupts are not cleared at setup

This commit is contained in:
J. Nick Koston
2026-04-04 10:22:50 -10:00
parent af87f21e68
commit 173195ee1b
2 changed files with 6 additions and 0 deletions
@@ -27,6 +27,9 @@ template<uint8_t N> class MCP23XXXBase : public Component, public gpio_expander:
}
protected:
// No need to clear latched interrupts before attaching the ISR — if INT is
// already low the ISR fires immediately, loop runs, cache invalidates, and
// the GPIO read clears the latch. One harmless extra read at most.
void setup_interrupt_pin_() {
if (this->interrupt_pin_ != nullptr) {
this->interrupt_pin_->setup();
@@ -34,6 +34,9 @@ void PI4IOE5V6408Component::setup() {
}
}
// No need to clear latched interrupts before attaching the ISR — if INT is
// already low the ISR fires immediately, loop runs, cache invalidates, and
// the read clears the latch. One harmless extra read at most.
if (this->interrupt_pin_ != nullptr) {
this->interrupt_pin_->setup();
this->interrupt_pin_->attach_interrupt(&PI4IOE5V6408Component::gpio_intr, this, gpio::INTERRUPT_FALLING_EDGE);