11 uint8_t *read_buffer,
size_t read_count) {
12#ifdef I2C_PORT_FREQUENCY_COUNT
14 if (select_frequency != 0) {
27#ifdef I2C_PORT_FREQUENCY_COUNT
45 const uint8_t *write_buffer,
size_t write_count,
46 uint8_t *read_buffer,
size_t read_count) {
55 err = this->
transfer_(select_frequency,
address, write_buffer, write_count, read_buffer, read_count);
64 size_t write_count, uint8_t *read_buffer,
size_t read_count) {
66 if (transfer_frequency == select_frequency) {
95#ifdef I2C_PORT_FREQUENCY_COUNT
98 this->
mark_failed(LOG_STR(
"Failed to switch the bus frequency"));
103#ifdef I2C_PORT_FREQUENCY_COUNT
107 ESP_LOGE(TAG,
"TCA9548A failed");
111#ifdef I2C_PORT_FREQUENCY_COUNT
113 this->
mark_failed(LOG_STR(
"Failed to switch the bus frequency"));
117 ESP_LOGD(TAG,
"Channels currently open: %d",
status);
120 ESP_LOGCONFIG(TAG,
"TCA9548A:");
121 LOG_I2C_DEVICE(
this);
128 const uint8_t channel_val = 1 << channel;
129 return this->
write(&channel_val, 1);
void mark_failed()
Mark this component as failed.
virtual ErrorCode write_readv(uint8_t address, const uint8_t *write_buffer, size_t write_count, uint8_t *read_buffer, size_t read_count)=0
This virtual method writes bytes to an I2CBus from an array, then reads bytes into an array of ReadBu...
virtual uint32_t get_frequency() const
The frequency the bus runs at.
virtual ErrorCode switch_frequency(uint32_t frequency)
Switch the bus frequency for the transactions that follow; an external bus that does not override thi...
ErrorCode write(const uint8_t *data, size_t len) const
writes an array of bytes to a device using an I2CBus
I2CBus * bus_
pointer to I2CBus instance
ErrorCode read(uint8_t *data, size_t len) const
reads an array of bytes from the device using an I2CBus
i2c::ErrorCode write_readv_at_port_frequency_(uint32_t select_frequency, uint8_t address, const uint8_t *write_buffer, size_t write_count, uint8_t *read_buffer, size_t read_count)
uint32_t transfer_frequency_() const
uint32_t get_frequency() const override
i2c::ErrorCode write_readv(uint8_t address, const uint8_t *write_buffer, size_t write_count, uint8_t *read_buffer, size_t read_count) override
i2c::ErrorCode switch_frequency(uint32_t frequency) override
i2c::ErrorCode switch_bus_(uint32_t frequency)
Switch the upstream bus, flagging the multiplexer on failure.
TCA9548AComponent * parent_
i2c::ErrorCode transfer_(uint32_t select_frequency, uint8_t address, const uint8_t *write_buffer, size_t write_count, uint8_t *read_buffer, size_t read_count)
uint32_t select_frequency_() const
i2c::ErrorCode switch_to_channel(uint8_t channel)
void disable_all_channels()
void dump_config() override
ErrorCode
Error codes returned by I2CBus and I2CDevice methods.
@ ERROR_OK
No error found during execution of method.
@ ERROR_NOT_INITIALIZED
call method to a not initialized bus
ESPHOME_LOG_TAG(TAG, "tca9548a")