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

📄 usbdesc.c

📁 用keil开发的.单片机税控器程序.单片机用的是AT公司的.upsd3245
💻 C
字号:
/*
* Copyright (c) 2004,成都港顺科技发展有限公司
* All rights reserved.
*
* 编 译 器:Keil:C Compiler:7.20;Assembler:7.10
* 工程名称:POS-Test.UV2
* 文件名称:USB_DESC.C
* 摘    要:USB与PC通讯
* 
* 单 片 机:uPSD3254 
* 当前版本:0.4
* 作    者:林云
* 完成日期:2004-12-7 14:45
*/

#pragma NOAREGS


#include "Main.h"
#include "Usb.h"
//-------------------
#define USB_clk_in  6000                     // Khz,USB clock input, DO NOT CHANGE//2004-08-02

const uchar code cUSCL_value = (uchar)((((OSC*10L/2L)/(USB_clk_in*1000L))+5)/10) - 1;//2004-08-02
//--------------------

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);






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
  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

const uchar code 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
 }
  ;

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:001/2004")*2
const uchar code string3Desc[] =
 {
  SD3LEN, DT_STRING,                         // Size, Type
  'S', 0,                                    // Unicode String
  '/', 0,
  'N', 0,
  ':', 0,
  '0', 0,
  '0', 0,
  '1', 0,
  '/', 0,
  '2', 0,
  '0', 0,
  '0', 0,
  '4', 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 + -