libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
core.hpp
1#pragma once
2#include <cstdint>
3
4namespace LibXR::USB
5{
10enum class RequestDirection : uint8_t
11{
12 OUT = 0x00,
13 IN = 0x80
14};
15
20enum class RequestType : uint8_t
21{
22 STANDARD = 0x00,
23 CLASS = 0x20,
24 VENDOR = 0x40,
25 RESERVED = 0x60
26};
27
32enum class Recipient : uint8_t
33{
34 DEVICE = 0x00,
35 INTERFACE = 0x01,
36 ENDPOINT = 0x02,
37 OTHER = 0x03
38};
39
44constexpr uint8_t REQ_DIRECTION_MASK = 0x80;
45constexpr uint8_t REQ_TYPE_MASK = 0x60;
46constexpr uint8_t REQ_RECIPIENT_MASK = 0x1F;
47
48#pragma pack(push, 1)
57{
58 uint8_t bmRequestType;
60 uint8_t bRequest;
61 uint16_t
63 uint16_t wIndex;
64 uint16_t wLength;
65};
66#pragma pack(pop)
67
68// 标准请求枚举
69enum class StandardRequest : uint8_t
70{
71 GET_STATUS = 0,
72 CLEAR_FEATURE = 1,
73 SET_FEATURE = 3,
74 SET_ADDRESS = 5,
75 GET_DESCRIPTOR = 6,
76 SET_DESCRIPTOR = 7,
77 GET_CONFIGURATION = 8,
78 SET_CONFIGURATION = 9,
79 GET_INTERFACE = 10,
80 SET_INTERFACE = 11,
81 SYNCH_FRAME = 12
82};
83
88enum class Speed : uint8_t
89{
90 LOW, // 1.5 Mbps
91 FULL, // 12 Mbps
92 HIGH, // 480 Mbps
93 SUPER, // 5 Gbps (USB 3.x,可选)
94 SUPER_PLUS // 10 Gbps(可选,暂不支持)
95};
96
97enum class USBSpec : uint16_t
98{
99 USB_1_0 = 0x0100,
100 USB_1_1 = 0x0110,
101 USB_2_0 = 0x0200,
102 USB_2_1 = 0x0210,
103 USB_3_0 = 0x0300,
104 USB_3_1 = 0x0310,
105 USB_3_2 = 0x0320,
106 USB_3_1_SUPER_SPEED_PLUS = 0x0321
107};
108} // namespace LibXR::USB
USB 标准请求 SETUP 包(固定8字节) Standard USB setup packet (8 bytes)
Definition core.hpp:57
uint16_t wIndex
对象索引,如接口号或端点号 / Index (e.g., interface or endpoint)
Definition core.hpp:63
uint16_t wLength
数据阶段长度 / Number of bytes in data stage
Definition core.hpp:64
uint16_t wValue
参数字段,含请求相关值 / Value field (e.g., descriptor type/index)
Definition core.hpp:62
uint8_t bRequest
请求码 / Request code (e.g., GET_DESCRIPTOR)
Definition core.hpp:60