3using namespace LibXR::USB;
14 const auto ep_num =
static_cast<size_t>(ep->
GetNumber());
29 if (
slots_[ep_num][d] !=
nullptr)
43 if (
slots_[ep_num][d] !=
nullptr)
55 const auto num =
static_cast<size_t>(ep_num);
61 const size_t d =
DirIndex(direction);
95 if (ep_info ==
nullptr)
100 const auto num =
static_cast<size_t>(ep_info->
GetNumber());
106 bool released =
false;
124 if ((ep_addr & 0x7F) == 0)
130 const size_t num = ep_addr & 0x7F;
136 const size_t d =
DirIndex(direction);
USB 端点基类 / USB Endpoint base class.
EPNumber
端点号 Endpoint number
Direction AvailableDirection() const
获取允许配置的方向 / Get allowed endpoint direction
uint8_t GetAddress() const
获取端点地址(方向 + 号) / Get endpoint address (dir + num)
Direction
端点方向 Endpoint direction
@ BOTH
双向(可配置为 IN/OUT) / Both (configurable as IN/OUT)
@ OUT
输出方向 / OUT direction
Direction GetDirection() const
获取当前端点方向 / Get current endpoint direction
EPNumber GetNumber() const
获取端点号 / Get endpoint number
SlotUse use_[SLOT_COUNT][DIR_COUNT]
对应槽占用状态 / Per-slot usage
EndpointPool(size_t endpoint_num)
构造函数 / Constructor
static constexpr size_t DIR_COUNT
方向数量(OUT=0, IN=1)/ Number of direction slots (OUT=0, IN=1)
ErrorCode Put(Endpoint *ep)
登记一个端点到池中 / Register an endpoint into the pool
Endpoint * GetEndpoint0In()
获取端点0的IN对象 / Get Endpoint 0's IN object
void SetEndpoint0(Endpoint *ep0_in, Endpoint *ep0_out)
设置端点0的IN/OUT对象 / Set Endpoint 0 IN/OUT objects
ErrorCode Release(Endpoint *ep_info)
回收端点 / Release endpoint
@ AVAILABLE
已登记、空闲可分配 / Registered and free to allocate
@ IN_USE
已分配、正在使用 / Allocated and in use
Endpoint * slots_[SLOT_COUNT][DIR_COUNT]
[端点号][方向] 端点指针 / [num][dir]
Endpoint * ep0_in_
端点0 IN对象 / Endpoint 0 IN pointer
ErrorCode FindEndpoint(uint8_t ep_addr, Endpoint *&ans)
查找端点/ Lookup endpoint
static constexpr size_t SLOT_COUNT
索引数组容量(端点号 0..EP_MAX_NUM-1)/ Index array size (endpoint numbers)
Endpoint * ep0_out_
端点0 OUT对象 / Endpoint 0 OUT pointer
Endpoint * GetEndpoint0Out()
获取端点0的OUT对象 / Get Endpoint 0's OUT object
static size_t DirIndex(Endpoint::Direction dir)
方向枚举转索引下标 / Convert direction enum to array index
ErrorCode Get(Endpoint *&ep_info, Endpoint::Direction direction, Endpoint::EPNumber ep_num)
分配端点 / Allocate endpoint
@ NOT_FOUND
未找到 | Not found
@ OK
操作成功 | Operation successful
@ ARG_ERR
参数错误 | Argument error