📄 usb_desc.c
字号:
/////////////////////////////////////////////////////////////////////////////
// usb_desc.c
//
// USB descriptors.
//
// Author: Jon Moore
//
// Revision History:
//
// 07/22/02 (JAM) Initial coding.
// 08/30/03 (JAM) Changed to ST vendor ID.
/*---------------------------------------------------------------------------
Copyright (c) 2002 ST Microelectronics
This example demo code is provided as is and has no warranty,
implied or otherwise. You are free to use/modify any of the provided
code at your own risk in your applications with the expressed limitation
of liability (see below) so long as your product using the code contains
at least one uPSD products (device).
LIMITATION OF LIABILITY: NEITHER STMicroelectronics NOR ITS VENDORS OR
AGENTS SHALL BE LIABLE FOR ANY LOSS OF PROFITS, LOSS OF USE, LOSS OF DATA,
INTERRUPTION OF BUSINESS, NOR FOR INDIRECT, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES OF ANY KIND WHETHER UNDER THIS AGREEMENT OR
OTHERWISE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
--------------------------------------------------------------------------*/
#include "general.h"
#include "usb.h"
#define REPORT_DESC_LEN 46
const device_descriptor code deviceDesc =
{
sizeof(device_descriptor), // Size of this Descriptor in Bytes
DT_DEVICE, // Descriptor Type (=1)
{0x10, 0x01}, // USB Spec Release Number in BCD = 1.10
0, // Device Class Code (none)
0, // Device Subclass Code (none)
0, // Device Protocol Code (none)
8, // Maximum Packet Size for EP0
{0x83, 0x04}, // Vendor ID
{0x00, 0x00}, // Product ID
{0x00, 0x01}, // Device Release Number in BCD
1, // Index of String Desc for Manufacturer
2, // Index of String Desc for Product
0, // Index of String Desc for SerNo
1 // Number of possible Configurations
};
// Copy of HID class descriptor embedded in configDesc below
const uchar code hidClassDescSize = 9;
const uchar code hidClassDesc[] =
{
9, // Descriptor length
0x21, // Descriptor type (HID)
0, 1, // HID release (1.0)
0, // Country code (none)
1, // Number of HID class descriptors to follow
0x22, // Report descriptor type (HID)
REPORT_DESC_LEN, 0 // Byte length of report descriptor
};
const uchar code configDesc[] =
{
9, // Configuration descriptor length
2, // Descriptor type (configuration)
34, 0, // Total length of this descriptor
1, // Number of interfaces
1, // Configuration value
0, // Index of string descriptor (none)
0xC0, // Self powered, no remote wakeup
250, // 250 mA max power consumption
// Interface
9, // Descriptor length
4, // Descriptor type (interface)
0, // Number of interface
0, // Alternate setting
1, // Number of endpoints
3, // Class code (HID)
0, // Subclass (none)
0, // Protocol (none)
0, // Index of string descriptor (none)
// HID class descriptor (copy of hidClassDesc)
9, // Descriptor length
0x21, // Descriptor type (HID)
0, 1, // HID release (1.0)
0, // Country code (none)
1, // Number of HID class descriptors to follow
0x22, // Report descriptor type (HID)
REPORT_DESC_LEN, 0, // Byte length of report descriptor
// Endpoint descriptor
7, // Descriptor length (7 bytes)
5, // Descriptor type (endpoint)
0x81, // Address (IN1)
3, // Attributes (interrupt)
8, 0, // Maximum packet size (8 bytes)
10 // Polling interval (10 msec)
};
const uchar code reportDescSize = REPORT_DESC_LEN;
const uchar code reportDesc[REPORT_DESC_LEN] =
{
0x06, 0xA0, 0xFF, // Usage page (vendor defined)
0x09, 0xA5, // Usage (vendor defined)
0xA1, 0x01, // Collection (application)
0x09, 0xA6, // Usage (vendor defined)
// Feature report
0x09, 0xA5, // Usage (vendor defined)
0x15, 0x80, // Logical min (-127)
0x25, 0x7F, // Logical max (128)
0x75, 0x08, // Report size (8 bits)
0x95, 0x40, // Report count (64 bytes)
0xB1, 0x02, // Feature (data, variable, absolute)
// Input report
0x09, 0xA7, // Usage (vendor defined)
0x15, 0x80, // Logical min (-127)
0x25, 0x7F, // Logical max (128)
0x75, 0x08, // Report size (8 bits)
0x95, 0x08, // Report count (8 bytes)
0x81, 0x02, // Input (data, variable, absolute)
// Output report
0x09, 0xA9, // Usage (vendor defined)
0x15, 0x80, // Logical min (-127)
0x25, 0x7F, // Logical max (128)
0x75, 0x08, // Report size (8 bits)
0x95, 0x40, // Report count (64 bytes)
0x91, 0x02, // Output (data, variable, absolute)
0xC0 // End collection
};
// Language IDs
//--------------
#define SD0LEN 4
//--------------
const uchar code string0Desc[SD0LEN] =
{
// Size, Type
SD0LEN, DT_STRING,
// LangID Codes
0x09, 0x04
};
// Manufacturer String
//--------------------------------------------
#define SD1LEN sizeof("ST Microelectronics")*2
//--------------------------------------------
const uchar code string1Desc[SD1LEN] = {
// Size, Type
SD1LEN, DT_STRING,
// Unicode String
'S', 0,
'T', 0,
' ', 0,
'M', 0,
'i', 0,
'c', 0,
'r', 0,
'o', 0,
'e', 0,
'l', 0,
'e', 0,
'c', 0,
't', 0,
'r', 0,
'o', 0,
'n', 0,
'i', 0,
'c', 0,
's', 0
};
// Product String
//-----------------------------------------------
#define SD2LEN sizeof("DK3000 Evaluation Board")*2
//-----------------------------------------------
const uchar code string2Desc[SD2LEN] =
{
// Size, Type
SD2LEN, DT_STRING,
// Unicode String
'D', 0,
'K', 0,
'3', 0,
'0', 0,
'0', 0,
'0', 0,
' ', 0,
'E', 0,
'v', 0,
'a', 0,
'l', 0,
'u', 0,
'a', 0,
't', 0,
'i', 0,
'o', 0,
'n', 0,
' ', 0,
'B', 0,
'o', 0,
'a', 0,
'r', 0,
'd', 0
};
// Table of String Descriptors
//
const uchar * const code stringDescTable[] =
{
string0Desc,
string1Desc,
string2Desc
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -