ESPHome 2026.3.0-dev
Loading...
Searching...
No Matches
esphome::usb_uart::USBUartChannel Class Reference

#include <usb_uart.h>

Inheritance diagram for esphome::usb_uart::USBUartChannel:
esphome::uart::UARTComponent esphome::Parented< USBUartComponent >

Public Member Functions

 USBUartChannel (uint8_t index, uint16_t buffer_size)
 
void write_array (const uint8_t *data, size_t len) override
 
bool peek_byte (uint8_t *data) override
 
bool read_array (uint8_t *data, size_t len) override
 
size_t available () override
 
void flush () override
 
void check_logger_conflict () override
 
void set_parity (UARTParityOptions parity)
 
void set_debug (bool debug)
 
void set_dummy_receiver (bool dummy_receiver)
 
void set_rx_callback (std::function< void()> cb)
 Register a callback invoked immediately after data is pushed to the input ring buffer.
 
- Public Member Functions inherited from esphome::uart::UARTComponent
void write_array (const std::vector< uint8_t > &data)
 
void write_byte (uint8_t data)
 
void write_str (const char *str)
 
bool read_byte (uint8_t *data)
 
void set_tx_pin (InternalGPIOPin *tx_pin)
 
void set_rx_pin (InternalGPIOPin *rx_pin)
 
void set_flow_control_pin (InternalGPIOPin *flow_control_pin)
 
void set_rx_buffer_size (size_t rx_buffer_size)
 
size_t get_rx_buffer_size ()
 
virtual void set_rx_full_threshold (size_t rx_full_threshold)
 
void set_rx_full_threshold_ms (uint8_t time)
 
size_t get_rx_full_threshold ()
 
virtual void set_rx_timeout (size_t rx_timeout)
 
size_t get_rx_timeout ()
 
void set_stop_bits (uint8_t stop_bits)
 
uint8_t get_stop_bits () const
 
void set_data_bits (uint8_t data_bits)
 
uint8_t get_data_bits () const
 
void set_parity (UARTParityOptions parity)
 
UARTParityOptions get_parity () const
 
void set_baud_rate (uint32_t baud_rate)
 
uint32_t get_baud_rate () const
 
virtual void load_settings (bool dump_config)
 Load the UART settings.
 
virtual void load_settings ()
 Load the UART settings.
 
void add_debug_callback (std::function< void(UARTDirection, uint8_t)> &&callback)
 
- Public Member Functions inherited from esphome::Parented< USBUartComponent >
 Parented ()
 
 Parented (USBUartComponent *parent)
 
USBUartComponent * get_parent () const
 Get the parent of this object.
 
void set_parent (USBUartComponent *parent)
 Set the parent of this object.
 

Static Public Attributes

static constexpr uint8_t USB_OUTPUT_CHUNK_COUNT = 8
 

Protected Attributes

RingBuffer input_buffer_
 
LockFreeQueue< UsbOutputChunk, USB_OUTPUT_CHUNK_COUNToutput_queue_
 
EventPool< UsbOutputChunk, USB_OUTPUT_CHUNK_COUNToutput_pool_
 
std::function< void()> rx_callback_ {}
 
CdcEps cdc_dev_ {}
 
UARTParityOptions parity_ {UART_CONFIG_PARITY_NONE}
 
std::atomic< bool > input_started_ {true}
 
std::atomic< bool > output_started_ {true}
 
std::atomic< bool > initialised_ {false}
 
const uint8_t index_
 
bool debug_ {}
 
bool dummy_receiver_ {}
 
- Protected Attributes inherited from esphome::uart::UARTComponent
InternalGPIOPintx_pin_
 
InternalGPIOPinrx_pin_
 
InternalGPIOPinflow_control_pin_
 
size_t rx_buffer_size_
 
size_t rx_full_threshold_ {1}
 
size_t rx_timeout_ {0}
 
uint32_t baud_rate_ {0}
 
uint8_t stop_bits_ {0}
 
uint8_t data_bits_ {0}
 
UARTParityOptions parity_ {UART_CONFIG_PARITY_NONE}
 
CallbackManager< void(UARTDirection, uint8_t)> debug_callback_ {}
 
- Protected Attributes inherited from esphome::Parented< USBUartComponent >
USBUartComponent * parent_
 

Additional Inherited Members

- Protected Member Functions inherited from esphome::uart::UARTComponent
bool check_read_timeout_ (size_t len=1)
 

Detailed Description

Definition at line 98 of file usb_uart.h.

Constructor & Destructor Documentation

◆ USBUartChannel()

esphome::usb_uart::USBUartChannel::USBUartChannel ( uint8_t index,
uint16_t buffer_size )
inline

Definition at line 108 of file usb_uart.h.

Member Function Documentation

◆ available()

size_t esphome::usb_uart::USBUartChannel::available ( )
inlineoverridevirtual

Implements esphome::uart::UARTComponent.

Definition at line 112 of file usb_uart.h.

◆ check_logger_conflict()

void esphome::usb_uart::USBUartChannel::check_logger_conflict ( )
inlineoverridevirtual

Implements esphome::uart::UARTComponent.

Definition at line 114 of file usb_uart.h.

◆ flush()

void esphome::usb_uart::USBUartChannel::flush ( )
overridevirtual

Implements esphome::uart::UARTComponent.

Definition at line 168 of file usb_uart.cpp.

◆ peek_byte()

bool esphome::usb_uart::USBUartChannel::peek_byte ( uint8_t * data)
overridevirtual

Implements esphome::uart::UARTComponent.

Definition at line 181 of file usb_uart.cpp.

◆ read_array()

bool esphome::usb_uart::USBUartChannel::read_array ( uint8_t * data,
size_t len )
overridevirtual

Implements esphome::uart::UARTComponent.

Definition at line 188 of file usb_uart.cpp.

◆ set_debug()

void esphome::usb_uart::USBUartChannel::set_debug ( bool debug)
inline

Definition at line 116 of file usb_uart.h.

◆ set_dummy_receiver()

void esphome::usb_uart::USBUartChannel::set_dummy_receiver ( bool dummy_receiver)
inline

Definition at line 117 of file usb_uart.h.

◆ set_parity()

void esphome::usb_uart::USBUartChannel::set_parity ( UARTParityOptions parity)
inline

Definition at line 115 of file usb_uart.h.

◆ set_rx_callback()

void esphome::usb_uart::USBUartChannel::set_rx_callback ( std::function< void()> cb)
inline

Register a callback invoked immediately after data is pushed to the input ring buffer.

Called from USBUartComponent::loop() in the main loop context. Allows consumers (e.g. ZigbeeProxy) to process bytes in the same loop iteration they arrive, eliminating one full main-loop-wakeup cycle of latency.

Definition at line 123 of file usb_uart.h.

◆ write_array()

void esphome::usb_uart::USBUartChannel::write_array ( const uint8_t * data,
size_t len )
overridevirtual

Implements esphome::uart::UARTComponent.

Definition at line 131 of file usb_uart.cpp.

Field Documentation

◆ cdc_dev_

CdcEps esphome::usb_uart::USBUartChannel::cdc_dev_ {}
protected

Definition at line 131 of file usb_uart.h.

◆ debug_

bool esphome::usb_uart::USBUartChannel::debug_ {}
protected

Definition at line 140 of file usb_uart.h.

◆ dummy_receiver_

bool esphome::usb_uart::USBUartChannel::dummy_receiver_ {}
protected

Definition at line 141 of file usb_uart.h.

◆ index_

const uint8_t esphome::usb_uart::USBUartChannel::index_
protected

Definition at line 139 of file usb_uart.h.

◆ initialised_

std::atomic<bool> esphome::usb_uart::USBUartChannel::initialised_ {false}
protected

Definition at line 137 of file usb_uart.h.

◆ input_buffer_

RingBuffer esphome::usb_uart::USBUartChannel::input_buffer_
protected

Definition at line 127 of file usb_uart.h.

◆ input_started_

std::atomic<bool> esphome::usb_uart::USBUartChannel::input_started_ {true}
protected

Definition at line 135 of file usb_uart.h.

◆ output_pool_

EventPool<UsbOutputChunk, USB_OUTPUT_CHUNK_COUNT> esphome::usb_uart::USBUartChannel::output_pool_
protected

Definition at line 129 of file usb_uart.h.

◆ output_queue_

LockFreeQueue<UsbOutputChunk, USB_OUTPUT_CHUNK_COUNT> esphome::usb_uart::USBUartChannel::output_queue_
protected

Definition at line 128 of file usb_uart.h.

◆ output_started_

std::atomic<bool> esphome::usb_uart::USBUartChannel::output_started_ {true}
protected

Definition at line 136 of file usb_uart.h.

◆ parity_

UARTParityOptions esphome::usb_uart::USBUartChannel::parity_ {UART_CONFIG_PARITY_NONE}
protected

Definition at line 133 of file usb_uart.h.

◆ rx_callback_

std::function<void()> esphome::usb_uart::USBUartChannel::rx_callback_ {}
protected

Definition at line 130 of file usb_uart.h.

◆ USB_OUTPUT_CHUNK_COUNT

uint8_t esphome::usb_uart::USBUartChannel::USB_OUTPUT_CHUNK_COUNT = 8
staticconstexpr

Definition at line 106 of file usb_uart.h.


The documentation for this class was generated from the following files: