11using namespace weikai;
28 uint8_t
const addr = base_address | channel << 1 | fifo << 0;
43 ESP_LOGVV(TAG,
"WeikaiRegisterI2C::read_reg() @%02X reg=%s ch=%u I2C_code:%d, buf=%02X",
address,
47 ESP_LOGE(TAG,
"WeikaiRegisterI2C::read_reg() @%02X reg=%s ch=%u I2C_code:%d, buf=%02X",
address,
60#ifdef ESPHOME_LOG_HAS_VERY_VERBOSE
61 ESP_LOGVV(TAG,
"WeikaiRegisterI2C::read_fifo() @%02X ch=%d I2C_code:%d len=%d buffer",
address, this->
channel_,
67 ESP_LOGE(TAG,
"WeikaiRegisterI2C::read_fifo() @%02X reg=N/A ch=%d I2C_code:%d len=%d buf=%02X",
address,
79 ESP_LOGVV(TAG,
"WK2168Reg::write_reg() @%02X reg=%s ch=%d I2C_code:%d buf=%02X",
address,
83 ESP_LOGE(TAG,
"WK2168Reg::write_reg() @%02X reg=%s ch=%d I2C_code:%d buf=%d",
address,
95#ifdef ESPHOME_LOG_HAS_VERY_VERBOSE
96 ESP_LOGVV(TAG,
"WK2168Reg::write_fifo() @%02X ch=%d I2C_code:%d len=%d buffer",
address, this->
channel_,
102 ESP_LOGE(TAG,
"WK2168Reg::write_fifo() @%02X reg=N/A, ch=%d I2C_code:%d len=%d, buf=%02X",
address, this->
channel_,
103 (
int) error,
length, data[0]);
113 ESP_LOGCONFIG(TAG,
"Setup %s (%d UARTs) @ 0x%02X", this->
get_name(), this->
children_.size(), this->base_address_);
125 child->setup_channel();
131 "Initialization of %s with %d UARTs completed\n"
132 " Crystal: %" PRIu32,
137 " Transfer buffer size: %d",
141 LOG_I2C_DEVICE(
this);
144 child->dump_channel();
void status_set_warning()
void status_clear_warning()
ErrorCode write_register(uint8_t a_register, const uint8_t *data, size_t len) const
writes an array of bytes to a specific register in the I²C device
ErrorCode write(const uint8_t *data, size_t len) const
writes an array of bytes to a device using an I2CBus
ErrorCode read(uint8_t *data, size_t len) const
reads an array of bytes from the device using an I2CBus
uint8_t address_
store the address of the device on the bus
void set_i2c_address(uint8_t address)
We store the address of the device on the bus.
ErrorCode read_register(uint8_t a_register, uint8_t *data, size_t len)
reads an array of bytes from a specific register in the I²C device
int test_mode_
test mode value (0 -> no tests)
bool page1_
set to true when in "page1 mode"
std::vector< WeikaiChannel * > children_
the list of WeikaiChannel UART children
const char * get_name()
Get the name of the component.
uint8_t register_
address of the register
uint8_t channel_
channel for this register
WeikaiComponent *const comp_
pointer to our parent (aggregation)
The WeikaiComponentI2C class stores the information to the WeiKai component connected through an I2C ...
weikai::WeikaiRegister & reg(uint8_t reg, uint8_t channel) override
uint8_t base_address_
base address of I2C device
void dump_config() override
void write_fifo(uint8_t *data, size_t length) override
uint8_t read_reg() const override
void write_reg(uint8_t value) override
void read_fifo(uint8_t *data, size_t length) const override
constexpr uint8_t WKREG_SPAGE
Global Page register c0/c1 0011.
constexpr uint8_t GRST_C4RST
Channel 4 soft reset (0: not reset, 1: reset)
constexpr uint8_t GRST_C2RST
Channel 2 soft reset (0: not reset, 1: reset)
constexpr uint8_t WKREG_GRST
Global Reset Register - 00 0001.
constexpr uint8_t GRST_C3RST
Channel 3 soft reset (0: not reset, 1: reset)
constexpr uint8_t GENA_C2EN
Channel 2 enable clock (0: disable, 1: enable)
constexpr uint8_t GRST_C1RST
Channel 1 soft reset (0: not reset, 1: reset)
constexpr uint8_t GENA_C3EN
Channel 3 enable clock (0: disable, 1: enable)
constexpr uint8_t GENA_C4EN
Channel 4 enable clock (0: disable, 1: enable)
constexpr uint8_t WKREG_GENA
Global Control Register - 00 0000.
constexpr uint8_t GENA_C1EN
Channel 1 enable clock (0: disable, 1: enable)
@ NO_ERROR
No error found during execution of method.
uint8_t i2c_address(uint8_t base_address, uint8_t channel, RegType fifo)
Computes the I²C bus's address used to access the component.
const LogString * reg_to_str(int reg, bool page1)
Name of a register for the log messages.
constexpr size_t XFER_MAX_SIZE
XFER_MAX_SIZE defines the maximum number of bytes allowed during one transfer.
void print_buffer(const char *tag, const uint8_t *data, size_t length, int level)
Display a buffer in hexadecimal format (32 hex values / line) for debug.
ESPHOME_LOG_TAG(TAG, "weikai")
WeiKai component family - classes declaration.