ESPHome  2024.4.1
mcp23008.cpp
Go to the documentation of this file.
1 #include "mcp23008.h"
2 #include "esphome/core/log.h"
3 
4 namespace esphome {
5 namespace mcp23008 {
6 
7 static const char *const TAG = "mcp23008";
8 
10  ESP_LOGCONFIG(TAG, "Setting up MCP23008...");
11  uint8_t iocon;
12  if (!this->read_reg(mcp23x08_base::MCP23X08_IOCON, &iocon)) {
13  this->mark_failed();
14  return;
15  }
16 
17  // Read current output register state
19 
20  if (this->open_drain_ints_) {
21  // enable open-drain interrupt pins, 3.3V-safe
23  }
24 }
25 
26 void MCP23008::dump_config() { ESP_LOGCONFIG(TAG, "MCP23008:"); }
27 
28 bool MCP23008::read_reg(uint8_t reg, uint8_t *value) {
29  if (this->is_failed())
30  return false;
31 
32  return this->read_byte(reg, value);
33 }
34 
35 bool MCP23008::write_reg(uint8_t reg, uint8_t value) {
36  if (this->is_failed())
37  return false;
38 
39  return this->write_byte(reg, value);
40 }
41 
42 } // namespace mcp23008
43 } // namespace esphome
void dump_config() override
Definition: mcp23008.cpp:26
bool read_byte(uint8_t a_register, uint8_t *data, bool stop=true)
Definition: i2c.h:235
I2CRegister reg(uint8_t a_register)
calls the I2CRegister constructor
Definition: i2c.h:149
bool read_reg(uint8_t reg, uint8_t *value) override
Definition: mcp23008.cpp:28
bool write_reg(uint8_t reg, uint8_t value) override
Definition: mcp23008.cpp:35
bool write_byte(uint8_t a_register, uint8_t data, bool stop=true)
Definition: i2c.h:262
virtual void mark_failed()
Mark this component as failed.
Definition: component.cpp:118
void setup() override
Definition: mcp23008.cpp:9
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7