libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
cdc_base.hpp
1#pragma once
2#include <cstring>
3
4#include "dev_core.hpp"
5#include "uart.hpp"
6#include "usb/core/desc_cfg.hpp"
7
8namespace LibXR::USB
9{
10
22class CDCBase : public DeviceClass
23{
25 enum class DescriptorSubtype : uint8_t
26 {
27 HEADER = 0x00,
29 0x01,
30 ACM = 0x02,
31 UNION = 0x06,
32 };
33
35 enum class Class : uint8_t
36 {
37 COMM = 0x02,
38 DATA = 0x0A
39 };
40
42 enum class Protocol : uint8_t
43 {
44 NONE = 0x00,
45 AT_COMMAND = 0x01,
46 };
47
49 enum class Subclass : uint8_t
50 {
51 NONE = 0x00,
53 0x01,
55 0x02,
56 };
57
59 enum class ClassRequest : uint8_t
60 {
61 SET_LINE_CODING = 0x20,
62 GET_LINE_CODING = 0x21,
64 SEND_BREAK = 0x23
65 };
66
68 enum class CDCNotification : uint8_t
69 {
70 NETWORK_CONNECTION = 0x00,
71 RESPONSE_AVAILABLE = 0x01,
72 AUX_JACK_HOOK_STATE = 0x08,
73 RING_DETECT = 0x09,
74 SERIAL_STATE = 0x20,
76 };
77
78#pragma pack(push, 1)
87 {
88 uint32_t dwDTERate;
89 uint8_t bCharFormat;
90 uint8_t bParityType;
92 uint8_t bDataBits;
93 };
94
103 {
107 uint16_t wValue;
108 uint16_t wIndex;
109 uint16_t wLength;
110 uint16_t serialState;
111 };
112#pragma pack(pop)
113
114 // 确保CDCLineCoding结构体大小为7字节
115 static_assert(sizeof(CDCLineCoding) == 7, "LineCoding结构必须7字节");
116
117 // 控制线路状态位定义
118 static constexpr uint16_t CDC_CONTROL_LINE_DTR = 0x01;
119 static constexpr uint16_t CDC_CONTROL_LINE_RTS = 0x02;
120
121 public:
133 : data_in_ep_num_(data_in_ep_num),
134 data_out_ep_num_(data_out_ep_num),
135 comm_ep_num_(comm_ep_num)
136 {
137 }
138
146 bool IsDtrSet() const { return (control_line_state_ & CDC_CONTROL_LINE_DTR) != 0; }
147
155 bool IsRtsSet() const { return (control_line_state_ & CDC_CONTROL_LINE_RTS) != 0; }
156
164 ErrorCode SendSerialState()
165 {
167 {
168 return ErrorCode::BUSY;
169 }
170 auto buffer = ep_comm_in_->GetBuffer();
171 ASSERT(buffer.size_ >= sizeof(SerialStateNotification));
172 SerialStateNotification* notification =
173 reinterpret_cast<SerialStateNotification*>(buffer.addr_);
174 notification->wIndex = itf_comm_in_num_;
175
176 // 设置串行状态位
177 if (IsDtrSet())
178 {
179 // DTR有效时报告载波检测(DCD)和数据集就绪(DSR)
180 notification->serialState = 0x03; // DCD / DSR
181 }
182 else
183 {
184 notification->serialState = 0x00; // 无状态
185 }
186
187 // 填充固定字段
188 notification->bmRequestType = 0xA1; // 设备到主机,类,接口
189 notification->bNotification = static_cast<uint8_t>(CDCNotification::SERIAL_STATE);
190 notification->wValue = 0;
191 notification->wLength = 2;
192
194
195 return ErrorCode::OK;
196 }
197
206
215
216 protected:
227 virtual void Init(EndpointPool& endpoint_pool, uint8_t start_itf_num) override
228 {
230 // 获取并配置数据IN端点
231 auto ans = endpoint_pool.Get(ep_data_in_, Endpoint::Direction::IN, data_in_ep_num_);
232 ASSERT(ans == ErrorCode::OK);
233
234 // 获取并配置数据OUT端点
236 ASSERT(ans == ErrorCode::OK);
237
238 // 获取并配置通信端点
240 ASSERT(ans == ErrorCode::OK);
241
242 // 配置端点参数
244 {Endpoint::Direction::IN, Endpoint::Type::BULK, UINT16_MAX, true});
248
249 // === 填充CDC描述符块 ===
250 static constexpr uint8_t COMM_INTERFACE = 0; // 通信接口号
251 static constexpr uint8_t DATA_INTERFACE = 1; // 数据接口号
252
253 // IAD描述符(关联接口)
254 desc_block_.iad = {8,
255 static_cast<uint8_t>(DescriptorType::IAD),
256 static_cast<uint8_t>(COMM_INTERFACE + start_itf_num),
257 2,
258 static_cast<uint8_t>(Class::COMM),
259 static_cast<uint8_t>(Subclass::ABSTRACT_CONTROL_MODEL),
260 static_cast<uint8_t>(Protocol::NONE),
261 0};
262
263 // 通信接口描述符
264 desc_block_.comm_intf = {9,
265 static_cast<uint8_t>(DescriptorType::INTERFACE),
266 static_cast<uint8_t>(COMM_INTERFACE + start_itf_num),
267 0,
268 1,
269 static_cast<uint8_t>(Class::COMM),
270 static_cast<uint8_t>(Subclass::ABSTRACT_CONTROL_MODEL),
271 static_cast<uint8_t>(Protocol::NONE),
272 0};
273
274 // CDC头功能描述符
275 desc_block_.cdc_header = {5, DescriptorType::CS_INTERFACE, DescriptorSubtype::HEADER,
276 0x0110}; // CDC规范版本1.10
277
278 // 呼叫管理功能描述符
279 desc_block_.cdc_callmgmt = {
280 5, DescriptorType::CS_INTERFACE, DescriptorSubtype::CALL_MANAGEMENT,
281 0x00, // 无呼叫管理能力
282 static_cast<uint8_t>(DATA_INTERFACE + start_itf_num)}; // 数据接口号
283
284 // ACM功能描述符
285 desc_block_.cdc_acm = {4, DescriptorType::CS_INTERFACE, DescriptorSubtype::ACM,
286 0x02}; // 支持SetLineCoding/GetLineCoding/SetControlLineState
287
288 // 联合功能描述符
289 desc_block_.cdc_union = {5, DescriptorType::CS_INTERFACE, DescriptorSubtype::UNION,
290 static_cast<uint8_t>(COMM_INTERFACE + start_itf_num),
291 static_cast<uint8_t>(DATA_INTERFACE + start_itf_num)};
292
293 // 数据接口描述符
294 desc_block_.data_intf = {9,
295 static_cast<uint8_t>(DescriptorType::INTERFACE),
296 static_cast<uint8_t>(DATA_INTERFACE + start_itf_num),
297 0,
298 2,
299 static_cast<uint8_t>(Class::DATA),
300 0x00, // 无子类
301 0x00, // 无协议
302 0};
303
304 // 数据OUT端点描述符
305 desc_block_.data_ep_out = {7,
306 static_cast<uint8_t>(DescriptorType::ENDPOINT),
308 static_cast<uint8_t>(Endpoint::Type::BULK),
310 0}; // 轮询间隔0(BULK忽略)
311
312 // 数据IN端点描述符
313 desc_block_.data_ep_in = {7,
314 static_cast<uint8_t>(DescriptorType::ENDPOINT),
315 static_cast<uint8_t>(ep_data_in_->GetAddress()),
316 static_cast<uint8_t>(Endpoint::Type::BULK),
318 0}; // 轮询间隔0(BULK忽略)
319
320 // 通信端点描述符
321 desc_block_.comm_ep = {
322 7,
323 static_cast<uint8_t>(DescriptorType::ENDPOINT),
324 static_cast<uint8_t>(ep_comm_in_->GetAddress()), // IN端点地址
325 static_cast<uint8_t>(Endpoint::Type::INTERRUPT),
326 16, // 16字节最大包大小
327 0x04 // 轮询间隔FS-4ms HS-1ms
328 };
329
330 itf_comm_in_num_ = start_itf_num;
331
332 // 设置描述符原始数据
333 SetData(RawData{reinterpret_cast<uint8_t*>(&desc_block_), sizeof(desc_block_)});
334
335 // 设置端点传输完成回调
336 ep_data_out_->SetOnTransferCompleteCallback(on_data_out_complete_cb_);
337 ep_data_in_->SetOnTransferCompleteCallback(on_data_in_complete_cb_);
338
339 inited_ = true;
340
341 // 启动OUT端点传输
343 }
344
352 virtual void Deinit(EndpointPool& endpoint_pool) override
353 {
354 inited_ = false;
359 ep_data_in_->SetActiveLength(0);
360 ep_data_out_->SetActiveLength(0);
361 ep_comm_in_->SetActiveLength(0);
362 endpoint_pool.Release(ep_data_in_);
363 endpoint_pool.Release(ep_data_out_);
364 endpoint_pool.Release(ep_comm_in_);
365 ep_data_in_ = nullptr;
366 ep_data_out_ = nullptr;
367 ep_comm_in_ = nullptr;
368 }
369
374 static void OnDataOutCompleteStatic(bool in_isr, CDCBase* self, ConstRawData& data)
375 {
376 if (!self->inited_)
377 {
378 return;
379 }
380 self->OnDataOutComplete(in_isr, data);
381 }
382
387 static void OnDataInCompleteStatic(bool in_isr, CDCBase* self, ConstRawData& data)
388 {
389 if (!self->inited_)
390 {
391 return;
392 }
393 self->OnDataInComplete(in_isr, data);
394 }
395
403 virtual void OnDataOutComplete(bool in_isr, ConstRawData& data) = 0;
404
412 virtual void OnDataInComplete(bool in_isr, ConstRawData& data) = 0;
413
420 size_t GetInterfaceNum() override { return 2; }
421
429 bool HasIAD() override { return true; }
430
437 size_t GetMaxConfigSize() override { return sizeof(desc_block_); }
438
446 ErrorCode OnClassRequest(bool in_isr, uint8_t bRequest, uint16_t wValue,
447 uint16_t wLength, DeviceClass::RequestResult& result) override
448 {
449 UNUSED(in_isr);
450 switch (static_cast<ClassRequest>(bRequest))
451 {
453 // 主机将在数据阶段发送7字节参数
454 if (wLength != sizeof(line_coding_))
455 {
456 return ErrorCode::ARG_ERR;
457 }
458 result.read_data =
459 RawData{reinterpret_cast<uint8_t*>(&line_coding_), sizeof(line_coding_)};
460 return ErrorCode::OK;
461
463 // 返回当前线路编码设置
464 if (wLength != sizeof(line_coding_))
465 {
466 return ErrorCode::ARG_ERR;
467 }
468
469 result.write_data = ConstRawData{reinterpret_cast<const uint8_t*>(&line_coding_),
470 sizeof(line_coding_)};
471 return ErrorCode::OK;
472
474 // 设置DTR/RTS状态
475 control_line_state_ = wValue;
476 result.write_zlp = true;
479 return ErrorCode::OK;
480
482 // BREAK信号通常忽略
483 return ErrorCode::OK;
484
485 default:
486 return ErrorCode::NOT_SUPPORT;
487 }
488 }
489
494 ErrorCode OnClassData(bool in_isr, uint8_t bRequest, LibXR::ConstRawData& data) override
495 {
496 UNUSED(in_isr);
497 UNUSED(data);
498
499 switch (static_cast<ClassRequest>(bRequest))
500 {
502 {
503 // 将CDC线路编码转换为UART配置
507 {
508 case 0:
509 cfg.stop_bits = 1;
510 break;
511 //TODO: 1.5
512 case 2:
513 cfg.stop_bits = 2;
514 break;
515 default:
516 cfg.stop_bits = 1;
517 }
519 {
520 case 1:
522 break;
523 case 2:
525 break;
526 default:
528 }
530 on_set_line_coding_cb_.Run(in_isr, cfg);
531 }
532 return ErrorCode::OK;
533 default:
534 return ErrorCode::NOT_SUPPORT;
535 }
536 }
537
538#pragma pack(push, 1)
547 {
551
552 // CDC类特定描述符
553 struct
554 {
555 uint8_t bFunctionLength = 5;
556 DescriptorType bDescriptorType = DescriptorType::CS_INTERFACE;
557 DescriptorSubtype bDescriptorSubtype = DescriptorSubtype::HEADER;
558 uint16_t bcdCDC = 0x0110;
559 } cdc_header;
560
561 struct
562 {
563 uint8_t bFunctionLength = 5;
564 DescriptorType bDescriptorType = DescriptorType::CS_INTERFACE;
566 uint8_t bmCapabilities = 0x00;
568 } cdc_callmgmt;
569
570 struct
571 {
572 uint8_t bFunctionLength = 4;
573 DescriptorType bDescriptorType = DescriptorType::CS_INTERFACE;
574 DescriptorSubtype bDescriptorSubtype = DescriptorSubtype::ACM;
575 uint8_t bmCapabilities = 0x02;
576 } cdc_acm;
577
578 struct
579 {
580 uint8_t bFunctionLength = 5;
581 DescriptorType bDescriptorType = DescriptorType::CS_INTERFACE;
582 DescriptorSubtype bDescriptorSubtype = DescriptorSubtype::UNION;
585 } cdc_union;
586
588
590
593 } desc_block_;
594#pragma pack(pop)
595
596 protected:
597 CDCLineCoding& GetLineCoding() { return line_coding_; }
598
599 bool Inited() { return inited_; }
600
601 Endpoint* GetDataInEndpoint() { return ep_data_in_; }
602
603 Endpoint* GetDataOutEndpoint() { return ep_data_out_; }
604
605 Endpoint* GetCommInEndpoint() { return ep_comm_in_; }
606
607 private:
608 // 端点号
612
613 // 端点指针
617
618 // 端点回调
619 LibXR::Callback<LibXR::ConstRawData&> on_data_out_complete_cb_ =
621
622 LibXR::Callback<LibXR::ConstRawData&> on_data_in_complete_cb_ =
624
625 // 用户回调
631
632 // 状态标志
633 bool inited_ = false;
634
635 // 接口信息
637
638 // CDC参数
639 CDCLineCoding line_coding_ = {115200, 0, 0, 8};
640 uint16_t control_line_state_ = 0;
641};
642
643} // namespace LibXR::USB
提供一个通用的回调包装,支持动态参数传递。 Provides a generic callback wrapper, supporting dynamic argument passing.
Definition libxr_cb.hpp:124
void Run(bool in_isr, PassArgs &&...args) const
执行回调函数,并传递参数。 Executes the callback function, passing the arguments.
Definition libxr_cb.hpp:207
static Callback Create(FunType fun, ArgType arg)
创建一个新的回调对象,并绑定回调函数和参数。 Creates a new callback instance, binding a function and an argument.
Definition libxr_cb.hpp:142
常量原始数据封装类。 A class for encapsulating constant raw data.
原始数据封装类。 A class for encapsulating raw data.
@ NO_PARITY
无校验 / No parity
@ ODD
奇校验 / Odd parity
@ EVEN
偶校验 / Even parity
USB CDC ACM (Abstract Control Model) 设备类实现 USB CDC ACM (Abstract Control Model) device class implemen...
Definition cdc_base.hpp:23
void SetOnSetControlLineStateCallback(LibXR::Callback< bool, bool > cb)
设置控制线路状态变更回调 Set control line state change callback
Definition cdc_base.hpp:202
LibXR::Callback< bool, bool > on_set_control_line_state_cb_
Definition cdc_base.hpp:627
Protocol
CDC协议代码 / CDC protocol codes.
Definition cdc_base.hpp:43
@ AT_COMMAND
AT命令协议 / AT Command protocol.
@ NONE
无协议 / No protocol
size_t GetMaxConfigSize() override
获取最大配置描述符大小 Get maximum configuration descriptor size
Definition cdc_base.hpp:437
size_t GetInterfaceNum() override
获取接口数量 Get number of interfaces
Definition cdc_base.hpp:420
Endpoint::EPNumber data_in_ep_num_
数据IN端点号 / Data IN endpoint number
Definition cdc_base.hpp:609
uint8_t itf_comm_in_num_
通信接口号 / Communication interface number
Definition cdc_base.hpp:636
CDCNotification
CDC通知类型 / CDC notification types.
Definition cdc_base.hpp:69
@ RESPONSE_AVAILABLE
响应可用通知 / Response available
@ NETWORK_CONNECTION
网络连接通知 / Network connection
@ AUX_JACK_HOOK_STATE
辅助插槽状态通知 / Aux jack hook state
@ RING_DETECT
响铃检测通知 / Ring detect
ErrorCode OnClassRequest(bool in_isr, uint8_t bRequest, uint16_t wValue, uint16_t wLength, DeviceClass::RequestResult &result) override
处理类特定请求 Handle class-specific requests
Definition cdc_base.hpp:446
void SetOnSetLineCodingCallback(LibXR::Callback< LibXR::UART::Configuration > cb)
设置线路编码变更回调 Set line coding change callback
Definition cdc_base.hpp:211
Endpoint::EPNumber comm_ep_num_
通信端点号 / Communication endpoint number
Definition cdc_base.hpp:611
Class
USB设备类代码 / USB device class codes.
Definition cdc_base.hpp:36
@ COMM
通信设备类 / Communications device class
@ DATA
数据接口类 / Data interface class
virtual void OnDataInComplete(bool in_isr, ConstRawData &data)=0
数据IN端点传输完成处理 Handle data IN endpoint transfer completion
Subclass
CDC子类代码 / CDC subclass codes.
Definition cdc_base.hpp:50
@ DIRECT_LINE_CONTROL_MODEL
直接控制模型(CDC-DCM)| Direct Control Model (CDC-DCM)
@ ABSTRACT_CONTROL_MODEL
抽象控制模型(CDC-ACM)| Abstract Control Model (CDC-ACM)
Endpoint * ep_comm_in_
通信IN端点 / Communication IN endpoint
Definition cdc_base.hpp:616
bool inited_
初始化标志 / Initialization flag
Definition cdc_base.hpp:633
Endpoint * ep_data_in_
数据IN端点 / Data IN endpoint
Definition cdc_base.hpp:614
static void OnDataOutCompleteStatic(bool in_isr, CDCBase *self, ConstRawData &data)
数据OUT端点传输完成静态回调 Static callback for data OUT endpoint transfer completion
Definition cdc_base.hpp:374
static constexpr uint16_t CDC_CONTROL_LINE_DTR
DTR控制位 / DTR control bit.
Definition cdc_base.hpp:118
ClassRequest
CDC类特定请求 / CDC class-specific requests.
Definition cdc_base.hpp:60
@ SEND_BREAK
发送BREAK信号 / Send BREAK signal
@ GET_LINE_CODING
获取当前线路编码 / Get current line coding
@ SET_CONTROL_LINE_STATE
设置控制线路状态 / Set control line state
@ SET_LINE_CODING
设置串行线路编码 / Set line coding parameters
virtual void Deinit(EndpointPool &endpoint_pool) override
反初始化CDC设备 Deinitialize CDC device
Definition cdc_base.hpp:352
DescriptorSubtype
CDC功能描述符子类型定义 / CDC functional descriptor subtypes.
Definition cdc_base.hpp:26
@ ACM
抽象控制模型描述符 / Abstract control model descriptor
@ CALL_MANAGEMENT
呼叫管理功能描述符 / Call management functional descriptor
@ HEADER
头功能描述符 / Header functional descriptor
@ UNION
联合功能描述符 / Union functional descriptor
LibXR::Callback< LibXR::UART::Configuration > on_set_line_coding_cb_
线路编码变更回调 / Line coding change callback
Definition cdc_base.hpp:630
bool IsRtsSet() const
检查RTS状态 Check RTS state
Definition cdc_base.hpp:155
CDCBase(Endpoint::EPNumber data_in_ep_num=Endpoint::EPNumber::EP_AUTO, Endpoint::EPNumber data_out_ep_num=Endpoint::EPNumber::EP_AUTO, Endpoint::EPNumber comm_ep_num=Endpoint::EPNumber::EP_AUTO)
CDC构造函数 CDC constructor.
Definition cdc_base.hpp:130
Endpoint::EPNumber data_out_ep_num_
数据OUT端点号 / Data OUT endpoint number
Definition cdc_base.hpp:610
uint16_t control_line_state_
控制线路状态 / Control line state
Definition cdc_base.hpp:640
virtual void OnDataOutComplete(bool in_isr, ConstRawData &data)=0
数据OUT端点传输完成处理 Handle data OUT endpoint transfer completion
bool HasIAD() override
检查是否包含IAD Check if IAD is present
Definition cdc_base.hpp:429
static void OnDataInCompleteStatic(bool in_isr, CDCBase *self, ConstRawData &data)
数据IN端点传输完成静态回调 Static callback for data IN endpoint transfer completion
Definition cdc_base.hpp:387
CDCLineCoding line_coding_
当前线路编码 / Current line coding
Definition cdc_base.hpp:639
virtual void Init(EndpointPool &endpoint_pool, uint8_t start_itf_num) override
初始化CDC设备 Initialize CDC device
Definition cdc_base.hpp:227
ErrorCode OnClassData(bool in_isr, uint8_t bRequest, LibXR::ConstRawData &data) override
处理类请求数据阶段 Handle class request data stage
Definition cdc_base.hpp:494
Endpoint * ep_data_out_
数据OUT端点 / Data OUT endpoint
Definition cdc_base.hpp:615
ErrorCode SendSerialState()
发送串行状态通知 Send serial state notification
Definition cdc_base.hpp:164
static constexpr uint16_t CDC_CONTROL_LINE_RTS
RTS控制位 / RTS control bit.
Definition cdc_base.hpp:119
bool IsDtrSet() const
检查DTR状态 Check DTR state
Definition cdc_base.hpp:146
void SetData(RawData data)
设置配置项数据 Set configuration item data
Definition desc_cfg.hpp:197
USB 设备类接口基类,所有自定义 USB 类(如 HID、CDC、MSC)都需派生自本类。 USB device class base interface, all custom device cla...
Definition dev_core.hpp:22
USB端点基类 / USB Endpoint base class.
Definition ep.hpp:22
EPNumber
端点号 / Endpoint number
Definition ep.hpp:39
@ EP_AUTO
自动分配端点号 / Auto allocate
uint8_t GetAddress() const
获取端点地址(方向 + 号) Get endpoint address (dir + num)
Definition ep.hpp:199
@ IN
输入方向 / IN direction
@ OUT
输出方向 / OUT direction
virtual size_t MaxTransferSize() const
返回最大可传输字节数 Return the maximum transferable size at this time
Definition ep.hpp:289
void SetOnTransferCompleteCallback(Callback< ConstRawData & > cb)
设置传输完成回调 / Set transfer complete callback
Definition ep.hpp:273
virtual void Configure(const Config &cfg)=0
二次初始化/配置端点协议参数(由Pool/Manager分配后调用) Configure endpoint protocol parameters (call after pool allocation...
@ BULK
批量端点 / Bulk
@ INTERRUPT
中断端点 / Interrupt
virtual void Close()=0
关闭端点(软禁用/资源复位) Close (soft disable)
uint16_t MaxPacketSize() const
获取最大包长 Get max packet size
Definition ep.hpp:232
State GetState() const
获取端点状态 Get endpoint state
Definition ep.hpp:212
virtual ErrorCode Transfer(size_t size)=0
传输数据 Transfer data
RawData GetBuffer() const
获取端点缓冲区 Get endpoint buffer
Definition ep.hpp:256
USB端点池类 / USB endpoint pool class.
Definition ep_pool.hpp:23
ErrorCode Get(Endpoint *&ep_info, Endpoint::Direction direction, Endpoint::EPNumber ep_num=Endpoint::EPNumber::EP_AUTO)
分配端点 / Allocate endpoint
Definition ep_pool.cpp:11
ErrorCode Release(Endpoint *ep_info)
回收端点 / Release endpoint
Definition ep_pool.cpp:37
UART 配置结构体 / UART configuration structure.
Definition uart.hpp:44
uint8_t stop_bits
停止位长度 / Number of stop bits
Definition uart.hpp:50
Parity parity
校验模式 / Parity mode
Definition uart.hpp:47
uint8_t data_bits
数据位长度 / Number of data bits
Definition uart.hpp:48
uint32_t baudrate
波特率 / Baud rate
Definition uart.hpp:45
CDC描述符块结构 CDC descriptor block structure.
Definition cdc_base.hpp:547
InterfaceDescriptor data_intf
数据接口描述符 / Data interface descriptor
Definition cdc_base.hpp:589
uint8_t bSlaveInterface0
从接口号 / Slave interface number
Definition cdc_base.hpp:584
EndpointDescriptor data_ep_out
数据OUT端点描述符 / Data OUT endpoint descriptor
Definition cdc_base.hpp:591
uint16_t bcdCDC
CDC规范版本 / CDC specification version.
Definition cdc_base.hpp:558
uint8_t bmCapabilities
呼叫管理能力 / Call management capabilities
Definition cdc_base.hpp:566
InterfaceDescriptor comm_intf
通信接口描述符 / Communication interface descriptor
Definition cdc_base.hpp:550
uint8_t bDataInterface
数据接口号 / Data interface number
Definition cdc_base.hpp:567
EndpointDescriptor comm_ep
通信端点描述符 / Communication endpoint descriptor
Definition cdc_base.hpp:587
uint8_t bMasterInterface
主接口号 / Master interface number
Definition cdc_base.hpp:583
EndpointDescriptor data_ep_in
数据IN端点描述符 / Data IN endpoint descriptor
Definition cdc_base.hpp:592
IADDescriptor iad
接口关联描述符 / Interface association descriptor
Definition cdc_base.hpp:548
CDC线路编码参数结构体 CDC line coding parameters structure.
Definition cdc_base.hpp:87
uint32_t dwDTERate
波特率(小端格式)| Baud rate (little-endian)
Definition cdc_base.hpp:88
uint8_t bCharFormat
停止位:0=1位,1=1.5位,2=2位 / Stop bits: 0=1, 1=1.5, 2=2
Definition cdc_base.hpp:89
uint8_t bDataBits
数据位:5,6,7,8或16 / Data bits: 5,6,7,8 or 16
Definition cdc_base.hpp:92
串行状态通知结构体 Serial state notification structure
Definition cdc_base.hpp:103
uint16_t wLength
数据长度(固定为2)| Data length (fixed to 2)
Definition cdc_base.hpp:109
uint16_t wIndex
接口号 / Interface number
Definition cdc_base.hpp:108
uint16_t serialState
串行状态位图 / Serial state bitmap
Definition cdc_base.hpp:110
uint8_t bmRequestType
请求类型(固定为0xA1)| Request type (fixed to 0xA1)
Definition cdc_base.hpp:104
uint16_t wValue
值(固定为0)| Value (fixed to 0)
Definition cdc_base.hpp:107
端点描述符结构体 Endpoint descriptor structure (USB 2.0 Spec 9.6.6)
Definition desc_cfg.hpp:91
接口关联描述符(IAD,Interface Association Descriptor) IAD descriptor structure (用于复合设备多接口归组 / used for groupi...
Definition desc_cfg.hpp:57
接口描述符结构体 Interface descriptor structure (USB 2.0 Spec 9.6.5)
Definition desc_cfg.hpp:73
控制请求结果结构体 / Structure for control transfer results
Definition dev_core.hpp:28
RawData read_data
设备返回给主机的数据 / Data to read (to host)
Definition dev_core.hpp:29
bool write_zlp
写操作是否需要发送 0 长度包 / Send ZLP after write
Definition dev_core.hpp:33
ConstRawData write_data
主机写入设备的数据 / Data to write (from host)
Definition dev_core.hpp:30