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