00001
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 #ifndef _USB_DESCRIPTORS_H_
00045 #define _USB_DESCRIPTORS_H_
00046
00047
00048
00049 #include "config.h"
00050 #include "modules/usb/device_chap9/usb_standard_request.h"
00051 #include "conf_usb.h"
00052
00053
00054
00055 #define Usb_get_dev_desc_pointer() (&(usb_dev_desc.bLength))
00056 #define Usb_get_dev_desc_length() (sizeof (usb_dev_desc))
00057 #define Usb_get_conf_desc_pointer() (&(usb_conf_desc.cfg.bLength))
00058 #define Usb_get_conf_desc_length() (sizeof (usb_conf_desc))
00059
00060
00061
00062
00063 #define USB_SPECIFICATION 0x0200
00064 #define DEVICE_CLASS 0 // each configuration has its own class
00065 #define DEVICE_SUB_CLASS 0 // each configuration has its own sub-class
00066 #define DEVICE_PROTOCOL 0 // each configuration has its own protocol
00067 #define EP_CONTROL_LENGTH 64
00068 #define VENDOR_ID VID_ATMEL
00069 #define PRODUCT_ID PID_MegaMS
00070 #define RELEASE_NUMBER 0x1000
00071 #define MAN_INDEX 0x01
00072 #define PROD_INDEX 0x02
00073 #if (USB_DEVICE_SN_USE==ENABLE)
00074 #define SN_INDEX 0x03
00075 #else
00076 #define SN_INDEX 0x00 // No serial number field
00077 #endif
00078 #define NB_CONFIGURATION 1
00079
00080
00081 #define NB_INTERFACE 1 // Number of interfaces
00082 #define CONF_NB 1
00083 #define CONF_INDEX 0
00084 #define CONF_ATTRIBUTES USB_CONFIG_BUSPOWERED
00085 #define MAX_POWER 50 // 100 mA
00086
00087
00088 #define INTERFACE_NB 0 // Interface's number
00089 #define ALTERNATE 0
00090 #define NB_ENDPOINT 2
00091 #define INTERFACE_CLASS MS_CLASS // Mass Storage Class
00092 #define INTERFACE_SUB_CLASS MS_SUB_CLASS6 // SCSI transparent Command Set
00093 #define INTERFACE_PROTOCOL MS_PROTOCOL // Bulk-Only Transport
00094 #define INTERFACE_INDEX 0
00095
00096
00097 #define ENDPOINT_NB_1 (EP_MS_IN | USB_ENDPOINT_IN)
00098 #define EP_ATTRIBUTES_1 0x02 // BULK = 0x02, INTERUPT = 0x03
00099 #define EP_IN_LENGTH 64
00100 #define EP_SIZE_1 EP_IN_LENGTH
00101 #define EP_INTERVAL_1 0x00
00102
00103
00104
00105 #define ENDPOINT_NB_2 EP_MS_OUT
00106 #define EP_ATTRIBUTES_2 0x02 // BULK = 0x02, INTERUPT = 0x03
00107 #define EP_IN_LENGTH 64
00108 #define EP_SIZE_2 EP_IN_LENGTH
00109 #define EP_INTERVAL_2 0x00
00110
00111 #define DEVICE_STATUS USB_DEVICE_STATUS_BUS_POWERED
00112
00113 #define LANG_ID 0x00
00114
00115
00116 #define USB_MN_LENGTH 5
00117 #define USB_MANUFACTURER_NAME \
00118 { Usb_unicode('A') \
00119 , Usb_unicode('T') \
00120 , Usb_unicode('M') \
00121 , Usb_unicode('E') \
00122 , Usb_unicode('L') \
00123 }
00124
00125 #define USB_PN_LENGTH 16
00126 #define USB_PRODUCT_NAME \
00127 { Usb_unicode('A') \
00128 ,Usb_unicode('V') \
00129 ,Usb_unicode('R') \
00130 ,Usb_unicode(' ') \
00131 ,Usb_unicode('U') \
00132 ,Usb_unicode('S') \
00133 ,Usb_unicode('B') \
00134 ,Usb_unicode(' ') \
00135 ,Usb_unicode('S') \
00136 ,Usb_unicode('T') \
00137 ,Usb_unicode('O') \
00138 ,Usb_unicode('R') \
00139 ,Usb_unicode('A') \
00140 ,Usb_unicode('G') \
00141 ,Usb_unicode('E') \
00142 ,Usb_unicode(' ') \
00143 }
00144
00145 #define USB_SN_LENGTH 0x0D
00146
00147 #define USB_SERIAL_NUMBER \
00148 { Usb_unicode('0') \
00149 ,Usb_unicode('0') \
00150 ,Usb_unicode('0') \
00151 ,Usb_unicode('0') \
00152 ,Usb_unicode('0') \
00153 ,Usb_unicode('0') \
00154 ,Usb_unicode('0') \
00155 ,Usb_unicode('0') \
00156 ,Usb_unicode('0') \
00157 ,Usb_unicode('0') \
00158 ,Usb_unicode('0') \
00159 ,Usb_unicode('0') \
00160 ,Usb_unicode('0') \
00161 }
00162
00163 #define LANGUAGE_ID 0x0409
00164
00165
00167 typedef struct
00168 {
00169 U8 bmRequestType;
00170 U8 bRequest;
00171 U16 wValue;
00172 U16 wIndex;
00173 U16 wLength;
00174 } S_UsbRequest;
00175
00177 typedef struct {
00178 U8 bLength;
00179 U8 bDescriptorType;
00180 U16 bscUSB;
00181 U8 bDeviceClass;
00182 U8 bDeviceSubClass;
00183 U8 bDeviceProtocol;
00184 U8 bMaxPacketSize0;
00185 U16 idVendor;
00186 U16 idProduct;
00187 U16 bcdDevice;
00188 U8 iManufacturer;
00189 U8 iProduct;
00190 U8 iSerialNumber;
00191 U8 bNumConfigurations;
00192 } S_usb_device_descriptor;
00193
00194
00196 typedef struct {
00197 U8 bLength;
00198 U8 bDescriptorType;
00199 U16 wTotalLength;
00200 U8 bNumInterfaces;
00201 U8 bConfigurationValue;
00202 U8 iConfiguration;
00203 U8 bmAttibutes;
00204 U8 MaxPower;
00205 } S_usb_configuration_descriptor;
00206
00207
00209 typedef struct {
00210 U8 bLength;
00211 U8 bDescriptorType;
00212 U8 bInterfaceNumber;
00213 U8 bAlternateSetting;
00214 U8 bNumEndpoints;
00215 U8 bInterfaceClass;
00216 U8 bInterfaceSubClass;
00217 U8 bInterfaceProtocol;
00218 U8 iInterface;
00219 } S_usb_interface_descriptor;
00220
00221
00223 typedef struct {
00224 U8 bLength;
00225 U8 bDescriptorType;
00226 U8 bEndpointAddress;
00227 U8 bmAttributes;
00228 U16 wMaxPacketSize;
00229 U8 bInterval;
00230 } S_usb_endpoint_descriptor;
00231
00232
00234 typedef struct {
00235 U8 bLength;
00236 U8 bDescriptorType;
00237 U16 wlangid;
00238 } S_usb_language_id;
00239
00240
00241
00242
00243
00244
00245 typedef struct {
00246 U8 bLength;
00247 U8 bDescriptorType;
00248 U16 wstring[USB_MN_LENGTH];
00249 } S_usb_manufacturer_string_descriptor;
00250
00251
00252
00253
00254
00255
00256 typedef struct {
00257 U8 bLength;
00258 U8 bDescriptorType;
00259 U16 wstring[USB_PN_LENGTH];
00260 } S_usb_product_string_descriptor;
00261
00262
00263
00264
00265 #if (USB_DEVICE_SN_USE==ENABLE)
00266
00267 typedef struct {
00268 U8 bLength;
00269 U8 bDescriptorType;
00270 #if (USE_DEVICE_SN_UNIQUE==ENABLE)
00271
00272 #else
00273 U16 wstring[USB_SN_LENGTH];
00274 #endif
00275 } S_usb_serial_number;
00276 #endif
00277
00278
00279
00280
00281 typedef struct
00282 {
00283 S_usb_configuration_descriptor cfg;
00284 S_usb_interface_descriptor ifc;
00285 S_usb_endpoint_descriptor ep1;
00286 S_usb_endpoint_descriptor ep2;
00287 } S_usb_user_configuration_descriptor;
00288
00289
00290
00291
00292
00293
00294
00295 #endif
00296