• Main Page
  • Data Structures
  • Files
  • File List
  • Globals

descriptors.c

Go to the documentation of this file.
00001 //******************************************************************************
00002 //THIS PROGRAM IS PROVIDED "AS IS". TI MAKES NO WARRANTIES OR
00003 //REPRESENTATIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
00004 //INCLUDING ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
00005 //FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR
00006 //COMPLETENESS OF RESPONSES, RESULTS AND LACK OF NEGLIGENCE.
00007 //TI DISCLAIMS ANY WARRANTY OF TITLE, QUIET ENJOYMENT, QUIET
00008 //POSSESSION, AND NON-INFRINGEMENT OF ANY THIRD PARTY
00009 //INTELLECTUAL PROPERTY RIGHTS WITH REGARD TO THE PROGRAM OR
00010 //YOUR USE OF THE PROGRAM.
00011 //
00012 //IN NO EVENT SHALL TI BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
00013 //CONSEQUENTIAL OR INDIRECT DAMAGES, HOWEVER CAUSED, ON ANY
00014 //THEORY OF LIABILITY AND WHETHER OR NOT TI HAS BEEN ADVISED
00015 //OF THE POSSIBILITY OF SUCH DAMAGES, ARISING IN ANY WAY OUT
00016 //OF THIS AGREEMENT, THE PROGRAM, OR YOUR USE OF THE PROGRAM.
00017 //EXCLUDED DAMAGES INCLUDE, BUT ARE NOT LIMITED TO, COST OF
00018 //REMOVAL OR REINSTALLATION, COMPUTER TIME, LABOR COSTS, LOSS
00019 //OF GOODWILL, LOSS OF PROFITS, LOSS OF SAVINGS, OR LOSS OF
00020 //USE OR INTERRUPTION OF BUSINESS. IN NO EVENT WILL TI'S
00021 //AGGREGATE LIABILITY UNDER THIS AGREEMENT OR ARISING OUT OF
00022 //YOUR USE OF THE PROGRAM EXCEED FIVE HUNDRED DOLLARS
00023 //(U.S.$500).
00024 //
00025 //Unless otherwise stated, the Program written and copyrighted
00026 //by Texas Instruments is distributed as "freeware".  You may,
00027 //only under TI's copyright in the Program, use and modify the
00028 //Program without any charge or restriction.  You may
00029 //distribute to third parties, provided that you transfer a
00030 //copy of this license to the third party and the third party
00031 //agrees to these terms by its first use of the Program. You
00032 //must reproduce the copyright notice and any other legend of
00033 //ownership on each copy or partial copy, of the Program.
00034 //
00035 //You acknowledge and agree that the Program contains
00036 //copyrighted material, trade secrets and other TI proprietary
00037 //information and is protected by copyright laws,
00038 //international copyright treaties, and trade secret laws, as
00039 //well as other intellectual property laws.  To protect TI's
00040 //rights in the Program, you agree not to decompile, reverse
00041 //engineer, disassemble or otherwise translate any object code
00042 //versions of the Program to a human-readable form.  You agree
00043 //that in no event will you alter, remove or destroy any
00044 //copyright notice included in the Program.  TI reserves all
00045 //rights not specifically granted under this license. Except
00046 //as specifically provided herein, nothing in this agreement
00047 //shall be construed as conferring by implication, estoppel,
00048 //or otherwise, upon you, any license or other right under any
00049 //TI patents, copyrights or trade secrets.
00050 // 
00051 //You may not use the Program in non-TI devices.
00064 // (c)2009 by Texas Instruments Incorporated, All Rights Reserved.
00065 /*----------------------------------------------------------------------------+
00066 |                                                                             |
00067 |                              Texas Instruments                              |
00068 |                                                                             |
00069 |                          MSP430 USB-Example (CDC/HID Driver)                |
00070 |                                                                             |
00071 +-----------------------------------------------------------------------------+
00072 |  Source: Descriptors.c, v1.18 2009/06/11                                    |
00073 |  Author: RSTO                                                               |
00074 |                                                                             |
00075 |  WHO          WHEN         WHAT                                             |
00076 |  ---          ----------   ------------------------------------------------ |
00077 |  RSTO         2008/09/03   born                                             |
00078 |  RSTO         2008/12/23   enhancements of CDC API                          |
00079 |  RSTO         2009/01/12   enhancements for USB serial number               |
00080 |  RSTO         2009/03/01   added HID descriptors                            |
00081 |  RSTO         2009/05/25   put all config constants into this file          |
00082 +----------------------------------------------------------------------------*/
00083 
00084 /*----------------------------------------------------------------------------+
00085 | Include files                                                               |
00086 +----------------------------------------------------------------------------*/
00087 
00088 #include "MSP430.h"
00089 #include "..\Common\types.h"              // Basic Type declarations
00090 #include "..\USB_Common\defMSP430USB.h"
00091 #include "..\USB_Common\usb.h"            // USB-specific Data Structures
00092 #include "..\USB_Common\descriptors.h"
00093 #include "..\USB_CDC_API\UsbCdc.h"
00094 
00095 /*----------------------------------------------------------------------------+
00096 | Internal Type Definition & Macro                                            |
00097 +----------------------------------------------------------------------------*/
00098 
00099 
00100 BYTE const abromDeviceDescriptor[SIZEOF_DEVICE_DESCRIPTOR] = {
00101     SIZEOF_DEVICE_DESCRIPTOR,       // Length of this descriptor (12h bytes)
00102     DESC_TYPE_DEVICE,               // Type code of this descriptor (01h)
00103     0x00,0x02,                      // Release of USB spec (Rev 2.0)
00104     0x00,                           // Device's base class code
00105     0,                              // Device's sub class code
00106     0,                              // Device's protocol type code
00107     EP0_PACKET_SIZE,                // End point 0's packet size = 8
00108     USB_VID&0xFF, USB_VID>>8,       // Vendor ID for device, TI=0x0451
00109                                     //      this is Texas Instruments VID
00110                                     //      you can use is only in this example.
00111                                     //      You can order your own VID at www.usb.org
00112     USB_PID&0xFF, USB_PID>>8,       // Product ID for device,
00113                                     //      this ID is to only with this example
00114     VER_FW_L, VER_FW_H,             // Revision level of device, Rev=1.00
00115     1,                              // Index of manufacturer name string desc
00116     2,                              // Index of product name string desc
00117     USB_STR_INDEX_SERNUM,           // Index of serial number string desc
00118     1                               // Number of configurations supported
00119 };
00120 
00121 
00122 
00123 BYTE const abromConfigurationDescriptorGroup[] =
00124 {
00125     // CONFIGURATION DESCRIPTOR (9 bytes)
00126     SIZEOF_CONFIG_DESCRIPTOR,       // bLength
00127     DESC_TYPE_CONFIG,               // bDescriptorType: 2
00128     SIZEOF_CONFIGURATION_DESCRIPTOR,0x00,  // wTotalLength
00129     USB_NUM_CONFIGURATIONS,         // bNumInterfaces
00130     0x01,                           // bConfigurationValue
00131     CONFIG_STRING_INDEX,            // iConfiguration Description offset
00132 //    CFG_DESC_ATTR_BUS_POWERED | USB_SUPPORT_REM_WAKE,  // bmAttributes, bus power, remote wakeup
00133     CFG_DESC_ATTR_BUS_POWERED,      // Bus powered, does not support remote wake-up
00134     USB_MAX_POWER,                  // Max. Power Consumption at 2mA unit
00135 
00136 
00137   #ifdef _CDC_
00138 
00139     //-------- Descriptor for CDC class device -------------------------------------
00140     // INTERFACE DESCRIPTOR (9 bytes)
00141     0x09,                           // bLength: Interface Descriptor size
00142     DESC_TYPE_INTERFACE,            // bDescriptorType: Interface
00143     INTERFACE_NUMBER_CDC,       // bInterfaceNumber
00144     0x00,                       // bAlternateSetting: Alternate setting
00145     0x03,                       // bNumEndpoints: Three endpoints used
00146     0x02,                       // bInterfaceClass: Communication Interface Class
00147     0x02,                       // bInterfaceSubClass: Abstract Control Model
00148     0x01,                       // bInterfaceProtocol: Common AT commands
00149     INTF_STRING_INDEX,          // iInterface:
00150 
00151     //Header Functional Descriptor
00152     0x05,                           // bLength: Endpoint Descriptor size
00153     0x24,                           // bDescriptorType: CS_INTERFACE
00154     0x00,                           // bDescriptorSubtype: Header Func Desc
00155     0x10,                           // bcdCDC: spec release number
00156     0x01,
00157 
00158     //Call Managment Functional Descriptor
00159     0x05,                           // bFunctionLength
00160     0x24,                           // bDescriptorType: CS_INTERFACE
00161     0x01,                           // bDescriptorSubtype: Call Management Func Desc
00162     0x00,                           // bmCapabilities: D0+D1
00163     INTERFACE_NUMBER_CDC,       // bDataInterface: 0
00164 
00165     //ACM Functional Descriptor
00166     0x04,                           // bFunctionLength
00167     0x24,                           // bDescriptorType: CS_INTERFACE
00168     0x02,                           // bDescriptorSubtype: Abstract Control Management desc
00169     0x02,                           // bmCapabilities
00170 
00171 
00172     // ENDPOINT #2 INPUT DESCRIPTOR, (7 bytes)
00173     SIZEOF_ENDPOINT_DESCRIPTOR,     // bLength: Endpoint Descriptor size
00174     DESC_TYPE_ENDPOINT,             // bDescriptorType: Endpoint
00175     CDC_INTEP_ADDR,                     // bEndpointAddress: (IN2)
00176     EP_DESC_ATTR_TYPE_INT,              // bmAttributes: Interrupt
00177     0x40, 0x00,                     // wMaxPacketSize, 64 bytes
00178     0xFF,                               // bInterval
00179 
00180     // ENDPOINT #3 OUTPUT DESCRIPTOR, (7 bytes)
00181     SIZEOF_ENDPOINT_DESCRIPTOR,     // bLength: Endpoint Descriptor size
00182     DESC_TYPE_ENDPOINT,             // bDescriptorType: Endpoint
00183     CDC_OUTEP_ADDR,                     // bEndpointAddress: (OUT3)
00184     EP_DESC_ATTR_TYPE_BULK,             // bmAttributes: Bulk
00185     0x40, 0x00,                     // wMaxPacketSize, 64 bytes
00186     0xFF,                               // bInterval: ignored for Bulk transfer
00187 
00188     // ENDPOINT #3 INPUT DESCRIPTOR, (7 bytes)
00189     SIZEOF_ENDPOINT_DESCRIPTOR,     // bLength: Endpoint Descriptor size
00190     DESC_TYPE_ENDPOINT,             // bDescriptorType: Endpoint
00191     CDC_INEP_ADDR,                      // bEndpointAddress: (IN3)
00192     EP_DESC_ATTR_TYPE_BULK,             // bmAttributes: Bulk
00193     0x40, 0x00,                     // wMaxPacketSize, 64 bytes
00194     0xFF,                               // bInterval: ignored for bulk transfer
00195 
00196   #endif // _CDC_
00197 
00198 
00199   #ifdef _HID_
00200     //-------- Descriptor for HID class device -------------------------------------
00201     // INTERFACE DESCRIPTOR (9 bytes)
00202     SIZEOF_INTERFACE_DESCRIPTOR,    // bLength
00203     DESC_TYPE_INTERFACE,            // bDescriptorType: 4
00204     INTERFACE_NUMBER_HID,           // bInterfaceNumber
00205     0x00,                           // bAlternateSetting
00206     2,                              // bNumEndpoints
00207     0x03,                           // bInterfaceClass: 3 = HID Device
00208     0,                              // bInterfaceSubClass:
00209     0,                              // bInterfaceProtocol:
00210     INTF_STRING_INDEX,              // iInterface:1
00211 
00212     // HID DESCRIPTOR (9 bytes)
00213     0x09,                           // bLength of HID descriptor
00214     0x21,                           // HID Descriptor Type: 0x21
00215     0x01,0x01,                      // HID Revision number 1.01
00216     0x00,                           // Target country, nothing specified (00h)
00217     0x01,                           // Number of HID classes to follow
00218     0x22,                           // Report descriptor type
00219     (SIZEOF_REPORT_DESCRIPTOR& 0x0ff),  // Total length of report descriptor
00220     (SIZEOF_REPORT_DESCRIPTOR >>8),
00221 
00222     // ENDPOINT #1 INPUT DESCRIPTOR, (7 bytes)
00223     SIZEOF_ENDPOINT_DESCRIPTOR,     // bLength
00224     DESC_TYPE_ENDPOINT,             // bDescriptorType
00225     HID_INEP_ADDR,                 // bEndpointAddress; bit7=1 for IN, bits 3-0=1 for ep1
00226     EP_DESC_ATTR_TYPE_INT,          // bmAttributes, interrupt transfers
00227     0x40, 0x00,                     // wMaxPacketSize, 64 bytes
00228     0x01,                           // bInterval, ms
00229 
00230     // ENDPOINT #1 OUTPUT DESCRIPTOR, (7 bytes)
00231     SIZEOF_ENDPOINT_DESCRIPTOR,     // bLength
00232     DESC_TYPE_ENDPOINT,             // bDescriptorType
00233     HID_OUTEP_ADDR,                 // bEndpointAddress; bit7=1 for IN, bits 3-0=1 for ep1
00234     EP_DESC_ATTR_TYPE_INT,          // bmAttributes, interrupt transfers
00235     0x40, 0x00,                     // wMaxPacketSize, 64 bytes
00236     0x01,                           // bInterval, ms
00237   #endif // _HID_
00238 
00239 
00240 };
00241 
00242 
00243 BYTE const abromStringDescriptor[] = {
00244     // string index 0, language support
00245     4,                              // Length of language descriptor ID
00246     3,                              // LANGID tag
00247     0x09,0x04,                      // 0x0409 for English
00248 
00249     // string index 1, manufacture
00250     36,                             // Length of this string descriptor
00251     DESC_TYPE_STRING,
00252     'T',0x00,'e',0x00,'x',0x00,'a',0x00,'s',0x00,' ',0x00,
00253     'I',0x00,'n',0x00,'s',0x00,'t',0x00,'r',0x00,'u',0x00,
00254     'm',0x00,'e',0x00,'n',0x00,'t',0x00,'s',0x00,
00255 
00256     // string index 2, product
00257     38,                            // Length of this string descriptor
00258     DESC_TYPE_STRING,
00259     'M',0x00,'S',0x00,'P',0x00,'4',0x00,'3',0x00,'0',0x00,
00260     '-',0x00,'U',0x00,'S',0x00,'B',0x00,
00261     ' ',0x00,'E',0x00,'x',0x00,'a',0x00,'m',0x00,'p',0x00,
00262         'l',0x00,'e',0x00,
00263 
00264     // string index 3, serial (dummy index. real serial number will be stored in RAM)
00265     4,
00266     DESC_TYPE_STRING,
00267     '0',0x00,
00268 
00269     // string index 4, interface 0
00270 
00271     50-22,                        // Length of this string descriptor
00272     DESC_TYPE_STRING,
00273     'H',0x00,'I',0x00,'D',0x00,' ',0x00,'I',0x00,'n',0x00,
00274     't',0x00,'e',0x00,'r',0x00,'f',0x00,'a',0x00,'c',0x00,
00275     'e',0x00,
00276     /*'S',0x00,'e',0x00,'r',0x00,'i',0x00,'a',0x00,
00277         'l',0x00,' ',0x00,'p',0x00,'o',0x00,'r',0x00,'t',0x00, */
00278 
00279     // string index 5, interface 0
00280 
00281     46,                           // Length of this string descriptor
00282     DESC_TYPE_STRING,
00283     'V',0x00,'i',0x00,'r',0x00,'t',0x00,'u',0x00,'a',0x00,
00284     'l',0x00,' ',0x00,'C',0x00,'O',0x00,'M',0x00,' ',0x00,
00285     'p',0x00,'o',0x00,'r',0x00,'t',0x00,' ',0x00,'(',0x00,
00286         'C',0x00,'D',0x00,'C',0x00,')',0x00,
00287 };
00288 
00289 
00290 BYTE const abromReportDescriptor[SIZEOF_REPORT_DESCRIPTOR]=
00291 {
00292     0x06, 0x00, 0xff,              // USAGE_PAGE (Vendor Defined Page 1)
00293     0x09, 0x01,                    // USAGE (Vendor Usage 1)
00294     0xa1, 0x01,                    // COLLECTION (Application)
00295 
00296     0x85, 0x3F,                    //   Report ID
00297     0x95, 0x3F,                    //   REPORT_COUNT ()
00298     0x75, 0x08,                    //   REPORT_SIZE (8)
00299     0x25, 0x01,
00300     0x15, 0x01,
00301     0x09, 0x01,                    //   USAGE (Vendor Usage 1)
00302     0x81, 0x02,                    //   INPUT (Data,Var,Abs)
00303 
00304     0x85, 0x3F,                    //   Report ID
00305     0x95, 0x3F,                    //   REPORT_COUNT ()
00306     0x75, 0x08,                    //   REPORT_SIZE (8)
00307     0x25, 0x01,
00308     0x15, 0x01,
00309     0x09, 0x01,                    //   USAGE (Vendor Usage 1)
00310     0x91, 0x02,                    //   OUTPUT (Data,Var,Abs)
00311 
00312     0xC0                           //   end Application Collection
00313 };
00314 
00315 
00316 /*----------------------------------------------------------------------------+
00317 | End of source file                                                          |
00318 +----------------------------------------------------------------------------*/
00319 /*------------------------ Nothing Below This Line --------------------------*/

Generated on Fri Dec 17 2010 12:08:30 for Multi-cell Lithium-Ion Battery Manager System using MSP430 and BQ76PL536 by  doxygen 1.7.1