SAMV71 Xplained Ultra Software Package 1.4

USBDDriverDescriptors.c

Go to the documentation of this file.
00001 /* ----------------------------------------------------------------------------
00002  *         SAM Software Package License 
00003  * ----------------------------------------------------------------------------
00004  * Copyright (c) 2011, 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     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     /* Configuration descriptor */
00116     {
00117         sizeof(USBConfigurationDescriptor),
00118         USBGenericDescriptor_CONFIGURATION,
00119         sizeof(HIDDKeyboardDriverConfigurationDescriptors),
00120         1, /* One interface in this configuration */
00121         1, /* This is configuration #1 */
00122         0, /* No associated string descriptor */
00123         USBD_BMATTRIBUTES,
00124         USBConfigurationDescriptor_POWER(100)
00125     },
00126     /* Interface descriptor */
00127     {
00128         sizeof(USBInterfaceDescriptor),
00129         USBGenericDescriptor_INTERFACE,
00130         0, /* This is interface #0 */
00131         0, /* This is alternate setting #0 */
00132         2, /* Two endpoints used */
00133         HIDInterfaceDescriptor_CLASS,
00134         HIDInterfaceDescriptor_SUBCLASS_NONE,
00135         HIDInterfaceDescriptor_PROTOCOL_NONE,
00136         0  /* No associated string descriptor */
00137     },
00138     /* HID descriptor */
00139     {
00140         sizeof(HIDDescriptor1),
00141         HIDGenericDescriptor_HID,
00142         HIDDescriptor_HID1_11,
00143         0, /* Device is not localized, no country code */
00144         1, /* One HID-specific descriptor (apart from this one) */
00145         HIDGenericDescriptor_REPORT,
00146         {HIDDKeyboard_REPORTDESCRIPTORSIZE}
00147     },
00148     /* Interrupt IN endpoint descriptor */
00149     {
00150         sizeof(USBEndpointDescriptor),
00151         USBGenericDescriptor_ENDPOINT,
00152         USBEndpointDescriptor_ADDRESS(
00153             USBEndpointDescriptor_IN,
00154             HIDDKeyboardDriverDescriptors_INTERRUPTIN),
00155         USBEndpointDescriptor_INTERRUPT,
00156         sizeof(HIDDKeyboardInputReport),
00157         HIDDKeyboardDriverDescriptors_INTERRUPTIN_POLLING
00158     },
00159     /* Interrupt OUT endpoint descriptor */
00160     {
00161         sizeof(USBEndpointDescriptor),
00162         USBGenericDescriptor_ENDPOINT,
00163         USBEndpointDescriptor_ADDRESS(
00164             USBEndpointDescriptor_OUT,
00165             HIDDKeyboardDriverDescriptors_INTERRUPTOUT),
00166         USBEndpointDescriptor_INTERRUPT,
00167         sizeof(HIDDKeyboardOutputReport),
00168         HIDDKeyboardDriverDescriptors_INTERRUPTIN_POLLING
00169     }
00170 };
00171 
00172 /** Language ID string descriptor. */
00173 static const unsigned char languageIdDescriptor[] = {
00174 
00175     USBStringDescriptor_LENGTH(1),
00176     USBGenericDescriptor_STRING,
00177     USBStringDescriptor_ENGLISH_US
00178 };
00179 
00180 /** Manufacturer name. */
00181 static const unsigned char manufacturerDescriptor[] = {
00182 
00183     USBStringDescriptor_LENGTH(5),
00184     USBGenericDescriptor_STRING,
00185     USBStringDescriptor_UNICODE('A'),
00186     USBStringDescriptor_UNICODE('T'),
00187     USBStringDescriptor_UNICODE('M'),
00188     USBStringDescriptor_UNICODE('E'),
00189     USBStringDescriptor_UNICODE('L')
00190 };
00191 
00192 /** Product name. */
00193 static const unsigned char productDescriptor[] = {
00194 
00195     USBStringDescriptor_LENGTH(23),
00196     USBGenericDescriptor_STRING,
00197     USBStringDescriptor_UNICODE('A'),
00198     USBStringDescriptor_UNICODE('T'),
00199     USBStringDescriptor_UNICODE('M'),
00200     USBStringDescriptor_UNICODE('E'),
00201     USBStringDescriptor_UNICODE('L'),
00202     USBStringDescriptor_UNICODE(' '),
00203     USBStringDescriptor_UNICODE('A'),
00204     USBStringDescriptor_UNICODE('T'),
00205     USBStringDescriptor_UNICODE('9'),
00206     USBStringDescriptor_UNICODE('1'),
00207     USBStringDescriptor_UNICODE(' '),
00208     USBStringDescriptor_UNICODE('H'),
00209     USBStringDescriptor_UNICODE('I'),
00210     USBStringDescriptor_UNICODE('D'),
00211     USBStringDescriptor_UNICODE(' '),
00212     USBStringDescriptor_UNICODE('K'),
00213     USBStringDescriptor_UNICODE('E'),
00214     USBStringDescriptor_UNICODE('Y'),
00215     USBStringDescriptor_UNICODE('B'),
00216     USBStringDescriptor_UNICODE('O'),
00217     USBStringDescriptor_UNICODE('A'),
00218     USBStringDescriptor_UNICODE('R'),
00219     USBStringDescriptor_UNICODE('D')
00220 };
00221 
00222 /** Product serial number. */
00223 static const unsigned char serialNumberDescriptor[] = {
00224 
00225     USBStringDescriptor_LENGTH(12),
00226     USBGenericDescriptor_STRING,
00227     USBStringDescriptor_UNICODE('0'),
00228     USBStringDescriptor_UNICODE('1'),
00229     USBStringDescriptor_UNICODE('2'),
00230     USBStringDescriptor_UNICODE('3'),
00231     USBStringDescriptor_UNICODE('4'),
00232     USBStringDescriptor_UNICODE('5'),
00233     USBStringDescriptor_UNICODE('6'),
00234     USBStringDescriptor_UNICODE('7'),
00235     USBStringDescriptor_UNICODE('8'),
00236     USBStringDescriptor_UNICODE('9'),
00237     USBStringDescriptor_UNICODE('A'),
00238     USBStringDescriptor_UNICODE('F')
00239 };
00240 
00241 /** Array of pointers to string descriptors. */
00242 static const unsigned char *stringDescriptors[] = {
00243 
00244     languageIdDescriptor,
00245     manufacturerDescriptor,
00246     productDescriptor,
00247     serialNumberDescriptor
00248 };
00249 
00250 /*------------------------------------------------------------------------------
00251  *         Exported variables
00252  *----------------------------------------------------------------------------*/
00253 
00254 /** List of descriptors used by the HID keyboard driver. */
00255 USBDDriverDescriptors hiddKeyboardDriverDescriptors = {
00256 
00257     &deviceDescriptor,
00258     (USBConfigurationDescriptor *) &configurationDescriptors,
00259     &qualifierDescriptor,
00260     0, /* No full-speed other speed configuration */
00261     0, /* No high-speed device descriptor */
00262     0, /* No high-speed configuration descriptor */
00263     &qualifierDescriptor,
00264     0, /* No high-speed other speed configuration descriptor */
00265     stringDescriptors,
00266     4 /* Four string descriptors in list */
00267 };
00268 
00269 /**@}*/
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines