7#include "esp_intr_alloc.h"
8#include "esp_private/critical_section.h"
9#include "serialized_service.hpp"
10#include "soc/soc_caps.h"
13#if (SOC_USB_SERIAL_JTAG_SUPPORTED && \
14 ((defined(CONFIG_IDF_TARGET_ESP32C3) && CONFIG_IDF_TARGET_ESP32C3) || \
15 (defined(CONFIG_IDF_TARGET_ESP32C6) && CONFIG_IDF_TARGET_ESP32C6))) || \
44#if defined(CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG) && CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG
46 "ESP32CDCJtag conflicts with ESP-IDF primary USB Serial/JTAG console. "
47 "Set CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=n or disable this backend.");
75 explicit ESP32CDCJtag(
size_t rx_buffer_size = 1024,
size_t tx_buffer_size = 512,
76 uint32_t tx_queue_size = 5,
94 static constexpr uint32_t EVENT_WRITE = 1U << 0U;
95 static constexpr uint32_t EVENT_TX_EMPTY = 1U << 1U;
96 static constexpr uint32_t EVENT_RX_DATA = 1U << 2U;
97 static constexpr uint32_t EVENT_RX_SPACE = 1U << 3U;
100 static void IsrEntry(
void* arg);
105 void ServiceEvents(uint32_t events,
bool in_isr);
107 void ResumeRx(
bool in_isr);
117 void ProgressTx(
bool in_isr);
121 void ArmTxEmptyInterrupt();
123 void DisarmTxEmptyInterrupt();
127 void HandleInterrupt();
130 void EnableInterrupt(uint32_t mask);
132 void DisableInterrupt(uint32_t mask);
134 void ClearInterrupt(uint32_t mask);
136 void DisableAndClearInterrupt(uint32_t mask);
138 uint32_t CaptureInterrupt(uint32_t mask);
141 intr_handle_t intr_handle_ =
nullptr;
143 bool hw_inited_ =
false;
145 bool tx_empty_interrupt_armed_ =
false;
147 bool tx_flush_pending_ =
false;
150 DECLARE_CRIT_SECTION_LOCK_IN_STRUCT(irq_lock_)
直接使用硬件 FIFO 的 ESP USB Serial/JTAG 后端 / ESP USB Serial/JTAG backend using the hardware FIFO directly.
ESP32CDCJtag(size_t rx_buffer_size=1024, size_t tx_buffer_size=512, uint32_t tx_queue_size=5, UART::Configuration config={115200, UART::Parity::NO_PARITY, 8, 1})
构造并初始化 USB Serial/JTAG 后端 / Construct the USB Serial/JTAG backend.
static void WriteFun(WritePort &port, bool in_isr)
通知处理已提交写入 / Notify released writes.
ErrorCode SetConfig(UART::Configuration config, bool in_isr=false) override
检查虚拟串口帧格式 / Check virtual UART framing.
通知 CDC-JTAG 恢复接收的读端口 / Read port that resumes CDC-JTAG RX.
ESP32CDCJtagReadPort(size_t size, ESP32CDCJtag &owner)
构造接收端口并关联后端 / Construct the RX port associated with its backend.
void OnReadQueueSpaceAvailable(bool in_isr) override
发布接收空间通知 / Publish RX space availability.
接收队列的短期写入接口 / Short-lived producer interface for the RX queue.
基于 SPSC 字节队列的读端口 / Read endpoint backed by an SPSC byte queue.
事件合并与回调串行化服务 / Event-coalescing serialized-callback service.
通用异步收发传输(UART)基类 / Abstract base class for Universal Asynchronous Receiver-Transmitter (UART)
@ NO_PARITY
无校验 / No parity
已提交队头的出队接口 / Consumer interface for one released front.
基于 SPSC 字节队列的写端口 / Write endpoint backed by an SPSC byte queue.
LibXR 命名空间 / LibXR namespace.
ErrorCode
定义错误码枚举 / Defines an enumeration for error codes
UART 配置结构体 / UART configuration structure.