ESPHome  2024.9.0
Data Structures | Enumerations | Functions | Variables
esphome::weikai Namespace Reference

Data Structures

class  WeikaiChannel
 The WeikaiChannel class is used to implement all the virtual methods of the ESPHome uart::UARTComponent virtual class. More...
 
class  WeikaiComponent
 The WeikaiComponent class stores the information global to the WeiKai component and provides methods to set/access this information. More...
 
class  WeikaiGPIOPin
 Helper class to expose a WeiKai family IO pin as an internal GPIO pin. More...
 
class  WeikaiRegister
 WeikaiRegister objects acts as proxies to access remote register independently of the bus type. More...
 
class  WKRingBuffer
 This is an helper class that provides a simple ring buffers that works as a FIFO. More...
 

Enumerations

enum  RegType { REG = 0, FIFO = 1 }
 

Functions

std::string i2s (uint8_t val)
 convert an int to binary representation as C++ std::string More...
 
uint32_t elapsed_ms (uint32_t &last_time)
 measure the time elapsed between two calls More...
 
const char * p2s (uart::UARTParityOptions parity)
 Converts the parity enum value to a C string. More...
 
void print_buffer (const uint8_t *data, size_t length)
 Display a buffer in hexadecimal format (32 hex values / line) for debug. More...
 
const char * reg_to_str (int reg, bool page1)
 
void print_buffer (std::vector< uint8_t > buffer)
 Hex converter to print/display a buffer in hexadecimal format (32 hex values / line). More...
 

Variables

constexpr size_t XFER_MAX_SIZE = I2C_BUFFER_LENGTH
 XFER_MAX_SIZE defines the maximum number of bytes allowed during one transfer. More...
 
constexpr size_t FIFO_SIZE = 256
 size of the internal WeiKai FIFO More...
 
constexpr size_t RING_BUFFER_SIZE = FIFO_SIZE
 size of the ring buffer set to size of the FIFO More...
 
constexpr uint8_t WKREG_GENA = 0x00
 Global Control Register - 00 0000. More...
 
constexpr uint8_t GENA_C4EN = 1 << 3
 Channel 4 enable clock (0: disable, 1: enable) More...
 
constexpr uint8_t GENA_C3EN = 1 << 2
 Channel 3 enable clock (0: disable, 1: enable) More...
 
constexpr uint8_t GENA_C2EN = 1 << 1
 Channel 2 enable clock (0: disable, 1: enable) More...
 
constexpr uint8_t GENA_C1EN = 1 << 0
 Channel 1 enable clock (0: disable, 1: enable) More...
 
constexpr uint8_t WKREG_GRST = 0x01
 Global Reset Register - 00 0001. More...
 
constexpr uint8_t GRST_C4RST = 1 << 3
 Channel 4 soft reset (0: not reset, 1: reset) More...
 
constexpr uint8_t GRST_C3RST = 1 << 2
 Channel 3 soft reset (0: not reset, 1: reset) More...
 
constexpr uint8_t GRST_C2RST = 1 << 1
 Channel 2 soft reset (0: not reset, 1: reset) More...
 
constexpr uint8_t GRST_C1RST = 1 << 0
 Channel 1 soft reset (0: not reset, 1: reset) More...
 
constexpr uint8_t WKREG_GMUT = 0x02
 Global Master channel control register (not used) - 000010. More...
 
constexpr uint8_t WKREG_GIER = 0x10
 Global interrupt register (not used) - 01 0000. More...
 
constexpr uint8_t WKREG_GIFR = 0x11
 Global interrupt flag register (not used) 01 0001. More...
 
constexpr uint8_t WKREG_GPDIR = 0x21
 Global GPIO direction register - 10 0001. More...
 
constexpr uint8_t WKREG_GPDAT = 0x31
 Global GPIO data register - 11 0001. More...
 
constexpr uint8_t WKREG_SPAGE = 0x03
 Global Page register c0/c1 0011. More...
 
constexpr uint8_t WKREG_SCR = 0x04
 Serial Control Register - c0/c1 0100. More...
 
constexpr uint8_t SCR_TXEN = 1 << 1
 transmission control (0: enable, 1: disable) More...
 
constexpr uint8_t SCR_RXEN = 1 << 0
 receiving control (0: enable, 1: disable) More...
 
constexpr uint8_t WKREG_LCR = 0x05
 Line Configuration Register - c0/c1 0101. More...
 
constexpr uint8_t LCR_PAEN = 1 << 3
 Parity enable (0: no check, 1: check) More...
 
constexpr uint8_t LCR_PAR_F0 = 0 << 1
 Parity force 0. More...
 
constexpr uint8_t LCR_PAR_ODD = 1 << 1
 Parity odd. More...
 
constexpr uint8_t LCR_PAR_EVEN = 2 << 1
 Parity even. More...
 
constexpr uint8_t LCR_PAR_F1 = 3 << 1
 Parity force 1. More...
 
constexpr uint8_t LCR_STPL = 1 << 0
 Stop length (0: 1 bit, 1: 2 bits) More...
 
constexpr uint8_t WKREG_FCR = 0x06
 FIFO Control Register - c0/c1 0110. More...
 
constexpr uint8_t FCR_TFEN = 1 << 3
 Transmitter FIFO enable. More...
 
constexpr uint8_t FCR_RFEN = 1 << 2
 Receiver FIFO enable. More...
 
constexpr uint8_t FCR_TFRST = 1 << 1
 Transmitter FIFO reset. More...
 
constexpr uint8_t FCR_RFRST = 1 << 0
 Receiver FIFO reset. More...
 
constexpr uint8_t WKREG_SIER = 0x07
 Serial Interrupt Enable Register (not used) - c0/c1 0111. More...
 
constexpr uint8_t WKREG_SIFR = 0x08
 Serial Interrupt Flag Register (not used) - c0/c1 1000. More...
 
constexpr uint8_t WKREG_TFCNT = 0x09
 Transmitter FIFO Count - c0/c1 1001. More...
 
constexpr uint8_t WKREG_RFCNT = 0x0A
 Receiver FIFO count - c0/c1 1010. More...
 
constexpr uint8_t WKREG_FSR = 0x0B
 FIFO Status Register - c0/c1 1011. More...
 
constexpr uint8_t FSR_RFOE = 1 << 7
 Receiver FIFO Overflow Error (0: no OE, 1: OE) More...
 
constexpr uint8_t FSR_RFLB = 1 << 6
 Receiver FIFO Line Break (0: no LB, 1: LB) More...
 
constexpr uint8_t FSR_RFFE = 1 << 5
 Receiver FIFO Frame Error (0: no FE, 1: FE) More...
 
constexpr uint8_t FSR_RFPE = 1 << 4
 Receiver Parity Error (0: no PE, 1: PE) More...
 
constexpr uint8_t FSR_RFDAT = 1 << 3
 Receiver FIFO count (0: empty, 1: not empty) More...
 
constexpr uint8_t FSR_TFDAT = 1 << 2
 Transmitter FIFO count (0: empty, 1: not empty) More...
 
constexpr uint8_t FSR_TFFULL = 1 << 1
 Transmitter FIFO full (0: not full, 1: full) More...
 
constexpr uint8_t FSR_TBUSY = 1 << 0
 Transmitter busy (0 nothing to transmit, 1: transmitter busy sending) More...
 
constexpr uint8_t WKREG_LSR = 0x0C
 Line Status Register (not used - using FIFO) More...
 
constexpr uint8_t WKREG_FDAT = 0x0D
 FIFO Data Register (not used - does not seems to work) More...
 
constexpr uint8_t WKREG_BRH = 0x04
 Baud rate configuration register: high byte - c0/c1 0100. More...
 
constexpr uint8_t WKREG_BRL = 0x05
 Baud rate configuration register: low byte - c0/c1 0101. More...
 
constexpr uint8_t WKREG_BRD = 0x06
 Baud rate configuration register decimal part - c0/c1 0110. More...
 
constexpr uint8_t WKREG_RFI = 0x07
 Receive FIFO Interrupt trigger configuration (not used) - c0/c1 0111. More...
 
constexpr uint8_t WKREG_TFI = 0x08
 Transmit FIFO interrupt trigger configuration (not used) - c0/c1 1000. More...
 

Enumeration Type Documentation

◆ RegType

Enumerator
REG 
FIFO 

Definition at line 131 of file weikai.cpp.

Function Documentation

◆ elapsed_ms()

uint32_t esphome::weikai::elapsed_ms ( uint32_t &  last_time)

measure the time elapsed between two calls

Parameters
last_timetime of the previous call
Returns
the elapsed time in milliseconds

Definition at line 75 of file weikai.cpp.

◆ i2s()

std::string esphome::weikai::i2s ( uint8_t  val)
inline

convert an int to binary representation as C++ std::string

Parameters
valinteger to convert
Returns
a std::string

Definition at line 68 of file weikai.cpp.

◆ p2s()

const char* esphome::weikai::p2s ( uart::UARTParityOptions  parity)

Converts the parity enum value to a C string.

Parameters
parityenum
Returns
the string

Definition at line 84 of file weikai.cpp.

◆ print_buffer()

void esphome::weikai::print_buffer ( const uint8_t *  data,
size_t  length 
)

Display a buffer in hexadecimal format (32 hex values / line) for debug.

Definition at line 99 of file weikai.cpp.

◆ reg_to_str()

const char* esphome::weikai::reg_to_str ( int  reg,
bool  page1 
)

Definition at line 121 of file weikai.cpp.

Variable Documentation

◆ FIFO_SIZE

constexpr size_t esphome::weikai::FIFO_SIZE = 256

size of the internal WeiKai FIFO

Definition at line 40 of file weikai.h.

◆ RING_BUFFER_SIZE

constexpr size_t esphome::weikai::RING_BUFFER_SIZE = FIFO_SIZE

size of the ring buffer set to size of the FIFO

Definition at line 43 of file weikai.h.

◆ XFER_MAX_SIZE

constexpr size_t esphome::weikai::XFER_MAX_SIZE = I2C_BUFFER_LENGTH

XFER_MAX_SIZE defines the maximum number of bytes allowed during one transfer.

Definition at line 34 of file weikai.h.