ESPHome 2026.5.0-dev
Loading...
Searching...
No Matches
mcp23xxx_base.cpp
Go to the documentation of this file.
1#include "mcp23xxx_base.h"
3#include "esphome/core/log.h"
4
5namespace esphome {
6namespace mcp23xxx_base {
7
8template<uint8_t N> void MCP23XXXGPIOPin<N>::setup() {
9 this->pin_mode(flags_);
10 // When interrupt_pin is configured, pin_mode() already auto-enables CHANGE
11 // interrupt for input pins, so skip the explicit call if the user didn't
12 // override the default (NO_INTERRUPT)
13 if (this->interrupt_mode_ != MCP23XXX_NO_INTERRUPT || this->parent_->get_interrupt_pin() == nullptr) {
14 this->parent_->pin_interrupt_mode(this->pin_, this->interrupt_mode_);
15 }
16}
17template<uint8_t N> void MCP23XXXGPIOPin<N>::pin_mode(gpio::Flags flags) { this->parent_->pin_mode(this->pin_, flags); }
18template<uint8_t N> bool MCP23XXXGPIOPin<N>::digital_read() {
19 return this->parent_->digital_read(this->pin_) != this->inverted_;
20}
21template<uint8_t N> void MCP23XXXGPIOPin<N>::digital_write(bool value) {
22 this->parent_->digital_write(this->pin_, value != this->inverted_);
23}
24template<uint8_t N> size_t MCP23XXXGPIOPin<N>::dump_summary(char *buffer, size_t len) const {
25 return buf_append_printf(buffer, len, 0, "%u via MCP23XXX", this->pin_);
26}
27
28template class MCP23XXXGPIOPin<8>;
29template class MCP23XXXGPIOPin<16>;
30
31} // namespace mcp23xxx_base
32} // namespace esphome
void digital_write(bool value) override
void pin_mode(gpio::Flags flags) override
size_t dump_summary(char *buffer, size_t len) const override
uint16_t flags
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
std::string size_t len
Definition helpers.h:1045