usb_descriptors.c

Go to the documentation of this file.
00001 /* This file has been prepared for Doxygen automatic documentation generation.*/
00002 /*! \file usb_descriptors.c *****************************************************
00003  *
00004  * \brief
00005  *      This file contains the usb parameters that uniquely identify the
00006  *      application through descriptor tables.
00007  *
00008  * \addtogroup usbstick
00009  *
00010  * \author
00011  *      Atmel Corporation: http://www.atmel.com \n
00012  *      Support email: avr@atmel.com
00013  * \author
00014  *      Colin O'Flynn <coflynn@newae.com>
00015  *
00016  ******************************************************************************/
00017 /* Copyright (c) 2008  ATMEL Corporation
00018    All rights reserved.
00019 
00020    Redistribution and use in source and binary forms, with or without
00021    modification, are permitted provided that the following conditions are met:
00022 
00023    * Redistributions of source code must retain the above copyright
00024      notice, this list of conditions and the following disclaimer.
00025    * Redistributions in binary form must reproduce the above copyright
00026      notice, this list of conditions and the following disclaimer in
00027      the documentation and/or other materials provided with the
00028      distribution.
00029    * Neither the name of the copyright holders nor the names of
00030      contributors may be used to endorse or promote products derived
00031      from this software without specific prior written permission.
00032 
00033   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00034   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00035   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00036   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00037   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00038   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00039   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00040   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00041   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00042   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00043   POSSIBILITY OF SUCH DAMAGE.
00044 */
00045 
00046 /**
00047   \addtogroup usbconf
00048   @{
00049   */
00050 
00051 //_____ I N C L U D E S ____________________________________________________
00052 
00053 #include "config.h"
00054 
00055 #include "usb_drv.h"
00056 #include "usb_descriptors.h"
00057 #include "usb_specific_request.h"
00058 #include "rndis/rndis_task.h"
00059 
00060 
00061 //_____ M A C R O S ________________________________________________________
00062 
00063 
00064 #define USB_ETH_NET_FUNC_DESC(MACAddrString,etherStat,maxSegmentSize,nMCFilters,nPowerFilters) \
00065  { sizeof(S_usb_ethernet_networking_functional_descriptor)      \
00066  , 0x24, 0x0F   \
00067 , MACAddrString \
00068 , etherStat     \
00069 , Usb_write_word_enum_struc(maxSegmentSize)     \
00070 , Usb_write_word_enum_struc(nMCFilters) \
00071 , nPowerFilters \
00072 }
00073 
00074 
00075 
00076 #define USB_CONFIG_DESC(totalsize,interfaceCount,value,stringIndex,attr,power) \
00077  { sizeof(S_usb_configuration_descriptor)       \
00078  , CONFIGURATION_DESCRIPTOR     \
00079  , Usb_write_word_enum_struc(totalsize) \
00080  , interfaceCount       \
00081  , value        \
00082  , stringIndex  \
00083  , attr \
00084  , power        \
00085  }
00086 
00087 #define USB_ENDPOINT(nb,attr,maxpktsize,interval) \
00088 { sizeof(S_usb_endpoint_descriptor) \
00089  , ENDPOINT_DESCRIPTOR \
00090  , nb \
00091  , attr \
00092  , Usb_write_word_enum_struc(maxpktsize) \
00093  , interval \
00094  }
00095 
00096 #define USB_IAD(firstinterface,interfacecount,funcClass,funcSubClass,funcProto,stringIndex) \
00097   { \
00098     sizeof(S_usb_interface_association_descriptor), \
00099     DSC_TYPE_IAD, \
00100     firstinterface,   \
00101     interfacecount,   \
00102     funcClass,        \
00103     funcSubClass,     \
00104     funcProto,        \
00105         stringIndex                     \
00106   }
00107 
00108 #define USB_INTERFACEDESC(nb,altsetting,endpointCount,interfaceClass,interfaceSubClass,interfaceProto,stringIndex) \
00109  { sizeof(S_usb_interface_descriptor)   \
00110  , INTERFACE_DESCRIPTOR \
00111  , nb   \
00112  , altsetting   \
00113  , endpointCount        \
00114  , interfaceClass       \
00115  , interfaceSubClass    \
00116  , interfaceProto       \
00117  , stringIndex  \
00118  }
00119 
00120 
00121 #define FUNC_DESC_HEADER \
00122 0x05, /* bFunctionLength, Descriptor size in bytes*/ \
00123 0x24, /* bDescriptorType, CS_INTERFACE */ \
00124 0x00, /* bDescriptorSubtype, Header Functional Descriptor */ \
00125 0x10,0x01 /* bcdCDC, CDC specification release number in BCD format (1,1) */ 
00126 
00127 #define FUNC_DESC_CALL_MANAGEMENT(caps,dataInterface) \
00128 0x05, /* bFunctionLength, Descriptor size in bytes */ \
00129 0x24, /* bDescriptorType, CS_INTERFACE */ \
00130 0x01, /* bDescriptorSubtype, Call Management Functional Descriptor */ \
00131 caps, /* bmCapabilities */ \
00132 dataInterface /* bDataInterface, Interface used for call management */ 
00133 
00134 /* Abstract Control Management Functional Descriptor */
00135 #define FUNC_DESC_ABSTRACT_CONTROL_MANAGEMENT(caps) \
00136 0x04, /* bFunctionLength, Descriptor size in bytes */ \
00137 0x24, /* bDescriptorType, CS_INTERFACE */ \
00138 0x02, /* bDescriptorSubtype, Call Management Functional Descriptor */ \
00139 caps /* bmCapabilities */
00140 
00141 /* Union Functional Descriptor */ \
00142 #define FUNC_DESC_UNION(masterInterface,slaveInterface) \
00143 0x05, /* bFunctionLength, Descriptor size in bytes */ \
00144 0x24, /* bDescriptorType, CS_INTERFACE */ \
00145 0x06, /* bDescriptorSubtype, Union Functional Descriptor */ \
00146 masterInterface, /* bMasterInterface, The controlling interface for the union (bInterfaceNumber of a Communication or Data Class interface in this configuration) */ \
00147 slaveInterface /* bSlaveInterface0, The controlled interace in the union (bInterfaceNumber of an interface in this configuration) */ \
00148 
00149 #define RNDIS_INTERFACES        \
00150 USB_INTERFACEDESC(      \
00151         INTERFACE0_NB,  \
00152         ALTERNATE0,     \
00153         NB_ENDPOINT0,   \
00154         INTERFACE0_CLASS,       \
00155         INTERFACE0_SUB_CLASS,   \
00156         INTERFACE0_PROTOCOL,    \
00157         USB_STRING_INTERFACE_RNDIS      \
00158 ),      \
00159         {       \
00160                 FUNC_DESC_HEADER, \
00161                 FUNC_DESC_CALL_MANAGEMENT(0x00/*caps*/,0x00/*dataInterface*/), \
00162                 FUNC_DESC_ABSTRACT_CONTROL_MANAGEMENT(0x00), \
00163                 FUNC_DESC_UNION(0x00,0x01), \
00164         }, \
00165         USB_ENDPOINT(ENDPOINT_NB_1,EP_ATTRIBUTES_1,EP_SIZE_1,EP_INTERVAL_1), \
00166 \
00167 USB_INTERFACEDESC(      \
00168         INTERFACE1_NB,  \
00169         ALTERNATE1,     \
00170         NB_ENDPOINT1,   \
00171         INTERFACE1_CLASS,       \
00172         INTERFACE1_SUB_CLASS,   \
00173         INTERFACE1_PROTOCOL,    \
00174         USB_STRING_NONE \
00175 ),      \
00176         USB_ENDPOINT(ENDPOINT_NB_2,EP_ATTRIBUTES_2,EP_SIZE_2,EP_INTERVAL_2), \
00177         USB_ENDPOINT(ENDPOINT_NB_3,EP_ATTRIBUTES_3,EP_SIZE_3,EP_INTERVAL_3)
00178 
00179 #define CDC_SERIAL_INTERFACES \
00180 USB_INTERFACEDESC(      \
00181         INTERFACE2_NB,  \
00182         ALTERNATE2,     \
00183         NB_ENDPOINT2,   \
00184         INTERFACE2_CLASS,       \
00185         INTERFACE2_SUB_CLASS,   \
00186         INTERFACE2_PROTOCOL,    \
00187         USB_STRING_INTERFACE_SERIAL     \
00188 ),      \
00189 {       \
00190                 FUNC_DESC_HEADER, \
00191                 FUNC_DESC_CALL_MANAGEMENT(0x03/*caps*/,0x03/*dataInterface*/), \
00192                 FUNC_DESC_ABSTRACT_CONTROL_MANAGEMENT(0x02), \
00193                 FUNC_DESC_UNION(0x02,0x03), \
00194 },      \
00195 USB_ENDPOINT(ENDPOINT_NB_4,EP_ATTRIBUTES_4,EP_SIZE_4,EP_INTERVAL_4),    \
00196 USB_INTERFACEDESC(      \
00197         INTERFACE3_NB,  \
00198         ALTERNATE3,     \
00199         NB_ENDPOINT3,   \
00200         INTERFACE3_CLASS,       \
00201         INTERFACE3_SUB_CLASS,   \
00202         INTERFACE3_PROTOCOL,    \
00203         USB_STRING_NONE \
00204 ),      \
00205 USB_ENDPOINT(ENDPOINT_NB_5,EP_ATTRIBUTES_5,EP_SIZE_5,EP_INTERVAL_5),    \
00206 USB_ENDPOINT(ENDPOINT_NB_6,EP_ATTRIBUTES_6,EP_SIZE_6,EP_INTERVAL_6)
00207 
00208 #define CDC_EEM_INTERFACES      \
00209 USB_INTERFACEDESC(      \
00210         EEM_INTERFACE0_NB,      \
00211         EEM_ALTERNATE0, \
00212         EEM_NB_ENDPOINT0,       \
00213         EEM_INTERFACE0_CLASS,   \
00214         EEM_INTERFACE0_SUB_CLASS,       \
00215         EEM_INTERFACE0_PROTOCOL,        \
00216         USB_STRING_INTERFACE_EEM        \
00217 ),      \
00218         USB_ENDPOINT(ENDPOINT_NB_1,EP_ATTRIBUTES_1,EP_SIZE_1,EP_INTERVAL_1), \
00219         USB_ENDPOINT(ENDPOINT_NB_2,EP_ATTRIBUTES_2,EP_SIZE_2,EP_INTERVAL_2)
00220 
00221 
00222 
00223 
00224 #if CDC_ECM_USES_INTERRUPT_ENDPOINT
00225 #define CDC_ECM_CONTROL_ENDPOINT_COUNT  1
00226 #define CDC_ECM_CONTROL_ENDPOINT        USB_ENDPOINT(ENDPOINT_NB_1,EP_ATTRIBUTES_1,EP_SIZE_1,EP_INTERVAL_1),
00227 #else
00228 #define CDC_ECM_CONTROL_ENDPOINT_COUNT  0
00229 #define CDC_ECM_CONTROL_ENDPOINT
00230 #endif
00231 
00232 
00233 #define CDC_ECM_INTERFACES      \
00234 USB_INTERFACEDESC(      \
00235         ECM_INTERFACE0_NB,      \
00236         ECM_ALTERNATE0, \
00237         CDC_ECM_CONTROL_ENDPOINT_COUNT, \
00238         ECM_INTERFACE0_CLASS,   \
00239         ECM_INTERFACE0_SUB_CLASS,       \
00240         ECM_INTERFACE0_PROTOCOL,        \
00241         USB_STRING_INTERFACE_ECM        \
00242 ),      \
00243 {       \
00244                 FUNC_DESC_HEADER, \
00245                 FUNC_DESC_UNION(0x00,0x01), \
00246 },      \
00247         USB_ETH_NET_FUNC_DESC(  \
00248                 USB_STRING_MAC_ADDRESS, \
00249                 0,      /* Support no stats for now */ \
00250                 USB_ETH_MTU, /* maxSegmentSize */ \
00251                 0, /* nMCFilters*/      \
00252                 0 /*nPowerFilters*/     \
00253         ), \
00254         CDC_ECM_CONTROL_ENDPOINT \
00255 USB_INTERFACEDESC(      \
00256         ECM_INTERFACE0_NB+1,    \
00257         0,      \
00258         2,      \
00259         10,     \
00260         0,      \
00261         0,      \
00262         USB_STRING_NONE \
00263 ),      \
00264         USB_ENDPOINT(ENDPOINT_NB_2,EP_ATTRIBUTES_2,EP_SIZE_2,EP_INTERVAL_2), \
00265         USB_ENDPOINT(ENDPOINT_NB_3,EP_ATTRIBUTES_3,EP_SIZE_3,EP_INTERVAL_3)
00266 
00267 /*
00268 USB_INTERFACEDESC(      \
00269         ECM_INTERFACE0_NB+1,    \
00270         0,      \
00271         0,      \
00272         10,     \
00273         0,      \
00274         0,      \
00275         USB_STRING_NONE \
00276 ),      \
00277 */
00278 
00279 
00280 
00281 //_____ D E F I N I T I O N ________________________________________________
00282 
00283 /************* COMPOSITE DEVICE DESCRIPTORS (using IAD) **********/
00284 //TODO:Serial port enumeration will prevent falling through to the
00285 //supported network on Mac or Windows. Linux will take either.
00286 //Once Windows loads the RNDIS driver it will use it on a subsequent
00287 //Mac enumeration, and the device will fail to start.
00288 //This doesn't seem to hurt anything but beware, system corruption is
00289 //a possibility.
00290 #if USB_CONF_MACINTOSH
00291 /* Prefer CDC-ECM network enumeration (Macintosh, linux) */
00292 FLASH uint8_t usb_dev_config_order[] = {
00293         USB_CONFIG_RNDIS, //windows gets networking only (if not here gets serial only)
00294 #if USB_CONF_SERIAL
00295         USB_CONFIG_ECM_DEBUG, //mac, linux get networking and serial port
00296 #endif
00297         USB_CONFIG_ECM,
00298 #if USB_CONF_SERIAL
00299         USB_CONFIG_RNDIS_DEBUG,
00300 #endif
00301 //      USB_CONFIG_RNDIS,
00302         USB_CONFIG_EEM,
00303 #if USB_CONF_STORAGE
00304         USB_CONFIG_MS,
00305 #endif
00306 };
00307 #else
00308 /* Prefer RNDIS network enumeration (Windows, linux) */
00309 FLASH uint8_t usb_dev_config_order[] = {
00310 
00311 //      USB_CONFIG_ECM, //windows doesnt like this here, will not go on to RNDIS
00312 #if USB_CONF_SERIAL
00313         USB_CONFIG_RNDIS_DEBUG,
00314 #else
00315         USB_CONFIG_RNDIS,
00316 #endif
00317 #if 0 //XP may have a problem with these extra configurations
00318         USB_CONFIG_RNDIS,
00319 #if USB_CONF_SERIAL
00320         USB_CONFIG_ECM_DEBUG,
00321 #endif
00322         USB_CONFIG_ECM,
00323         USB_CONFIG_EEM,
00324 #if USB_CONF_STORAGE
00325         USB_CONFIG_MS,
00326 #endif
00327 #endif
00328 };
00329 #endif /* USB_CONF_MACINTOSH */
00330 
00331 // usb_user_device_descriptor
00332 FLASH S_usb_device_descriptor usb_dev_desc_composite =
00333 {
00334   sizeof(usb_dev_desc_composite)
00335 , DEVICE_DESCRIPTOR
00336 , Usb_write_word_enum_struc(USB_SPECIFICATION)
00337 , COMPOSITE_DEVICE_CLASS
00338 , COMPOSITE_DEVICE_SUB_CLASS
00339 , COMPOSITE_DEVICE_PROTOCOL
00340 , EP_CONTROL_LENGTH
00341 , Usb_write_word_enum_struc(VENDOR_ID)
00342 , Usb_write_word_enum_struc(COMPOSITE_PRODUCT_ID)
00343 , Usb_write_word_enum_struc(RELEASE_NUMBER)
00344 , USB_STRING_MAN
00345 , USB_STRING_PRODUCT
00346 , USB_STRING_SERIAL
00347 , (sizeof(usb_dev_config_order)/sizeof(*usb_dev_config_order)) //sizeof(*) is sizeof first element
00348 };
00349 
00350 
00351 // usb_user_configuration_descriptor FS
00352 FLASH S_usb_user_configuration_descriptor_composite usb_conf_desc_composite = {
00353         USB_CONFIG_DESC(
00354                 sizeof(usb_conf_desc_composite),
00355                 COMPOSITE_NB_INTERFACE,
00356                 USB_CONFIG_RNDIS_DEBUG,
00357                 USB_STRING_CONFIG_COMPOSITE,
00358                 CONF_ATTRIBUTES,
00359                 MAX_POWER
00360         ),
00361 
00362         USB_IAD(
00363                 0x00,   // First interface
00364                 0x02,   // Interface count
00365                 0x02,   // Function Class
00366                 0x02,   // Function Subclass
00367                 0xFF,   // Function Protocol
00368                 USB_STRING_INTERFACE_RNDIS
00369         ),RNDIS_INTERFACES,
00370 
00371         USB_IAD(
00372                 0x02,   // First interface
00373                 0x02,   // Interface count
00374                 0x02,   // Function Class
00375                 0x02,   // Function Subclass
00376                 0x01,   // Function Protocol
00377                 USB_STRING_INTERFACE_SERIAL
00378         ),CDC_SERIAL_INTERFACES
00379 };
00380 
00381 /****************** NETWORK-ONLY DEVICE DESCRIPTORS **************************/
00382 
00383 /*
00384 FLASH S_usb_device_descriptor usb_dev_desc_network =
00385 {
00386   sizeof(usb_dev_desc_network)
00387 , DEVICE_DESCRIPTOR
00388 , Usb_write_word_enum_struc(USB_SPECIFICATION)
00389 , NETWORK_DEVICE_CLASS
00390 , NETWORK_DEVICE_SUB_CLASS
00391 , NETWORK_DEVICE_PROTOCOL
00392 , EP_CONTROL_LENGTH
00393 , Usb_write_word_enum_struc(VENDOR_ID)
00394 , Usb_write_word_enum_struc(NETWORK_PRODUCT_ID)
00395 , Usb_write_word_enum_struc(RELEASE_NUMBER)
00396 , USB_STRING_MAN
00397 , USB_STRING_PRODUCT
00398 , USB_STRING_SERIAL
00399 , NB_CONFIGURATION
00400 };
00401 */
00402 
00403 // usb_user_configuration_descriptor FS
00404 FLASH S_usb_user_configuration_descriptor_network usb_conf_desc_network = {
00405         USB_CONFIG_DESC(
00406                 sizeof(usb_conf_desc_network),
00407                 NETWORK_NB_INTERFACE,
00408                 CONF_NB,        // value
00409                 USB_STRING_CONFIG_RNDIS,
00410                 CONF_ATTRIBUTES,
00411                 MAX_POWER
00412         ),
00413         RNDIS_INTERFACES
00414 };
00415 
00416 
00417 
00418 /************* EEM-ONLY ***************/
00419 
00420 // usb_user_device_descriptor
00421 /*
00422 FLASH S_usb_device_descriptor usb_dev_desc_eem =
00423 {
00424   sizeof(usb_dev_desc_composite)
00425 , DEVICE_DESCRIPTOR
00426 , Usb_write_word_enum_struc(USB_SPECIFICATION)
00427 , EEM_DEVICE_CLASS
00428 , EEM_DEVICE_SUB_CLASS
00429 , EEM_DEVICE_PROTOCOL
00430 , EP_CONTROL_LENGTH
00431 , Usb_write_word_enum_struc(VENDOR_ID)
00432 , Usb_write_word_enum_struc(COMPOSITE_PRODUCT_ID)
00433 , Usb_write_word_enum_struc(RELEASE_NUMBER)
00434 , USB_STRING_MAN
00435 , USB_STRING_PRODUCT
00436 , USB_STRING_SERIAL
00437 , NB_CONFIGURATION
00438 };
00439 */
00440 
00441 
00442 // usb_user_configuration_descriptor FS
00443 FLASH S_usb_user_configuration_descriptor_eem usb_conf_desc_eem = {
00444         USB_CONFIG_DESC(
00445                 sizeof(usb_conf_desc_eem),
00446                 EEM_NB_INTERFACE,
00447                 USB_CONFIG_EEM, // value
00448                 USB_STRING_CONFIG_EEM,
00449                 CONF_ATTRIBUTES,
00450                 MAX_POWER
00451         ),
00452         CDC_EEM_INTERFACES
00453 };
00454 
00455 
00456 FLASH S_usb_user_configuration_descriptor_ecm usb_conf_desc_ecm = {
00457         USB_CONFIG_DESC(
00458                 sizeof(usb_conf_desc_ecm),
00459                 2,      // Interface Count
00460                 USB_CONFIG_ECM, // value
00461                 USB_STRING_CONFIG_ECM,
00462                 CONF_ATTRIBUTES,
00463                 MAX_POWER
00464         ),
00465         CDC_ECM_INTERFACES
00466 };
00467 
00468 FLASH S_usb_user_configuration_descriptor_ecm_debug usb_conf_desc_ecm_debug = {
00469         USB_CONFIG_DESC(
00470                 sizeof(usb_conf_desc_ecm_debug),
00471                 4,      // Interface Count
00472                 USB_CONFIG_ECM_DEBUG,   // value
00473                 USB_STRING_CONFIG_ECM_DEBUG,
00474                 CONF_ATTRIBUTES,
00475                 MAX_POWER
00476         ),
00477 
00478         USB_IAD(
00479                 0x00,   // First interface
00480                 0x02,   // Interface count
00481                 0x02,   // Function Class
00482                 0x06,   // Function Subclass
00483                 0x00,   // Function Protocol
00484                 USB_STRING_INTERFACE_ECM
00485         ),CDC_ECM_INTERFACES,
00486 
00487         USB_IAD(
00488                 0x02,   // First interface
00489                 0x02,   // Interface count
00490                 0x02,   // Function Class
00491                 0x02,   // Function Subclass
00492                 0x01,   // Function Protocol
00493                 USB_STRING_INTERFACE_SERIAL
00494         ),CDC_SERIAL_INTERFACES
00495 
00496 
00497         
00498 };
00499 
00500 
00501 
00502 /****************** MASS-STORAGE DEVICE DESCRIPTORS **************************/
00503 
00504 /*
00505 FLASH S_usb_device_descriptor usb_dev_desc_mass =
00506 {
00507   sizeof(usb_dev_desc_mass)
00508 , DEVICE_DESCRIPTOR
00509 , Usb_write_word_enum_struc(USB_SPECIFICATION)
00510 , MASS_DEVICE_CLASS
00511 , MASS_DEVICE_SUB_CLASS
00512 , MASS_DEVICE_PROTOCOL
00513 , EP_CONTROL_LENGTH
00514 , Usb_write_word_enum_struc(VENDOR_ID)
00515 , Usb_write_word_enum_struc(MASS_PRODUCT_ID)
00516 , Usb_write_word_enum_struc(RELEASE_NUMBER)
00517 , USB_STRING_MAN
00518 , USB_STRING_PRODUCT
00519 , USB_STRING_SERIAL
00520 , NB_CONFIGURATION
00521 };
00522 */
00523 #if USB_CONF_STORAGE
00524 
00525 // usb_user_configuration_descriptor FS
00526 FLASH S_usb_user_configuration_descriptor_mass usb_conf_desc_mass = {
00527  { sizeof(S_usb_configuration_descriptor)
00528  , CONFIGURATION_DESCRIPTOR
00529  , Usb_write_word_enum_struc(sizeof(S_usb_user_configuration_descriptor_mass))
00530  , MASS_NB_INTERFACE
00531  , CONF_NB
00532  , USB_STRING_CONFIG_MS
00533  , CONF_ATTRIBUTES
00534  , MAX_POWER
00535  },//9
00536 
00537   /// Mass storage
00538  { sizeof(S_usb_interface_descriptor)
00539  , INTERFACE_DESCRIPTOR
00540  , MS_INTERFACE_NB
00541  , MS_ALTERNATE
00542  , MS_NB_ENDPOINT
00543  , MS_INTERFACE_CLASS
00544  , MS_INTERFACE_SUB_CLASS
00545  , MS_INTERFACE_PROTOCOL
00546  , USB_STRING_INTERFACE_MS
00547  } //9
00548 ,
00549 { sizeof(S_usb_endpoint_descriptor)
00550  , ENDPOINT_DESCRIPTOR
00551  , MS_ENDPOINT_NB_1
00552  , MS_EP_ATTRIBUTES_1
00553  , Usb_write_word_enum_struc(MS_EP_SIZE_1)
00554  , MS_EP_INTERVAL_1
00555  } //7
00556  ,
00557  { sizeof(S_usb_endpoint_descriptor)
00558  , ENDPOINT_DESCRIPTOR
00559  , MS_ENDPOINT_NB_2
00560  , MS_EP_ATTRIBUTES_2
00561  , Usb_write_word_enum_struc(MS_EP_SIZE_2)
00562  , MS_EP_INTERVAL_2
00563  }
00564 };
00565 
00566 #endif
00567 
00568 /************* COMMON *****************/
00569 
00570 
00571 
00572                                       // usb_user_language_id
00573 
00574 FLASH S_usb_language_id usb_user_language_id = {
00575   sizeof(usb_user_language_id)
00576 , STRING_DESCRIPTOR
00577 , Usb_write_word_enum_struc(LANGUAGE_ID)
00578 };
00579 
00580 
00581 
00582 
00583 
00584 PGM_VOID_P Usb_get_dev_desc_pointer(void)
00585 {
00586 #if 1
00587         return &(usb_dev_desc_composite.bLength);
00588 #else  //these are all the same length
00589         if (usb_mode == rndis_only)
00590                 return &(usb_dev_desc_network.bLength);
00591 
00592         if (usb_mode == rndis_debug)
00593                 return &(usb_dev_desc_composite.bLength);
00594 
00595         if (usb_mode == eem)
00596                 return &(usb_dev_desc_eem.bLength);
00597 
00598         return &(usb_dev_desc_mass.bLength);
00599 #endif
00600 }
00601 
00602 
00603 U8 Usb_get_dev_desc_length(void)
00604 {
00605 #if 1 
00606         return sizeof(usb_dev_desc_composite);
00607 #else  //these are all the same size
00608         if (usb_mode == rndis_only)
00609                 return sizeof(usb_dev_desc_network);
00610 
00611         if (usb_mode == rndis_debug)
00612                 return sizeof(usb_dev_desc_composite);
00613 
00614         if (usb_mode == eem)
00615                 return sizeof(usb_dev_desc_eem);
00616 
00617         return sizeof(usb_dev_desc_mass);
00618 #endif
00619 }
00620 
00621 
00622 PGM_VOID_P  Usb_get_conf_desc_pointer(U8 index)
00623 {
00624         
00625         switch(pgm_read_byte_near(&usb_dev_config_order[index])) {
00626                 case USB_CONFIG_ECM:
00627                         return &(usb_conf_desc_ecm.cfg.bLength);
00628                 case USB_CONFIG_ECM_DEBUG:
00629                         return &(usb_conf_desc_ecm_debug.cfg.bLength);
00630                 case USB_CONFIG_RNDIS_DEBUG:
00631                         return &(usb_conf_desc_composite.cfg.bLength);
00632                 case USB_CONFIG_RNDIS:
00633                         return &(usb_conf_desc_network.cfg.bLength);
00634                 case USB_CONFIG_EEM:
00635                         return &(usb_conf_desc_eem.cfg.bLength);                
00636 #if USB_CONF_STORAGE
00637                 case USB_CONFIG_MS:
00638                         return &(usb_conf_desc_mass.cfg.bLength);
00639 #endif
00640                 default:
00641                         return 0;
00642         }
00643 }
00644 
00645 
00646 U8  Usb_get_conf_desc_length(U8 index)
00647 {
00648         switch(pgm_read_byte_near(&usb_dev_config_order[index])) {
00649                 case USB_CONFIG_ECM:
00650                         return sizeof(usb_conf_desc_ecm);
00651                 case USB_CONFIG_ECM_DEBUG:
00652                         return sizeof(usb_conf_desc_ecm_debug);
00653                 case USB_CONFIG_RNDIS_DEBUG:
00654                         return sizeof(usb_conf_desc_composite);
00655                 case USB_CONFIG_RNDIS:
00656                         return sizeof (usb_conf_desc_network);
00657                 case USB_CONFIG_EEM:
00658                         return sizeof(usb_conf_desc_eem);
00659 #if USB_CONF_STORAGE
00660                 case USB_CONFIG_MS:
00661                         return sizeof(usb_conf_desc_mass);
00662 #endif
00663                 default:
00664                         return 0;
00665         }
00666 }
00667 
00668 /** @} */

Generated on Mon Apr 11 14:23:36 2011 for Contiki 2.5 by  doxygen 1.6.1