32#if defined(I2C_BUFFER_LENGTH)
45const LogString *
reg_to_str(
int reg,
bool page1);
48void print_buffer(
const char *tag,
const uint8_t *data,
size_t length,
int level = ESPHOME_LOG_LEVEL_VERY_VERBOSE);
92 operator uint8_t()
const {
return read_reg(); }
146 void loop()
override;
207 void setup()
override;
313#if defined(USE_ESP8266) || defined(USE_ESP32)
319 using UARTComponent::load_settings;
Fixed-size circular buffer with FIFO semantics and iteration support.
The WeikaiChannel class is used to implement all the virtual methods of the ESPHome uart::UARTCompone...
size_t available() override
Returns the number of bytes in the receive buffer.
void dump_channel()
dump channel information
void setup_channel()
Setup the channel.
WeikaiRegister & reg(uint8_t reg)
Factory method to create a WeikaiRegister proxy object.
void set_line_param_()
set the line parameters
void set_baudrate_()
set the baud rate
uint8_t data_
a one byte buffer for register read storage
bool check_channel_down_()
check if channel is alive
bool peek_byte(uint8_t *buffer) override
Reads the first byte in FIFO without removing it.
size_t xfer_fifo_to_buffer_()
transfer bytes from the weikai internal FIFO to the buffer (if any)
void load_settings(bool dump_config) override
Re-apply the current line settings (baud, parity, etc) to the channel.
void check_logger_conflict() override
this cannot happen with external uart therefore we do nothing
std::string name_
name of the entity
uart::UARTFlushResult flush() override
Flush the output fifo.
const char * get_channel_name()
Get the channel name.
WeikaiComponent * parent_
our WK2168component parent
bool read_array(uint8_t *buffer, size_t length) override
Reads a specified number of bytes from a serial port.
void set_channel_name(std::string &&name)
The name as generated by the Python code generator.
void reset_fifo_()
reset the weikai internal FIFO
bool tx_fifo_is_not_empty_()
test if transmit buffer is not empty in the status register (optimization)
StaticRingBuffer< uint8_t, RING_BUFFER_SIZE > receive_buffer_
the buffer where we store temporarily the bytes received
uint8_t channel_
our Channel number
void set_parent(WeikaiComponent *parent)
We belongs to this WeikaiComponent.
size_t rx_in_fifo_()
Returns the number of bytes in the receive fifo.
void set_channel(uint8_t channel)
Sets the channel number.
size_t tx_in_fifo_()
Returns the number of bytes in the transmit fifo.
void write_array(const uint8_t *buffer, size_t length) override
Writes a specified number of bytes to a serial port.
The WeikaiComponent class stores the information global to the WeiKai component and provides methods ...
void set_name(std::string &&name)
store the name for the component
int test_mode_
test mode value (0 -> no tests)
virtual WeikaiRegister & reg(uint8_t reg, uint8_t channel)=0
Factory method to create a Register object.
uint8_t input_state_
input pin states: 1 means HIGH, 0 means LOW
uint32_t crystal_
crystal value;
void write_pin_val_(uint8_t pin, bool value)
Helper method to write the value of a pin.
bool read_pin_val_(uint8_t pin)
Helper method to read the value of a pin.
uint8_t output_state_
output state: 1 means HIGH, 0 means LOW
bool page1_
set to true when in "page1 mode"
void set_crystal(uint32_t crystal)
store crystal frequency
std::vector< WeikaiChannel * > children_
the list of WeikaiChannel UART children
void set_test_mode(int test_mode)
store if the component is in test mode
void loop() override
override the Component loop()
std::string name_
name of entity
void set_pin_direction_(uint8_t pin, gpio::Flags flags)
Helper method to set the pin mode of a pin.
float get_setup_priority() const override
Get the priority of the component.
uint8_t pin_config_
pin config mask: 1 means OUTPUT, 0 means INPUT
virtual ~WeikaiComponent()
virtual destructor
const char * get_name()
Get the name of the component.
Helper class to expose a WeiKai family IO pin as an internal GPIO pin.
void digital_write(bool value) override
void set_inverted(bool inverted)
bool digital_read() override
void set_pin(uint8_t pin)
gpio::Flags get_flags() const override
void pin_mode(gpio::Flags flags) override
void set_parent(WeikaiComponent *parent)
void set_flags(gpio::Flags flags)
size_t dump_summary(char *buffer, size_t len) const override
WeikaiComponent * parent_
WeikaiRegister objects acts as proxies to access remote register independently of the bus type.
virtual void write_reg(uint8_t value)=0
writes the register
WeikaiRegister & operator|=(uint8_t value)
overloads the compound |= operator.
WeikaiRegister & operator&=(uint8_t value)
overloads the compound &= operator.
virtual void write_fifo(uint8_t *data, size_t length)=0
write an array of bytes to the transmitter fifo
WeikaiRegister & operator=(uint8_t value)
overloads the = operator.
uint8_t register_
address of the register
WeikaiRegister(WeikaiComponent *const comp, uint8_t reg, uint8_t channel)
WeikaiRegister constructor.
uint8_t channel_
channel for this register
virtual ~WeikaiRegister()
WeikaiComponent *const comp_
pointer to our parent (aggregation)
virtual uint8_t read_reg() const =0
reads the register
virtual void read_fifo(uint8_t *data, size_t length) const =0
read an array of bytes from the receiver fifo
const LogString * message
bool uart_receive_test_(char *message)
Test the read_array() method.
void uart_send_test_(char *message)
Test the write_array() method.
constexpr float BUS
For communication buses like i2c/spi.
UARTFlushResult
Result of a flush() call.
When the TEST_COMPONENT flag is defined we include some auto-test methods.
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.
constexpr size_t RING_BUFFER_SIZE
size of the ring buffer set to size of the FIFO
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.
constexpr size_t FIFO_SIZE
size of the internal WeiKai FIFO
WeiKai component family - registers' definition.