SAM3S8/SD8 Software Package: examples_usb/usb_massstorage/device_descriptor.c Source File

SAM3S8/SD8 Software Package 1.2

# device_descriptor.c

Go to the documentation of this file.

    00001 /* ----------------------------------------------------------------------------
    00002  *         ATMEL Microcontroller Software Support
    00003  * ----------------------------------------------------------------------------
    00004  * Copyright (c) 2008, 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  * \addtogroup usbd_msd
    00032  *@{
    00033  */
    00034
    00035 /*------------------------------------------------------------------------------
    00036  *         Headers
    00037  *------------------------------------------------------------------------------*/
    00038
    00039 #include "board.h"
    00040 #include "USBDescriptors.h"
    00041 #include "MSDescriptors.h"
    00042 #include "MSDDriver.h"
    00043
    00044
    00045 /*------------------------------------------------------------------------------
    00046  *         Internal definitions
    00047  *------------------------------------------------------------------------------*/
    00048
    00049 /** \addtogroup usbd_general_config USBD General Configure
    00050  *      @{
    00051  * This page lists general configurations for all USB device drivers.
    00052  * - \ref USBD_BMATTRIBUTES
    00053  */
    00054 /** default USB Device attributes configuration descriptor
    00055  *  (bus or self powered, remote wakeup) */
    00056 #define USBD_BMATTRIBUTES           BOARD_USB_BMATTRIBUTES
    00057 /**     @}*/
    00058
    00059 /** \addtogroup usbd_msdd_config USB MassStorage Configure
    00060  *      @{
    00061  * This page lists the defines used by the Mass Storage driver.
    00062  *
    00063  * \section msd_ep_addr Endpoint Addresses
    00064  * - \ref MSDDriverDescriptors_BULKOUT
    00065  * - \ref MSDDriverDescriptors_BULKIN
    00066  */
    00067 /** Address of the Mass Storage bulk-out endpoint.*/
    00068 #define MSDDriverDescriptors_BULKOUT                1
    00069 /** Address of the Mass Storage bulk-in endpoint.*/
    00070 #define MSDDriverDescriptors_BULKIN                 2
    00071 /**      @}*/
    00072
    00073 /** \addtogroup usbd_msd_device_descriptor_ids MSD Device Descriptor IDs
    00074  *      @{
    00075  * \section IDs
    00076  * - MSDDriverDescriptors_VENDORID
    00077  * - MSDDriverDescriptors_PRODUCTID
    00078  * - MSDDriverDescriptors_RELEASE
    00079  */
    00080
    00081 /** Vendor ID for the Mass Storage device driver. */
    00082 #define MSDDriverDescriptors_VENDORID       0x03EB
    00083 /** Product ID for the Mass Storage device driver. */
    00084 #define MSDDriverDescriptors_PRODUCTID      0x6129
    00085 /** Device release number for the Mass Storage device driver. */
    00086 #define MSDDriverDescriptors_RELEASE        0x0100
    00087 /*------------------------------------------------------------------------------ */
    00088
    00089 /**      @}*/
    00090
    00091 /*------------------------------------------------------------------------------
    00092  *         Macros
    00093  *------------------------------------------------------------------------------*/
    00094
    00095 /** Returns the minimum between two values. */
    00096 #define MIN(a, b)       ((a < b) ? a : b)
    00097
    00098 /*------------------------------------------------------------------------------
    00099  *         Local variables
    00100  *------------------------------------------------------------------------------*/
    00101
    00102 /** Mass storage driver device descriptor. */
    00103 static const USBDeviceDescriptor deviceDescriptor = {
    00104
    00105     sizeof(USBDeviceDescriptor),
    00106     USBGenericDescriptor_DEVICE,
    00107     USBDeviceDescriptor_USB2_00,
    00108     MSDeviceDescriptor_CLASS,
    00109     MSDeviceDescriptor_SUBCLASS,
    00110     MSDeviceDescriptor_PROTOCOL,
    00111     CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0),
    00112     MSDDriverDescriptors_VENDORID,
    00113     MSDDriverDescriptors_PRODUCTID,
    00114     MSDDriverDescriptors_RELEASE,
    00115     1, /* Manufacturer string descriptor index. */
    00116     2, /* Product string descriptor index. */
    00117     3, /* Serial number string descriptor index. */
    00118     1  /* Device has one possible configuration. */
    00119 };
    00120
    00121 /** Full-speed configuration descriptor. */
    00122 static const MSDConfigurationDescriptors configurationDescriptorsFS = {
    00123
    00124     /* Standard configuration descriptor. */
    00125     {
    00126         sizeof(USBConfigurationDescriptor),
    00127         USBGenericDescriptor_CONFIGURATION,
    00128         sizeof(MSDConfigurationDescriptors),
    00129         1, /* Configuration has one interface. */
    00130         1, /* This is configuration #1. */
    00131         0, /* No string descriptor for configuration. */
    00132         USBD_BMATTRIBUTES,
    00133         USBConfigurationDescriptor_POWER(100)
    00134     },
    00135     /* Mass Storage interface descriptor. */
    00136     {
    00137         sizeof(USBInterfaceDescriptor),
    00138         USBGenericDescriptor_INTERFACE,
    00139         0, /* This is interface #0. */
    00140         0, /* This is alternate setting #0. */
    00141         2, /* Interface uses two endpoints. */
    00142         MSInterfaceDescriptor_CLASS,
    00143         MSInterfaceDescriptor_SCSI,
    00144         MSInterfaceDescriptor_BULKONLY,
    00145         0 /* No string descriptor for interface. */
    00146     },
    00147     /* Bulk-OUT endpoint descriptor */
    00148     {
    00149         sizeof(USBEndpointDescriptor),
    00150         USBGenericDescriptor_ENDPOINT,
    00151         USBEndpointDescriptor_ADDRESS(
    00152             USBEndpointDescriptor_OUT,
    00153             MSDDriverDescriptors_BULKOUT),
    00154         USBEndpointDescriptor_BULK,
    00155         MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(MSDDriverDescriptors_BULKOUT),
    00156             USBEndpointDescriptor_MAXBULKSIZE_FS),
    00157         0 /* Must be 0 for full-speed Bulk endpoints. */
    00158     },
    00159     /* Bulk-IN endpoint descriptor */
    00160     {
    00161         sizeof(USBEndpointDescriptor),
    00162         USBGenericDescriptor_ENDPOINT,
    00163         USBEndpointDescriptor_ADDRESS(
    00164             USBEndpointDescriptor_IN,
    00165             MSDDriverDescriptors_BULKIN),
    00166         USBEndpointDescriptor_BULK,
    00167         MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(MSDDriverDescriptors_BULKIN),
    00168             USBEndpointDescriptor_MAXBULKSIZE_FS),
    00169         0 /* Must be 0 for full-speed Bulk endpoints. */
    00170
    00171     }
    00172 };
    00173
    00174 /** Language ID string descriptor. */
    00175 static const unsigned char languageIdDescriptor[] = {
    00176
    00177     USBStringDescriptor_LENGTH(1),
    00178     USBGenericDescriptor_STRING,
    00179     USBStringDescriptor_ENGLISH_US
    00180 };
    00181
    00182 /** Manufacturer string descriptor. */
    00183 static const unsigned char manufacturerDescriptor[] = {
    00184
    00185     USBStringDescriptor_LENGTH(5),
    00186     USBGenericDescriptor_STRING,
    00187     USBStringDescriptor_UNICODE('A'),
    00188     USBStringDescriptor_UNICODE('T'),
    00189     USBStringDescriptor_UNICODE('M'),
    00190     USBStringDescriptor_UNICODE('E'),
    00191     USBStringDescriptor_UNICODE('L')
    00192 };
    00193
    00194 /** Product string descriptor. */
    00195 static const unsigned char productDescriptor[] = {
    00196
    00197     USBStringDescriptor_LENGTH(14),
    00198     USBGenericDescriptor_STRING,
    00199     USBStringDescriptor_UNICODE('A'),
    00200     USBStringDescriptor_UNICODE('T'),
    00201     USBStringDescriptor_UNICODE('M'),
    00202     USBStringDescriptor_UNICODE('E'),
    00203     USBStringDescriptor_UNICODE('L'),
    00204     USBStringDescriptor_UNICODE(' '),
    00205     USBStringDescriptor_UNICODE('A'),
    00206     USBStringDescriptor_UNICODE('T'),
    00207     USBStringDescriptor_UNICODE('9'),
    00208     USBStringDescriptor_UNICODE('1'),
    00209     USBStringDescriptor_UNICODE(' '),
    00210     USBStringDescriptor_UNICODE('M'),
    00211     USBStringDescriptor_UNICODE('S'),
    00212     USBStringDescriptor_UNICODE('D')
    00213 };
    00214
    00215 /** Serial number string descriptor. The serial number must be at least 12 */
    00216 /** characters long and made up of only letters & numbers to be compliant with */
    00217 /** the MSD specification. */
    00218 static const unsigned char serialNumberDescriptor[] = {
    00219
    00220     USBStringDescriptor_LENGTH(12),
    00221     USBGenericDescriptor_STRING,
    00222     USBStringDescriptor_UNICODE('0'),
    00223     USBStringDescriptor_UNICODE('1'),
    00224     USBStringDescriptor_UNICODE('2'),
    00225     USBStringDescriptor_UNICODE('3'),
    00226     USBStringDescriptor_UNICODE('4'),
    00227     USBStringDescriptor_UNICODE('5'),
    00228     USBStringDescriptor_UNICODE('6'),
    00229     USBStringDescriptor_UNICODE('7'),
    00230     USBStringDescriptor_UNICODE('8'),
    00231     USBStringDescriptor_UNICODE('9'),
    00232     USBStringDescriptor_UNICODE('A'),
    00233     USBStringDescriptor_UNICODE('B')
    00234 };
    00235
    00236 /** List of all string descriptors used. */
    00237 static const unsigned char *stringDescriptors[] = {
    00238
    00239     languageIdDescriptor,
    00240     manufacturerDescriptor,
    00241     productDescriptor,
    00242     serialNumberDescriptor
    00243 };
    00244
    00245 /*------------------------------------------------------------------------------ */
    00246
    00247 /*         Global variables */
    00248
    00249 /*------------------------------------------------------------------------------ */
    00250
    00251
    00252 /** List of the standard descriptors used by the Mass Storage driver. */
    00253 const USBDDriverDescriptors msdDriverDescriptors = {
    00254
    00255     &deviceDescriptor,
    00256     (USBConfigurationDescriptor *) &configurationDescriptorsFS,
    00257     0, /* No full-speed device qualifier descriptor */
    00258     0, /* No full-speed other speed configuration */
    00259     0, /* No high-speed device descriptor */
    00260     0, /* No high-speed configuration descriptor */
    00261     0, /* No high-speed device qualifier descriptor */
    00262     0, /* No high-speed other speed configuration descriptor */
    00263     stringDescriptors,
    00264     4 /* Four string descriptors in array */
    00265
    00266 };
    00267
    00268 /**@}*/

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines