SAMV71 Xplained Ultra Software Package 1.3

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 
00031 /** \file
00032  * \addtogroup usbd_eem
00033  *@{
00034  */
00035 
00036 /*------------------------------------------------------------------------------
00037  *         Headers
00038  *------------------------------------------------------------------------------*/
00039 
00040 #include "board.h"
00041 #include "USBD_Config.h"
00042 #include "CDCDEEMDriver.h"
00043 
00044 /*------------------------------------------------------------------------------
00045  *         Definitions
00046  *------------------------------------------------------------------------------*/
00047 
00048 /** \addtogroup usbd_cdc_serial_device_ids CDC EEM Device IDs
00049  *      @{
00050  * This page lists the IDs used in the CDC EEM Device Descriptor.
00051  *
00052  * \section IDs
00053  * - CDCDEEMDriverDescriptors_PRODUCTID
00054  * - CDCDEEMDriverDescriptors_VENDORID
00055  * - CDCDEEMDriverDescriptors_RELEASE
00056  */
00057 
00058 /** Device product ID. */
00059 #define CDCDEEMDriverDescriptors_PRODUCTID       USBD_PID_CDCEEM
00060 /** Device vendor ID (Atmel). */
00061 #define CDCDEEMDriverDescriptors_VENDORID        USBD_VID_ATMEL
00062 /** Device release number. */
00063 #define CDCDEEMDriverDescriptors_RELEASE         USBD_RELEASE_1_00
00064 /**      @}*/
00065 
00066 /*------------------------------------------------------------------------------
00067  *         Macros
00068  *------------------------------------------------------------------------------*/
00069 
00070 /** Returns the minimum between two values. */
00071 #define MIN(a, b)       ((a < b) ? a : b)
00072 
00073 /*------------------------------------------------------------------------------
00074  *         Exported variables
00075  *------------------------------------------------------------------------------*/
00076 
00077 /** Standard USB device descriptor for the CDC serial driver */
00078 const USBDeviceDescriptor deviceDescriptor = {
00079 
00080     sizeof(USBDeviceDescriptor),
00081     USBGenericDescriptor_DEVICE,
00082     USBDeviceDescriptor_USB2_00,
00083     CDCDeviceDescriptor_CLASS,
00084     CDCDeviceDescriptor_SUBCLASS,
00085     CDCDeviceDescriptor_PROTOCOL,
00086     CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0),
00087     CDCDEEMDriverDescriptors_VENDORID,
00088     CDCDEEMDriverDescriptors_PRODUCTID,
00089     CDCDEEMDriverDescriptors_RELEASE,
00090     0, /* No string descriptor for manufacturer */
00091     1, /* Index of product string descriptor is #1 */
00092     0, /* No string descriptor for serial number */
00093     1 /* Device has 1 possible configuration */
00094 };
00095 
00096 /** Standard USB configuration descriptor for the CDC serial driver */
00097 const CDCDEEMDriverConfigurationDescriptors configurationDescriptorsFS = {
00098 
00099     /* Standard configuration descriptor */
00100     {
00101         sizeof(USBConfigurationDescriptor),
00102         USBGenericDescriptor_CONFIGURATION,
00103         sizeof(CDCDEEMDriverConfigurationDescriptors),
00104         1, /* There is one interface in this configuration */
00105         1, /* This is configuration #1 */
00106         0, /* No string descriptor for this configuration */
00107         USBD_BMATTRIBUTES,
00108         USBConfigurationDescriptor_POWER(100)
00109     },
00110     /* Communication class interface standard descriptor */
00111     {
00112         sizeof(USBInterfaceDescriptor),
00113         USBGenericDescriptor_INTERFACE,
00114         0, /* This is interface #0 */
00115         0, /* This is alternate setting #0 for this interface */
00116         2, /* This interface uses 2 endpoints */
00117         CDCCommunicationInterfaceDescriptor_CLASS,
00118         CDCCommunicationInterfaceDescriptor_ETHERNETEMULATIONMODEL,
00119         CDCCommunicationInterfaceDescriptor_EEMPROTOCOL,
00120         0  /* No string descriptor for this interface */
00121     },
00122     /* Bulk-OUT endpoint standard descriptor */
00123     {
00124         sizeof(USBEndpointDescriptor),
00125         USBGenericDescriptor_ENDPOINT,
00126         USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT,
00127                                       CDCDEEMDriverDescriptors_BULKOUT),
00128         USBEndpointDescriptor_BULK,
00129         MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDEEMDriverDescriptors_BULKOUT),
00130             USBEndpointDescriptor_MAXBULKSIZE_FS),
00131         0 /* Must be 0 for full-speed bulk endpoints */
00132     },
00133     /* Bulk-IN endpoint descriptor */
00134     {
00135         sizeof(USBEndpointDescriptor),
00136         USBGenericDescriptor_ENDPOINT,
00137         USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
00138                                       CDCDEEMDriverDescriptors_BULKIN),
00139         USBEndpointDescriptor_BULK,
00140         MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDEEMDriverDescriptors_BULKIN),
00141             USBEndpointDescriptor_MAXBULKSIZE_FS),
00142         0 /* Must be 0 for full-speed bulk endpoints */
00143     }
00144 };
00145 
00146 /** Other-speed configuration descriptor (when in full-speed). */
00147 const CDCDEEMDriverConfigurationDescriptors otherSpeedDescriptorsFS = {
00148 
00149     /* Standard configuration descriptor */
00150     {
00151         sizeof(USBConfigurationDescriptor),
00152         USBGenericDescriptor_OTHERSPEEDCONFIGURATION,
00153         sizeof(CDCDEEMDriverConfigurationDescriptors),
00154         1, /* There is one interface in this configuration */
00155         1, /* This is configuration #1 */
00156         0, /* No string descriptor for this configuration */
00157         BOARD_USB_BMATTRIBUTES,
00158         USBConfigurationDescriptor_POWER(100)
00159     },
00160     /* Communication class interface standard descriptor */
00161     {
00162         sizeof(USBInterfaceDescriptor),
00163         USBGenericDescriptor_INTERFACE,
00164         0, /* This is interface #0 */
00165         0, /* This is alternate setting #0 for this interface */
00166         2, /* This interface uses 2 endpoints */
00167         CDCCommunicationInterfaceDescriptor_CLASS,
00168         CDCCommunicationInterfaceDescriptor_ETHERNETEMULATIONMODEL,
00169         CDCCommunicationInterfaceDescriptor_EEMPROTOCOL,
00170         0  /* No string descriptor for this interface */
00171     },
00172     /* Bulk-OUT endpoint standard descriptor */
00173     {
00174         sizeof(USBEndpointDescriptor), 
00175         USBGenericDescriptor_ENDPOINT,
00176         USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT,
00177                                       CDCDEEMDriverDescriptors_BULKOUT),
00178         USBEndpointDescriptor_BULK,
00179         MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDEEMDriverDescriptors_BULKOUT),
00180             USBEndpointDescriptor_MAXBULKSIZE_HS),
00181         0 /* Must be 0 for full-speed bulk endpoints */
00182     },
00183     /* Bulk-IN endpoint descriptor */
00184     {
00185         sizeof(USBEndpointDescriptor),
00186         USBGenericDescriptor_ENDPOINT,
00187         USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
00188                                       CDCDEEMDriverDescriptors_BULKIN),
00189         USBEndpointDescriptor_BULK,
00190         MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDEEMDriverDescriptors_BULKIN),
00191             USBEndpointDescriptor_MAXBULKSIZE_HS),
00192         0 /* Must be 0 for full-speed bulk endpoints */
00193     }
00194 };
00195 
00196 /** Configuration descriptor (when in high-speed). */
00197 const CDCDEEMDriverConfigurationDescriptors configurationDescriptorsHS = {
00198 
00199     /* Standard configuration descriptor */
00200     {
00201         sizeof(USBConfigurationDescriptor),
00202         USBGenericDescriptor_CONFIGURATION,
00203         sizeof(CDCDEEMDriverConfigurationDescriptors),
00204         1, /* There is one interface in this configuration */
00205         1, /* This is configuration #1 */
00206         0, /* No string descriptor for this configuration */
00207         BOARD_USB_BMATTRIBUTES,
00208         USBConfigurationDescriptor_POWER(100)
00209     },
00210     /* Communication class interface standard descriptor */
00211     {
00212         sizeof(USBInterfaceDescriptor),
00213         USBGenericDescriptor_INTERFACE,
00214         0, /* This is interface #0 */
00215         0, /* This is alternate setting #0 for this interface */
00216         2, /* This interface uses 2 endpoints */
00217         CDCCommunicationInterfaceDescriptor_CLASS,
00218         CDCCommunicationInterfaceDescriptor_ETHERNETEMULATIONMODEL,
00219         CDCCommunicationInterfaceDescriptor_EEMPROTOCOL,
00220         0  /* No string descriptor for this interface */
00221     },
00222     /* Bulk-OUT endpoint standard descriptor */
00223     {
00224         sizeof(USBEndpointDescriptor), 
00225         USBGenericDescriptor_ENDPOINT,
00226         USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT,
00227                                       CDCDEEMDriverDescriptors_BULKOUT),
00228         USBEndpointDescriptor_BULK,
00229         MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDEEMDriverDescriptors_BULKOUT),
00230             USBEndpointDescriptor_MAXBULKSIZE_HS),
00231         0 /* Must be 0 for full-speed bulk endpoints */
00232     },
00233     /* Bulk-IN endpoint descriptor */
00234     {
00235         sizeof(USBEndpointDescriptor),
00236         USBGenericDescriptor_ENDPOINT,
00237         USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
00238                                       CDCDEEMDriverDescriptors_BULKIN),
00239         USBEndpointDescriptor_BULK,
00240         MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDEEMDriverDescriptors_BULKIN),
00241             USBEndpointDescriptor_MAXBULKSIZE_HS),
00242         0 /* Must be 0 for full-speed bulk endpoints */
00243     }
00244 };
00245 
00246 /** Other-speed configuration descriptor (when in high-speed). */
00247 const CDCDEEMDriverConfigurationDescriptors otherSpeedDescriptorsHS = {
00248 
00249     /* Standard configuration descriptor */
00250     {
00251         sizeof(USBConfigurationDescriptor),
00252         USBGenericDescriptor_OTHERSPEEDCONFIGURATION,
00253         sizeof(CDCDEEMDriverConfigurationDescriptors),
00254         1, /* There is one interface in this configuration */
00255         1, /* This is configuration #1 */
00256         0, /* No string descriptor for this configuration */
00257         BOARD_USB_BMATTRIBUTES,
00258         USBConfigurationDescriptor_POWER(100)
00259     },
00260     /* Communication class interface standard descriptor */
00261     {
00262         sizeof(USBInterfaceDescriptor),
00263         USBGenericDescriptor_INTERFACE,
00264         0, /* This is interface #0 */
00265         0, /* This is alternate setting #0 for this interface */
00266         2, /* This interface uses 2 endpoints */
00267         CDCCommunicationInterfaceDescriptor_CLASS,
00268         CDCCommunicationInterfaceDescriptor_ETHERNETEMULATIONMODEL,
00269         CDCCommunicationInterfaceDescriptor_EEMPROTOCOL,
00270         0  /* No string descriptor for this interface */
00271     },
00272     /* Bulk-OUT endpoint standard descriptor */
00273     {
00274         sizeof(USBEndpointDescriptor), 
00275         USBGenericDescriptor_ENDPOINT,
00276         USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT,
00277                                       CDCDEEMDriverDescriptors_BULKOUT),
00278         USBEndpointDescriptor_BULK,
00279         MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDEEMDriverDescriptors_BULKOUT),
00280             USBEndpointDescriptor_MAXBULKSIZE_FS),
00281         0 /* Must be 0 for full-speed bulk endpoints */
00282     },
00283     /* Bulk-IN endpoint descriptor */
00284     {
00285         sizeof(USBEndpointDescriptor),
00286         USBGenericDescriptor_ENDPOINT,
00287         USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
00288                                       CDCDEEMDriverDescriptors_BULKIN),
00289         USBEndpointDescriptor_BULK,
00290         MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDEEMDriverDescriptors_BULKIN),
00291             USBEndpointDescriptor_MAXBULKSIZE_FS),
00292         0 /* Must be 0 for full-speed bulk endpoints */
00293     }
00294 };
00295 
00296 /** Language ID string descriptor */
00297 const unsigned char languageIdStringDescriptor[] = {
00298 
00299     USBStringDescriptor_LENGTH(1),
00300     USBGenericDescriptor_STRING,
00301     USBStringDescriptor_ENGLISH_US
00302 };
00303 
00304 /** Product string descriptor */
00305 const unsigned char productStringDescriptor[] = {
00306 
00307     USBStringDescriptor_LENGTH(12),
00308     USBGenericDescriptor_STRING,
00309     USBStringDescriptor_UNICODE('A'),
00310     USBStringDescriptor_UNICODE('T'),
00311     USBStringDescriptor_UNICODE('9'),
00312     USBStringDescriptor_UNICODE('1'),
00313     USBStringDescriptor_UNICODE('E'),
00314     USBStringDescriptor_UNICODE('t'),
00315     USBStringDescriptor_UNICODE('h'),
00316     USBStringDescriptor_UNICODE('e'),
00317     USBStringDescriptor_UNICODE('r'),
00318     USBStringDescriptor_UNICODE('n'),
00319     USBStringDescriptor_UNICODE('e'),
00320     USBStringDescriptor_UNICODE('t')
00321 };
00322 
00323 /** List of string descriptors used by the device */
00324 const unsigned char *stringDescriptors[] = {
00325 
00326     languageIdStringDescriptor,
00327     productStringDescriptor,
00328 };
00329 
00330 /** List of standard descriptors for the serial driver. */
00331 WEAK const USBDDriverDescriptors cdcdEEMDriverDescriptors = {
00332 
00333     &deviceDescriptor,
00334     (USBConfigurationDescriptor *) &(configurationDescriptorsFS),
00335     0, /* No full-speed device qualifier descriptor */
00336     (USBConfigurationDescriptor *) &(otherSpeedDescriptorsFS),
00337     0, /* No high-speed device descriptor (uses FS one) */
00338     (USBConfigurationDescriptor *) &(configurationDescriptorsHS),
00339     0, /* No high-speed device qualifier descriptor */
00340     (USBConfigurationDescriptor *) &(otherSpeedDescriptorsHS),
00341     stringDescriptors,
00342     2 /* 2 string descriptors in list */
00343 };
00344 
00345 /**@}*/
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines