2019-10-31 18:00:42 +00:00
|
|
|
#pragma once
|
2019-11-13 11:16:13 +00:00
|
|
|
#include "Result.h"
|
2019-10-31 18:00:42 +00:00
|
|
|
#include "IUSBEndpoint.h"
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
class IUSBInterface
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
public:
|
|
|
|
struct InterfaceDescriptor
|
|
|
|
{
|
|
|
|
uint8_t bLength;
|
|
|
|
uint8_t bDescriptorType; ///< Must match USB_DT_INTERFACE.
|
|
|
|
uint8_t bInterfaceNumber; ///< See also USBDS_DEFAULT_InterfaceNumber.
|
|
|
|
uint8_t bAlternateSetting; ///< Must match 0.
|
|
|
|
uint8_t bNumEndpoints;
|
|
|
|
uint8_t bInterfaceClass;
|
|
|
|
uint8_t bInterfaceSubClass;
|
|
|
|
uint8_t bInterfaceProtocol;
|
|
|
|
uint8_t iInterface; ///< Ignored.
|
|
|
|
};
|
|
|
|
virtual ~IUSBInterface() = default;
|
|
|
|
|
2019-11-13 11:16:13 +00:00
|
|
|
virtual Result Open() = 0;
|
2019-10-31 18:00:42 +00:00
|
|
|
virtual void Close() = 0;
|
|
|
|
|
2024-11-06 19:00:07 +00:00
|
|
|
virtual Result ControlTransfer(uint8_t bmRequestType, uint8_t bmRequest, uint16_t wValue, uint16_t wIndex, uint16_t wLength, void* buffer) = 0;
|
|
|
|
virtual Result ControlTransfer(uint8_t bmRequestType, uint8_t bmRequest, uint16_t wValue, uint16_t wIndex, uint16_t wLength, const void* buffer) = 0;
|
2019-11-04 12:32:43 +00:00
|
|
|
|
2024-11-06 19:00:07 +00:00
|
|
|
virtual IUSBEndpoint* GetEndpoint(IUSBEndpoint::Direction direction, uint8_t index) = 0;
|
|
|
|
virtual InterfaceDescriptor* GetDescriptor() = 0;
|
2019-10-31 18:00:42 +00:00
|
|
|
|
2019-11-13 11:16:13 +00:00
|
|
|
virtual Result Reset() = 0;
|
2019-10-31 18:00:42 +00:00
|
|
|
};
|