ESPHome 2025.9.0-dev
Loading...
Searching...
No Matches
mcp23008.cpp
Go to the documentation of this file.
1#include "mcp23008.h"
2#include "esphome/core/log.h"
3
4namespace esphome {
5namespace mcp23008 {
6
7static const char *const TAG = "mcp23008";
8
10 uint8_t iocon;
11 if (!this->read_reg(mcp23x08_base::MCP23X08_IOCON, &iocon)) {
12 this->mark_failed();
13 return;
14 }
15
16 // Read current output register state
18
19 if (this->open_drain_ints_) {
20 // enable open-drain interrupt pins, 3.3V-safe
22 }
23}
24
25void MCP23008::dump_config() { ESP_LOGCONFIG(TAG, "MCP23008:"); }
26
27bool MCP23008::read_reg(uint8_t reg, uint8_t *value) {
28 if (this->is_failed())
29 return false;
30
31 return this->read_byte(reg, value);
32}
33
34bool MCP23008::write_reg(uint8_t reg, uint8_t value) {
35 if (this->is_failed())
36 return false;
37
38 return this->write_byte(reg, value);
39}
40
41} // namespace mcp23008
42} // 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 mcp23008.cpp:34
void dump_config() override
Definition mcp23008.cpp:25
bool read_reg(uint8_t reg, uint8_t *value) override
Definition mcp23008.cpp:27
void setup() override
Definition mcp23008.cpp:9
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7