📄 usbdesc.c
字号:
/*----------------------------------------------------------------------------
* U S B - K e r n e l
*----------------------------------------------------------------------------
* Name: usbdesc.c
* Purpose: USB Descriptors
* Version: V1.20
* Note(s):
*----------------------------------------------------------------------------
* This file is part of the uVision/ARM development tools.
* This software may only be used under the terms of a valid, current,
* end user licence from KEIL for a compatible version of KEIL software
* development tools. Nothing else gives you the right to use this software.
*
* This software is supplied "AS IS" without warranties of any kind.
*
* Copyright (c) 2008 Keil - An ARM Company. All rights reserved.
*----------------------------------------------------------------------------
* History:
* V1.00 Initial Version
* V1.10
* V1.20 simplified HID Report Descriptor
*----------------------------------------------------------------------------*/
#include "type.h"
#include "usb.h"
#include "hid.h"
#include "usbcfg.h"
#include "usbdesc.h"
/*------------------------------------------------------------------------------
HID Report Descriptor
*------------------------------------------------------------------------------*/
/* Bit Input Output
0 Button0 LED0
1 Button1 LED1
2 Button2 LED2
3 Button3 LED3
4 --- ---
5 --- ---
6 --- ---
7 --- ---
*/
#define HID_INPUT_REPORT_BYTES 1 /* size of report in Bytes */
#define HID_OUTPUT_REPORT_BYTES 1 /* size of report in Bytes */
#define HID_FEATURE_REPORT_BYTES 1 /* size of report in Bytes */
const BYTE HID_ReportDescriptor[] = {
HID_UsagePageVendor( 0x00 ),
HID_Usage ( 0x01 ),
HID_Collection ( HID_Application ),
HID_LogicalMin ( 0 ), /* value range: 0 - 0xFF */
HID_LogicalMaxS ( 0xFF ),
HID_ReportSize ( 8 ), /* 8 bits */
HID_ReportCount ( HID_INPUT_REPORT_BYTES ),
HID_Usage ( 0x01 ),
HID_Input ( HID_Data | HID_Variable | HID_Absolute ),
HID_ReportCount ( HID_OUTPUT_REPORT_BYTES ),
HID_Usage ( 0x01 ),
HID_Output ( HID_Data | HID_Variable | HID_Absolute ),
HID_ReportCount ( HID_FEATURE_REPORT_BYTES ),
HID_Usage ( 0x01 ),
HID_Feature ( HID_Data | HID_Variable | HID_Absolute ),
HID_EndCollection,
};
const WORD HID_ReportDescSize = sizeof(HID_ReportDescriptor);
/* USB Standard Device Descriptor */
const BYTE USB_DeviceDescriptor[] = {
USB_DEVICE_DESC_SIZE, /* bLength */
USB_DEVICE_DESCRIPTOR_TYPE, /* bDescriptorType */
WBVAL(0x0110), /* 1.10 */ /* bcdUSB */
0x00, /* bDeviceClass */
0x00, /* bDeviceSubClass */
0x00, /* bDeviceProtocol */
USB_MAX_PACKET0, /* bMaxPacketSize0 */
WBVAL(0x04CC), /* idVendor */
WBVAL(0x1D06), /* idProduct */
WBVAL(0x0100), /* 1.00 */ /* bcdDevice */
0x04, /* iManufacturer */
0x2A, /* iProduct */
0x4C, /* iSerialNumber */
0x01 /* bNumConfigurations */
};
/* USB Configuration Descriptor */
/* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
const BYTE USB_ConfigDescriptor[] = {
/* Configuration 1 */
USB_CONFIGUARTION_DESC_SIZE, /* bDescriptorType */
USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */
WBVAL( /* wTotalLength */
USB_CONFIGUARTION_DESC_SIZE +
USB_INTERFACE_DESC_SIZE +
HID_DESC_SIZE +
USB_ENDPOINT_DESC_SIZE
),
0x01, /* bNumInterfaces */
0x01, /* bConfigurationValue */
0x00, /* iConfiguration */
USB_CONFIG_BUS_POWERED /*|*/ /* bmAttributes */
/*USB_CONFIG_REMOTE_WAKEUP*/,
USB_CONFIG_POWER_MA(100), /* bMaxPower */
/* Interface 0, Alternate Setting 0, HID Class */
USB_INTERFACE_DESC_SIZE, /* bLength */
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
0x00, /* bInterfaceNumber */
0x00, /* bAlternateSetting */
0x01, /* bNumEndpoints */
USB_DEVICE_CLASS_HUMAN_INTERFACE, /* bInterfaceClass */
HID_SUBCLASS_NONE, /* bInterfaceSubClass */
HID_PROTOCOL_NONE, /* bInterfaceProtocol */
0x6A, /* iInterface */
/* HID Class Descriptor */
/* HID_DESC_OFFSET = 0x0012 */
HID_DESC_SIZE, /* bLength */
HID_HID_DESCRIPTOR_TYPE, /* bDescriptorType */
WBVAL(0x0100), /* 1.00 */ /* bcdHID */
0x00, /* bCountryCode */
0x01, /* bNumDescriptors */
HID_REPORT_DESCRIPTOR_TYPE, /* bDescriptorType */
WBVAL(HID_REPORT_DESC_SIZE), /* wDescriptorLength */
/* Endpoint, HID Interrupt In */
USB_ENDPOINT_DESC_SIZE, /* bLength */
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */
USB_ENDPOINT_IN(1), /* bEndpointAddress */
USB_ENDPOINT_TYPE_INTERRUPT, /* bmAttributes */
WBVAL(0x0004), /* wMaxPacketSize */
0x20, /* 32ms */ /* bInterval */
/* Terminator */
0 /* bLength */
};
/* USB String Descriptor (optional) */
const BYTE USB_StringDescriptor[] = {
/* Index 0x00: LANGID Codes */
0x04, /* bLength */
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
WBVAL(0x0409), /* US English */ /* wLANGID */
/* Index 0x04: Manufacturer */
0x26, /* bLength */
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
'N',0,
'X',0,
'P',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,
's',0,
/* Index 0x2A: Product */
0x22, /* bLength */
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
'L',0,
'P',0,
'C',0,
'2',0,
'4',0,
'6',0,
'8',0,
' ',0,
'H',0,
'I',0,
'D',0,
' ',0,
'D',0,
'e',0,
'm',0,
'o',0,
/* Index 0x4C: Serial Number */
0x1E, /* bLength */
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
'U',0,
'S',0,
'B',0,
' ',0,
'B',0,
'o',0,
'o',0,
't',0,
'l',0,
'a',0,
'a',0,
'd',0,
'e',0,
'r',0,
/* Index 0x6A: Interface 0, Alternate Setting 0 */
0x08, /* bLength */
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
'I',0,
'R',0,
'D',0,
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -