|
libxr
1.0
Want to be the best embedded framework
|
USB端点池类 / USB endpoint pool class. More...
#include <ep_pool.hpp>
Public Member Functions | |
| EndpointPool (size_t endpoint_num) | |
| 构造函数 / Constructor | |
| ErrorCode | Get (Endpoint *&ep_info, Endpoint::Direction direction, Endpoint::EPNumber ep_num=Endpoint::EPNumber::EP_AUTO) |
| 分配端点 / Allocate endpoint | |
| ErrorCode | Release (Endpoint *ep_info) |
| 回收端点 / Release endpoint | |
| ErrorCode | FindEndpoint (uint8_t ep_addr, Endpoint *&ans) |
| 查找端点/ Lookup endpoint | |
| Endpoint * | GetEndpoint0Out () |
| 获取端点0的OUT对象 / Get Endpoint 0's OUT object | |
| 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 | |
Private Attributes | |
| Endpoint * | ep0_in_ = nullptr |
| 端点0 IN对象 / Endpoint 0 IN pointer | |
| Endpoint * | ep0_out_ = nullptr |
| 端点0 OUT对象 / Endpoint 0 OUT pointer | |
Additional Inherited Members | |
Protected Types inherited from LibXR::LockFreePool< Endpoint * > | |
| enum | SlotState |
| 槽状态 / Slot state More... | |
Protected Member Functions inherited from LibXR::LockFreePool< Endpoint * > | |
| Slot & | operator[] (uint32_t index) |
| LockFreePool (uint32_t slot_count) | |
| 构造对象池 / Constructor for the pool | |
| ~LockFreePool () | |
| 析构,释放槽池内存 / Destructor, releasing pool memory | |
| ErrorCode | Put (const Endpoint *&data) |
| 向池中放入一个元素 / Put an element into the pool | |
| ErrorCode | Put (const Endpoint *&data, uint32_t &start_index) |
| 向池中放入一个元素,返回起始槽索引 / Put an element into the pool and return the starting slot index | |
| ErrorCode | PutToSlot (const Endpoint *&data, uint32_t index) |
| 向指定槽放入一个元素 / Put an element into a specific slot | |
| ErrorCode | Get (Endpoint *&data) |
| 从池中取出一个元素 / Retrieve an element from the pool | |
| ErrorCode | Get (Endpoint *&data, uint32_t &start_index) |
| 从指定槽位开始,取出一个元素 / Retrieve an element from the pool | |
| ErrorCode | GetFromSlot (Endpoint *&data, uint32_t index) |
| 从指定槽位开始,取出一个元素 / Retrieve an element from the pool | |
| ErrorCode | RecycleSlot (uint32_t index) |
| 回收指定槽位 / Recycle a slot | |
| size_t | Size () const |
| 查询池中可取元素数量 / Query the number of available elements in the pool | |
| size_t | EmptySize () |
| 查询当前池可用槽数量 / Query the number of writable slots in the pool | |
| uint32_t | SlotCount () const |
| 获取槽总数 / Get the total number of slots in the pool | |
USB端点池类 / USB endpoint pool class.
继承自 LockFreePool<Endpoint*>,用于高效管理 USB 端点对象指针。 所有 Endpoint* 在池初始化时填充,池只负责分配、查找与回收,不负责对象生命周期。
Inherited from LockFreePool<Endpoint*>, this pool manages fixed Endpoint pointers. All Endpoint objects must be valid during the pool's lifetime.
Definition at line 22 of file ep_pool.hpp.
| EndpointPool::EndpointPool | ( | size_t | endpoint_num | ) |
构造函数 / Constructor
| endpoint_num | 端点总数(包含端点0,必须 >=2)/ Total number of endpoints (including EP0, must >=2) |
Definition at line 5 of file ep_pool.cpp.
| ErrorCode EndpointPool::FindEndpoint | ( | uint8_t | ep_addr, |
| Endpoint *& | ans ) |
查找端点/ Lookup endpoint
| ep_addr | 端点地址,IN端点高位需加0x80 / Endpoint address (0x80 for IN endpoints) | |
| [out] | ans | 查找到的端点对象指针 / Found endpoint pointer |
| ErrorCode | 操作结果(OK/NOT_FOUND)/ Operation result |
Definition at line 61 of file ep_pool.cpp.
| ErrorCode EndpointPool::Get | ( | Endpoint *& | ep_info, |
| Endpoint::Direction | direction, | ||
| Endpoint::EPNumber | ep_num = Endpoint::EPNumber::EP_AUTO ) |
分配端点 / Allocate endpoint
| [out] | ep_info | 分配得到的端点对象指针 / Allocated endpoint pointer |
| direction | 端点方向(IN/OUT/BOTH)/ Endpoint direction | |
| ep_num | 指定端点号/ Endpoint number 0) |
| ErrorCode | 操作结果(OK/NOT_FOUND)/ Operation result |
Definition at line 11 of file ep_pool.cpp.
| Endpoint * EndpointPool::GetEndpoint0In | ( | ) |
获取端点0的IN对象 / Get Endpoint 0's IN object
Definition at line 94 of file ep_pool.cpp.
| Endpoint * EndpointPool::GetEndpoint0Out | ( | ) |
获取端点0的OUT对象 / Get Endpoint 0's OUT object
Definition at line 92 of file ep_pool.cpp.
| ErrorCode EndpointPool::Release | ( | Endpoint * | ep_info | ) |
回收端点 / Release endpoint
| ep_info | 待回收的端点对象指针 / Endpoint pointer to release |
| ErrorCode | 操作结果(OK/NOT_FOUND)/ Operation result |
Definition at line 37 of file ep_pool.cpp.
|
private |
端点0 IN对象 / Endpoint 0 IN pointer
Definition at line 81 of file ep_pool.hpp.
|
private |
端点0 OUT对象 / Endpoint 0 OUT pointer
Definition at line 82 of file ep_pool.hpp.