usb_descriptors.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 #ifndef _USB_USERCONFIG_H_
00052 #define _USB_USERCONFIG_H_
00053
00054
00055
00056 #include "config.h"
00057 #include "usb_standard_request.h"
00058 #include "conf_usb.h"
00059 #include <avr/pgmspace.h>
00060
00061
00062
00063
00064
00065
00066
00067 #define USB_SPECIFICATION 0x0200
00068 #if USB_CONF_MACINTOSH
00069 #define COMPOSITE_DEVICE_CLASS 0x02 // Misc
00070 #define COMPOSITE_DEVICE_SUB_CLASS 0x00 // Common
00071 #define COMPOSITE_DEVICE_PROTOCOL 0x00 // IAD
00072 #else //Windows wants these for composite device
00073
00074 #define COMPOSITE_DEVICE_CLASS 0xEF // Misc
00075 #define COMPOSITE_DEVICE_SUB_CLASS 0x02 // Common
00076 #define COMPOSITE_DEVICE_PROTOCOL 0x01 // IAD
00077 #endif
00078
00079 #define NETWORK_DEVICE_CLASS 0x02 // CDC ACM
00080 #define NETWORK_DEVICE_SUB_CLASS 0x02 //
00081 #define NETWORK_DEVICE_PROTOCOL 0xFF // Vendor-specific
00082
00083 #define MASS_DEVICE_CLASS 0x00 //
00084 #define MASS_DEVICE_SUB_CLASS 0x00 //
00085 #define MASS_DEVICE_PROTOCOL 0x00 //
00086
00087 #define EEM_DEVICE_CLASS 0x02 // CDC
00088 #define EEM_DEVICE_SUB_CLASS 0x0C // EEM
00089 #define EEM_DEVICE_PROTOCOL 0x07 // EEM
00090
00091 #define EP_CONTROL_LENGTH 64
00092 #define VENDOR_ID 0x03EB // Atmel vendor ID = 03EBh
00093
00094 #if USB_CONF_MACINTOSH
00095
00096
00097 #define COMPOSITE_PRODUCT_ID 0x9921 //Product ID for composite device
00098 #define NETWORK_PRODUCT_ID 0x9919 //Product ID for just CDC-ECM device
00099 #else
00100 #define COMPOSITE_PRODUCT_ID 0x2021 //Product ID for composite device
00101 #define NETWORK_PRODUCT_ID 0x2019 //Product ID for just RNDIS device
00102 #endif
00103
00104 #define MASS_PRODUCT_ID 0x202F //Product ID for mass storage
00105 #define RELEASE_NUMBER 0x1000
00106
00107 enum {
00108 USB_STRING_NONE = 0,
00109 USB_STRING_MAN = 1,
00110 USB_STRING_PRODUCT,
00111 USB_STRING_SERIAL,
00112 USB_STRING_MAC_ADDRESS,
00113 USB_STRING_CONFIG_COMPOSITE,
00114 USB_STRING_CONFIG_RNDIS,
00115 USB_STRING_CONFIG_EEM,
00116 USB_STRING_CONFIG_ECM,
00117 USB_STRING_CONFIG_ECM_DEBUG,
00118 USB_STRING_CONFIG_MS,
00119 USB_STRING_INTERFACE_RNDIS,
00120 USB_STRING_INTERFACE_EEM,
00121 USB_STRING_INTERFACE_ECM,
00122 USB_STRING_INTERFACE_ECM_ATTACHED,
00123 USB_STRING_INTERFACE_ECM_DETACHED,
00124 USB_STRING_INTERFACE_SERIAL,
00125 USB_STRING_INTERFACE_MS,
00126
00127 };
00128
00129 enum {
00130 USB_CONFIG_UNCONFIGURED = 0,
00131
00132 USB_CONFIG_RNDIS = 1,
00133 USB_CONFIG_RNDIS_DEBUG = 1+(1<<7),
00134
00135 USB_CONFIG_ECM = 2,
00136 USB_CONFIG_ECM_DEBUG = 2+(1<<7),
00137
00138 USB_CONFIG_EEM = 3,
00139
00140 #if USB_CONF_STORAGE
00141 USB_CONFIG_MS = 4,
00142 #endif
00143 };
00144
00145 #define USB_CONFIG_HAS_DEBUG_PORT(x) ((x==USB_CONFIG_ECM_DEBUG)||(x==USB_CONFIG_RNDIS_DEBUG))
00146
00147
00148
00149
00150 #define NETWORK_NB_INTERFACE 2
00151 #define COMPOSITE_NB_INTERFACE 4
00152 #define MASS_NB_INTERFACE 1
00153 #define EEM_NB_INTERFACE 1
00154 #define CONF_NB 1
00155 #define CONF_INDEX 0
00156 #define CONF_ATTRIBUTES USB_CONFIG_BUSPOWERED
00157 #define MAX_POWER 50 // 100 mA
00158
00159
00160
00161
00162 #define INTERFACE0_NB 0
00163 #define ALTERNATE0 0
00164 #define NB_ENDPOINT0 1
00165 #define INTERFACE0_CLASS 0x02 // CDC ACM Com
00166 #define INTERFACE0_SUB_CLASS 0x02
00167 #define INTERFACE0_PROTOCOL 0xFF // Vendor specific
00168 #define INTERFACE0_INDEX 0
00169
00170
00171 #define INTERFACE1_NB 1
00172 #define ALTERNATE1 0
00173 #define NB_ENDPOINT1 2
00174 #define INTERFACE1_CLASS 0x0A // CDC ACM Data
00175 #define INTERFACE1_SUB_CLASS 0
00176 #define INTERFACE1_PROTOCOL 0
00177 #define INTERFACE1_INDEX 0
00178
00179
00180
00181 #define ENDPOINT_NB_1 0x80 | INT_EP
00182 #define EP_ATTRIBUTES_1 0x03 // BULK = 0x02, INTERUPT = 0x03
00183 #define EP_SIZE_1 0x08
00184 #define EP_INTERVAL_1 0x01 //ms interrupt pooling from host
00185
00186
00187
00188 #define ENDPOINT_NB_2 0x80 | TX_EP
00189 #define EP_ATTRIBUTES_2 0x02 // BULK = 0x02, INTERUPT = 0x03
00190 #define EP_SIZE_2 0x40 //64 byte max size
00191 #define EP_INTERVAL_2 0x01
00192
00193
00194
00195 #define ENDPOINT_NB_3 RX_EP
00196 #define EP_ATTRIBUTES_3 0x02 // BULK = 0x02, INTERUPT = 0x03
00197 #define EP_SIZE_3 0x40 //64 byte max size
00198 #define EP_INTERVAL_3 0x01
00199
00200
00201
00202
00203 #define INTERFACE2_NB 2
00204 #define ALTERNATE2 0
00205 #define NB_ENDPOINT2 1
00206 #define INTERFACE2_CLASS 0x02 // CDC ACM Com
00207 #define INTERFACE2_SUB_CLASS 0x02
00208 #define INTERFACE2_PROTOCOL 0x01
00209 #define INTERFACE2_INDEX 0
00210
00211
00212 #define INTERFACE3_NB 3
00213 #define ALTERNATE3 0
00214 #define NB_ENDPOINT3 2
00215 #define INTERFACE3_CLASS 0x0A // CDC ACM Data
00216 #define INTERFACE3_SUB_CLASS 0
00217 #define INTERFACE3_PROTOCOL 0
00218 #define INTERFACE3_INDEX 0
00219
00220
00221
00222 #define TX_EP_SIZE 0x20
00223 #define ENDPOINT_NB_4 0x80 | VCP_INT_EP
00224 #define EP_ATTRIBUTES_4 0x03 // BULK = 0x02, INTERUPT = 0x03
00225 #define EP_SIZE_4 TX_EP_SIZE
00226 #define EP_INTERVAL_4 0xFF //ms interrupt pooling from host
00227
00228
00229
00230 #define ENDPOINT_NB_5 0x80 | VCP_TX_EP
00231 #define EP_ATTRIBUTES_5 0x02 // BULK = 0x02, INTERUPT = 0x03
00232 #define EP_SIZE_5 0x20
00233 #define EP_INTERVAL_5 0x01
00234
00235
00236
00237 #define ENDPOINT_NB_6 VCP_RX_EP
00238 #define EP_ATTRIBUTES_6 0x02 // BULK = 0x02, INTERUPT = 0x03
00239 #define EP_SIZE_6 0x20
00240 #define EP_INTERVAL_6 0x01
00241
00242
00243
00244 #define MS_INTERFACE_NB 0
00245 #define MS_ALTERNATE 0
00246 #define MS_NB_ENDPOINT 2
00247 #define MS_INTERFACE_CLASS 0x08 // Mass Storage Class
00248 #define MS_INTERFACE_SUB_CLASS 0x06 // SCSI transparent Command Set
00249 #define MS_INTERFACE_PROTOCOL 0x50 // Bulk-Only Transport
00250 #define MS_INTERFACE_INDEX 0
00251
00252
00253 #define MS_ENDPOINT_NB_1 (MS_IN_EP | 0x80)
00254 #define MS_EP_ATTRIBUTES_1 0x02 // BULK = 0x02, INTERUPT = 0x03
00255 #define MS_EP_IN_LENGTH 64
00256 #define MS_EP_SIZE_1 MS_EP_IN_LENGTH
00257 #define MS_EP_INTERVAL_1 0x00
00258
00259
00260
00261 #define MS_ENDPOINT_NB_2 MS_OUT_EP
00262 #define MS_EP_ATTRIBUTES_2 0x02 // BULK = 0x02, INTERUPT = 0x03
00263 #define MS_EP_IN_LENGTH 64
00264 #define MS_EP_SIZE_2 MS_EP_IN_LENGTH
00265 #define MS_EP_INTERVAL_2 0x00
00266
00267
00268
00269
00270 #define EEM_INTERFACE0_NB 0
00271 #define EEM_ALTERNATE0 0
00272 #define EEM_NB_ENDPOINT0 2
00273 #define EEM_INTERFACE0_CLASS 0x02 // CDC ACM Com
00274 #define EEM_INTERFACE0_SUB_CLASS 0x0C // EEM
00275 #define EEM_INTERFACE0_PROTOCOL 0x07 // EEM
00276 #define EEM_INTERFACE0_INDEX 0
00277
00278
00279
00280 #define EEM_ENDPOINT_NB_1 0x80 | TX_EP
00281 #define EEM_EP_ATTRIBUTES_1 0x02 // BULK = 0x02, INTERUPT = 0x03
00282 #define EEM_EP_SIZE_1 0x40 //64 byte max size
00283 #define EEM_EP_INTERVAL_1 0x01
00284
00285
00286
00287 #define EEM_ENDPOINT_NB_2 RX_EP
00288 #define EEM_EP_ATTRIBUTES_2 0x02 // BULK = 0x02, INTERUPT = 0x03
00289 #define EEM_EP_SIZE_2 0x40 //64 byte max size
00290 #define EEM_EP_INTERVAL_2 0x01
00291
00292
00293
00294
00295 #define ECM_INTERFACE0_NB 0
00296 #define ECM_ALTERNATE0 0
00297 #define ECM_NB_ENDPOINT0 2
00298 #define ECM_INTERFACE0_CLASS 0x02 // CDC ACM Com
00299 #define ECM_INTERFACE0_SUB_CLASS 0x06 // ECM
00300 #define ECM_INTERFACE0_PROTOCOL 0x00 // Empty
00301 #define ECM_INTERFACE0_INDEX 0
00302
00303
00304
00305 #define DEVICE_STATUS 0x00 // TBD
00306 #define INTERFACE_STATUS 0x00 // TBD
00307
00308 #define LANG_ID 0x00
00309
00310 #define LANGUAGE_ID 0x0409
00311
00312
00313 typedef struct
00314 {
00315 U8 bmRequestType;
00316 U8 bRequest;
00317 U16 wValue;
00318 U16 wIndex;
00319 U16 wLength;
00320 } S_UsbRequest;
00321
00322
00323 typedef struct {
00324 U8 bLength;
00325 U8 bDescriptorType;
00326 U16 bscUSB;
00327 U8 bDeviceClass;
00328 U8 bDeviceSubClass;
00329 U8 bDeviceProtocol;
00330 U8 bMaxPacketSize0;
00331 U16 idVendor;
00332 U16 idProduct;
00333 U16 bcdDevice;
00334 U8 iManufacturer;
00335 U8 iProduct;
00336 U8 iSerialNumber;
00337 U8 bNumConfigurations;
00338 } S_usb_device_descriptor;
00339
00340
00341
00342 typedef struct {
00343 U8 bLength;
00344 U8 bDescriptorType;
00345 U16 wTotalLength;
00346 U8 bNumInterfaces;
00347 U8 bConfigurationValue;
00348 U8 iConfiguration;
00349 U8 bmAttibutes;
00350 U8 MaxPower;
00351 } S_usb_configuration_descriptor;
00352
00353
00354
00355 typedef struct {
00356 U8 bLength;
00357 U8 bDescriptorType;
00358 U8 bInterfaceNumber;
00359 U8 bAlternateSetting;
00360 U8 bNumEndpoints;
00361 U8 bInterfaceClass;
00362 U8 bInterfaceSubClass;
00363 U8 bInterfaceProtocol;
00364 U8 iInterface;
00365 } S_usb_interface_descriptor;
00366
00367
00368
00369 typedef struct {
00370 U8 bLength;
00371 U8 bDescriptorType;
00372 U8 bEndpointAddress;
00373 U8 bmAttributes;
00374 U16 wMaxPacketSize;
00375 U8 bInterval;
00376 } S_usb_endpoint_descriptor;
00377
00378
00379
00380 typedef struct {
00381 U8 bLength;
00382 U8 bDescriptorType;
00383 U16 bscUSB;
00384 U8 bDeviceClass;
00385 U8 bDeviceSubClass;
00386 U8 bDeviceProtocol;
00387 U8 bMaxPacketSize0;
00388 U8 bNumConfigurations;
00389 U8 bReserved;
00390 } S_usb_device_qualifier_descriptor;
00391
00392
00393
00394 typedef struct {
00395 U8 bLength;
00396 U8 bDescriptorType;
00397 U16 wlangid;
00398 } S_usb_language_id;
00399
00400
00401
00402
00403 #define DSC_TYPE_IAD 11
00404
00405 typedef struct
00406 {
00407 U8 bLength;
00408 U8 bDescriptorType;
00409 U8 bFirstInterface;
00410 U8 bInterfaceCount;
00411 U8 bFunctionClass;
00412 U8 bFunctionSubClass;
00413 U8 bFunctionProtocol;
00414 U8 iInterface;
00415 } S_usb_interface_association_descriptor;
00416
00417
00418
00419
00420 typedef struct
00421 {
00422 S_usb_configuration_descriptor cfg;
00423
00424 S_usb_interface_association_descriptor iad0;
00425 S_usb_interface_descriptor ifc0;
00426 U8 CS1_INTERFACE[19];
00427 S_usb_endpoint_descriptor ep1;
00428 S_usb_interface_descriptor ifc1;
00429 S_usb_endpoint_descriptor ep2;
00430 S_usb_endpoint_descriptor ep3;
00431
00432 S_usb_interface_association_descriptor iad1;
00433 S_usb_interface_descriptor ifc2;
00434 U8 CS2_INTERFACE[19];
00435 S_usb_endpoint_descriptor ep4;
00436 S_usb_interface_descriptor ifc3;
00437 S_usb_endpoint_descriptor ep5;
00438 S_usb_endpoint_descriptor ep6;
00439
00440 } S_usb_user_configuration_descriptor_composite;
00441
00442
00443 typedef struct
00444 {
00445 S_usb_configuration_descriptor cfg;
00446 S_usb_interface_descriptor ifc0;
00447 U8 CS1_INTERFACE[19];
00448 S_usb_endpoint_descriptor ep1;
00449 S_usb_interface_descriptor ifc1;
00450 S_usb_endpoint_descriptor ep2;
00451 S_usb_endpoint_descriptor ep3;
00452
00453 } S_usb_user_configuration_descriptor_network;
00454
00455
00456 typedef struct
00457 {
00458 S_usb_configuration_descriptor cfg;
00459 S_usb_interface_descriptor ifc0;
00460 S_usb_endpoint_descriptor ep1;
00461 S_usb_endpoint_descriptor ep2;
00462 } S_usb_user_configuration_descriptor_eem;
00463
00464
00465
00466
00467 typedef struct
00468 {
00469 U8 bLength;
00470 U8 bDescriptorType;
00471 U8 bDescriptorSubtype;
00472 U8 iMACAddress;
00473 U32 bmEthernetStatistics;
00474 U16 wMaxSegmentSize;
00475 U16 wNumberMCFilters;
00476 U8 bNumberPowerFilters;
00477 } S_usb_ethernet_networking_functional_descriptor;
00478
00479
00480
00481 typedef struct
00482 {
00483 S_usb_configuration_descriptor cfg;
00484 S_usb_interface_descriptor ifc0;
00485 U8 CS1_INTERFACE[5+5];
00486 S_usb_ethernet_networking_functional_descriptor fd0;
00487 #if CDC_ECM_USES_INTERRUPT_ENDPOINT
00488 S_usb_endpoint_descriptor ep1;
00489 #endif
00490 #if 0
00491 S_usb_interface_descriptor ifc1_0;
00492 #endif
00493 S_usb_interface_descriptor ifc1_1;
00494 S_usb_endpoint_descriptor ep2;
00495 S_usb_endpoint_descriptor ep3;
00496 } S_usb_user_configuration_descriptor_ecm;
00497
00498
00499
00500 typedef struct
00501 {
00502 S_usb_configuration_descriptor cfg;
00503 S_usb_interface_association_descriptor iad0;
00504 S_usb_interface_descriptor ifc0;
00505 U8 CS1_INTERFACE[5+5];
00506 S_usb_ethernet_networking_functional_descriptor fd0;
00507 #if CDC_ECM_USES_INTERRUPT_ENDPOINT
00508 S_usb_endpoint_descriptor ep1;
00509 #endif
00510 #if 0
00511 S_usb_interface_descriptor ifc1_0;
00512 #endif
00513 S_usb_interface_descriptor ifc1_1;
00514 S_usb_endpoint_descriptor ep2;
00515 S_usb_endpoint_descriptor ep3;
00516
00517 S_usb_interface_association_descriptor iad1;
00518 S_usb_interface_descriptor ifc2;
00519 U8 CS2_INTERFACE[19];
00520 S_usb_endpoint_descriptor ep4;
00521 S_usb_interface_descriptor ifc3;
00522 S_usb_endpoint_descriptor ep5;
00523 S_usb_endpoint_descriptor ep6;
00524
00525 } S_usb_user_configuration_descriptor_ecm_debug;
00526
00527
00528
00529
00530 typedef struct
00531 {
00532 S_usb_configuration_descriptor cfg;
00533 S_usb_interface_descriptor ifc0;
00534 S_usb_endpoint_descriptor ep1;
00535 S_usb_endpoint_descriptor ep2;
00536
00537 } S_usb_user_configuration_descriptor_mass;
00538
00539
00540
00541 PGM_VOID_P Usb_get_dev_desc_pointer(void);
00542 U8 Usb_get_dev_desc_length(void);
00543 PGM_VOID_P Usb_get_conf_desc_pointer(U8 index) ;
00544 U8 Usb_get_conf_desc_length(U8 index);
00545
00546 #endif // _USB_USERCONFIG_H_
00547
00548