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 "libxr_def.hpp"
6#include "uart.hpp"
7#include "usb/core/desc_cfg.hpp"
8
9namespace LibXR::USB
10{
11
23class CDCBase : public DeviceClass
24{
26 enum class DescriptorSubtype : uint8_t
27 {
28 HEADER = 0x00,
30 0x01,
31 ACM = 0x02,
32 UNION = 0x06,
33 };
34
36 enum class Class : uint8_t
37 {
38 COMM = 0x02,
39 DATA = 0x0A
40 };
41
43 enum class Protocol : uint8_t
44 {
45 NONE = 0x00,
46 AT_COMMAND = 0x01,
47 };
48
50 enum class Subclass : uint8_t
51 {
52 NONE = 0x00,
54 0x01,
56 0x02,
57 };
58
60 enum class ClassRequest : uint8_t
61 {
62 SET_LINE_CODING = 0x20,
63 GET_LINE_CODING = 0x21,
65 SEND_BREAK = 0x23
66 };
67
69 enum class CDCNotification : uint8_t
70 {
71 NETWORK_CONNECTION = 0x00,
72 RESPONSE_AVAILABLE = 0x01,
73 AUX_JACK_HOOK_STATE = 0x08,
74 RING_DETECT = 0x09,
75 SERIAL_STATE = 0x20,
77 };
78
79#pragma pack(push, 1)
88 {
89 uint32_t dwDTERate;
90 uint8_t bCharFormat;
91 uint8_t bParityType;
93 uint8_t bDataBits;
94 };
95
104 {
108 uint16_t wValue;
109 uint16_t wIndex;
110 uint16_t wLength;
111 uint16_t serialState;
112 };
113#pragma pack(pop)
114
115 // 确保CDCLineCoding结构体大小为7字节
116 static_assert(sizeof(CDCLineCoding) == 7, "LineCoding结构必须7字节");
117
118 // 控制线路状态位定义
119 static constexpr uint16_t CDC_CONTROL_LINE_DTR = 0x01;
120 static constexpr uint16_t CDC_CONTROL_LINE_RTS = 0x02;
121
122 public:
134 : data_in_ep_num_(data_in_ep_num),
135 data_out_ep_num_(data_out_ep_num),
136 comm_ep_num_(comm_ep_num)
137 {
138 }
139
147 bool IsDtrSet() const { return (control_line_state_ & CDC_CONTROL_LINE_DTR) != 0; }
148
156 bool IsRtsSet() const { return (control_line_state_ & CDC_CONTROL_LINE_RTS) != 0; }
157
165 ErrorCode SendSerialState()
166 {
168 {
169 return ErrorCode::BUSY;
170 }
171 auto buffer = ep_comm_in_->GetBuffer();
172 ASSERT(buffer.size_ >= sizeof(SerialStateNotification));
173 SerialStateNotification* notification =
174 reinterpret_cast<SerialStateNotification*>(buffer.addr_);
175 notification->wIndex = itf_comm_in_num_;
176
177 // 设置串行状态位
178 if (IsDtrSet())
179 {
180 // DTR有效时报告载波检测(DCD)和数据集就绪(DSR)
181 notification->serialState = 0x03; // DCD / DSR
182 }
183 else
184 {
185 notification->serialState = 0x00; // 无状态
186 }
187
188 // 填充固定字段
189 notification->bmRequestType = 0xA1; // 设备到主机,类,接口
190 notification->bNotification = static_cast<uint8_t>(CDCNotification::SERIAL_STATE);
191 notification->wValue = 0;
192 notification->wLength = 2;
193
195
196 return ErrorCode::OK;
197 }
198
207
216
217 protected:
229 virtual void BindEndpoints(EndpointPool& endpoint_pool, uint8_t start_itf_num,
230 bool) override
231 {
233 // 获取并配置数据IN端点
234 auto ans = endpoint_pool.Get(ep_data_in_, Endpoint::Direction::IN, data_in_ep_num_);
235 ASSERT(ans == ErrorCode::OK);
236
237 // 获取并配置数据OUT端点
239 ASSERT(ans == ErrorCode::OK);
240
241 // 获取并配置通信端点
243 ASSERT(ans == ErrorCode::OK);
244
245 // 配置端点参数
247 {Endpoint::Direction::IN, Endpoint::Type::BULK, UINT16_MAX, true});
251
252 // === 填充CDC描述符块 ===
253 static constexpr uint8_t COMM_INTERFACE = 0; // 通信接口号
254 static constexpr uint8_t DATA_INTERFACE = 1; // 数据接口号
255
256 // IAD描述符(关联接口)
257 desc_block_.iad = {8,
258 static_cast<uint8_t>(DescriptorType::IAD),
259 static_cast<uint8_t>(COMM_INTERFACE + start_itf_num),
260 2,
261 static_cast<uint8_t>(Class::COMM),
262 static_cast<uint8_t>(Subclass::ABSTRACT_CONTROL_MODEL),
263 static_cast<uint8_t>(Protocol::NONE),
264 0};
265
266 // 通信接口描述符
267 desc_block_.comm_intf = {9,
268 static_cast<uint8_t>(DescriptorType::INTERFACE),
269 static_cast<uint8_t>(COMM_INTERFACE + start_itf_num),
270 0,
271 1,
272 static_cast<uint8_t>(Class::COMM),
273 static_cast<uint8_t>(Subclass::ABSTRACT_CONTROL_MODEL),
274 static_cast<uint8_t>(Protocol::NONE),
275 0};
276
277 // CDC头功能描述符
278 desc_block_.cdc_header = {5, DescriptorType::CS_INTERFACE, DescriptorSubtype::HEADER,
279 0x0110}; // CDC规范版本1.10
280
281 // 呼叫管理功能描述符
282 desc_block_.cdc_callmgmt = {
283 5, DescriptorType::CS_INTERFACE, DescriptorSubtype::CALL_MANAGEMENT,
284 0x00, // 无呼叫管理能力
285 static_cast<uint8_t>(DATA_INTERFACE + start_itf_num)}; // 数据接口号
286
287 // ACM功能描述符
288 desc_block_.cdc_acm = {4, DescriptorType::CS_INTERFACE, DescriptorSubtype::ACM,
289 0x02}; // 支持SetLineCoding/GetLineCoding/SetControlLineState
290
291 // 联合功能描述符
292 desc_block_.cdc_union = {5, DescriptorType::CS_INTERFACE, DescriptorSubtype::UNION,
293 static_cast<uint8_t>(COMM_INTERFACE + start_itf_num),
294 static_cast<uint8_t>(DATA_INTERFACE + start_itf_num)};
295
296 // 数据接口描述符
297 desc_block_.data_intf = {9,
298 static_cast<uint8_t>(DescriptorType::INTERFACE),
299 static_cast<uint8_t>(DATA_INTERFACE + start_itf_num),
300 0,
301 2,
302 static_cast<uint8_t>(Class::DATA),
303 0x00, // 无子类
304 0x00, // 无协议
305 0};
306
307 // 数据OUT端点描述符
308 desc_block_.data_ep_out = {7,
309 static_cast<uint8_t>(DescriptorType::ENDPOINT),
311 static_cast<uint8_t>(Endpoint::Type::BULK),
313 0}; // 轮询间隔0(BULK忽略)
314
315 // 数据IN端点描述符
316 desc_block_.data_ep_in = {7,
317 static_cast<uint8_t>(DescriptorType::ENDPOINT),
318 static_cast<uint8_t>(ep_data_in_->GetAddress()),
319 static_cast<uint8_t>(Endpoint::Type::BULK),
321 0}; // 轮询间隔0(BULK忽略)
322
323 // 通信端点描述符
324 desc_block_.comm_ep = {
325 7,
326 static_cast<uint8_t>(DescriptorType::ENDPOINT),
327 static_cast<uint8_t>(ep_comm_in_->GetAddress()), // IN端点地址
328 static_cast<uint8_t>(Endpoint::Type::INTERRUPT),
329 16, // 16字节最大包大小
330 0x04 // 轮询间隔FS-4ms HS-1ms
331 };
332
333 itf_comm_in_num_ = start_itf_num;
334
335 // 设置描述符原始数据
336 SetData(RawData{reinterpret_cast<uint8_t*>(&desc_block_), sizeof(desc_block_)});
337
338 // 设置端点传输完成回调
339 ep_data_out_->SetOnTransferCompleteCallback(on_data_out_complete_cb_);
340 ep_data_in_->SetOnTransferCompleteCallback(on_data_in_complete_cb_);
341
342 inited_ = true;
343
344 // 启动OUT端点传输
346 }
347
355 virtual void UnbindEndpoints(EndpointPool& endpoint_pool, bool) override
356 {
357 inited_ = false;
365 endpoint_pool.Release(ep_data_in_);
366 endpoint_pool.Release(ep_data_out_);
367 endpoint_pool.Release(ep_comm_in_);
368 ep_data_in_ = nullptr;
369 ep_data_out_ = nullptr;
370 ep_comm_in_ = nullptr;
371 }
372
377 static void OnDataOutCompleteStatic(bool in_isr, CDCBase* self, ConstRawData& data)
378 {
379 if (!self->inited_)
380 {
381 return;
382 }
383 self->OnDataOutComplete(in_isr, data);
384 }
385
390 static void OnDataInCompleteStatic(bool in_isr, CDCBase* self, ConstRawData& data)
391 {
392 if (!self->inited_)
393 {
394 return;
395 }
396 self->OnDataInComplete(in_isr, data);
397 }
398
406 virtual void OnDataOutComplete(bool in_isr, ConstRawData& data) = 0;
407
415 virtual void OnDataInComplete(bool in_isr, ConstRawData& data) = 0;
416
423 size_t GetInterfaceCount() override { return 2; }
424
432 bool HasIAD() override { return true; }
433
434 bool OwnsEndpoint(uint8_t ep_addr) const override
435 {
436 if (!inited_)
437 {
438 return false;
439 }
440
441 return ep_data_in_->GetAddress() == ep_addr ||
442 ep_data_out_->GetAddress() == ep_addr || ep_comm_in_->GetAddress() == ep_addr;
443 }
444
451 size_t GetMaxConfigSize() override { return sizeof(desc_block_); }
452
460 ErrorCode OnClassRequest(bool in_isr, uint8_t bRequest, uint16_t wValue,
461 uint16_t wLength, uint16_t wIndex,
462 DeviceClass::ControlTransferResult& result) override
463 {
464 UNUSED(in_isr);
465 UNUSED(wIndex);
466
467 switch (static_cast<ClassRequest>(bRequest))
468 {
470 // 主机将在数据阶段发送7字节参数
471 if (wLength != sizeof(line_coding_))
472 {
473 return ErrorCode::ARG_ERR;
474 }
475 result.read_data =
476 RawData{reinterpret_cast<uint8_t*>(&line_coding_), sizeof(line_coding_)};
477 return ErrorCode::OK;
478
480 // 返回当前线路编码设置
481 if (wLength != sizeof(line_coding_))
482 {
483 return ErrorCode::ARG_ERR;
484 }
485
486 result.write_data = ConstRawData{reinterpret_cast<const uint8_t*>(&line_coding_),
487 sizeof(line_coding_)};
488 return ErrorCode::OK;
489
491 // 设置DTR/RTS状态
492 control_line_state_ = wValue;
493 result.write_zlp = true;
496 return ErrorCode::OK;
497
499 // BREAK信号通常忽略
500 return ErrorCode::OK;
501
502 default:
503 return ErrorCode::NOT_SUPPORT;
504 }
505 }
506
511 ErrorCode OnClassData(bool in_isr, uint8_t bRequest, LibXR::ConstRawData& data) override
512 {
513 UNUSED(in_isr);
514 UNUSED(data);
515
516 switch (static_cast<ClassRequest>(bRequest))
517 {
519 {
520 // 将CDC线路编码转换为UART配置
524 {
525 case 0:
526 cfg.stop_bits = 1;
527 break;
528 // TODO: 1.5
529 case 2:
530 cfg.stop_bits = 2;
531 break;
532 default:
533 cfg.stop_bits = 1;
534 }
536 {
537 case 1:
539 break;
540 case 2:
542 break;
543 default:
545 }
547 on_set_line_coding_cb_.Run(in_isr, cfg);
548 }
549 return ErrorCode::OK;
550 default:
551 return ErrorCode::NOT_SUPPORT;
552 }
553 }
554
555#pragma pack(push, 1)
564 {
568
569 // CDC类特定描述符
570 struct
571 {
572 uint8_t bFunctionLength = 5;
573 DescriptorType bDescriptorType = DescriptorType::CS_INTERFACE;
574 DescriptorSubtype bDescriptorSubtype = DescriptorSubtype::HEADER;
575 uint16_t bcdCDC = 0x0110;
576 } cdc_header;
577
578 struct
579 {
580 uint8_t bFunctionLength = 5;
581 DescriptorType bDescriptorType = DescriptorType::CS_INTERFACE;
583 uint8_t bmCapabilities = 0x00;
585 } cdc_callmgmt;
586
587 struct
588 {
589 uint8_t bFunctionLength = 4;
590 DescriptorType bDescriptorType = DescriptorType::CS_INTERFACE;
591 DescriptorSubtype bDescriptorSubtype = DescriptorSubtype::ACM;
592 uint8_t bmCapabilities = 0x02;
593 } cdc_acm;
594
595 struct
596 {
597 uint8_t bFunctionLength = 5;
598 DescriptorType bDescriptorType = DescriptorType::CS_INTERFACE;
599 DescriptorSubtype bDescriptorSubtype = DescriptorSubtype::UNION;
602 } cdc_union;
603
605
607
610 } desc_block_;
611#pragma pack(pop)
612
613 protected:
614 CDCLineCoding& GetLineCoding() { return line_coding_; }
615
616 bool Inited() { return inited_; }
617
618 Endpoint* GetDataInEndpoint() { return ep_data_in_; }
619
620 Endpoint* GetDataOutEndpoint() { return ep_data_out_; }
621
622 Endpoint* GetCommInEndpoint() { return ep_comm_in_; }
623
624 private:
625 // 端点号
629
630 // 端点指针
634
635 // 端点回调
636 LibXR::Callback<LibXR::ConstRawData&> on_data_out_complete_cb_ =
638
639 LibXR::Callback<LibXR::ConstRawData&> on_data_in_complete_cb_ =
641
642 // 用户回调
648
649 // 状态标志
650 bool inited_ = false;
651
652 // 接口信息
654
655 // CDC参数
656 CDCLineCoding line_coding_ = {115200, 0, 0, 8};
657 uint16_t control_line_state_ = 0;
658};
659
660} // namespace LibXR::USB
通用回调包装,支持动态参数传递 / Generic callback wrapper supporting dynamic argument passing
Definition libxr_cb.hpp:150
static Callback Create(FunType fun, ArgType arg)
创建回调对象并绑定回调函数与参数 / Create a callback instance with bound function and argument
Definition libxr_cb.hpp:167
void Run(bool in_isr, PassArgs &&... args) const
执行回调函数并传递参数 / Execute the callback with arguments
Definition libxr_cb.hpp:225
常量原始数据封装类。 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:24
void SetOnSetControlLineStateCallback(LibXR::Callback< bool, bool > cb)
设置控制线路状态变更回调 Set control line state change callback
Definition cdc_base.hpp:203
virtual void BindEndpoints(EndpointPool &endpoint_pool, uint8_t start_itf_num, bool) override
初始化CDC设备 Initialize CDC device
Definition cdc_base.hpp:229
LibXR::Callback< bool, bool > on_set_control_line_state_cb_
Definition cdc_base.hpp:644
Protocol
CDC协议代码 / CDC protocol codes.
Definition cdc_base.hpp:44
@ AT_COMMAND
AT命令协议 / AT Command protocol.
@ NONE
无协议 / No protocol
size_t GetMaxConfigSize() override
获取最大配置描述符大小 Get maximum configuration descriptor size
Definition cdc_base.hpp:451
Endpoint::EPNumber data_in_ep_num_
数据IN端点号 / Data IN endpoint number
Definition cdc_base.hpp:626
uint8_t itf_comm_in_num_
通信接口号 / Communication interface number
Definition cdc_base.hpp:653
CDCNotification
CDC通知类型 / CDC notification types.
Definition cdc_base.hpp:70
@ RESPONSE_AVAILABLE
响应可用通知 / Response available
@ NETWORK_CONNECTION
网络连接通知 / Network connection
@ AUX_JACK_HOOK_STATE
辅助插槽状态通知 / Aux jack hook state
@ RING_DETECT
响铃检测通知 / Ring detect
void SetOnSetLineCodingCallback(LibXR::Callback< LibXR::UART::Configuration > cb)
设置线路编码变更回调 Set line coding change callback
Definition cdc_base.hpp:212
Endpoint::EPNumber comm_ep_num_
通信端点号 / Communication endpoint number
Definition cdc_base.hpp:628
Class
USB设备类代码 / USB device class codes.
Definition cdc_base.hpp:37
@ 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:51
@ 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:633
bool inited_
初始化标志 / Initialization flag
Definition cdc_base.hpp:650
Endpoint * ep_data_in_
数据IN端点 / Data IN endpoint
Definition cdc_base.hpp:631
static void OnDataOutCompleteStatic(bool in_isr, CDCBase *self, ConstRawData &data)
数据OUT端点传输完成静态回调 Static callback for data OUT endpoint transfer completion
Definition cdc_base.hpp:377
bool OwnsEndpoint(uint8_t ep_addr) const override
可选:端点归属判定 / Optional: endpoint ownership
Definition cdc_base.hpp:434
static constexpr uint16_t CDC_CONTROL_LINE_DTR
DTR控制位 / DTR control bit.
Definition cdc_base.hpp:119
ClassRequest
CDC类特定请求 / CDC class-specific requests.
Definition cdc_base.hpp:61
@ 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
DescriptorSubtype
CDC功能描述符子类型定义 / CDC functional descriptor subtypes.
Definition cdc_base.hpp:27
@ 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:647
bool IsRtsSet() const
检查RTS状态 Check RTS state
Definition cdc_base.hpp:156
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:131
Endpoint::EPNumber data_out_ep_num_
数据OUT端点号 / Data OUT endpoint number
Definition cdc_base.hpp:627
uint16_t control_line_state_
控制线路状态 / Control line state
Definition cdc_base.hpp:657
ErrorCode OnClassRequest(bool in_isr, uint8_t bRequest, uint16_t wValue, uint16_t wLength, uint16_t wIndex, DeviceClass::ControlTransferResult &result) override
处理类特定请求 Handle class-specific requests
Definition cdc_base.hpp:460
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:432
static void OnDataInCompleteStatic(bool in_isr, CDCBase *self, ConstRawData &data)
数据IN端点传输完成静态回调 Static callback for data IN endpoint transfer completion
Definition cdc_base.hpp:390
CDCLineCoding line_coding_
当前线路编码 / Current line coding
Definition cdc_base.hpp:656
ErrorCode OnClassData(bool in_isr, uint8_t bRequest, LibXR::ConstRawData &data) override
处理类请求数据阶段 Handle class request data stage
Definition cdc_base.hpp:511
Endpoint * ep_data_out_
数据OUT端点 / Data OUT endpoint
Definition cdc_base.hpp:632
ErrorCode SendSerialState()
发送串行状态通知 Send serial state notification
Definition cdc_base.hpp:165
static constexpr uint16_t CDC_CONTROL_LINE_RTS
RTS控制位 / RTS control bit.
Definition cdc_base.hpp:120
virtual void UnbindEndpoints(EndpointPool &endpoint_pool, bool) override
反初始化CDC设备 Deinitialize CDC device
Definition cdc_base.hpp:355
size_t GetInterfaceCount() override
获取接口数量 Get number of interfaces
Definition cdc_base.hpp:423
bool IsDtrSet() const
检查DTR状态 Check DTR state
Definition cdc_base.hpp:147
void SetData(RawData data)
设置内部数据缓存 / Set internal data cache
Definition desc_cfg.hpp:194
USB 设备类接口基类 / USB device class interface base.
Definition dev_core.hpp:26
USB 端点基类 / USB Endpoint base class.
Definition ep.hpp:23
EPNumber
端点号 Endpoint number
Definition ep.hpp:41
@ EP_AUTO
自动分配端点号 / Auto allocate
uint8_t GetAddress() const
获取端点地址(方向 + 号) / Get endpoint address (dir + num)
Definition ep.hpp:194
@ IN
输入方向 / IN direction
@ OUT
输出方向 / OUT direction
void SetActiveLength(uint16_t len)
设置当前活动缓冲区有效长度 / Set active buffer valid length
Definition ep.hpp:270
void SetOnTransferCompleteCallback(Callback< ConstRawData & > cb)
设置传输完成回调 / Set transfer complete callback
Definition ep.hpp:261
virtual void Configure(const Config &cfg)=0
配置端点协议参数 / Configure endpoint protocol parameters
@ BULK
批量端点 / Bulk
@ INTERRUPT
中断端点 / Interrupt
virtual void Close()=0
关闭端点 / Close endpoint
uint16_t MaxPacketSize() const
获取最大包长 / Get max packet size
Definition ep.hpp:225
State GetState() const
获取端点状态 / Get endpoint state
Definition ep.hpp:207
virtual ErrorCode Transfer(size_t size)=0
启动一次传输 / Start a transfer
RawData GetBuffer() const
获取当前可用于传输的缓冲区 / Get current transfer buffer
Definition ep.hpp:245
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:564
InterfaceDescriptor data_intf
数据接口描述符 / Data interface descriptor
Definition cdc_base.hpp:606
uint8_t bSlaveInterface0
从接口号 / Slave interface number
Definition cdc_base.hpp:601
EndpointDescriptor data_ep_out
数据OUT端点描述符 / Data OUT endpoint descriptor
Definition cdc_base.hpp:608
uint16_t bcdCDC
CDC规范版本 / CDC specification version.
Definition cdc_base.hpp:575
uint8_t bmCapabilities
呼叫管理能力 / Call management capabilities
Definition cdc_base.hpp:583
InterfaceDescriptor comm_intf
通信接口描述符 / Communication interface descriptor
Definition cdc_base.hpp:567
uint8_t bDataInterface
数据接口号 / Data interface number
Definition cdc_base.hpp:584
EndpointDescriptor comm_ep
通信端点描述符 / Communication endpoint descriptor
Definition cdc_base.hpp:604
uint8_t bMasterInterface
主接口号 / Master interface number
Definition cdc_base.hpp:600
EndpointDescriptor data_ep_in
数据IN端点描述符 / Data IN endpoint descriptor
Definition cdc_base.hpp:609
IADDescriptor iad
接口关联描述符 / Interface association descriptor
Definition cdc_base.hpp:565
CDC线路编码参数结构体 CDC line coding parameters structure.
Definition cdc_base.hpp:88
uint32_t dwDTERate
波特率(小端格式)| Baud rate (little-endian)
Definition cdc_base.hpp:89
uint8_t bCharFormat
停止位:0=1位,1=1.5位,2=2位 / Stop bits: 0=1, 1=1.5, 2=2
Definition cdc_base.hpp:90
uint8_t bDataBits
数据位:5,6,7,8或16 / Data bits: 5,6,7,8 or 16
Definition cdc_base.hpp:93
串行状态通知结构体 Serial state notification structure
Definition cdc_base.hpp:104
uint16_t wLength
数据长度(固定为2)| Data length (fixed to 2)
Definition cdc_base.hpp:110
uint16_t wIndex
接口号 / Interface number
Definition cdc_base.hpp:109
uint16_t serialState
串行状态位图 / Serial state bitmap
Definition cdc_base.hpp:111
uint8_t bmRequestType
请求类型(固定为0xA1)| Request type (fixed to 0xA1)
Definition cdc_base.hpp:105
uint16_t wValue
值(固定为0)| Value (fixed to 0)
Definition cdc_base.hpp:108
端点描述符(7 字节)/ Endpoint descriptor (7 bytes)
Definition desc_cfg.hpp:92
IAD(8 字节)/ Interface Association Descriptor (8 bytes)
Definition desc_cfg.hpp:61
接口描述符(9 字节)/ Interface descriptor (9 bytes)
Definition desc_cfg.hpp:76
控制请求(Class/Vendor)处理结果 / Control request (Class/Vendor) handling result
Definition dev_core.hpp:51
bool write_zlp
发送 STATUS IN(发送 ZLP)/ Send STATUS IN (send ZLP)
Definition dev_core.hpp:58