SAMV71 Xplained Ultra Software Package 1.3

USBDDriverDescriptors.c

Go to the documentation of this file.
00001 /* ----------------------------------------------------------------------------
00002  *         SAM Software Package License 
00003  * ----------------------------------------------------------------------------
00004  * Copyright (c) 2012, Atmel Corporation
00005  *
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions are met:
00010  *
00011  * - Redistributions of source code must retain the above copyright notice,
00012  * this list of conditions and the disclaimer below.
00013  *
00014  * Atmel's name may not be used to endorse or promote products derived from
00015  * this software without specific prior written permission.
00016  *
00017  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00019  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
00020  * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00022  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
00023  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00024  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00025  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
00026  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  * ----------------------------------------------------------------------------
00028  */
00029 
00030 /** \file
00031  * Declaration of the descriptors used by the HID device Transfer driver.
00032  */
00033 
00034 /** \addtogroup usbd_hid_tran
00035  *@{
00036  */
00037 
00038 /*------------------------------------------------------------------------------
00039  *         Headers
00040  *----------------------------------------------------------------------------*/
00041 
00042 #include "board.h"
00043 #include "USBD_Config.h"
00044 
00045 #include "HIDDTransferDriver.h"
00046 #include "HIDReports.h"
00047 
00048 /*------------------------------------------------------------------------------
00049  *         Definitions
00050  *----------------------------------------------------------------------------*/
00051 
00052 /** \addtogroup usbd_hid_trans_device_descriptor_ids HID Transfer Device
00053  * Descriptor IDs
00054  *      @{
00055  *
00056  * \section IDs
00057  * - HIDDTransferDriverDescriptors_PRODUCTID
00058  * - HIDDTransferDriverDescriptors_VENDORID
00059  * - HIDDTransferDriverDescriptors_RELEASE
00060  */
00061 
00062 /** Device product ID. */
00063 #define HIDDTransferDriverDescriptors_PRODUCTID       USBD_PID_HIDTRANSFER
00064 /** Device vendor ID. */
00065 #define HIDDTransferDriverDescriptors_VENDORID        USBD_VID_ATMEL
00066 /** Device release number. */
00067 #define HIDDTransferDriverDescriptors_RELEASE         USBD_RELEASE_1_00
00068 /**      @}*/
00069 
00070 /*------------------------------------------------------------------------------
00071  *         Macros
00072  *----------------------------------------------------------------------------*/
00073 
00074 /** Returns the minimum between two values. */
00075 #define MIN(a, b)       ((a < b) ? a : b)
00076 
00077 /*------------------------------------------------------------------------------
00078  *         Internal variables
00079  *----------------------------------------------------------------------------*/
00080 
00081 /** Device descriptor. */
00082 static const USBDeviceDescriptor deviceDescriptor = {
00083 
00084     sizeof(USBDeviceDescriptor),
00085     USBGenericDescriptor_DEVICE,
00086     USBDeviceDescriptor_USB2_00,
00087     HIDDeviceDescriptor_CLASS,
00088     HIDDeviceDescriptor_SUBCLASS,
00089     HIDDeviceDescriptor_PROTOCOL,
00090     CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0),
00091     HIDDTransferDriverDescriptors_VENDORID,
00092     HIDDTransferDriverDescriptors_PRODUCTID,
00093     HIDDTransferDriverDescriptors_RELEASE,
00094     1, /* Index of manufacturer description */
00095     2, /* Index of product description */
00096     3, /* Index of serial number description */
00097     1  /* One possible configuration */
00098 };
00099 
00100 /** Configuration descriptor. */
00101 static const HIDDTransferDriverConfigurationDescriptors configurationDescriptors = {
00102 
00103     /* Configuration descriptor */
00104 
00105     {
00106         sizeof(USBConfigurationDescriptor),
00107         USBGenericDescriptor_CONFIGURATION,
00108         sizeof(HIDDTransferDriverConfigurationDescriptors),
00109         1, /* One interface in this configuration */
00110         1, /* This is configuration #1 */
00111         0, /* No associated string descriptor */
00112         USBD_BMATTRIBUTES,
00113         USBConfigurationDescriptor_POWER(100)
00114     },
00115     /* Interface descriptor */
00116 
00117     {
00118         sizeof(USBInterfaceDescriptor),
00119         USBGenericDescriptor_INTERFACE,
00120         0, /* This is interface #0 */
00121         0, /* This is alternate setting #0 */
00122         2, /* Two endpoints used */
00123         HIDInterfaceDescriptor_CLASS,
00124         HIDInterfaceDescriptor_SUBCLASS_NONE,
00125         HIDInterfaceDescriptor_PROTOCOL_NONE,
00126         0  /* No associated string descriptor */
00127     },
00128     /* HID descriptor */
00129 
00130     {
00131         sizeof(HIDDescriptor1),
00132         HIDGenericDescriptor_HID,
00133         HIDDescriptor_HID1_11,
00134         0, /* Device is not localized, no country code */
00135         1, /* One HID-specific descriptor (apart from this one) */
00136         HIDGenericDescriptor_REPORT,
00137         {HIDDTransferDriver_REPORTDESCRIPTORSIZE}
00138     },
00139     /* Interrupt IN endpoint descriptor */
00140 
00141     {
00142         sizeof(USBEndpointDescriptor),
00143         USBGenericDescriptor_ENDPOINT,
00144         USBEndpointDescriptor_ADDRESS(
00145             USBEndpointDescriptor_IN,
00146             HIDDTransferDriverDescriptors_INTERRUPTIN),
00147         USBEndpointDescriptor_INTERRUPT,
00148         MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(
00149                         HIDDTransferDriverDescriptors_INTERRUPTIN),
00150             MIN(USBEndpointDescriptor_MAXINTERRUPTSIZE_FS,
00151                                 HIDDTransferDriver_REPORTSIZE)),
00152         HIDDTransferDriverDescriptors_INTERRUPTIN_POLLING
00153     },
00154     /* Interrupt OUT endpoint descriptor */
00155 
00156     {
00157         sizeof(USBEndpointDescriptor),
00158         USBGenericDescriptor_ENDPOINT,
00159         USBEndpointDescriptor_ADDRESS(
00160             USBEndpointDescriptor_OUT,
00161             HIDDTransferDriverDescriptors_INTERRUPTOUT),
00162         USBEndpointDescriptor_INTERRUPT,
00163         MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(
00164                         HIDDTransferDriverDescriptors_INTERRUPTOUT),
00165             MIN(USBEndpointDescriptor_MAXINTERRUPTSIZE_FS,
00166                                     HIDDTransferDriver_REPORTSIZE)),
00167         HIDDTransferDriverDescriptors_INTERRUPTOUT_POLLING
00168     }
00169 };
00170 
00171 /**
00172  *  Variables: String descriptors
00173  *      languageIdDescriptor - Language ID string descriptor.
00174  *      manufacturerDescriptor - Manufacturer name.
00175  *      productDescriptor - Product name.
00176  *      serialNumberDescriptor - Product serial number.
00177  *      stringDescriptors - Array of pointers to string descriptors.
00178  */
00179 static const unsigned char languageIdDescriptor[] = {
00180 
00181     USBStringDescriptor_LENGTH(1),
00182     USBGenericDescriptor_STRING,
00183     USBStringDescriptor_ENGLISH_US
00184 };
00185 
00186 static const unsigned char manufacturerDescriptor[] = {
00187 
00188     USBStringDescriptor_LENGTH(5),
00189     USBGenericDescriptor_STRING,
00190     USBStringDescriptor_UNICODE('A'),
00191     USBStringDescriptor_UNICODE('T'),
00192     USBStringDescriptor_UNICODE('M'),
00193     USBStringDescriptor_UNICODE('E'),
00194     USBStringDescriptor_UNICODE('L')
00195 };
00196 
00197 static const unsigned char productDescriptor[] = {
00198 
00199     USBStringDescriptor_LENGTH(22),
00200     USBGenericDescriptor_STRING,
00201     USBStringDescriptor_UNICODE('A'),
00202     USBStringDescriptor_UNICODE('T'),
00203     USBStringDescriptor_UNICODE('M'),
00204     USBStringDescriptor_UNICODE('E'),
00205     USBStringDescriptor_UNICODE('L'),
00206     USBStringDescriptor_UNICODE(' '),
00207     USBStringDescriptor_UNICODE('A'),
00208     USBStringDescriptor_UNICODE('T'),
00209     USBStringDescriptor_UNICODE('9'),
00210     USBStringDescriptor_UNICODE('1'),
00211     USBStringDescriptor_UNICODE(' '),
00212     USBStringDescriptor_UNICODE('H'),
00213     USBStringDescriptor_UNICODE('I'),
00214     USBStringDescriptor_UNICODE('D'),
00215     USBStringDescriptor_UNICODE(' '),
00216     USBStringDescriptor_UNICODE('T'),
00217     USBStringDescriptor_UNICODE('R'),
00218     USBStringDescriptor_UNICODE('A'),
00219     USBStringDescriptor_UNICODE('N'),
00220     USBStringDescriptor_UNICODE('S'),
00221     USBStringDescriptor_UNICODE('F'),
00222     USBStringDescriptor_UNICODE('E'),
00223     USBStringDescriptor_UNICODE('R'),
00224 };
00225 
00226 static const unsigned char serialNumberDescriptor[] = {
00227 
00228     USBStringDescriptor_LENGTH(12),
00229     USBGenericDescriptor_STRING,
00230     USBStringDescriptor_UNICODE('0'),
00231     USBStringDescriptor_UNICODE('1'),
00232     USBStringDescriptor_UNICODE('2'),
00233     USBStringDescriptor_UNICODE('3'),
00234     USBStringDescriptor_UNICODE('4'),
00235     USBStringDescriptor_UNICODE('5'),
00236     USBStringDescriptor_UNICODE('6'),
00237     USBStringDescriptor_UNICODE('7'),
00238     USBStringDescriptor_UNICODE('8'),
00239     USBStringDescriptor_UNICODE('9'),
00240     USBStringDescriptor_UNICODE('A'),
00241     USBStringDescriptor_UNICODE('F')
00242 };
00243 
00244 static const unsigned char *stringDescriptors[] = {
00245 
00246     languageIdDescriptor,
00247     manufacturerDescriptor,
00248     productDescriptor,
00249     serialNumberDescriptor
00250 };
00251 
00252 /*------------------------------------------------------------------------------
00253  *         Exported variables
00254  *----------------------------------------------------------------------------*/
00255 
00256 /** List of descriptors used by the HID Transfer driver. */
00257 USBDDriverDescriptors hiddTransferDriverDescriptors = {
00258 
00259     &deviceDescriptor,
00260     (USBConfigurationDescriptor *) &configurationDescriptors,
00261     0, /* No full-speed device qualifier descriptor */
00262     0, /* No full-speed other speed configuration */
00263     0, /* No high-speed device descriptor */
00264     0, /* No high-speed configuration descriptor */
00265     0, /* No high-speed device qualifier descriptor */
00266     0, /* No high-speed other speed configuration descriptor */
00267     stringDescriptors,
00268     4 /* Four string descriptors in list */
00269 };
00270 
00271 /**@}*/
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines