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:
228 virtual void Init(EndpointPool& endpoint_pool, uint8_t start_itf_num) override
229 {
231 // 获取并配置数据IN端点
232 auto ans = endpoint_pool.Get(ep_data_in_, Endpoint::Direction::IN, data_in_ep_num_);
233 ASSERT(ans == ErrorCode::OK);
234
235 // 获取并配置数据OUT端点
237 ASSERT(ans == ErrorCode::OK);
238
239 // 获取并配置通信端点
241 ASSERT(ans == ErrorCode::OK);
242
243 // 配置端点参数
245 {Endpoint::Direction::IN, Endpoint::Type::BULK, UINT16_MAX, true});
249
250 // === 填充CDC描述符块 ===
251 static constexpr uint8_t COMM_INTERFACE = 0; // 通信接口号
252 static constexpr uint8_t DATA_INTERFACE = 1; // 数据接口号
253
254 // IAD描述符(关联接口)
255 desc_block_.iad = {8,
256 static_cast<uint8_t>(DescriptorType::IAD),
257 static_cast<uint8_t>(COMM_INTERFACE + start_itf_num),
258 2,
259 static_cast<uint8_t>(Class::COMM),
260 static_cast<uint8_t>(Subclass::ABSTRACT_CONTROL_MODEL),
261 static_cast<uint8_t>(Protocol::NONE),
262 0};
263
264 // 通信接口描述符
265 desc_block_.comm_intf = {9,
266 static_cast<uint8_t>(DescriptorType::INTERFACE),
267 static_cast<uint8_t>(COMM_INTERFACE + start_itf_num),
268 0,
269 1,
270 static_cast<uint8_t>(Class::COMM),
271 static_cast<uint8_t>(Subclass::ABSTRACT_CONTROL_MODEL),
272 static_cast<uint8_t>(Protocol::NONE),
273 0};
274
275 // CDC头功能描述符
276 desc_block_.cdc_header = {5, DescriptorType::CS_INTERFACE, DescriptorSubtype::HEADER,
277 0x0110}; // CDC规范版本1.10
278
279 // 呼叫管理功能描述符
280 desc_block_.cdc_callmgmt = {
281 5, DescriptorType::CS_INTERFACE, DescriptorSubtype::CALL_MANAGEMENT,
282 0x00, // 无呼叫管理能力
283 static_cast<uint8_t>(DATA_INTERFACE + start_itf_num)}; // 数据接口号
284
285 // ACM功能描述符
286 desc_block_.cdc_acm = {4, DescriptorType::CS_INTERFACE, DescriptorSubtype::ACM,
287 0x02}; // 支持SetLineCoding/GetLineCoding/SetControlLineState
288
289 // 联合功能描述符
290 desc_block_.cdc_union = {5, DescriptorType::CS_INTERFACE, DescriptorSubtype::UNION,
291 static_cast<uint8_t>(COMM_INTERFACE + start_itf_num),
292 static_cast<uint8_t>(DATA_INTERFACE + start_itf_num)};
293
294 // 数据接口描述符
295 desc_block_.data_intf = {9,
296 static_cast<uint8_t>(DescriptorType::INTERFACE),
297 static_cast<uint8_t>(DATA_INTERFACE + start_itf_num),
298 0,
299 2,
300 static_cast<uint8_t>(Class::DATA),
301 0x00, // 无子类
302 0x00, // 无协议
303 0};
304
305 // 数据OUT端点描述符
306 desc_block_.data_ep_out = {7,
307 static_cast<uint8_t>(DescriptorType::ENDPOINT),
309 static_cast<uint8_t>(Endpoint::Type::BULK),
311 0}; // 轮询间隔0(BULK忽略)
312
313 // 数据IN端点描述符
314 desc_block_.data_ep_in = {7,
315 static_cast<uint8_t>(DescriptorType::ENDPOINT),
316 static_cast<uint8_t>(ep_data_in_->GetAddress()),
317 static_cast<uint8_t>(Endpoint::Type::BULK),
319 0}; // 轮询间隔0(BULK忽略)
320
321 // 通信端点描述符
322 desc_block_.comm_ep = {
323 7,
324 static_cast<uint8_t>(DescriptorType::ENDPOINT),
325 static_cast<uint8_t>(ep_comm_in_->GetAddress()), // IN端点地址
326 static_cast<uint8_t>(Endpoint::Type::INTERRUPT),
327 16, // 16字节最大包大小
328 0x04 // 轮询间隔FS-4ms HS-1ms
329 };
330
331 itf_comm_in_num_ = start_itf_num;
332
333 // 设置描述符原始数据
334 SetData(RawData{reinterpret_cast<uint8_t*>(&desc_block_), sizeof(desc_block_)});
335
336 // 设置端点传输完成回调
337 ep_data_out_->SetOnTransferCompleteCallback(on_data_out_complete_cb_);
338 ep_data_in_->SetOnTransferCompleteCallback(on_data_in_complete_cb_);
339
340 inited_ = true;
341
342 // 启动OUT端点传输
344 }
345
353 virtual void Deinit(EndpointPool& endpoint_pool) override
354 {
355 inited_ = false;
360 ep_data_in_->SetActiveLength(0);
361 ep_data_out_->SetActiveLength(0);
362 ep_comm_in_->SetActiveLength(0);
363 endpoint_pool.Release(ep_data_in_);
364 endpoint_pool.Release(ep_data_out_);
365 endpoint_pool.Release(ep_comm_in_);
366 ep_data_in_ = nullptr;
367 ep_data_out_ = nullptr;
368 ep_comm_in_ = nullptr;
369 }
370
375 static void OnDataOutCompleteStatic(bool in_isr, CDCBase* self, ConstRawData& data)
376 {
377 if (!self->inited_)
378 {
379 return;
380 }
381 self->OnDataOutComplete(in_isr, data);
382 }
383
388 static void OnDataInCompleteStatic(bool in_isr, CDCBase* self, ConstRawData& data)
389 {
390 if (!self->inited_)
391 {
392 return;
393 }
394 self->OnDataInComplete(in_isr, data);
395 }
396
404 virtual void OnDataOutComplete(bool in_isr, ConstRawData& data) = 0;
405
413 virtual void OnDataInComplete(bool in_isr, ConstRawData& data) = 0;
414
421 size_t GetInterfaceNum() override { return 2; }
422
430 bool HasIAD() override { return true; }
431
432 bool OwnsEndpoint(uint8_t ep_addr) const override
433 {
434 if (!inited_)
435 {
436 return false;
437 }
438
439 return ep_data_in_->GetAddress() == ep_addr ||
440 ep_data_out_->GetAddress() == ep_addr || ep_comm_in_->GetAddress() == ep_addr;
441 }
442
449 size_t GetMaxConfigSize() override { return sizeof(desc_block_); }
450
458 ErrorCode OnClassRequest(bool in_isr, uint8_t bRequest, uint16_t wValue,
459 uint16_t wLength, uint16_t wIndex,
460 DeviceClass::RequestResult& result) override
461 {
462 UNUSED(in_isr);
463 UNUSED(wIndex);
464
465 switch (static_cast<ClassRequest>(bRequest))
466 {
468 // 主机将在数据阶段发送7字节参数
469 if (wLength != sizeof(line_coding_))
470 {
471 return ErrorCode::ARG_ERR;
472 }
473 result.read_data =
474 RawData{reinterpret_cast<uint8_t*>(&line_coding_), sizeof(line_coding_)};
475 return ErrorCode::OK;
476
478 // 返回当前线路编码设置
479 if (wLength != sizeof(line_coding_))
480 {
481 return ErrorCode::ARG_ERR;
482 }
483
484 result.write_data = ConstRawData{reinterpret_cast<const uint8_t*>(&line_coding_),
485 sizeof(line_coding_)};
486 return ErrorCode::OK;
487
489 // 设置DTR/RTS状态
490 control_line_state_ = wValue;
491 result.write_zlp = true;
494 return ErrorCode::OK;
495
497 // BREAK信号通常忽略
498 return ErrorCode::OK;
499
500 default:
501 return ErrorCode::NOT_SUPPORT;
502 }
503 }
504
509 ErrorCode OnClassData(bool in_isr, uint8_t bRequest, LibXR::ConstRawData& data) override
510 {
511 UNUSED(in_isr);
512 UNUSED(data);
513
514 switch (static_cast<ClassRequest>(bRequest))
515 {
517 {
518 // 将CDC线路编码转换为UART配置
522 {
523 case 0:
524 cfg.stop_bits = 1;
525 break;
526 // TODO: 1.5
527 case 2:
528 cfg.stop_bits = 2;
529 break;
530 default:
531 cfg.stop_bits = 1;
532 }
534 {
535 case 1:
537 break;
538 case 2:
540 break;
541 default:
543 }
545 on_set_line_coding_cb_.Run(in_isr, cfg);
546 }
547 return ErrorCode::OK;
548 default:
549 return ErrorCode::NOT_SUPPORT;
550 }
551 }
552
553#pragma pack(push, 1)
562 {
566
567 // CDC类特定描述符
568 struct
569 {
570 uint8_t bFunctionLength = 5;
571 DescriptorType bDescriptorType = DescriptorType::CS_INTERFACE;
572 DescriptorSubtype bDescriptorSubtype = DescriptorSubtype::HEADER;
573 uint16_t bcdCDC = 0x0110;
574 } cdc_header;
575
576 struct
577 {
578 uint8_t bFunctionLength = 5;
579 DescriptorType bDescriptorType = DescriptorType::CS_INTERFACE;
581 uint8_t bmCapabilities = 0x00;
583 } cdc_callmgmt;
584
585 struct
586 {
587 uint8_t bFunctionLength = 4;
588 DescriptorType bDescriptorType = DescriptorType::CS_INTERFACE;
589 DescriptorSubtype bDescriptorSubtype = DescriptorSubtype::ACM;
590 uint8_t bmCapabilities = 0x02;
591 } cdc_acm;
592
593 struct
594 {
595 uint8_t bFunctionLength = 5;
596 DescriptorType bDescriptorType = DescriptorType::CS_INTERFACE;
597 DescriptorSubtype bDescriptorSubtype = DescriptorSubtype::UNION;
600 } cdc_union;
601
603
605
608 } desc_block_;
609#pragma pack(pop)
610
611 protected:
612 CDCLineCoding& GetLineCoding() { return line_coding_; }
613
614 bool Inited() { return inited_; }
615
616 Endpoint* GetDataInEndpoint() { return ep_data_in_; }
617
618 Endpoint* GetDataOutEndpoint() { return ep_data_out_; }
619
620 Endpoint* GetCommInEndpoint() { return ep_comm_in_; }
621
622 private:
623 // 端点号
627
628 // 端点指针
632
633 // 端点回调
634 LibXR::Callback<LibXR::ConstRawData&> on_data_out_complete_cb_ =
636
637 LibXR::Callback<LibXR::ConstRawData&> on_data_in_complete_cb_ =
639
640 // 用户回调
646
647 // 状态标志
648 bool inited_ = false;
649
650 // 接口信息
652
653 // CDC参数
654 CDCLineCoding line_coding_ = {115200, 0, 0, 8};
655 uint16_t control_line_state_ = 0;
656};
657
658} // 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:24
void SetOnSetControlLineStateCallback(LibXR::Callback< bool, bool > cb)
设置控制线路状态变更回调 Set control line state change callback
Definition cdc_base.hpp:203
LibXR::Callback< bool, bool > on_set_control_line_state_cb_
Definition cdc_base.hpp:642
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:449
size_t GetInterfaceNum() override
获取接口数量 Get number of interfaces
Definition cdc_base.hpp:421
Endpoint::EPNumber data_in_ep_num_
数据IN端点号 / Data IN endpoint number
Definition cdc_base.hpp:624
uint8_t itf_comm_in_num_
通信接口号 / Communication interface number
Definition cdc_base.hpp:651
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:626
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:631
bool inited_
初始化标志 / Initialization flag
Definition cdc_base.hpp:648
Endpoint * ep_data_in_
数据IN端点 / Data IN endpoint
Definition cdc_base.hpp:629
static void OnDataOutCompleteStatic(bool in_isr, CDCBase *self, ConstRawData &data)
数据OUT端点传输完成静态回调 Static callback for data OUT endpoint transfer completion
Definition cdc_base.hpp:375
bool OwnsEndpoint(uint8_t ep_addr) const override
判断是否拥有该端点 Check if this configuration item owns this endpoint
Definition cdc_base.hpp:432
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
ErrorCode OnClassRequest(bool in_isr, uint8_t bRequest, uint16_t wValue, uint16_t wLength, uint16_t wIndex, DeviceClass::RequestResult &result) override
处理类特定请求 Handle class-specific requests
Definition cdc_base.hpp:458
virtual void Deinit(EndpointPool &endpoint_pool) override
反初始化CDC设备 Deinitialize CDC device
Definition cdc_base.hpp:353
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:645
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:625
uint16_t control_line_state_
控制线路状态 / Control line state
Definition cdc_base.hpp:655
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:430
static void OnDataInCompleteStatic(bool in_isr, CDCBase *self, ConstRawData &data)
数据IN端点传输完成静态回调 Static callback for data IN endpoint transfer completion
Definition cdc_base.hpp:388
CDCLineCoding line_coding_
当前线路编码 / Current line coding
Definition cdc_base.hpp:654
virtual void Init(EndpointPool &endpoint_pool, uint8_t start_itf_num) override
初始化CDC设备 Initialize CDC device
Definition cdc_base.hpp:228
ErrorCode OnClassData(bool in_isr, uint8_t bRequest, LibXR::ConstRawData &data) override
处理类请求数据阶段 Handle class request data stage
Definition cdc_base.hpp:509
Endpoint * ep_data_out_
数据OUT端点 / Data OUT endpoint
Definition cdc_base.hpp:630
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
bool IsDtrSet() const
检查DTR状态 Check DTR state
Definition cdc_base.hpp:147
void SetData(RawData data)
设置配置项数据 Set configuration item data
Definition desc_cfg.hpp:212
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:562
InterfaceDescriptor data_intf
数据接口描述符 / Data interface descriptor
Definition cdc_base.hpp:604
uint8_t bSlaveInterface0
从接口号 / Slave interface number
Definition cdc_base.hpp:599
EndpointDescriptor data_ep_out
数据OUT端点描述符 / Data OUT endpoint descriptor
Definition cdc_base.hpp:606
uint16_t bcdCDC
CDC规范版本 / CDC specification version.
Definition cdc_base.hpp:573
uint8_t bmCapabilities
呼叫管理能力 / Call management capabilities
Definition cdc_base.hpp:581
InterfaceDescriptor comm_intf
通信接口描述符 / Communication interface descriptor
Definition cdc_base.hpp:565
uint8_t bDataInterface
数据接口号 / Data interface number
Definition cdc_base.hpp:582
EndpointDescriptor comm_ep
通信端点描述符 / Communication endpoint descriptor
Definition cdc_base.hpp:602
uint8_t bMasterInterface
主接口号 / Master interface number
Definition cdc_base.hpp:598
EndpointDescriptor data_ep_in
数据IN端点描述符 / Data IN endpoint descriptor
Definition cdc_base.hpp:607
IADDescriptor iad
接口关联描述符 / Interface association descriptor
Definition cdc_base.hpp:563
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
端点描述符结构体 Endpoint descriptor structure (USB 2.0 Spec 9.6.6)
Definition desc_cfg.hpp:92
接口关联描述符(IAD,Interface Association Descriptor) IAD descriptor structure (用于复合设备多接口归组 / used for groupi...
Definition desc_cfg.hpp:58
接口描述符结构体 Interface descriptor structure (USB 2.0 Spec 9.6.5)
Definition desc_cfg.hpp:74
控制请求结果结构体 / 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