ESPHome  2024.12.2
tca9548a.h
Go to the documentation of this file.
1 #pragma once
2 
5 
6 namespace esphome {
7 namespace tca9548a {
8 
9 static const uint8_t TCA9548A_DISABLE_CHANNELS_COMMAND = 0x00;
10 
11 class TCA9548AComponent;
12 class TCA9548AChannel : public i2c::I2CBus {
13  public:
14  void set_channel(uint8_t channel) { channel_ = channel; }
15  void set_parent(TCA9548AComponent *parent) { parent_ = parent; }
16 
17  i2c::ErrorCode readv(uint8_t address, i2c::ReadBuffer *buffers, size_t cnt) override;
18  i2c::ErrorCode writev(uint8_t address, i2c::WriteBuffer *buffers, size_t cnt, bool stop) override;
19 
20  protected:
21  uint8_t channel_;
23 };
24 
25 class TCA9548AComponent : public Component, public i2c::I2CDevice {
26  public:
27  void setup() override;
28  void dump_config() override;
29  float get_setup_priority() const override { return setup_priority::IO; }
30  void update();
31 
32  i2c::ErrorCode switch_to_channel(uint8_t channel);
33  void disable_all_channels();
34 
35  protected:
36  friend class TCA9548AChannel;
37 };
38 } // namespace tca9548a
39 } // namespace esphome
void setup()
the WriteBuffer structure stores a pointer to a write buffer and its length
Definition: i2c_bus.h:30
float get_setup_priority() const override
Definition: tca9548a.h:29
i2c::ErrorCode writev(uint8_t address, i2c::WriteBuffer *buffers, size_t cnt, bool stop) override
Definition: tca9548a.cpp:17
the ReadBuffer structure stores a pointer to a read buffer and its length
Definition: i2c_bus.h:24
TCA9548AComponent * parent_
Definition: tca9548a.h:22
This Class provides the methods to read and write bytes from an I2CBus.
Definition: i2c_bus.h:40
void set_channel(uint8_t channel)
Definition: tca9548a.h:14
const float IO
For components that represent GPIO pins like PCF8573.
Definition: component.cpp:17
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
uint8_t address
Definition: bl0906.h:211
void set_parent(TCA9548AComponent *parent)
Definition: tca9548a.h:15
i2c::ErrorCode readv(uint8_t address, i2c::ReadBuffer *buffers, size_t cnt) override
Definition: tca9548a.cpp:9
ErrorCode
Error codes returned by I2CBus and I2CDevice methods.
Definition: i2c_bus.h:11
This Class provides the methods to read/write bytes from/to an i2c device.
Definition: i2c.h:133