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";
37 ESP_LOGCONFIG(TAG,
"TCA9555:");
41 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
69 if (!this->
read_bytes(TCA9555_OUTPUT_PORT_REGISTER_0, data, 2)) {
73 this->
output_mask_ = (uint16_t(data[1]) << 8) | (uint16_t(data[0]) << 0);
82 bool success = this->
read_bytes(TCA9555_CONFIGURATION_PORT_0, data, 2);
87 this->
mode_mask_ = (uint16_t(data[1]) << 8) | (uint16_t(data[0]) << 0);
96 uint8_t bank_number = pin < 8 ? 0 : 1;
97 uint8_t register_to_read = bank_number ? TCA9555_INPUT_PORT_REGISTER_1 : TCA9555_INPUT_PORT_REGISTER_0;
98 if (!this->
read_bytes(register_to_read, &data, 1)) {
105 this->
input_mask_ = (data << 8) | (uint16_t(first_half) << 0);
107 this->
input_mask_ = (uint16_t(second_half) << 8) | (data << 0);
127 if (!this->
write_bytes(TCA9555_OUTPUT_PORT_REGISTER_0, data, 2)) {
142 if (!this->
write_bytes(TCA9555_CONFIGURATION_PORT_0, data, 2)) {
159 return buf_append_printf(buffer,
len, 0,
"%u via TCA9555", this->
pin_);
void mark_failed()
Mark this component as failed.
void status_set_warning()
void enable_loop_soon_any_context()
Thread and ISR-safe version of enable_loop() that can be called from any context.
void enable_loop()
Enable this component's loop.
void disable_loop()
Disable this component's loop.
void status_clear_warning()
void attach_interrupt(void(*func)(T *), T *arg, gpio::InterruptType type) const
TCA9555Component * parent_
void set_invalidate_on_read_(bool invalidate)
bool write_bytes(uint8_t a_register, const uint8_t *data, uint8_t len) const
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.
InternalGPIOPin * interrupt_pin_
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)
static void IRAM_ATTR gpio_intr(TCA9555Component *arg)
bool read_gpio_outputs_()
void digital_write(bool value) override
bool digital_read() override
size_t dump_summary(char *buffer, size_t len) const override
void pin_mode(gpio::Flags flags) override
constexpr float IO
For components that represent GPIO pins like PCF8573.
Providing packet encoding functions for exchanging data with a remote host.