3#include "driver/uart.h"
4#include "freertos/queue.h"
5#include "freertos/semphr.h"
6#include "libxr_def.hpp"
27 void Reset() { read_size_ = 0; }
29 using ReadPort::operator=;
40 :
WritePort(queue_size, buffer_size), uart_(uart)
48 void Reset() { write_size_ = 0; }
50 using WritePort::operator=;
59 ESP32UART(uart_port_t port,
int tx_pin,
int rx_pin, uint32_t buffer_size = 256,
60 uint32_t rx_thread_stack_depth = 1024, uint32_t rx_thread_priority = 10);
71 static void RxTask(
void *param);
72 static void TxTask(
void *param);
73 void HandleEvent(
const uart_event_t &event);
76 QueueHandle_t event_queue_;
ErrorCode SetConfig(UART::Configuration config) override
设置 UART 配置 / Sets the UART configuration
size_t Size()
获取当前队列的已使用大小。 Gets the currently used size of the queue.
size_t EmptySize()
获取队列的剩余可用空间。 Gets the remaining available space in the queue.
void Reset()
Resets the ReadPort.
void ProcessPendingReads(bool in_isr=true)
Processes pending reads.
void Reset()
Resets the WritePort.
size_t Size()
获取当前数据队列的已使用大小。 Gets the used size of the current data queue.
size_t EmptySize()
获取数据队列的剩余可用空间。 Gets the remaining available space in the data queue.
原始数据封装类。 A class for encapsulating raw data.
ReadPort class for handling read operations.
ReadPort(size_t buffer_size=128)
Constructs a ReadPort with queue sizes.
通用异步收发传输(UART)基类 / Abstract base class for Universal Asynchronous Receiver-Transmitter (UART)
WritePort class for handling write operations.
WritePort(size_t queue_size=3, size_t buffer_size=128)
构造一个新的 WritePort 对象。 Constructs a new WritePort object.
ErrorCode(* ReadFun)(ReadPort &port)
Function pointer type for read operations.
ErrorCode(* WriteFun)(WritePort &port)
Function pointer type for write operations.
UART 配置结构体 / UART configuration structure.