ESPHome 2025.5.0
Loading...
Searching...
No Matches
mcp23017.cpp
Go to the documentation of this file.
1#include "mcp23017.h"
2#include "esphome/core/log.h"
3
4namespace esphome {
5namespace mcp23017 {
6
7static const char *const TAG = "mcp23017";
8
10 ESP_LOGCONFIG(TAG, "Setting up MCP23017...");
11 uint8_t iocon;
12 if (!this->read_reg(mcp23x17_base::MCP23X17_IOCONA, &iocon)) {
13 this->mark_failed();
14 return;
15 }
16
17 // Read current output register state
20
21 if (this->open_drain_ints_) {
22 // enable open-drain interrupt pins, 3.3V-safe
25 }
26}
27
28void MCP23017::dump_config() { ESP_LOGCONFIG(TAG, "MCP23017:"); }
29
30bool MCP23017::read_reg(uint8_t reg, uint8_t *value) {
31 if (this->is_failed())
32 return false;
33
34 return this->read_byte(reg, value);
35}
36bool MCP23017::write_reg(uint8_t reg, uint8_t value) {
37 if (this->is_failed())
38 return false;
39
40 return this->write_byte(reg, value);
41}
42
43} // namespace mcp23017
44} // namespace esphome
virtual void mark_failed()
Mark this component as failed.
bool is_failed() const
bool write_byte(uint8_t a_register, uint8_t data, bool stop=true)
Definition i2c.h:266
bool read_byte(uint8_t a_register, uint8_t *data, bool stop=true)
Definition i2c.h:239
bool write_reg(uint8_t reg, uint8_t value) override
Definition mcp23017.cpp:36
void dump_config() override
Definition mcp23017.cpp:28
void setup() override
Definition mcp23017.cpp:9
bool read_reg(uint8_t reg, uint8_t *value) override
Definition mcp23017.cpp:30
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7