// usb_desc.c
#include "usb_desc.h"
// USB标准描述符
const uint8_t USB_DeviceDescriptor[] = {
// Device Descriptor
0x12, // bLength
USB_DESC_TYPE_DEVICE, // bDescriptorType
0x00, 0x02, // bcdUSB (USB 2.0)
0x00, // bDeviceClass
0x00, // bDeviceSubClass
0x00, // bDeviceProtocol
USB_MAX_EP0_SIZE, // bMaxPacketSize0
LOBYTE(VENDOR_ID), // idVendor
HIBYTE(VENDOR_ID), // idVendor
LOBYTE(PRODUCT_ID), // idProduct
HIBYTE(PRODUCT_ID), // idProduct
0x00, 0x01, // bcdDevice (v1.00)
1, // Index of manufacturer string descriptor
2, // Index of product string descriptor
3, // Index of serial number string descriptor
0x01 // bNumConfigurations
};
// HID和MSC接口描述符定义
const uint8_t USB_ConfigDescriptor[] = {
// Configuration Descriptor
0x09, // bLength
USB_DESC_TYPE_CONFIG, // bDescriptorType
USB_DESC_LEN_CONFIG, // wTotalLength (to be defined)
0x00, // bNumInterfaces
0x01, // bConfigurationValue
0x00, // iConfiguration
0x80, // bmAttributes
USB_MAX_POWER, // bMaxPower
// HID Interface Descriptor
0x09, // bLength
USB_DESC_TYPE_INTERFACE,// bDescriptorType
0x00, // bInterfaceNumber
0x00, // bAlternateSetting
0x01, // bNumEndpoints
0x03, // bInterfaceClass (HID)
0x01, // bInterfaceSubClass
0x01, // bInterfaceProtocol
0x00, // iInterface
// HID Descriptor
0x09, // bLength
HID_DESCRIPTOR_TYPE, // bDescriptorType
0x11, 0x01, // bcdHID
0x00, // bCountryCode
0x01, // bNumDescriptors
0x22, // bDescriptorType
sizeof(HID_ReportDescriptor), 0x00, // wDescriptorLength
// Endpoint Descriptor
0x07, // bLength
USB_DESC_TYPE_ENDPOINT, // bDescriptorType
HID_EP_IN, // bEndpointAddress
0x03, // bmAttributes (Interrupt)
LOBYTE(HID_EP_SIZE), // wMaxPacketSize
HIBYTE(HID_EP_SIZE), // wMaxPacketSize
0x0A, // bInterval
// MSC Interface Descriptor
0x09, // bLength
USB_DESC_TYPE_INTERFACE,// bDescriptorType
0x01, // bInterfaceNumber
0x00, // bAlternateSetting
0x02, // bNumEndpoints
0x08, // bInterfaceClass (Mass Storage)
0x06, // bInterfaceSubClass
0x50, // bInterfaceProtocol
0x00, // iInterface
// Bulk IN Endpoint Descriptor
0x07, // bLength
USB_DESC_TYPE_ENDPOINT, // bDescriptorType
MSC_EP_IN, // bEndpointAddress
0x02, // bmAttributes (Bulk)
LOBYTE(MSC_EP_SIZE), // wMaxPacketSize
HIBYTE(MSC_EP_SIZE), // wMaxPacketSize
0x00, // bInterval
// Bulk OUT Endpoint Descriptor
0x07, // bLength
USB_DESC_TYPE_ENDPOINT, // bDescriptorType
MSC_EP_OUT, // bEndpointAddress
0x02, // bmAttributes (Bulk)
LOBYTE(MSC_EP_SIZE), // wMaxPacketSize
HIBYTE(MSC_EP_SIZE), // wMaxPacketSize
0x00 // bInterval
};
// HID报告描述符
const uint8_t HID_ReportDescriptor[] = {
// Your HID report descriptor here
};
|