ESPHome  2024.10.2
weikai_i2c.h
Go to the documentation of this file.
1 
8 #pragma once
9 #include <bitset>
10 #include <memory>
11 #include "esphome/core/component.h"
15 
16 namespace esphome {
17 namespace weikai_i2c {
18 
19 class WeikaiComponentI2C;
20 
21 // using namespace weikai;
26  public:
27  uint8_t read_reg() const override;
28  void write_reg(uint8_t value) override;
29  void read_fifo(uint8_t *data, size_t length) const override;
30  void write_fifo(uint8_t *data, size_t length) override;
31 
32  protected:
34  WeikaiRegisterI2C(weikai::WeikaiComponent *const comp, uint8_t reg, uint8_t channel)
35  : weikai::WeikaiRegister(comp, reg, channel) {}
36 };
37 
43  public:
44  weikai::WeikaiRegister &reg(uint8_t reg, uint8_t channel) override {
45  reg_i2c_.register_ = reg;
46  reg_i2c_.channel_ = channel;
47  return reg_i2c_;
48  }
49 
50  //
51  // override Component methods
52  //
53  void setup() override;
54  void dump_config() override;
55 
56  uint8_t base_address_;
57  WeikaiRegisterI2C reg_i2c_{this, 0, 0};
58 };
59 
60 } // namespace weikai_i2c
61 } // namespace esphome
void setup()
WeikaiRegisterI2C(weikai::WeikaiComponent *const comp, uint8_t reg, uint8_t channel)
Definition: weikai_i2c.h:34
uint8_t read_reg() const override
Definition: weikai_i2c.cpp:67
uint8_t base_address_
base address of I2C device
Definition: weikai_i2c.h:56
weikai::WeikaiRegister & reg(uint8_t reg, uint8_t channel) override
Definition: weikai_i2c.h:44
void write_reg(uint8_t value) override
Definition: weikai_i2c.cpp:104
The WeikaiComponent class stores the information global to the WeiKai component and provides methods ...
Definition: weikai.h:197
The WeikaiComponentI2C class stores the information to the WeiKai component connected through an I2C ...
Definition: weikai_i2c.h:42
WeiKai component family - classes declaration.
void write_fifo(uint8_t *data, size_t length) override
Definition: weikai_i2c.cpp:120
WeikaiRegisterI2C objects acts as proxies to access remote register through an I2C Bus...
Definition: weikai_i2c.h:25
WeikaiRegister objects acts as proxies to access remote register independently of the bus type...
Definition: weikai.h:139
uint16_t length
Definition: tt21100.cpp:12
uint8_t register_
address of the register
Definition: weikai.h:186
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void read_fifo(uint8_t *data, size_t length) const override
Definition: weikai_i2c.cpp:85
This Class provides the methods to read/write bytes from/to an i2c device.
Definition: i2c.h:133