SAMV71 Xplained Ultra Software Package 1.5

USBDDriverDescriptors.c

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 /** \addtogroup usbd_composite_cdchid
00031  *@{
00032  */
00033 
00034 /*----------------------------------------------------------------------------
00035  *      Headers
00036  *----------------------------------------------------------------------------*/
00037 
00038 #include <USBD_Config.h>
00039 
00040 /*- Composite */
00041 #include <CDCHIDDDriver.h>
00042 #include <CDCDSerial.h>
00043 #include <HIDDKeyboard.h>
00044 
00045 /*---------------------------------------------------------------------------
00046  *         Definitions
00047  *---------------------------------------------------------------------------*/
00048 
00049 
00050 /** Device product ID. */
00051 #define CDCHIDDDriverDescriptors_PRODUCTID       USBD_PID_CDCHID
00052 /** Device vendor ID (Atmel). */
00053 #define CDCHIDDDriverDescriptors_VENDORID        USBD_VID_ATMEL
00054 /** Device release number. */
00055 #define CDCHIDDDriverDescriptors_RELEASE         0x0003
00056 
00057 /*---------------------------------------------------------------------------
00058  *         Macros
00059  *---------------------------------------------------------------------------*/
00060 
00061 /** Returns the minimum between two values. */
00062 #define MIN(a, b)       ((a < b) ? a : b)
00063 
00064 /*----------------------------------------------------------------------------
00065  *         Exported variables
00066  *----------------------------------------------------------------------------*/
00067 
00068 /** Standard USB device descriptor for the composite device driver */
00069 static const USBDeviceDescriptor deviceDescriptor = {
00070 
00071     sizeof(USBDeviceDescriptor),
00072     USBGenericDescriptor_DEVICE,
00073     USBDeviceDescriptor_USB2_00,
00074     0xEF,/* MI */
00075     0x02,/* */
00076     0x01,/* */
00077     CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0),
00078     CDCHIDDDriverDescriptors_VENDORID,
00079     CDCHIDDDriverDescriptors_PRODUCTID,
00080     CDCHIDDDriverDescriptors_RELEASE,
00081     0, /* No string descriptor for manufacturer */
00082     1, /* Index of product string descriptor is #1 */
00083     0, /* No string descriptor for serial number */
00084     1 /* Device has 1 possible configuration */
00085 };
00086 
00087 
00088 /** Device qualifier descriptor (Necessary to pass USB test). */
00089 static const USBDeviceQualifierDescriptor qualifierDescriptor = {
00090 
00091     sizeof(USBDeviceQualifierDescriptor),
00092     USBGenericDescriptor_DEVICEQUALIFIER,
00093     USBDeviceDescriptor_USB2_00,
00094     0xEF,
00095     0x02,
00096     0x01,
00097     CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0),
00098     0, // Device has one possible configuration.
00099     0x00
00100 };
00101 
00102 
00103 /** USB configuration descriptors for the composite device driver */
00104 static const CdcHidDriverConfigurationDescriptors configurationDescriptorsFS = {
00105 
00106     /* Standard configuration descriptor */
00107     {
00108         sizeof(USBConfigurationDescriptor),
00109         USBGenericDescriptor_CONFIGURATION,
00110         sizeof(CdcHidDriverConfigurationDescriptors),
00111         CDCHIDDDriverDescriptors_NUMINTERFACE,
00112         1, /* This is configuration #1 */
00113         0, /* No string descriptor for this configuration */
00114         USBD_BMATTRIBUTES,
00115         USBConfigurationDescriptor_POWER(100)
00116     },
00117 
00118     /* CDC 0 */
00119     /* IAD for CDC/ACM port */
00120     {
00121         sizeof(USBInterfaceAssociationDescriptor),
00122         USBGenericDescriptor_INTERFACEASSOCIATION,
00123         CDCHIDDDriverDescriptors_CDC_INTERFACE,
00124         2,
00125         CDCCommunicationInterfaceDescriptor_CLASS,
00126         CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL,
00127         CDCCommunicationInterfaceDescriptor_NOPROTOCOL,
00128         0  /* No string descriptor for this interface */
00129     },
00130     /* Communication class interface standard descriptor */
00131     {
00132         sizeof(USBInterfaceDescriptor),
00133         USBGenericDescriptor_INTERFACE,
00134         CDCHIDDDriverDescriptors_CDC_INTERFACE, /* This is interface #0 */
00135         0, /* This is alternate setting #0 for this interface */
00136         1, /* This interface uses 1 endpoint */
00137         CDCCommunicationInterfaceDescriptor_CLASS,
00138         CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL,
00139         CDCCommunicationInterfaceDescriptor_NOPROTOCOL,
00140         0  /* No string descriptor for this interface */
00141     },
00142     /* Class-specific header functional descriptor */
00143     {
00144         sizeof(CDCHeaderDescriptor),
00145         CDCGenericDescriptor_INTERFACE,
00146         CDCGenericDescriptor_HEADER,
00147         CDCGenericDescriptor_CDC1_10
00148     },
00149     /* Class-specific call management functional descriptor */
00150     {
00151         sizeof(CDCCallManagementDescriptor),
00152         CDCGenericDescriptor_INTERFACE,
00153         CDCGenericDescriptor_CALLMANAGEMENT,
00154         CDCCallManagementDescriptor_SELFCALLMANAGEMENT,
00155         CDCHIDDDriverDescriptors_CDC_INTERFACE + 1 /* No associated data interface */
00156     },
00157     /* Class-specific abstract control management functional descriptor */
00158     {
00159         sizeof(CDCAbstractControlManagementDescriptor),
00160         CDCGenericDescriptor_INTERFACE,
00161         CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT,
00162         CDCAbstractControlManagementDescriptor_LINE
00163     },
00164     /* Class-specific union functional descriptor with one slave interface */
00165     {
00166         sizeof(CDCUnionDescriptor),
00167         CDCGenericDescriptor_INTERFACE,
00168         CDCGenericDescriptor_UNION,
00169         CDCHIDDDriverDescriptors_CDC_INTERFACE, /* Number of master interface is #0 */
00170         CDCHIDDDriverDescriptors_CDC_INTERFACE + 1 /* First slave interface is #1 */
00171     },
00172     /* Notification endpoint standard descriptor */
00173     {
00174         sizeof(USBEndpointDescriptor),
00175         USBGenericDescriptor_ENDPOINT,
00176         USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
00177         CDCD_Descriptors_NOTIFICATION0),
00178         USBEndpointDescriptor_INTERRUPT,
00179         MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_NOTIFICATION0),
00180         USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),
00181         CDCDSerialPort_INTERRUPT_INTERVAL_FS
00182     },
00183     /* Data class interface standard descriptor */
00184     {
00185         sizeof(USBInterfaceDescriptor),
00186         USBGenericDescriptor_INTERFACE,
00187         CDCHIDDDriverDescriptors_CDC_INTERFACE + 1, /* This is interface #1 */
00188         0, /* This is alternate setting #0 for this interface */
00189         2, /* This interface uses 2 endpoints */
00190         CDCDataInterfaceDescriptor_CLASS,
00191         CDCDataInterfaceDescriptor_SUBCLASS,
00192         CDCDataInterfaceDescriptor_NOPROTOCOL,
00193         0  /* No string descriptor for this interface */
00194     },
00195     /* Bulk-OUT endpoint standard descriptor */
00196     {
00197         sizeof(USBEndpointDescriptor),
00198         USBGenericDescriptor_ENDPOINT,
00199         USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT,
00200         CDCD_Descriptors_DATAOUT0),
00201         USBEndpointDescriptor_BULK,
00202         MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAOUT0),
00203         USBEndpointDescriptor_MAXBULKSIZE_FS),
00204         0 /* Must be 0 for full-speed bulk endpoints */
00205     },
00206     /* Bulk-IN endpoint descriptor */
00207     {
00208         sizeof(USBEndpointDescriptor),
00209         USBGenericDescriptor_ENDPOINT,
00210         USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
00211         CDCD_Descriptors_DATAIN0),
00212         USBEndpointDescriptor_BULK,
00213         MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAIN0),
00214         USBEndpointDescriptor_MAXBULKSIZE_FS),
00215         0 /* Must be 0 for full-speed bulk endpoints */
00216     },
00217 
00218     /* HID */
00219     /* Interface descriptor */
00220     {
00221         sizeof(USBInterfaceDescriptor),
00222         USBGenericDescriptor_INTERFACE,
00223         CDCHIDDDriverDescriptors_HID_INTERFACE,
00224         0, /* This is alternate setting #0 */
00225         2, /* Two endpoints used */
00226         HIDInterfaceDescriptor_CLASS,
00227         HIDInterfaceDescriptor_SUBCLASS_NONE,
00228         HIDInterfaceDescriptor_PROTOCOL_NONE,
00229         0  /* No associated string descriptor */
00230     },
00231     /* HID descriptor */
00232     {
00233         sizeof(HIDDescriptor1),
00234         HIDGenericDescriptor_HID,
00235         HIDDescriptor_HID1_11,
00236         0, /* Device is not localized, no country code */
00237         1, /* One HID-specific descriptor (apart from this one) */
00238         HIDGenericDescriptor_REPORT,
00239         {HIDDKeyboard_REPORTDESCRIPTORSIZE}
00240         /*
00241         {
00242          HIDDKeyboard_REPORTDESCRIPTORSIZE & 0xFF,
00243         (HIDDKeyboard_REPORTDESCRIPTORSIZE >> 8) & 0xFF
00244         }*/
00245     },
00246     /* Interrupt IN endpoint descriptor */
00247     {
00248         sizeof(USBEndpointDescriptor),
00249         USBGenericDescriptor_ENDPOINT,
00250         USBEndpointDescriptor_ADDRESS(
00251             USBEndpointDescriptor_IN,
00252             HIDD_Descriptors_INTERRUPTIN),
00253         USBEndpointDescriptor_INTERRUPT,
00254         sizeof(HIDDKeyboardInputReport),
00255         HIDDKeyboardDescriptors_INTERRUPTIN_POLLING_FS
00256     },
00257     /* Interrupt OUT endpoint descriptor */
00258     {
00259         sizeof(USBEndpointDescriptor),
00260         USBGenericDescriptor_ENDPOINT,
00261         USBEndpointDescriptor_ADDRESS(
00262             USBEndpointDescriptor_OUT,
00263             HIDD_Descriptors_INTERRUPTOUT),
00264         USBEndpointDescriptor_INTERRUPT,
00265         sizeof(HIDDKeyboardOutputReport),
00266         HIDDKeyboardDescriptors_INTERRUPTOUT_POLLING_FS
00267     }
00268 };
00269 
00270 /** String descriptor with the supported languages. */
00271 static const unsigned char languageIdDescriptor[] = {
00272 
00273     USBStringDescriptor_LENGTH(1),
00274     USBGenericDescriptor_STRING,
00275     USBStringDescriptor_ENGLISH_US
00276 };
00277 
00278 /** Manufacturer name. */
00279 static const unsigned char manufacturerDescriptor[] = {
00280 
00281     USBStringDescriptor_LENGTH(5),
00282     USBGenericDescriptor_STRING,
00283     USBStringDescriptor_UNICODE('A'),
00284     USBStringDescriptor_UNICODE('t'),
00285     USBStringDescriptor_UNICODE('m'),
00286     USBStringDescriptor_UNICODE('e'),
00287     USBStringDescriptor_UNICODE('l')
00288 };
00289 
00290 /** Product name. */
00291 static const unsigned char productDescriptor[] = {
00292 
00293     USBStringDescriptor_LENGTH(14),
00294     USBGenericDescriptor_STRING,
00295     USBStringDescriptor_UNICODE('C'),
00296     USBStringDescriptor_UNICODE('o'),
00297     USBStringDescriptor_UNICODE('m'),
00298     USBStringDescriptor_UNICODE('p'),
00299     USBStringDescriptor_UNICODE('o'),
00300     USBStringDescriptor_UNICODE('s'),
00301     USBStringDescriptor_UNICODE('i'),
00302     USBStringDescriptor_UNICODE('t'),
00303     USBStringDescriptor_UNICODE('e'),
00304     USBStringDescriptor_UNICODE(' '),
00305     USBStringDescriptor_UNICODE('D'),
00306     USBStringDescriptor_UNICODE('e'),
00307     USBStringDescriptor_UNICODE('m'),
00308     USBStringDescriptor_UNICODE('o')
00309 };
00310 
00311 /** Product serial number. */
00312 static const unsigned char serialNumberDescriptor[] = {
00313 
00314     USBStringDescriptor_LENGTH(4),
00315     USBGenericDescriptor_STRING,
00316     USBStringDescriptor_UNICODE('0'),
00317     USBStringDescriptor_UNICODE('1'),
00318     USBStringDescriptor_UNICODE('2'),
00319     USBStringDescriptor_UNICODE('3')
00320 };
00321 
00322 /** Array of pointers to the four string descriptors. */
00323 static const unsigned char *stringDescriptors[] = {
00324 
00325     languageIdDescriptor,
00326     manufacturerDescriptor,
00327     productDescriptor,
00328     serialNumberDescriptor,
00329 };
00330 
00331 /*----------------------------------------------------------------------------
00332  *         Exported variables
00333  *----------------------------------------------------------------------------*/
00334 
00335 /** List of descriptors required by an USB audio speaker device driver. */
00336 const USBDDriverDescriptors cdchiddDriverDescriptors = {
00337 
00338     &deviceDescriptor,
00339     (const USBConfigurationDescriptor *) &configurationDescriptorsFS,
00340     &qualifierDescriptor,
00341     0, 0, 0,
00342     &qualifierDescriptor, 0,
00343     stringDescriptors,
00344     4 /* Number of string descriptors */
00345 };
00346 /**@}*/
00347 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines