24 static const char *
const TAG =
"pca6416a";
27 ESP_LOGCONFIG(TAG,
"Setting up PCA6416A...");
31 ESP_LOGE(TAG,
"PCA6416A not available under 0x%02X", this->
address_);
51 ESP_LOGD(TAG,
"Initialization complete. Warning: %d, Error: %d", this->
status_has_warning(),
57 ESP_LOGCONFIG(TAG,
"PCAL6416A:");
59 ESP_LOGCONFIG(TAG,
"PCA6416A:");
63 ESP_LOGE(TAG,
"Communication with PCA6416A failed!");
68 uint8_t bit = pin % 8;
72 return value & (1 << bit);
96 ESP_LOGW(TAG,
"Your PCA6416A does not support pull-up resistors");
105 ESP_LOGD(TAG,
"Device marked failed");
111 ESP_LOGE(TAG,
"read_register_(): I2C I/O error: %d", (
int) this->
last_error_);
121 ESP_LOGD(TAG,
"Device marked failed");
127 ESP_LOGE(TAG,
"write_register_(): I2C I/O error: %d", (
int) this->
last_error_);
136 uint8_t bit = pin % 8;
137 uint8_t reg_value = 0;
147 reg_value |= 1 << bit;
149 reg_value &= ~(1 << bit);
169 snprintf(buffer,
sizeof(buffer),
"%u via PCA6416A", pin_);
bool digital_read(uint8_t pin)
Helper function to read the value of a pin.
void digital_write(bool value) override
ErrorCode read_register(uint8_t a_register, uint8_t *data, size_t len, bool stop=true)
reads an array of bytes from a specific register in the I²C device
void status_set_warning(const char *message="unspecified")
bool status_has_warning() const
bool write_register_(uint8_t reg, uint8_t value)
I2CRegister reg(uint8_t a_register)
calls the I2CRegister constructor
esphome::i2c::ErrorCode last_error_
Storage for last I2C error seen.
void digital_write(uint8_t pin, bool value)
Helper function to write the value of a pin.
bool has_pullup_
Only the PCAL6416A has pull-up resistors.
void pin_mode(gpio::Flags flags) override
void update_register_(uint8_t pin, bool pin_value, uint8_t reg_addr)
bool status_has_error() const
void dump_config() override
std::string dump_summary() const override
No error found during execution of method.
void status_clear_warning()
bool digital_read() override
void pin_mode(uint8_t pin, gpio::Flags flags)
Helper function to set the pin mode of a pin.
bool read_register_(uint8_t reg, uint8_t *value)
void setup() override
Check i2c availability and setup masks.
uint8_t address_
store the address of the device on the bus
virtual void mark_failed()
Mark this component as failed.
const float IO
For components that represent GPIO pins like PCF8573.
Implementation of SPI Controller mode.
ErrorCode write_register(uint8_t a_register, const uint8_t *data, size_t len, bool stop=true)
writes an array of bytes to a specific register in the I²C device
float get_setup_priority() const override
uint8_t output_0_
The mask to write as output state - 1 means HIGH, 0 means LOW.