4static const uint8_t TCA9555_INPUT_PORT_REGISTER_0 = 0x00;
5static const uint8_t TCA9555_INPUT_PORT_REGISTER_1 = 0x01;
6static const uint8_t TCA9555_OUTPUT_PORT_REGISTER_0 = 0x02;
7static const uint8_t TCA9555_OUTPUT_PORT_REGISTER_1 = 0x03;
8static const uint8_t TCA9555_POLARITY_REGISTER_0 = 0x04;
9static const uint8_t TCA9555_POLARITY_REGISTER_1 = 0x05;
10static const uint8_t TCA9555_CONFIGURATION_PORT_0 = 0x06;
11static const uint8_t TCA9555_CONFIGURATION_PORT_1 = 0x07;
16static const char *
const TAG =
"tca9555";
19 ESP_LOGCONFIG(TAG,
"Setting up TCA9555...");
30 ESP_LOGCONFIG(TAG,
"TCA9555:");
33 ESP_LOGE(TAG,
"Communication with TCA9555 failed!");
53 if (!this->
read_bytes(TCA9555_OUTPUT_PORT_REGISTER_0, data, 2)) {
57 this->
output_mask_ = (uint16_t(data[1]) << 8) | (uint16_t(data[0]) << 0);
66 bool success = this->
read_bytes(TCA9555_CONFIGURATION_PORT_0, data, 2);
71 this->
mode_mask_ = (uint16_t(data[1]) << 8) | (uint16_t(data[0]) << 0);
80 uint8_t bank_number = pin < 8 ? 0 : 1;
81 uint8_t register_to_read = bank_number ? TCA9555_INPUT_PORT_REGISTER_1 : TCA9555_INPUT_PORT_REGISTER_0;
82 if (!this->
read_bytes(register_to_read, &data, 1)) {
89 this->
input_mask_ = (data << 8) | (uint16_t(first_half) << 0);
91 this->
input_mask_ = (uint16_t(second_half) << 8) | (data << 0);
111 if (!this->
write_bytes(TCA9555_OUTPUT_PORT_REGISTER_0, data, 2)) {
126 if (!this->
write_bytes(TCA9555_CONFIGURATION_PORT_0, data, 2)) {
virtual void mark_failed()
Mark this component as failed.
void status_set_warning(const char *message="unspecified")
void status_clear_warning()
TCA9555Component * parent_
bool write_bytes(uint8_t a_register, const uint8_t *data, uint8_t len, bool stop=true)
bool read_bytes(uint8_t a_register, uint8_t *data, uint8_t len)
Compat APIs All methods below have been added for compatibility reasons.
bool digital_read_hw(uint8_t pin) override
bool digital_read_cache(uint8_t pin) override
uint16_t mode_mask_
Mask for the pin mode - 1 means output, 0 means input.
void setup() override
Check i2c availability and setup masks.
uint16_t input_mask_
The state read in digital_read_hw - 1 means HIGH, 0 means LOW.
float get_setup_priority() const override
uint16_t output_mask_
The mask to write as output state - 1 means HIGH, 0 means LOW.
void digital_write_hw(uint8_t pin, bool value) override
void dump_config() override
void pin_mode(uint8_t pin, gpio::Flags flags)
bool read_gpio_outputs_()
void digital_write(bool value) override
bool digital_read() override
void pin_mode(gpio::Flags flags) override
std::string dump_summary() const override
const float IO
For components that represent GPIO pins like PCF8573.
Providing packet encoding functions for exchanging data with a remote host.
std::string str_sprintf(const char *fmt,...)