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