From af87f21e681f7fbb8b571fb7f518ef3e517bb9ad Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 4 Apr 2026 10:22:19 -1000 Subject: [PATCH] Remove unnecessary latched interrupt clearing during setup A latched interrupt at boot is harmless - the ISR fires immediately, loop runs, cache invalidates, and a normal read cycle clears it. The extra register reads added unnecessary complexity. --- esphome/components/mcp23008/mcp23008.cpp | 5 ----- esphome/components/mcp23017/mcp23017.cpp | 6 ------ esphome/components/mcp23s08/mcp23s08.cpp | 5 ----- esphome/components/mcp23s17/mcp23s17.cpp | 6 ------ esphome/components/pi4ioe5v6408/pi4ioe5v6408.cpp | 3 --- 5 files changed, 25 deletions(-) diff --git a/esphome/components/mcp23008/mcp23008.cpp b/esphome/components/mcp23008/mcp23008.cpp index b7a4276c46d..5f73e03f6f6 100644 --- a/esphome/components/mcp23008/mcp23008.cpp +++ b/esphome/components/mcp23008/mcp23008.cpp @@ -23,11 +23,6 @@ void MCP23008::setup() { this->write_reg(mcp23x08_base::MCP23X08_IOCON, iocon | IOCON_ODR); } - // Clear any latched interrupt by reading GPIO before attaching ISR - if (this->interrupt_pin_ != nullptr) { - uint8_t val; - this->read_reg(mcp23x08_base::MCP23X08_GPIO, &val); - } this->setup_interrupt_pin_(); } diff --git a/esphome/components/mcp23017/mcp23017.cpp b/esphome/components/mcp23017/mcp23017.cpp index b1775f24024..212c15ccf27 100644 --- a/esphome/components/mcp23017/mcp23017.cpp +++ b/esphome/components/mcp23017/mcp23017.cpp @@ -33,12 +33,6 @@ void MCP23017::setup() { this->write_reg(mcp23x17_base::MCP23X17_IOCONB, iocon | iocon_flags); } - // Clear any latched interrupt by reading GPIO before attaching ISR - if (this->interrupt_pin_ != nullptr) { - uint8_t val; - this->read_reg(mcp23x17_base::MCP23X17_GPIOA, &val); - this->read_reg(mcp23x17_base::MCP23X17_GPIOB, &val); - } this->setup_interrupt_pin_(); } diff --git a/esphome/components/mcp23s08/mcp23s08.cpp b/esphome/components/mcp23s08/mcp23s08.cpp index 22913816464..983c1aa6008 100644 --- a/esphome/components/mcp23s08/mcp23s08.cpp +++ b/esphome/components/mcp23s08/mcp23s08.cpp @@ -35,11 +35,6 @@ void MCP23S08::setup() { this->write_reg(mcp23x08_base::MCP23X08_IOCON, IOCON_SEQOP | IOCON_HAEN | IOCON_ODR); } - // Clear any latched interrupt by reading GPIO before attaching ISR - if (this->interrupt_pin_ != nullptr) { - uint8_t val; - this->read_reg(mcp23x08_base::MCP23X08_GPIO, &val); - } this->setup_interrupt_pin_(); } diff --git a/esphome/components/mcp23s17/mcp23s17.cpp b/esphome/components/mcp23s17/mcp23s17.cpp index f27b55c6f6a..db9a34e2302 100644 --- a/esphome/components/mcp23s17/mcp23s17.cpp +++ b/esphome/components/mcp23s17/mcp23s17.cpp @@ -51,12 +51,6 @@ void MCP23S17::setup() { this->write_reg(mcp23x17_base::MCP23X17_IOCONB, iocon_flags); } - // Clear any latched interrupt by reading GPIO before attaching ISR - if (this->interrupt_pin_ != nullptr) { - uint8_t val; - this->read_reg(mcp23x17_base::MCP23X17_GPIOA, &val); - this->read_reg(mcp23x17_base::MCP23X17_GPIOB, &val); - } this->setup_interrupt_pin_(); } diff --git a/esphome/components/pi4ioe5v6408/pi4ioe5v6408.cpp b/esphome/components/pi4ioe5v6408/pi4ioe5v6408.cpp index 610015bbe6b..fe1df6cbb0f 100644 --- a/esphome/components/pi4ioe5v6408/pi4ioe5v6408.cpp +++ b/esphome/components/pi4ioe5v6408/pi4ioe5v6408.cpp @@ -35,9 +35,6 @@ void PI4IOE5V6408Component::setup() { } if (this->interrupt_pin_ != nullptr) { - // Clear any latched interrupt status from before boot - uint8_t status; - this->read_byte(PI4IOE5V6408_REGISTER_INTERRUPT_STATUS, &status); this->interrupt_pin_->setup(); this->interrupt_pin_->attach_interrupt(&PI4IOE5V6408Component::gpio_intr, this, gpio::INTERRUPT_FALLING_EDGE); this->set_invalidate_on_read_(false);