Пт окт 05, 2018 18:42:04
case USB_REQ_SET_CONFIGURATION:
USBD_SetConfig (pdev , req);
break;
//******************************************* Configuration descriptor ********************************************
#define USB_CUSTOM_HID_CONFIG_DESC_SIZE 59
__ALIGN_BEGIN static uint8_t configuration_descriptor[USB_CUSTOM_HID_CONFIG_DESC_SIZE] __ALIGN_END =
{
// bLength: Configuration Descriptor size
0x09,
// bDescriptorType: Configuration
USB_DESC_TYPE_CONFIGURATION,
// wTotalLength: Bytes returned
USB_CUSTOM_HID_CONFIG_DESC_SIZE, 0x00,
//bNumInterfaces: USBD_MAX_NUM_INTERFACES interfaces
USBD_MAX_NUM_INTERFACES,
//bConfigurationValue: Configuration value
0x01,
//iConfiguration: Index of string descriptor describing the configuration
0x00,
//bmAttributes: bus powered //DKOS check need
0xC0,
//MaxPower 100 mA
0x32,
//*********************** Iface 1 *************************
//************** Descriptor of interface ****************
//Offset 0x09(9)
//bLength: Interface Descriptor size
0x09,
//bDescriptorType: Interface descriptor type
USB_DESC_TYPE_INTERFACE,
//bInterfaceNumber: Number of Interface
0x00,
//bAlternateSetting: Alternate setting
0x00,
//bNumEndpoints
0x01,
//bInterfaceClass: HID
0x03,
//bInterfaceSubClass : 1=BOOT, 0=no boot
0x00,
//nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse
0x00,
//iInterface: Index of string descriptor
0,
//******************** Descriptor of hid ********************
//Offset 0x12(18)
//bLength: HID Descriptor size
0x09,
//bDescriptorType: HID
HID_DESCRIPTOR_TYPE,
//bcdHID: HID Class Spec release number //DKOS check need
0x00,
//bCountryCode: Hardware target country
0x01, 0x00,
//bNumDescriptors: Number of HID class descriptors to follow
0x01,
//bDescriptorType
0x22,
//wItemLength: Total length of Report descriptor
GAMEPAD_REPORT_DESC_SIZE, 0x00,
//******************* Descriptor of endpoints ***********
//Offset 0x1b(27)
//bLength: Endpoint Descriptor size
0x07,
//bDescriptorType:
USB_DESC_TYPE_ENDPOINT,
//bEndpointAddress: Endpoint Address (IN)
GAMEPAD1_EP_IN_ADDR,
//bmAttributes: Interrupt endpoint
0x03,
//wMaxPacketSize: 4 Byte max/
GAMEPAD_EPIN_SIZE,
//bInterval: Polling Interval (10 ms)
0x00, 10,
//*********************** Iface 2 *************************
//************** Descriptor of interface ****************
//Offset 0x22(34)
//bLength: Interface Descriptor size
0x09,
//bDescriptorType: Interface descriptor type
USB_DESC_TYPE_INTERFACE,
//bInterfaceNumber: Number of Interface
0x01,
//bAlternateSetting: Alternate setting
0x00,
//bNumEndpoints
0x01,
//bInterfaceClass: HID
0x03,
//bInterfaceSubClass : 1=BOOT, 0=no boot
0x00,
//nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse
0x00,
//iInterface: Index of string descriptor
0,
//******************** Descriptor of hid ********************
//Offset 0x2b(43)
//bLength: HID Descriptor size
0x09,
//bDescriptorType: HID
HID_DESCRIPTOR_TYPE,
//bcdHID: HID Class Spec release number //DKOS check need
0x00,
//bCountryCode: Hardware target country
0x01, 0x00,
//bNumDescriptors: Number of HID class descriptors to follow
0x01,
//bDescriptorType
0x22,
//wItemLength: Total length of Report descriptor
GAMEPAD_REPORT_DESC_SIZE, 0x00,
//******************* Descriptor of endpoints ***********
//Offset 0x34(52)
//bLength: Endpoint Descriptor size
0x07,
//bDescriptorType:
USB_DESC_TYPE_ENDPOINT,
//bEndpointAddress: Endpoint Address (IN)
GAMEPAD2_EP_IN_ADDR,
//bmAttributes: Interrupt endpoint
0x03,
//wMaxPacketSize: 4 Byte max/
GAMEPAD_EPIN_SIZE,
//bInterval: Polling Interval (10 ms)
0x00, 10,
//Offset 0x3b(59)
};
Сб окт 06, 2018 09:38:57