📄 usb_desc.c
字号:
/*
* File: usb_desc.c
* Purpose: Descriptors for USB Test
*/
#include "src/common/common.h"
#include "usb.h"
/********************************************************************/
/********************************************************************/
/* Initialize the Mouse descriptors */
DESCRIPTOR_STRUCT Descriptors =
{
/* Device Descriptor */
{
/* bLength */ sizeof(USB_DEVICE_DESC),
/* bDescriptorType */ DEVICE,
/* bcdUSBL */ 0x10, /* USB 1.1 */
/* bcdUSBH */ 0x01,
/* bDeviceClass */ 0x00,
/* bDeviceSubClass */ 0x00,
/* bDeviceProtocol */ 0x00,
/* bMaxPacketSize0 */ 0x08,
/* idVendorL */ 0x25,
/* idVendorH */ 0x04, /* arbitrary */
/* idProductL */ 0x34,
/* idProductH */ 0x33, /* arbitrary */
/* bcdDeviceL */ 0x00,
/* bcdDeviceH */ 0x01, /* arbitrary */
/* iManufacturern */ 0x01,
/* iProduct */ 0x02,
/* iSerialNumber */ 0x00,
/* bNumConfigurations */ 0x01
},
/* Configuration Descriptor */
{
/* bLength */ sizeof(USB_CONFIG_DESC),
/* bDescriptorType */ CONFIGURATION,
/* wTotalLengthL */ (sizeof(USB_CONFIG_DESC)+(sizeof(USB_INTERFACE_DESC)*2)+(sizeof(USB_ENDPOINT_DESC)*5)) & 0x00FF,
/* wTotalLengthH */ (sizeof(USB_CONFIG_DESC)+(sizeof(USB_INTERFACE_DESC)*2)+(sizeof(USB_ENDPOINT_DESC)*5)) >> 8,
/* bNumInterfaces */ 0x01,
/* bConfigurationValue */ 0x01, /* This is configuration #1 */
/* iConfiguration */ 0x00,
/* bmAttributes */ (SELF_POWERED),
/* maxPower */ 0x00
},
/* Interface Descriptor */
{
/* bLength */ sizeof(USB_INTERFACE_DESC),
/* bDescriptorType */ INTERFACE,
/* bInterfaceNumber */ 0x00, /* This is interface #0 */
/* bAlternateSetting */ 0x00, /* This is alt interface #0 */
/* bNumEndpoints */ 0x03,
/* bInterfaceClass */ 0x00,
/* bInterfaceSubClass */ 0x00,
/* bInterfaceProtocol */ 0x00,
/* iInterface */ 0x00
},
/* Endpoint1 Descriptor */
{
/* bLength */ sizeof(USB_ENDPOINT_DESC),
/* bDescriptorType */ ENDPOINT,
/* bEndpointAddress */ (1 | IN), /* This is endpoint #1 */
/* bmAttributes */ (BULK),
/* wMaxPacketSizeL */ 0x20,
/* wMaxPacketSizeH */ 0x00,
/* bInterval */ 0x00
},
/* Endpoint2 Descriptor */
{
/* bLength */ sizeof(USB_ENDPOINT_DESC),
/* bDescriptorType */ ENDPOINT,
/* bEndpointAddress */ (2 | OUT), /* This is endpoint #2 */
/* bmAttributes */ (BULK),
/* wMaxPacketSizeL */ 0x20,
/* wMaxPacketSizeH */ 0x00,
/* bInterval */ 0x00
},
/* Endpoint3 Descriptor */
{
/* bLength */ sizeof(USB_ENDPOINT_DESC),
/* bDescriptorType */ ENDPOINT,
/* bEndpointAddress */ (3 | OUT), /* This is endpoint #3 */
/* bmAttributes */ (BULK),
/* wMaxPacketSizeL */ 0x20,
/* wMaxPacketSizeH */ 0x00,
/* bInterval */ 0x00
},
/* Alternate Interface Descriptor */
{
/* bLength */ sizeof(USB_INTERFACE_DESC),
/* bDescriptorType */ INTERFACE,
/* bInterfaceNumber */ 0x00, /* This is interface #0 */
/* bAlternateSetting */ 0x01, /* This is alt interface #0 */
/* bNumEndpoints */ 0x02,
/* bInterfaceClass */ 0x00,
/* bInterfaceSubClass */ 0x00,
/* bInterfaceProtocol */ 0x00,
/* iInterface */ 0x00
},
/* Endpoint1 Descriptor */
{
/* bLength */ sizeof(USB_ENDPOINT_DESC),
/* bDescriptorType */ ENDPOINT,
/* bEndpointAddress */ (1 | IN), /* This is endpoint #1 */
/* bmAttributes */ (BULK),
/* wMaxPacketSizeL */ 0x20,
/* wMaxPacketSizeH */ 0x00,
/* bInterval */ 0x00
},
/* Endpoint2 Descriptor */
{
/* bLength */ sizeof(USB_ENDPOINT_DESC),
/* bDescriptorType */ ENDPOINT,
/* bEndpointAddress */ (2 | OUT), /* This is endpoint #2 */
/* bmAttributes */ (BULK),
/* wMaxPacketSizeL */ 0x20,
/* wMaxPacketSizeH */ 0x00,
/* bInterval */ 0x00
}
};
/********************************************************************/
// String descriptors
/********************************************************************/
// Language IDs
//--------------
const unsigned char String0Desc[SD0LEN] = {
SD0LEN, DT_STRING, /* Size, Type */
0x09, 0x04 /* LangID Codes */
};
//--------------------------------------------
const unsigned char String1Desc[SD1LEN] = {
// Size, Type
SD1LEN, DT_STRING,
// Unicode String
'F', 0,
'r', 0,
'e', 0,
'e', 0,
's', 0,
'c', 0,
'a', 0,
'l', 0,
'e', 0,
' ', 0,
'S', 0,
'e', 0,
'm', 0,
'i', 0,
'c', 0,
'o', 0,
'n', 0,
'd', 0,
'u', 0,
'c', 0,
't', 0,
'o', 0,
'r', 0
};
// Product String
//-----------------------------------------------
const unsigned char String2Desc[SD2LEN] = {
// Size, Type
SD2LEN, DT_STRING,
// Unicode String
'M', 0,
'C', 0,
'F', 0,
'5', 0,
'2', 0,
'7', 0,
'5', 0
};
/********************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -