⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usb_desc.c

📁 ST公司的upsd34XX评估板固定源程序
💻 C
字号:
 /* `=========================================================================`

                    ***************************************
                  ****   *                           *   ****
                                Title: USB_DESC
                             File name: usb_desc.c
                             Project name: USB_DESC
                  ***                                    ****
                    ****************** * ******************
                  ****                                   ****
                              Author: Petr PFEIFER
                           MPG Prague, Czech Republic
                  ****   *                           *   ****
                    ***************************************

                 $Version:  0.019a  Build: April 30, 2004

                 $Version:  0.019   Build: 2004-03-22,15:44:27

 
 
 
 
                                  Description:
                                  ============
                 Version 0.19 String descriptor problem fixed.
                  Since version 0.018 PhysicalReportDesc added
              Since version 0.016, no aux. string constants needed


                          based on USB demo version 7E
                               Author: Jon Moore
                         07/22/02 (JAM) Initial coding.
                    08/30/03 (JAM) Changed to ST vendor ID.


                                     Notes:
                                     ======
                                     -none


                           ..........................
                          .                          .
                          .      ******************  .
                          .     **PPPPPPPPPPPPPPPP   .
                          .     *PPPP*******PP****   .
                          .    **PPP********PP***    .
                          .    ***PPP******PP****    .
                          .   *****PPP****PP****     .
                          .   *****PPP****PP****     .
                          .  PPPPPPPP****PP****  (R) .
                          .                          .
                           ..........................


                                  =-=-=-=-=-=
                           =-=-=-=-=-=-=-=-=-=-=-=-=
                =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

                       Copyright 2004 ST Microelectronics

             This code/file 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.

                =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                           =-=-=-=-=-=-=-=-=-=-=-=-=
                                  =-=-=-=-=-=

                   For current information on uPSD products,
                please consult our pages on the World Wide Web:

                                 www.st.com/psm

                            - - - - - - - - - - - -

                     STMicroelectronics GROUP OF COMPANIES
    Australia - Brazil - China - Czech Republic - Finland - France - Germany
   Hong Kong - India - Italy - Japan - Malaysia - Malta - Morocco - Singapore
             Spain - Sweden - Switzerland - United Kingdom - U.S.A.

                               http://www.st.com


 `========================================================================` */


#pragma NOAREGS


#include "uPSD3200.h"
#include "usb.h"


const uchar code string1Desc[];
const uchar code string2Desc[];
const uchar code string3Desc[];
const uchar code stringXDesc[];



#define REPORT_DESC_LEN sizeof(reportDesc)

const uchar code reportDesc[] =
 {
  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 (Application)
 }
  ;

const uchar code reportDescSize = REPORT_DESC_LEN;





const uchar code PhysicalReportDesc[] =
 {
  0,0,0                                      // no physical descriptor defined now
 }
  ;

const uchar code PhysicalReportDescSize = sizeof(PhysicalReportDesc);





//device_descriptor                          //device_descriptor类型在usb.h中定义
                                            //定义设备描述符变量
const device_descriptor code deviceDesc =
 {
  sizeof(device_descriptor),                 // Size of this Descriptor in Bytes
  DT_DEVICE,                                 // Descriptor Type (=1)
   { 0x10, 0x01 },	      //changed on April 30, 2004
                              // USB Spec Release Number in BCD = 1.10  0x10,0x01
                              //{0x01,0x00},版本号是1.0 usb
                              //{0x10,0x01}是字结构的赋值
  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
  3,                                      // Index of String Desc for SerNo
  1                                       // Number of possible Configurations
 }
  ;

// Copy of HID class descriptor embedded in configDesc below
//HID类描述符,HID类主要的目的是识别HID通信中使用的其他描述符,可以有7个或9个字段
const uchar code hidClassDesc[] =
 {
  9,                                       // Descriptor length
  0x21,                                      // Descriptor type (HID)
                                             //0x21表明是人机接口类Hid;
  0x10,0x01,    		//changed on April 30, 2004     
                                 // HID release (1.10)
                                //这一次没有用到了iword结构
  0,                            // Country code (none)  //硬件不是本地化,字段是0,
  1,                                // Number of HID class descriptors to follow
  0x22,                                      // Report descriptor type (HID)
  REPORT_DESC_LEN, 0                         // Byte length of report descriptor
 }                                         //REPORT_DESC_LEN是设备描述符的总长度,应该是18个字节
  ;

const uchar code hidClassDescSize = sizeof(hidClassDesc);
                               
                               //我固件即设备的配置描述符
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
  25,                                   // <100 mA max power consumption, 2mA steps

                           /*===== Interface =====*/

  9,                                         // Descriptor length
  4,                                         // Descriptor type (interface)
  0,                                         // Number of interface
  0,                                         // Alternate setting
  1,                                         // Number of endpoints (except EP0)

// if you would like to disable EP1, easily write 0 (and 1 back for EP1/display copy refresh enable)
  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)
  0x10,0x01,                //changed on April 30, 2004        // HID release (1.10)
  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)
  100                                        // Polling interval (in msec)
 };


// Language IDs                       //字串描述符
#define SD0LEN 4
const uchar code string0Desc[] =
 {
  SD0LEN, DT_STRING ,                        // Size, Type
  0x09, 0x04                                 // LangID Codes
 }
  ;

// Manufacturer String
#define SD1LEN sizeof("ST Microelectronics")*2
const uchar code string1Desc[] =
  {
  SD1LEN, DT_STRING,                         // Size, Type
  'S', 0,                                    // Unicode String
  '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("DK3200 Evaluation Board")*2
const uchar code string2Desc[] =
 {
  SD2LEN, DT_STRING,                         // Size, Type
  'D', 0,                                    // Unicode String
  'K', 0,
  '3', 0,
  '2', 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
 } ;

// Serial Number String
#define SD3LEN sizeof("S/N:006/2008")*2
const uchar code string3Desc[] =
 {
  SD3LEN, DT_STRING,                         // Size, Type
  'S', 0,                                    // Unicode String
  '/', 0,
  'N', 0,
  ':', 0,
  '0', 0,
  '0', 0,
  '6', 0,
  '/', 0,
  '2', 0,
  '0', 0,
  '0', 0,
  '8', 0,
 };

const uchar code stringXDesc[2] =
 {
  2, 0,                                      // Size, Type
 };

// Table of String Descriptors
const uchar *  const code stringDescTable[] =
 {
  string0Desc,
  string1Desc,
  string2Desc,
  string3Desc,
  stringXDesc                                //no string
 } ;

/* *************************************************************************
  ***                                                                      ***
  **                         *** End of File ***                            **
  ***                                                                      ***
*************************************************************************  */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -