|
libxr
1.0
Want to be the best embedded framework
|
USB 设备类接口基类 / USB device class interface base. More...
#include <device_class.hpp>
Data Structures | |
| struct | ControlTransferResult |
| 控制请求(Class/Vendor)处理结果 / Control request (Class/Vendor) handling result More... | |
Public Member Functions | |
| DeviceClass ()=default | |
| 默认构造 / Default constructor | |
| virtual const char * | GetInterfaceString (size_t local_interface_index) const |
| 返回本类暴露的第 N 个接口字符串 Return the string for the Nth local interface exposed by this class. | |
| size_t | GetBosCapabilityCount () override |
| 返回本类提供的 BOS capability 数量 Return the number of BOS capabilities exposed by this class. | |
| BosCapability * | GetBosCapability (size_t index) override |
| 返回指定 BOS capability Return the BOS capability at the given index. | |
Public Member Functions inherited from LibXR::USB::ConfigDescriptorItem | |
| virtual void | BindEndpoints (EndpointPool &endpoint_pool, uint8_t start_itf_num, bool in_isr)=0 |
| 绑定端点资源 / Bind endpoint resources | |
| virtual void | UnbindEndpoints (EndpointPool &endpoint_pool, bool in_isr)=0 |
| 解绑端点资源 / Unbind endpoint resources | |
| virtual ErrorCode | WriteDeviceDescriptor (DeviceDescriptor &header) |
| 可选:覆盖设备描述符字段 / Optional: override device descriptor fields | |
| virtual ErrorCode | SetAltSetting (uint8_t itf, uint8_t alt) |
| 可选:设置接口备用设置 / Optional: set interface alternate setting | |
| virtual ErrorCode | GetAltSetting (uint8_t itf, uint8_t &alt) |
| 可选:获取接口备用设置 / Optional: get interface alternate setting | |
| virtual bool | OwnsEndpoint (uint8_t ep_addr) const |
| 可选:端点归属判定 / Optional: endpoint ownership | |
| virtual size_t | GetMaxConfigSize ()=0 |
| 最大配置描述符占用 / Maximum bytes required in configuration descriptor | |
| virtual size_t | GetInterfaceCount ()=0 |
| 接口数量 / Number of interfaces contributed | |
| virtual bool | HasIAD ()=0 |
| 是否包含 IAD / Whether an IAD is used | |
Public Member Functions inherited from LibXR::USB::BosCapabilityProvider | |
Protected Member Functions | |
| uint8_t | GetInterfaceStringIndex (size_t local_interface_index) const |
| 返回已分配的接口字符串索引 Return the assigned USB string index for a local interface. | |
| virtual ErrorCode | OnGetDescriptor (bool in_isr, uint8_t bRequest, uint16_t wValue, uint16_t wLength, ConstRawData &out_data) |
| 处理标准请求 GET_DESCRIPTOR(类特定描述符) Handle standard GET_DESCRIPTOR request (class-specific descriptors). | |
| virtual ErrorCode | OnClassRequest (bool in_isr, uint8_t bRequest, uint16_t wValue, uint16_t wLength, uint16_t wIndex, ControlTransferResult &result) |
| 处理 Class-specific 请求(Setup stage)/ Handle class-specific request (Setup stage) | |
| virtual ErrorCode | OnClassData (bool in_isr, uint8_t bRequest, LibXR::ConstRawData &data) |
| 处理 Class request 数据阶段 / Handle class request data stage | |
| virtual void | OnClassInDataStatusComplete (bool in_isr, uint8_t bRequest) |
| 类请求的 IN 数据阶段在 STATUS OUT 完成后回调 Called after the STATUS OUT completes for a Class IN data request. | |
| virtual ErrorCode | OnVendorRequest (bool in_isr, uint8_t bRequest, uint16_t wValue, uint16_t wLength, uint16_t wIndex, ControlTransferResult &result) |
| 处理 Vendor request(Setup stage)/ Handle vendor request (Setup stage) | |
Protected Member Functions inherited from LibXR::USB::ConfigDescriptorItem | |
| RawData | GetData () |
| 获取内部数据缓存 / Get internal data cache | |
| void | SetData (RawData data) |
| 设置内部数据缓存 / Set internal data cache | |
Private Member Functions | |
| void | SetInterfaceStringBaseIndex (uint8_t string_index) |
Private Attributes | |
| uint8_t | interface_string_base_index_ |
| 首个接口字符串索引 / First interface string index | |
Friends | |
| class | DeviceComposition |
| class | DeviceCore |
USB 设备类接口基类 / USB device class interface base.
所有自定义 USB 类(HID/CDC/MSC 等)应派生自本类。 All custom USB classes (HID/CDC/MSC, etc.) should derive from this class.
Definition at line 20 of file device_class.hpp.
|
inlineoverridevirtual |
返回指定 BOS capability Return the BOS capability at the given index.
Reimplemented from LibXR::USB::BosCapabilityProvider.
Reimplemented in LibXR::USB::DfuInterfaceClassBase.
Definition at line 51 of file device_class.hpp.
|
inlineoverridevirtual |
返回本类提供的 BOS capability 数量 Return the number of BOS capabilities exposed by this class.
Reimplemented from LibXR::USB::BosCapabilityProvider.
Reimplemented in LibXR::USB::DfuInterfaceClassBase.
Definition at line 45 of file device_class.hpp.
|
inlinevirtual |
返回本类暴露的第 N 个接口字符串 Return the string for the Nth local interface exposed by this class.
| local_interface_index | 类内局部接口序号 / Class-local interface index |
Reimplemented in LibXR::USB::CDCBase, LibXR::USB::DapLinkV2Class< SwdPort, DefaultDapPacketSize, AdvertisedPacketCount, MaxDapPacketSize, QueuedRequestBufferSize, QueuedCommandCountMax >, LibXR::USB::DfuInterfaceClassBase, LibXR::USB::GsUsbClass< CanChNum >, LibXR::USB::HID< REPORT_DESC_LEN, TX_REPORT_LEN, RX_REPORT_LEN >, LibXR::USB::HID< 50, 9, 0 >, LibXR::USB::HID< sizeof(DAPLINK_V1_REPORT_DESC), DapLinkV1Def::MAX_REQUEST_SIZE, DapLinkV1Def::MAX_RESPONSE_SIZE >, LibXR::USB::HID< sizeof(HID_KEYBOARD_REPORT_DESC), 8, 1 >, LibXR::USB::HID< sizeof(HID_MOUSE_REPORT_DESC), 4, 0 >, and LibXR::USB::UAC1MicrophoneQ< CHANNELS, BITS_PER_SAMPLE >.
Definition at line 35 of file device_class.hpp.
|
nodiscardprotected |
返回已分配的接口字符串索引 Return the assigned USB string index for a local interface.
| local_interface_index | 类内局部接口序号 / Class-local interface index |
Definition at line 5 of file device_class.cpp.
|
inlineprotectedvirtual |
处理 Class request 数据阶段 / Handle class request data stage
| in_isr | 是否在 ISR / Whether in ISR context |
| bRequest | 请求码 / Request code |
| data | 数据阶段数据 / Data stage payload |
Reimplemented in LibXR::USB::CDCBase, LibXR::USB::DFUClass< Backend, MAX_TRANSFER_SIZE >, LibXR::USB::DFUClass< DfuBootloaderBackend, 4096u >, LibXR::USB::GsUsbClass< CanChNum >, LibXR::USB::HID< REPORT_DESC_LEN, TX_REPORT_LEN, RX_REPORT_LEN >, LibXR::USB::HID< 50, 9, 0 >, LibXR::USB::HID< sizeof(DAPLINK_V1_REPORT_DESC), DapLinkV1Def::MAX_REQUEST_SIZE, DapLinkV1Def::MAX_RESPONSE_SIZE >, LibXR::USB::HID< sizeof(HID_KEYBOARD_REPORT_DESC), 8, 1 >, LibXR::USB::HID< sizeof(HID_MOUSE_REPORT_DESC), 4, 0 >, and LibXR::USB::UAC1MicrophoneQ< CHANNELS, BITS_PER_SAMPLE >.
Definition at line 155 of file device_class.hpp.
|
inlineprotectedvirtual |
类请求的 IN 数据阶段在 STATUS OUT 完成后回调 Called after the STATUS OUT completes for a Class IN data request.
| in_isr | 是否在 ISR / Whether in ISR context |
| bRequest | 请求码 / Request code |
Reimplemented in LibXR::USB::DFUClass< Backend, MAX_TRANSFER_SIZE >, and LibXR::USB::DFUClass< DfuBootloaderBackend, 4096u >.
Definition at line 170 of file device_class.hpp.
|
inlineprotectedvirtual |
处理 Class-specific 请求(Setup stage)/ Handle class-specific request (Setup stage)
| in_isr | 是否在 ISR / Whether in ISR context |
| bRequest | 请求码 / Request code |
| wValue | wValue / wValue |
| wLength | wLength / wLength |
| wIndex | wIndex / wIndex |
| result | 输出:控制传输结果 / Output: control transfer result |
Reimplemented in LibXR::USB::CDCBase, LibXR::USB::DFUClass< Backend, MAX_TRANSFER_SIZE >, LibXR::USB::DFUClass< DfuBootloaderBackend, 4096u >, LibXR::USB::DfuRuntimeClass, LibXR::USB::GsUsbClass< CanChNum >, LibXR::USB::HID< REPORT_DESC_LEN, TX_REPORT_LEN, RX_REPORT_LEN >, LibXR::USB::HID< 50, 9, 0 >, LibXR::USB::HID< sizeof(DAPLINK_V1_REPORT_DESC), DapLinkV1Def::MAX_REQUEST_SIZE, DapLinkV1Def::MAX_RESPONSE_SIZE >, LibXR::USB::HID< sizeof(HID_KEYBOARD_REPORT_DESC), 8, 1 >, LibXR::USB::HID< sizeof(HID_MOUSE_REPORT_DESC), 4, 0 >, and LibXR::USB::UAC1MicrophoneQ< CHANNELS, BITS_PER_SAMPLE >.
Definition at line 130 of file device_class.hpp.
|
inlineprotectedvirtual |
处理标准请求 GET_DESCRIPTOR(类特定描述符) Handle standard GET_DESCRIPTOR request (class-specific descriptors).
| in_isr | 是否在 ISR / Whether in ISR context |
| bRequest | 请求码 / Request code |
| wValue | wValue / wValue |
| wLength | wLength / wLength |
| out_data | 输出:返回给主机的描述符数据(Device->Host) Output: descriptor data to return (Device->Host) |
Reimplemented in LibXR::USB::DFUClass< Backend, MAX_TRANSFER_SIZE >, LibXR::USB::DFUClass< DfuBootloaderBackend, 4096u >, LibXR::USB::DfuRuntimeClass, LibXR::USB::HID< REPORT_DESC_LEN, TX_REPORT_LEN, RX_REPORT_LEN >, LibXR::USB::HID< 50, 9, 0 >, LibXR::USB::HID< sizeof(DAPLINK_V1_REPORT_DESC), DapLinkV1Def::MAX_REQUEST_SIZE, DapLinkV1Def::MAX_RESPONSE_SIZE >, LibXR::USB::HID< sizeof(HID_KEYBOARD_REPORT_DESC), 8, 1 >, LibXR::USB::HID< sizeof(HID_MOUSE_REPORT_DESC), 4, 0 >, and LibXR::USB::UAC1MicrophoneQ< CHANNELS, BITS_PER_SAMPLE >.
Definition at line 107 of file device_class.hpp.
|
inlineprotectedvirtual |
处理 Vendor request(Setup stage)/ Handle vendor request (Setup stage)
| in_isr | 是否在 ISR / Whether in ISR context |
| bRequest | 请求码 / Request code |
| wValue | wValue / wValue |
| wLength | wLength / wLength |
| wIndex | wIndex / wIndex |
| result | 输出:控制传输结果 / Output: control transfer result |
Reimplemented in LibXR::USB::DfuBootloaderClassT< MAX_TRANSFER_SIZE >, and LibXR::USB::GsUsbClass< CanChNum >.
Definition at line 187 of file device_class.hpp.
|
private |
Definition at line 27 of file device_class.cpp.
|
friend |
Definition at line 206 of file device_class.hpp.
|
friend |
Definition at line 207 of file device_class.hpp.
|
private |
首个接口字符串索引 / First interface string index
Definition at line 209 of file device_class.hpp.