libxr
1.0
Want to be the best embedded framework
|
USB端点基类 / USB Endpoint base class. More...
#include <ep.hpp>
Data Structures | |
struct | Config |
端点配置结构体 Endpoint configuration struct More... | |
Public Types | |
enum class | Direction : uint8_t { OUT = 0 , IN = 1 , BOTH = 2 } |
端点方向 Endpoint direction More... | |
enum class | EPNumber : uint8_t { EP0 = 0 , EP1 = 1 , EP2 = 2 , EP3 = 3 , EP4 = 4 , EP5 = 5 , EP6 = 6 , EP7 = 7 , EP8 = 8 , EP9 = 9 , EP10 = 10 , EP11 = 11 , EP12 = 12 , EP13 = 13 , EP14 = 14 , EP15 = 15 , EP_MAX_NUM = 16 , EP_AUTO = 0xFE , EP_INVALID = 0xFF } |
端点号 / Endpoint number More... | |
enum class | Type : uint8_t { CONTROL = 0 , ISOCHRONOUS = 1 , BULK = 2 , INTERRUPT = 3 } |
端点类型 Endpoint type More... | |
enum class | State : uint8_t { DISABLED , IDLE , BUSY , STALLED , ERROR } |
端点状态 Endpoint state More... | |
Public Member Functions | |
Endpoint (EPNumber number, Direction dir, RawData buffer) | |
构造函数 Constructor | |
~Endpoint ()=default | |
析构函数 Destructor | |
Endpoint (const Endpoint &)=delete | |
Endpoint & | operator= (const Endpoint &)=delete |
EPNumber | GetNumber () const |
获取端点号 Get endpoint number | |
Direction | AvailableDirection () const |
获取允许配置的端点方向 Get allowed endpoint direction | |
Direction | GetDirection () const |
获取端点方向 Get endpoint direction | |
uint8_t | GetAddress () const |
获取端点地址(方向 + 号) Get endpoint address (dir + num) | |
State | GetState () const |
获取端点状态 Get endpoint state | |
void | SetState (State state) |
设置端点状态 Set endpoint state | |
Type | GetType () const |
获取端点类型 Get endpoint type | |
uint16_t | MaxPacketSize () const |
获取最大包长 Get max packet size | |
bool | IsStalled () const |
是否挂起 / Is endpoint stalled | |
bool | UseDoubleBuffer () const |
是否使用双缓冲区 / Use double buffer | |
RawData | GetBuffer () const |
获取端点缓冲区 Get endpoint buffer | |
void | SetOnTransferCompleteCallback (Callback< ConstRawData & > cb) |
设置传输完成回调 / Set transfer complete callback | |
void | SetActiveLength (uint16_t len) |
size_t | GetActiveLength () |
virtual size_t | MaxTransferSize () const |
返回最大可传输字节数 Return the maximum transferable size at this time | |
virtual void | Configure (const Config &cfg)=0 |
二次初始化/配置端点协议参数(由Pool/Manager分配后调用) Configure endpoint protocol parameters (call after pool allocation) | |
virtual void | Close ()=0 |
关闭端点(软禁用/资源复位) Close (soft disable) | |
virtual ErrorCode | Stall ()=0 |
停止端点传输 Stop endpoint transfer | |
virtual ErrorCode | ClearStall ()=0 |
清除端点停止状态 Clear endpoint stop status | |
virtual ErrorCode | Transfer (size_t size)=0 |
传输数据 Transfer data | |
virtual ErrorCode | TransferZLP () |
传输空包 Transfer zero length packet | |
void | OnTransferCompleteCallback (bool in_isr, size_t actual_transfer_size) |
Static Public Member Functions | |
static constexpr uint8_t | EPNumberToInt8 (EPNumber ep) |
端点号转换为uint8_t / Convert endpoint number to uint8_t | |
static constexpr uint8_t | EPNumberToAddr (EPNumber ep, Direction dir) |
端点号转换为端点地址 / Convert endpoint number to endpoint address | |
static constexpr EPNumber | AddrToEPNumber (uint8_t addr, Direction &dir) |
端点地址转换为端点号 / Convert endpoint address to endpoint number | |
static constexpr EPNumber | NextEPNumber (EPNumber ep) |
获取下一个端点号 / Get the next endpoint number | |
Protected Member Functions | |
Config & | GetConfig () |
获取当前配置 Get endpoint config | |
virtual void | SwitchBuffer () |
切换缓冲区 Switch buffer | |
virtual void | SetActiveBlock (bool active_block) |
设置当前活动缓冲区 Set active buffer | |
Private Attributes | |
LibXR::Callback< LibXR::ConstRawData & > | on_transfer_complete_ |
传输完成回调 / Called when transfer completes | |
EPNumber | number_ |
当前端点编号 / Endpoint number | |
Direction | avail_direction_ |
可配置方向 / Allowed direction | |
Config | config_ |
当前端点配置 / Current configuration | |
State | state_ = State::DISABLED |
当前状态 / Endpoint status | |
LibXR::RawData | buffer_ |
端点缓冲区 / Endpoint buffer | |
LibXR::DoubleBuffer | double_buffer_ |
双缓冲区 / Double buffer | |
USB端点基类 / USB Endpoint base class.
用于描述和操作USB端点,包括配置、数据读写、状态管理等接口。 Used for describing and manipulating USB endpoints, including configuration, data read/write, state management, etc.
|
strong |
|
strong |
端点号 / Endpoint number
Enumerator | |
---|---|
EP0 | 端点0 / Endpoint 0 |
EP1 | 端点1 / Endpoint 1 |
EP2 | 端点2 / Endpoint 2 |
EP3 | 端点3 / Endpoint 3 |
EP4 | 端点4 / Endpoint 4 |
EP5 | 端点5 / Endpoint 5 |
EP6 | 端点6 / Endpoint 6 |
EP7 | 端点7 / Endpoint 7 |
EP8 | 端点8 / Endpoint 8 |
EP9 | 端点9 / Endpoint 9 |
EP10 | 端点10 / Endpoint 10 |
EP11 | 端点11 / Endpoint 11 |
EP12 | 端点12 / Endpoint 12 |
EP13 | 端点13 / Endpoint 13 |
EP14 | 端点14 / Endpoint 14 |
EP15 | 端点15 / Endpoint 15 |
EP_MAX_NUM | 端点数量上限 / Maximum number of endpoints |
EP_AUTO | 自动分配端点号 / Auto allocate |
EP_INVALID | 非法端点号 / Invalid endpoint |
|
strong |
|
strong |
构造函数 Constructor
number | 端点号 / Endpoint number |
dir | 允许配置的端点方向 / Allowed endpoint direction |
Definition at line 155 of file ep.hpp.
|
inlinestaticconstexpr |
|
inline |
|
pure virtual |
清除端点停止状态 Clear endpoint stop status
Implemented in LibXR::CH32EndpointOtgFs, LibXR::CH32EndpointOtgHs, and LibXR::STM32Endpoint.
|
pure virtual |
关闭端点(软禁用/资源复位) Close (soft disable)
Implemented in LibXR::CH32EndpointOtgFs, LibXR::CH32EndpointOtgHs, and LibXR::STM32Endpoint.
|
pure virtual |
二次初始化/配置端点协议参数(由Pool/Manager分配后调用) Configure endpoint protocol parameters (call after pool allocation)
Implemented in LibXR::CH32EndpointOtgFs, LibXR::CH32EndpointOtgHs, and LibXR::STM32Endpoint.
|
inlinestaticconstexpr |
|
inlinestaticconstexpr |
|
inline |
Definition at line 280 of file ep.hpp.
|
inline |
获取端点地址(方向 + 号) Get endpoint address (dir + num)
Definition at line 199 of file ep.hpp.
|
inline |
获取端点缓冲区 Get endpoint buffer
Definition at line 256 of file ep.hpp.
|
inlineprotected |
|
inline |
获取端点方向 Get endpoint direction
Definition at line 186 of file ep.hpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
获取最大包长 Get max packet size
Definition at line 232 of file ep.hpp.
|
inlinevirtual |
返回最大可传输字节数 Return the maximum transferable size at this time
默认为最大包长,可在支持 FIFO 优化的平台中重载为动态剩余容量。 Default equals MaxPacketSize; override for FIFO-aware implementation.
Reimplemented in LibXR::STM32Endpoint.
Definition at line 289 of file ep.hpp.
获取下一个端点号 / Get the next endpoint number
ep | 当前端点号 / Current endpoint number |
|
inline |
Definition at line 336 of file ep.hpp.
|
inlineprotectedvirtual |
设置当前活动缓冲区 Set active buffer
active_block | true 表示使用第二个缓冲区,false 表示使用第一个缓冲区 |
Definition at line 384 of file ep.hpp.
|
inline |
Definition at line 278 of file ep.hpp.
|
inline |
设置传输完成回调 / Set transfer complete callback
cb | 传输完成回调 / Transfer complete callback |
|
inline |
|
pure virtual |
停止端点传输 Stop endpoint transfer
Implemented in LibXR::CH32EndpointOtgFs, LibXR::CH32EndpointOtgHs, and LibXR::STM32Endpoint.
|
inlineprotectedvirtual |
切换缓冲区 Switch buffer
Reimplemented in LibXR::CH32EndpointOtgFs, and LibXR::CH32EndpointOtgHs.
Definition at line 372 of file ep.hpp.
|
pure virtual |
传输数据 Transfer data
size | 传输大小 / Transfer size |
Implemented in LibXR::CH32EndpointOtgFs, LibXR::CH32EndpointOtgHs, and LibXR::STM32Endpoint.
|
inlinevirtual |
|
inline |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |