UART Bus

API Reference

class UARTComponent : public Component

Public Functions

UARTComponent(int8_t tx_pin, int8_t rx_pin, uint32_t baud_rate = 9600)
void setup()

Where the component’s initialization should happen.

Analogous to Arduino’s setup(). This method is guaranteed to only be called once. Defaults to doing nothing.

void dump_config()
void write_byte(uint8_t data)
void write_array(const uint8_t *data, size_t len)
void write_str(const char *str)
bool peek_byte(uint8_t *data)
bool read_byte(uint8_t *data)
bool read_array(uint8_t *data, size_t len)
size_t available()
void flush()
float get_setup_priority() const

priority of setup().

higher -> executed earlier

Defaults to 0.

Return
The setup priority of this component

Protected Functions

bool check_read_timeout_(size_t len = 1)

Protected Attributes

HardwareSerial *hw_serial_ = {nullptr}
ESP8266SoftwareSerial *sw_serial_ = {nullptr}
int8_t tx_pin_
int8_t rx_pin_
uint32_t baud_rate_
class UARTDevice

Subclassed by binary_sensor::RDM6300Component, display::Nextion, sensor::CSE7766Component, sensor::MHZ19Component, sensor::PMSX003Component, switch_::UARTSwitch

Public Functions

UARTDevice(UARTComponent *parent)
void write_byte(uint8_t data)
void write_array(const uint8_t *data, size_t len)
void write_str(const char *str)
bool read_byte(uint8_t *data)
bool peek_byte(uint8_t *data)
bool read_array(uint8_t *data, size_t len)
size_t available()
void flush()

Protected Attributes

UARTComponent *parent_
class ESP8266SoftwareSerial

Public Functions

void setup(int8_t tx_pin, int8_t rx_pin, uint32_t baud_rate)
uint8_t read_byte()
uint8_t peek_byte()
void flush()
void ICACHE_RAM_ATTR HOT ESP8266SoftwareSerial::write_byte(uint8_t data)
size_t available()

Protected Functions

void ICACHE_RAM_ATTR HOT ESP8266SoftwareSerial::gpio_intr_()
void wait_(uint32_t &wait, const uint32_t &start)
uint8_t read_bit_(uint32_t &wait, const uint32_t &start)
void write_bit_(bool bit, uint32_t &wait, const uint32_t &start)
void tx_high_()
void tx_low_()

Protected Attributes

uint32_t rx_mask_ = {0}
uint32_t tx_mask_ = {0}
uint32_t bit_time_ = {0}
uint8_t *rx_buffer_ = {nullptr}
size_t rx_buffer_size_ = {64}
volatile size_t rx_in_pos_ = {0}
size_t rx_out_pos_ = {0}