ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
cached_gpio_component.cpp
Go to the documentation of this file.
2
4
5// Not a member of the template: GCC 10 (ESP8266) ignores section attributes on template instantiations.
6static void IRAM_ATTR interrupt_pin_isr(Component *arg) { arg->enable_loop_soon_any_context(); }
7
9 // Polling mode enables the loop in pin_mode() for the first input; interrupt mode from the ISR.
10 this->disable_loop();
11 if (this->interrupt_pin_ == nullptr)
12 return false;
13 this->interrupt_pin_->setup();
14 this->interrupt_pin_->attach_interrupt(&interrupt_pin_isr, static_cast<Component *>(this),
16 // An INT line already low at attach gives no falling edge, so read the inputs now
17 if (!this->interrupt_pin_->digital_read())
18 this->enable_loop();
19 return true;
20}
21
22// Input changes that straddle the read leave INT asserted without a new falling edge, so keep looping
23// until the line is released or the expander would keep stale state forever.
28
29} // namespace esphome::gpio_expander
void enable_loop()
Enable this component's loop.
Definition component.h:248
void disable_loop()
Disable this component's loop.
void attach_interrupt(void(*func)(T *), T *arg, gpio::InterruptType type) const
Definition gpio.h:29
bool attach_interrupt_pin_()
Attach the falling-edge ISR when there is an interrupt pin, then disable the loop until an input need...
void disable_loop_when_released_()
The loop runs again after the INT line falls; stop it once the line is released (HIGH).
@ INTERRUPT_FALLING_EDGE
Definition gpio_pin.h:53