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