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     Title: HIDDKeyboardDriverDescriptors
00032 
00033     About: Purpose
00034         Declaration of the descriptors used by the HID device keyboard driver.
00035 */
00036 
00037 /** \addtogroup usbd_hid_key
00038  *@{
00039  */
00040 
00041 /*------------------------------------------------------------------------------
00042  *         Headers
00043  *----------------------------------------------------------------------------*/
00044 
00045 #include <USBD_Config.h>
00046 
00047 #include <HIDDKeyboardDriver.h>
00048 
00049 #include <USBDescriptors.h>
00050 #include <HIDDescriptors.h>
00051 
00052 #include <USBDDriver.h>
00053 
00054 /*------------------------------------------------------------------------------
00055  *         Definitions
00056  *----------------------------------------------------------------------------*/
00057 
00058 /** \addtogroup usbd_hid_device_desc HID Device Descriptor IDs
00059  *      @{
00060  * This page lists VID, PID & Release number.
00061  *
00062  * \section IDs
00063  * - HIDDKeyboardDriverDescriptors_PRODUCTID
00064  * - HIDDKeyboardDriverDescriptors_VENDORID
00065  * - HIDDKeyboardDriverDescriptors_RELEASE
00066  */
00067 
00068 /** Device product ID. */
00069 #define HIDDKeyboardDriverDescriptors_PRODUCTID       USBD_PID_HIDKEYBOARD
00070 /** Device vendor ID. */
00071 #define HIDDKeyboardDriverDescriptors_VENDORID        USBD_VID_ATMEL
00072 /** Device release number. */
00073 #define HIDDKeyboardDriverDescriptors_RELEASE         USBD_RELEASE_1_00
00074 /**      @}*/
00075 
00076 /*------------------------------------------------------------------------------
00077  *         Internal variables
00078  *----------------------------------------------------------------------------*/
00079 
00080 /** Device descriptor. */
00081 static const USBDeviceDescriptor deviceDescriptor = {
00082 
00083     sizeof(USBDeviceDescriptor),
00084     USBGenericDescriptor_DEVICE,
00085     USBDeviceDescriptor_USB2_00,
00086     HIDDeviceDescriptor_CLASS,
00087     HIDDeviceDescriptor_SUBCLASS,
00088     HIDDeviceDescriptor_PROTOCOL,
00089     CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0),
00090     HIDDKeyboardDriverDescriptors_VENDORID,
00091     HIDDKeyboardDriverDescriptors_PRODUCTID,
00092     HIDDKeyboardDriverDescriptors_RELEASE,
00093     1, /* Index of manufacturer description */
00094     2, /* Index of product description */
00095     3, /* Index of serial number description */
00096     1  /* One possible configuration */
00097 };
00098 
00099 /** Device qualifier descriptor (Necessary to pass USB test). */
00100 static const USBDeviceQualifierDescriptor qualifierDescriptor = {
00101 
00102     sizeof(USBDeviceQualifierDescriptor),
00103     USBGenericDescriptor_DEVICEQUALIFIER,
00104     USBDeviceDescriptor_USB2_00,
00105     HIDDeviceDescriptor_CLASS,
00106     HIDDeviceDescriptor_SUBCLASS,
00107     HIDDeviceDescriptor_PROTOCOL,
00108     CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0),
00109     0, // Device has one possible configuration.
00110     0x00
00111 };
00112 /** Configuration descriptor. */
00113 static const HIDDKeyboardDriverConfigurationDescriptors configurationDescriptors
00114 = {
00115 
00116     /* Configuration descriptor */
00117     {
00118         sizeof(USBConfigurationDescriptor),
00119         USBGenericDescriptor_CONFIGURATION,
00120         sizeof(HIDDKeyboardDriverConfigurationDescriptors),
00121         1, /* One interface in this configuration */
00122         1, /* This is configuration #1 */
00123         0, /* No associated string descriptor */
00124         USBD_BMATTRIBUTES,
00125         USBConfigurationDescriptor_POWER(100)
00126     },
00127     /* Interface descriptor */
00128     {
00129         sizeof(USBInterfaceDescriptor),
00130         USBGenericDescriptor_INTERFACE,
00131         0, /* This is interface #0 */
00132         0, /* This is alternate setting #0 */
00133         2, /* Two endpoints used */
00134         HIDInterfaceDescriptor_CLASS,
00135         HIDInterfaceDescriptor_SUBCLASS_NONE,
00136         HIDInterfaceDescriptor_PROTOCOL_NONE,
00137         0  /* No associated string descriptor */
00138     },
00139     /* HID descriptor */
00140     {
00141         sizeof(HIDDescriptor1),
00142         HIDGenericDescriptor_HID,
00143         HIDDescriptor_HID1_11,
00144         0, /* Device is not localized, no country code */
00145         1, /* One HID-specific descriptor (apart from this one) */
00146         HIDGenericDescriptor_REPORT,
00147         {HIDDKeyboard_REPORTDESCRIPTORSIZE}
00148     },
00149     /* Interrupt IN endpoint descriptor */
00150     {
00151         sizeof(USBEndpointDescriptor),
00152         USBGenericDescriptor_ENDPOINT,
00153         USBEndpointDescriptor_ADDRESS(
00154             USBEndpointDescriptor_IN,
00155             HIDDKeyboardDriverDescriptors_INTERRUPTIN),
00156         USBEndpointDescriptor_INTERRUPT,
00157         sizeof(HIDDKeyboardInputReport),
00158         HIDDKeyboardDriverDescriptors_INTERRUPTIN_POLLING
00159     },
00160     /* Interrupt OUT endpoint descriptor */
00161     {
00162         sizeof(USBEndpointDescriptor),
00163         USBGenericDescriptor_ENDPOINT,
00164         USBEndpointDescriptor_ADDRESS(
00165             USBEndpointDescriptor_OUT,
00166             HIDDKeyboardDriverDescriptors_INTERRUPTOUT),
00167         USBEndpointDescriptor_INTERRUPT,
00168         sizeof(HIDDKeyboardOutputReport),
00169         HIDDKeyboardDriverDescriptors_INTERRUPTIN_POLLING
00170     }
00171 };
00172 
00173 /** Language ID string descriptor. */
00174 static const unsigned char languageIdDescriptor[] = {
00175 
00176     USBStringDescriptor_LENGTH(1),
00177     USBGenericDescriptor_STRING,
00178     USBStringDescriptor_ENGLISH_US
00179 };
00180 
00181 /** Manufacturer name. */
00182 static const unsigned char manufacturerDescriptor[] = {
00183 
00184     USBStringDescriptor_LENGTH(5),
00185     USBGenericDescriptor_STRING,
00186     USBStringDescriptor_UNICODE('A'),
00187     USBStringDescriptor_UNICODE('T'),
00188     USBStringDescriptor_UNICODE('M'),
00189     USBStringDescriptor_UNICODE('E'),
00190     USBStringDescriptor_UNICODE('L')
00191 };
00192 
00193 /** Product name. */
00194 static const unsigned char productDescriptor[] = {
00195 
00196     USBStringDescriptor_LENGTH(23),
00197     USBGenericDescriptor_STRING,
00198     USBStringDescriptor_UNICODE('A'),
00199     USBStringDescriptor_UNICODE('T'),
00200     USBStringDescriptor_UNICODE('M'),
00201     USBStringDescriptor_UNICODE('E'),
00202     USBStringDescriptor_UNICODE('L'),
00203     USBStringDescriptor_UNICODE(' '),
00204     USBStringDescriptor_UNICODE('A'),
00205     USBStringDescriptor_UNICODE('T'),
00206     USBStringDescriptor_UNICODE('9'),
00207     USBStringDescriptor_UNICODE('1'),
00208     USBStringDescriptor_UNICODE(' '),
00209     USBStringDescriptor_UNICODE('H'),
00210     USBStringDescriptor_UNICODE('I'),
00211     USBStringDescriptor_UNICODE('D'),
00212     USBStringDescriptor_UNICODE(' '),
00213     USBStringDescriptor_UNICODE('K'),
00214     USBStringDescriptor_UNICODE('E'),
00215     USBStringDescriptor_UNICODE('Y'),
00216     USBStringDescriptor_UNICODE('B'),
00217     USBStringDescriptor_UNICODE('O'),
00218     USBStringDescriptor_UNICODE('A'),
00219     USBStringDescriptor_UNICODE('R'),
00220     USBStringDescriptor_UNICODE('D')
00221 };
00222 
00223 /** Product serial number. */
00224 static const unsigned char serialNumberDescriptor[] = {
00225 
00226     USBStringDescriptor_LENGTH(12),
00227     USBGenericDescriptor_STRING,
00228     USBStringDescriptor_UNICODE('0'),
00229     USBStringDescriptor_UNICODE('1'),
00230     USBStringDescriptor_UNICODE('2'),
00231     USBStringDescriptor_UNICODE('3'),
00232     USBStringDescriptor_UNICODE('4'),
00233     USBStringDescriptor_UNICODE('5'),
00234     USBStringDescriptor_UNICODE('6'),
00235     USBStringDescriptor_UNICODE('7'),
00236     USBStringDescriptor_UNICODE('8'),
00237     USBStringDescriptor_UNICODE('9'),
00238     USBStringDescriptor_UNICODE('A'),
00239     USBStringDescriptor_UNICODE('F')
00240 };
00241 
00242 /** Array of pointers to string descriptors. */
00243 static const unsigned char *stringDescriptors[] = {
00244 
00245     languageIdDescriptor,
00246     manufacturerDescriptor,
00247     productDescriptor,
00248     serialNumberDescriptor
00249 };
00250 
00251 /*------------------------------------------------------------------------------
00252  *         Exported variables
00253  *----------------------------------------------------------------------------*/
00254 
00255 /** List of descriptors used by the HID keyboard driver. */
00256 USBDDriverDescriptors hiddKeyboardDriverDescriptors = {
00257 
00258     &deviceDescriptor,
00259     (USBConfigurationDescriptor *) &configurationDescriptors,
00260     &qualifierDescriptor,
00261     0, /* No full-speed other speed configuration */
00262     0, /* No high-speed device descriptor */
00263     0, /* No high-speed configuration descriptor */
00264     &qualifierDescriptor,
00265     0, /* No high-speed other speed configuration descriptor */
00266     stringDescriptors,
00267     4 /* Four string descriptors in list */
00268 };
00269 
00270 /**@}*/
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines