Files
bds.mr.devmgr/src.devmgr/drv/mr.drv.usb.types.pas
T
2026-01-03 18:53:14 +01:00

153 lines
6.4 KiB
ObjectPascal

unit mr.drv.usb.types;
interface
const
// Standard request codes (btw not used)
CTRL_GET_STATUS = 0;
CTRL_CLEAR_FEATURE = 1;
CTRL_SET_FEATURE = 3;
CTRL_SET_ADDRESS = 5;
CTRL_GET_DESCRIPTOR = 6;
CTRL_SET_DESCRIPTOR = 7;
CTRL_GET_CONFIGURATION = 8;
CTRL_SET_CONFIGURATION = 9;
CTRL_GET_INTERFACE = 10;
CTRL_SET_INTERFACE = 11;
// Descriptor types
DSCR_DEVICE = 1;
DSCR_CONFIGURATION = 2;
DSCR_STRING = 3;
DSCR_INTERFACE = 4;
DSCR_ENDPOINT = 5;
DSCR_DEVICE_QUALIFIER = 6;
DSCR_OTHER_SPEED_CONF = 7;
DSCR_INTERFACE_POWER = 8;
type
// -----------------------------------------------------------------------------------
// USB Device Descriptor
// -----------------------------------------------------------------------------------
PUsbDeviceDescriptor = ^TUsbDeviceDescriptor;
TUsbDeviceDescriptor = packed record
Length : byte; // UCHAR bLength
DescriptorType : byte; // UCHAR bDescriptorType
bcdUSB : word; // USHORT bcdUSB
DeviceClass : byte; // UCHAR bDeviceClass
DeviceSubClass : byte; // UCHAR bDeviceSubClass
DeviceProtocol : byte; // UCHAR bDeviceProtocol
MaxPacketSize0 : byte; // UCHAR bMaxOacketSize0
VendorID : word; // USHORT idVendor
ProductID : word; // USHORT idProduct
DeviceID : word; // USHORT bcdDevice
Manufacturer : byte; // UCHAR iManufacturer
Product : byte; // UCHAR iProduct
SerialNumber : byte; // UCHAR iSerialNumber
ConfigurationCount : byte; // UCHAR bNumConfigurations
end;
// -----------------------------------------------------------------------------------
// USB Configuration Descriptor
// -----------------------------------------------------------------------------------
PUsbConfigurationDescriptor = ^TUsbConfigurationDescriptor;
TUsbConfigurationDescriptor = packed record
Length : byte; // UCHAR bLength
DescriptorType : byte; // UCHAR bDescriptorType
TotalLength : word; // USHORT wTotalLength
InterfaceCount : byte; // UCHAR bNumInterfaces
ConfigurationNumber : byte; // UCHAR Configuration Number
ConfigurationString : byte; // UCHAR Configuration String
Attributes : byte; // UCHAR bmAttributes
MaxPower : byte; // UCHAR MaxPower
end;
// -----------------------------------------------------------------------------------
// USB Interface Descriptor
// -----------------------------------------------------------------------------------
PUsbAlternateSettingDescriptor = ^TUsbAlternateSettingDescriptor;
TUsbAlternateSettingDescriptor = packed record
Length : byte; // UCHAR bLength
DescriptorType : byte; // UCHAR bDescriptorType
InterfaceNumber : byte; // UCHAR bInterfaceNumber
AlternateSetting : byte; // UCHAR bAlternateSetting
EndpointCount : byte; // UCHAR bNumEndPoints
InterfaceClass : byte; // UCHAR bInterfaceClass
InterfaceSubClass : byte; // UCHAR bInterfaceSubClass
InterfaceProtocol : byte; // UCHAR bInterfaceProtocol
InterfaceIndex : byte; // UCHAR iInterface
end;
// -----------------------------------------------------------------------------------
// USB Endpoint Descriptor
// -----------------------------------------------------------------------------------
PUsbEndpointDescriptor = ^TUsbEndpointDescriptor;
TUsbEndpointDescriptor = packed record
Length : byte; // UCHAR bLength
DescriptorType : byte; // UCHAR bDescriptorType
EndpointAddress : byte; // UCHAR bEndpointAddress
Attributes : byte; // UCHAR bmAttributes
MaxPacketSize : word; // USHORT wMaxPacketSize
Interval : byte; // UCHAR bInterval
end;
// -----------------------------------------------------------------------------------
// USB String Descriptor
// -----------------------------------------------------------------------------------
PUsbStringDescriptor = ^TUsbStringDescriptor;
TUsbStringDescriptor = packed record
Length : byte; // UCHAR bLength
DescriptorType : byte; // UCHAR bDescriptorType
Str : array of WideChar; // WCHAR String[1]
end;
// -----------------------------------------------------------------------------------
// USB Transfer Size Info
// -----------------------------------------------------------------------------------
PusbTransferSizeInfo = ^TusbTransferSizeInfo;
TusbTransferSizeInfo = packed record
EndpointAddress : byte;
TransferSize : cardinal;
end;
{$Z4}
TUsbDeviceSpeed = (LowSpeed, FullSpeed, HighSpeed);
TUsbPipeType = (ptControl, ptIsochronous, ptBulk, ptInterrupt);
{$Z1}
// Ez nekem nem teljesen vilagos itt. usb.h ???
PUsbPipeInformation = ^TUsbPipeInformation;
TUsbPipeInformation = record
PipeType : TUsbPipeType;
PipeId : byte;
MaxPacketSize : word;
Interval : byte;
end;
PUsbSetupPacket = ^TUsbSetupPacket;
TUsbSetupPacket = packed record
RequestType : byte;
case Request : byte of
0: (
Value : word;
Index : word;
Length : word;
);
1: (
SetupDat : array [2..7] of byte;
);
end;
type
IUsbDriver = interface
end;
implementation
end.