libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
LibXR::USB::DeviceClass Class Reference

USB 设备类接口基类,所有自定义 USB 类(如 HID、CDC、MSC)都需派生自本类。 USB device class base interface, all custom device classes (HID, CDC, MSC, etc.) should derive from this. More...

#include <dev_core.hpp>

Inheritance diagram for LibXR::USB::DeviceClass:
[legend]
Collaboration diagram for LibXR::USB::DeviceClass:
[legend]

Data Structures

struct  RequestResult
 控制请求结果结构体 / Structure for control transfer results More...
 

Protected Member Functions

virtual ErrorCode OnGetDescriptor (bool in_isr, uint8_t bRequest, uint16_t wValue, uint16_t wLength, ConstRawData &need_write)
 处理标准请求 GET_DESCRIPTOR Handle standard request GET_DESCRIPTOR
 
virtual ErrorCode OnClassRequest (bool in_isr, uint8_t bRequest, uint16_t wValue, uint16_t wLength, RequestResult &result)
 处理类特定请求(Class-specific Request) Handle class-specific request
 
virtual ErrorCode OnClassData (bool in_isr, uint8_t bRequest, LibXR::ConstRawData &data)
 处理类请求的数据阶段 Handle data stage for class request
 
- Protected Member Functions inherited from LibXR::USB::ConfigDescriptorItem
RawData GetData ()
 获取本配置项描述符的二进制数据 Get the binary data of this configuration item
 
void SetData (RawData data)
 设置配置项数据 Set configuration item data
 

Friends

class DeviceCore
 

Additional Inherited Members

- Public Member Functions inherited from LibXR::USB::ConfigDescriptorItem
virtual void Init (EndpointPool &endpoint_pool, uint8_t start_itf_num)=0
 USB配置描述符初始化,派生类在此处申请端点
 
virtual void Deinit (EndpointPool &endpoint_pool)=0
 USB配置描述符反初始化,派生类在此处释放端点
 
virtual ErrorCode WriteDeviceDescriptor (DeviceDescriptor &header)
 写入/补全设备描述符(非IAD情况下会被调用) Write device descriptor (non-IAD case will be called)
 
virtual ErrorCode SetAltSetting (uint8_t itf, uint8_t alt)
 设置接口的备用设置 Set the alternate setting of an interface
 
virtual ErrorCode GetAltSetting (uint8_t itf, uint8_t &alt)
 获取接口的备用设置 Get the alternate setting of an interface
 
virtual size_t GetMaxConfigSize ()=0
 获取该配置项的最大描述符长度 Get the maximum descriptor length of this configuration item
 
virtual size_t GetInterfaceNum ()=0
 获取该配置项包含的接口数 Get the number of interfaces included in this configuration item
 
virtual bool HasIAD ()=0
 判断是否包含IAD Check if this configuration item contains IAD
 

Detailed Description

USB 设备类接口基类,所有自定义 USB 类(如 HID、CDC、MSC)都需派生自本类。 USB device class base interface, all custom device classes (HID, CDC, MSC, etc.) should derive from this.

Note
仅供 DeviceCore 内部驱动和派生类扩展,普通用户无需直接使用。 Only for internal drivers and derived classes, users do not need to use it directly.

Definition at line 21 of file dev_core.hpp.

Member Function Documentation

◆ OnClassData()

virtual ErrorCode LibXR::USB::DeviceClass::OnClassData ( bool in_isr,
uint8_t bRequest,
LibXR::ConstRawData & data )
inlineprotectedvirtual

处理类请求的数据阶段 Handle data stage for class request

Parameters
in_isr是否在中断中 / In ISR
bRequest请求码 / Request code
data主机写入数据 / Data from host
Returns
ErrorCode 错误码 / Error code

Reimplemented in LibXR::USB::CDCBase, LibXR::USB::HID< REPORT_DESC_LEN, TX_REPORT_LEN, RX_REPORT_LEN >, LibXR::USB::HID< 50, 9, 0 >, LibXR::USB::HID< sizeof(HID_KEYBOARD_REPORT_DESC), 8, 1 >, and LibXR::USB::HID< sizeof(HID_MOUSE_REPORT_DESC), 4, 0 >.

Definition at line 86 of file dev_core.hpp.

87 {
88 UNUSED(in_isr);
89 UNUSED(bRequest);
90 UNUSED(data);
91 return ErrorCode::NOT_SUPPORT;
92 }

◆ OnClassRequest()

virtual ErrorCode LibXR::USB::DeviceClass::OnClassRequest ( bool in_isr,
uint8_t bRequest,
uint16_t wValue,
uint16_t wLength,
RequestResult & result )
inlineprotectedvirtual

处理类特定请求(Class-specific Request) Handle class-specific request

Parameters
in_isr是否在中断中 / In ISR
bRequest请求码 / Request code
wValue请求值 / wValue field
wLength请求长度 / Requested length
result读写数据结构体 / Data result struct
Returns
ErrorCode 错误码 / Error code

Reimplemented in LibXR::USB::CDCBase, LibXR::USB::HID< REPORT_DESC_LEN, TX_REPORT_LEN, RX_REPORT_LEN >, LibXR::USB::HID< 50, 9, 0 >, LibXR::USB::HID< sizeof(HID_KEYBOARD_REPORT_DESC), 8, 1 >, and LibXR::USB::HID< sizeof(HID_MOUSE_REPORT_DESC), 4, 0 >.

Definition at line 67 of file dev_core.hpp.

69 {
70 UNUSED(in_isr);
71 UNUSED(bRequest);
72 UNUSED(wValue);
73 UNUSED(wLength);
74 UNUSED(result);
75 return ErrorCode::NOT_SUPPORT;
76 }

◆ OnGetDescriptor()

virtual ErrorCode LibXR::USB::DeviceClass::OnGetDescriptor ( bool in_isr,
uint8_t bRequest,
uint16_t wValue,
uint16_t wLength,
ConstRawData & need_write )
inlineprotectedvirtual

处理标准请求 GET_DESCRIPTOR Handle standard request GET_DESCRIPTOR

Parameters
in_isr是否在中断中 / In ISR
bRequest请求码 / Request code
wValue请求值 / wValue field
wLength请求长度 / Requested length
need_write返回数据指针 / Output data
Returns
ErrorCode 错误码 / Error code

Reimplemented in LibXR::USB::HID< REPORT_DESC_LEN, TX_REPORT_LEN, RX_REPORT_LEN >, LibXR::USB::HID< 50, 9, 0 >, LibXR::USB::HID< sizeof(HID_KEYBOARD_REPORT_DESC), 8, 1 >, and LibXR::USB::HID< sizeof(HID_MOUSE_REPORT_DESC), 4, 0 >.

Definition at line 46 of file dev_core.hpp.

48 {
49 UNUSED(in_isr);
50 UNUSED(bRequest);
51 UNUSED(wValue);
52 UNUSED(wLength);
53 UNUSED(need_write);
54 return ErrorCode::NOT_SUPPORT;
55 }

Friends And Related Symbol Documentation

◆ DeviceCore

friend class DeviceCore
friend

Definition at line 94 of file dev_core.hpp.


The documentation for this class was generated from the following file: