SAMV71 Xplained Ultra Software Package 1.5

USBDDriverDescriptors.c

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------- */
00002 /*                  Atmel Microcontroller Software Support                      */
00003 /*                       SAM Software Package License                           */
00004 /* ---------------------------------------------------------------------------- */
00005 /* Copyright (c) 2015, Atmel Corporation                                        */
00006 /*                                                                              */
00007 /* All rights reserved.                                                         */
00008 /*                                                                              */
00009 /* Redistribution and use in source and binary forms, with or without           */
00010 /* modification, are permitted provided that the following condition is met:    */
00011 /*                                                                              */
00012 /* - Redistributions of source code must retain the above copyright notice,     */
00013 /* this list of conditions and the disclaimer below.                            */
00014 /*                                                                              */
00015 /* Atmel's name may not be used to endorse or promote products derived from     */
00016 /* this software without specific prior written permission.                     */
00017 /*                                                                              */
00018 /* DISCLAIMER:  THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR   */
00019 /* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
00020 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE   */
00021 /* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,      */
00022 /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
00023 /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,  */
00024 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    */
00025 /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING         */
00026 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */
00027 /* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                           */
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 
00104     /* Configuration descriptor */
00105 
00106     {
00107         sizeof(USBConfigurationDescriptor),
00108         USBGenericDescriptor_CONFIGURATION,
00109         sizeof(HIDDTransferDriverConfigurationDescriptors),
00110         1, /* One interface in this configuration */
00111         1, /* This is configuration #1 */
00112         0, /* No associated string descriptor */
00113         USBD_BMATTRIBUTES,
00114         USBConfigurationDescriptor_POWER(100)
00115     },
00116     /* Interface descriptor */
00117 
00118     {
00119         sizeof(USBInterfaceDescriptor),
00120         USBGenericDescriptor_INTERFACE,
00121         0, /* This is interface #0 */
00122         0, /* This is alternate setting #0 */
00123         2, /* Two endpoints used */
00124         HIDInterfaceDescriptor_CLASS,
00125         HIDInterfaceDescriptor_SUBCLASS_NONE,
00126         HIDInterfaceDescriptor_PROTOCOL_NONE,
00127         0  /* No associated string descriptor */
00128     },
00129     /* HID descriptor */
00130 
00131     {
00132         sizeof(HIDDescriptor1),
00133         HIDGenericDescriptor_HID,
00134         HIDDescriptor_HID1_11,
00135         0, /* Device is not localized, no country code */
00136         1, /* One HID-specific descriptor (apart from this one) */
00137         HIDGenericDescriptor_REPORT,
00138         {HIDDTransferDriver_REPORTDESCRIPTORSIZE}
00139     },
00140     /* Interrupt IN endpoint descriptor */
00141 
00142     {
00143         sizeof(USBEndpointDescriptor),
00144         USBGenericDescriptor_ENDPOINT,
00145         USBEndpointDescriptor_ADDRESS(
00146             USBEndpointDescriptor_IN,
00147             HIDDTransferDriverDescriptors_INTERRUPTIN),
00148         USBEndpointDescriptor_INTERRUPT,
00149         MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(
00150             HIDDTransferDriverDescriptors_INTERRUPTIN),
00151         MIN(USBEndpointDescriptor_MAXINTERRUPTSIZE_FS,
00152         HIDDTransferDriver_REPORTSIZE)),
00153         HIDDTransferDriverDescriptors_INTERRUPTIN_POLLING
00154     },
00155     /* Interrupt OUT endpoint descriptor */
00156 
00157     {
00158         sizeof(USBEndpointDescriptor),
00159         USBGenericDescriptor_ENDPOINT,
00160         USBEndpointDescriptor_ADDRESS(
00161             USBEndpointDescriptor_OUT,
00162             HIDDTransferDriverDescriptors_INTERRUPTOUT),
00163         USBEndpointDescriptor_INTERRUPT,
00164         MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(
00165             HIDDTransferDriverDescriptors_INTERRUPTOUT),
00166         MIN(USBEndpointDescriptor_MAXINTERRUPTSIZE_FS,
00167         HIDDTransferDriver_REPORTSIZE)),
00168         HIDDTransferDriverDescriptors_INTERRUPTOUT_POLLING
00169     }
00170 };
00171 
00172 /**
00173  *  Variables: String descriptors
00174  *      languageIdDescriptor - Language ID string descriptor.
00175  *      manufacturerDescriptor - Manufacturer name.
00176  *      productDescriptor - Product name.
00177  *      serialNumberDescriptor - Product serial number.
00178  *      stringDescriptors - Array of pointers to string descriptors.
00179  */
00180 static const unsigned char languageIdDescriptor[] = {
00181 
00182     USBStringDescriptor_LENGTH(1),
00183     USBGenericDescriptor_STRING,
00184     USBStringDescriptor_ENGLISH_US
00185 };
00186 
00187 static const unsigned char manufacturerDescriptor[] = {
00188 
00189     USBStringDescriptor_LENGTH(5),
00190     USBGenericDescriptor_STRING,
00191     USBStringDescriptor_UNICODE('A'),
00192     USBStringDescriptor_UNICODE('T'),
00193     USBStringDescriptor_UNICODE('M'),
00194     USBStringDescriptor_UNICODE('E'),
00195     USBStringDescriptor_UNICODE('L')
00196 };
00197 
00198 static const unsigned char productDescriptor[] = {
00199 
00200     USBStringDescriptor_LENGTH(22),
00201     USBGenericDescriptor_STRING,
00202     USBStringDescriptor_UNICODE('A'),
00203     USBStringDescriptor_UNICODE('T'),
00204     USBStringDescriptor_UNICODE('M'),
00205     USBStringDescriptor_UNICODE('E'),
00206     USBStringDescriptor_UNICODE('L'),
00207     USBStringDescriptor_UNICODE(' '),
00208     USBStringDescriptor_UNICODE('A'),
00209     USBStringDescriptor_UNICODE('T'),
00210     USBStringDescriptor_UNICODE('9'),
00211     USBStringDescriptor_UNICODE('1'),
00212     USBStringDescriptor_UNICODE(' '),
00213     USBStringDescriptor_UNICODE('H'),
00214     USBStringDescriptor_UNICODE('I'),
00215     USBStringDescriptor_UNICODE('D'),
00216     USBStringDescriptor_UNICODE(' '),
00217     USBStringDescriptor_UNICODE('T'),
00218     USBStringDescriptor_UNICODE('R'),
00219     USBStringDescriptor_UNICODE('A'),
00220     USBStringDescriptor_UNICODE('N'),
00221     USBStringDescriptor_UNICODE('S'),
00222     USBStringDescriptor_UNICODE('F'),
00223     USBStringDescriptor_UNICODE('E'),
00224     USBStringDescriptor_UNICODE('R'),
00225 };
00226 
00227 static const unsigned char serialNumberDescriptor[] = {
00228 
00229     USBStringDescriptor_LENGTH(12),
00230     USBGenericDescriptor_STRING,
00231     USBStringDescriptor_UNICODE('0'),
00232     USBStringDescriptor_UNICODE('1'),
00233     USBStringDescriptor_UNICODE('2'),
00234     USBStringDescriptor_UNICODE('3'),
00235     USBStringDescriptor_UNICODE('4'),
00236     USBStringDescriptor_UNICODE('5'),
00237     USBStringDescriptor_UNICODE('6'),
00238     USBStringDescriptor_UNICODE('7'),
00239     USBStringDescriptor_UNICODE('8'),
00240     USBStringDescriptor_UNICODE('9'),
00241     USBStringDescriptor_UNICODE('A'),
00242     USBStringDescriptor_UNICODE('F')
00243 };
00244 
00245 static const unsigned char *stringDescriptors[] = {
00246 
00247     languageIdDescriptor,
00248     manufacturerDescriptor,
00249     productDescriptor,
00250     serialNumberDescriptor
00251 };
00252 
00253 /*------------------------------------------------------------------------------
00254  *         Exported variables
00255  *----------------------------------------------------------------------------*/
00256 
00257 /** List of descriptors used by the HID Transfer driver. */
00258 USBDDriverDescriptors hiddTransferDriverDescriptors = {
00259 
00260     &deviceDescriptor,
00261     (USBConfigurationDescriptor *) &configurationDescriptors,
00262     0, /* No full-speed device qualifier descriptor */
00263     0, /* No full-speed other speed configuration */
00264     0, /* No high-speed device descriptor */
00265     0, /* No high-speed configuration descriptor */
00266     0, /* No high-speed device qualifier descriptor */
00267     0, /* No high-speed other speed configuration descriptor */
00268     stringDescriptors,
00269     4 /* Four string descriptors in list */
00270 };
00271 
00272 /**@}*/
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines