libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
ep_pool.hpp
1#pragma once
2
3#include <cstddef>
4#include <cstdint>
5#include <functional>
6
7#include "ep.hpp"
8#include "lockfree_pool.hpp"
9
10namespace LibXR::USB
11{
12
22class EndpointPool : protected LockFreePool<Endpoint*>
23{
24 public:
26
32 EndpointPool(size_t endpoint_num);
33
42 ErrorCode Get(Endpoint*& ep_info, Endpoint::Direction direction,
44
50 ErrorCode Release(Endpoint* ep_info);
51
59 ErrorCode FindEndpoint(uint8_t ep_addr, Endpoint*& ans);
60
66
72
78 void SetEndpoint0(Endpoint* ep0_in, Endpoint* ep0_out);
79
80 private:
81 Endpoint* ep0_in_ = nullptr;
82 Endpoint* ep0_out_ = nullptr;
83};
84
85} // namespace LibXR::USB
无锁无序槽池 / Lock-free, unordered slot pool
ErrorCode Put(const Endpoint *&data)
USB端点基类 / USB Endpoint base class.
Definition ep.hpp:22
EPNumber
端点号 / Endpoint number
Definition ep.hpp:39
@ EP_AUTO
自动分配端点号 / Auto allocate
Direction
端点方向 Endpoint direction
Definition ep.hpp:29
USB端点池类 / USB endpoint pool class.
Definition ep_pool.hpp:23
ErrorCode FindEndpoint(uint8_t ep_addr, Endpoint *&ans)
查找端点/ Lookup endpoint
Definition ep_pool.cpp:61
EndpointPool(size_t endpoint_num)
构造函数 / Constructor
Definition ep_pool.cpp:5
Endpoint * GetEndpoint0In()
获取端点0的IN对象 / Get Endpoint 0's IN object
Definition ep_pool.cpp:94
void SetEndpoint0(Endpoint *ep0_in, Endpoint *ep0_out)
设置端点0的IN/OUT对象 / Set Endpoint 0 IN/OUT objects
Definition ep_pool.cpp:96
Endpoint * ep0_in_
端点0 IN对象 / Endpoint 0 IN pointer
Definition ep_pool.hpp:81
ErrorCode Get(Endpoint *&ep_info, Endpoint::Direction direction, Endpoint::EPNumber ep_num=Endpoint::EPNumber::EP_AUTO)
分配端点 / Allocate endpoint
Definition ep_pool.cpp:11
Endpoint * ep0_out_
端点0 OUT对象 / Endpoint 0 OUT pointer
Definition ep_pool.hpp:82
Endpoint * GetEndpoint0Out()
获取端点0的OUT对象 / Get Endpoint 0's OUT object
Definition ep_pool.cpp:92
ErrorCode Release(Endpoint *ep_info)
回收端点 / Release endpoint
Definition ep_pool.cpp:37