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
00045
00046
00047 #ifndef _USB_DESCRIPTORS_H_
00048 #define _USB_DESCRIPTORS_H_
00049
00050
00051
00052 #include "config.h"
00053 #include "modules/usb/device_chap9/usb_standard_request.h"
00054 #include "conf_usb.h"
00055
00056
00057
00058 #define Usb_get_dev_desc_pointer() (&(usb_dev_desc.bLength))
00059 #define Usb_get_dev_desc_length() (sizeof (usb_dev_desc))
00060 #define Usb_get_conf_desc_pointer() (&(usb_conf_desc.cfg.bLength))
00061 #define Usb_get_conf_desc_length() (sizeof (usb_conf_desc))
00062
00063
00064
00065
00066 #define USB_SPECIFICATION 0x0200
00067 #define DEVICE_CLASS CDC_GLOB_CLASS // CDC class
00068 #define DEVICE_SUB_CLASS 0 // each configuration has its own sub-class
00069 #define DEVICE_PROTOCOL 0 // each configuration has its own protocol
00070 #define EP_CONTROL_LENGTH 64
00071 #define VENDOR_ID VID_ATMEL
00072 #define PRODUCT_ID PID_MegaCDC
00073 #define RELEASE_NUMBER 0x1000
00074 #define MAN_INDEX 0x00
00075 #define PROD_INDEX 0x00
00076 #if (USB_DEVICE_SN_USE==ENABLE)
00077 #define SN_INDEX 0x03
00078 #else
00079 #define SN_INDEX 0x00 // No serial number field
00080 #endif
00081 #define NB_CONFIGURATION 1
00082
00083
00084 #define NB_INTERFACE 2 // Number of interfaces
00085 #define CONF_NB 1
00086 #define CONF_INDEX 0
00087 #define CONF_ATTRIBUTES USB_CONFIG_BUSPOWERED
00088 #define MAX_POWER 50 // 100 mA
00089
00090
00091 #define INTERFACE0_NB 0
00092 #define ALTERNATE0 0
00093 #define NB_ENDPOINT0 1
00094 #define INTERFACE0_CLASS CDC_COMM_CLASS // CDC ACM Com
00095 #define INTERFACE0_SUB_CLASS CDC_COMM_SUBCLASS
00096 #define INTERFACE0_PROTOCOL CDC_COMM_PROTOCOL
00097 #define INTERFACE0_INDEX 0
00098
00099
00100 #define INTERFACE1_NB 1
00101 #define ALTERNATE1 0
00102 #define NB_ENDPOINT1 2
00103 #define INTERFACE1_CLASS CDC_DATA_CLASS // CDC ACM Data
00104 #define INTERFACE1_SUB_CLASS CDC_DATA_SUBCLASS
00105 #define INTERFACE1_PROTOCOL CDC_DATA_PROTOCOL
00106 #define INTERFACE1_INDEX 0
00107
00108
00109
00110 #define INT_EP_SIZE 0x20
00111 #define ENDPOINT_NB_3 USB_ENDPOINT_IN | INT_EP
00112 #define EP_ATTRIBUTES_3 0x03 // BULK = 0x02, INTERUPT = 0x03
00113 #define EP_SIZE_3 INT_EP_SIZE
00114 #define EP_INTERVAL_3 0xFF //ms interrupt pooling from host
00115
00116
00117
00118 #define TX_EP_SIZE 0x40
00119 #define ENDPOINT_NB_1 USB_ENDPOINT_IN | TX_EP
00120 #define EP_ATTRIBUTES_1 0x02 // BULK = 0x02, INTERUPT = 0x03
00121 #define EP_SIZE_1 TX_EP_SIZE
00122 #define EP_INTERVAL_1 0x00
00123
00124
00125
00126 #define RX_EP_SIZE 0x40
00127 #define ENDPOINT_NB_2 RX_EP
00128 #define EP_ATTRIBUTES_2 0x02 // BULK = 0x02, INTERUPT = 0x03
00129 #define EP_SIZE_2 RX_EP_SIZE
00130 #define EP_INTERVAL_2 0x00
00131
00132
00133
00134 #define DEVICE_STATUS USB_DEVICE_STATUS_BUS_POWERED
00135
00136 #define LANG_ID 0x00
00137
00138
00139
00140
00141 #define USB_MN_LENGTH 5
00142 #define USB_MANUFACTURER_NAME \
00143 { Usb_unicode('A') \
00144 , Usb_unicode('T') \
00145 , Usb_unicode('M') \
00146 , Usb_unicode('E') \
00147 , Usb_unicode('L') \
00148 }
00149
00150 #define USB_PN_LENGTH 16
00151 #define USB_PRODUCT_NAME \
00152 { Usb_unicode('A') \
00153 ,Usb_unicode('V') \
00154 ,Usb_unicode('R') \
00155 ,Usb_unicode(' ') \
00156 ,Usb_unicode('U') \
00157 ,Usb_unicode('S') \
00158 ,Usb_unicode('B') \
00159 ,Usb_unicode(' ') \
00160 ,Usb_unicode('C') \
00161 ,Usb_unicode('D') \
00162 ,Usb_unicode('C') \
00163 ,Usb_unicode(' ') \
00164 ,Usb_unicode('D') \
00165 ,Usb_unicode('E') \
00166 ,Usb_unicode('M') \
00167 ,Usb_unicode('O') \
00168 }
00169
00170 #define USB_SN_LENGTH 0x05
00171 #define USB_SERIAL_NUMBER \
00172 { Usb_unicode('0') \
00173 ,Usb_unicode('0') \
00174 ,Usb_unicode('0') \
00175 ,Usb_unicode('0') \
00176 ,Usb_unicode('0') \
00177 }
00178
00179 #define LANGUAGE_ID 0x0409
00180
00181
00183 typedef struct
00184 {
00185 U8 bmRequestType;
00186 U8 bRequest;
00187 U16 wValue;
00188 U16 wIndex;
00189 U16 wLength;
00190 } S_UsbRequest;
00191
00193 typedef struct {
00194 U8 bLength;
00195 U8 bDescriptorType;
00196 U16 bscUSB;
00197 U8 bDeviceClass;
00198 U8 bDeviceSubClass;
00199 U8 bDeviceProtocol;
00200 U8 bMaxPacketSize0;
00201 U16 idVendor;
00202 U16 idProduct;
00203 U16 bcdDevice;
00204 U8 iManufacturer;
00205 U8 iProduct;
00206 U8 iSerialNumber;
00207 U8 bNumConfigurations;
00208 } S_usb_device_descriptor;
00209
00210
00212 typedef struct {
00213 U8 bLength;
00214 U8 bDescriptorType;
00215 U16 wTotalLength;
00216 U8 bNumInterfaces;
00217 U8 bConfigurationValue;
00218 U8 iConfiguration;
00219 U8 bmAttibutes;
00220 U8 MaxPower;
00221 } S_usb_configuration_descriptor;
00222
00223
00225 typedef struct {
00226 U8 bLength;
00227 U8 bDescriptorType;
00228 U8 bInterfaceNumber;
00229 U8 bAlternateSetting;
00230 U8 bNumEndpoints;
00231 U8 bInterfaceClass;
00232 U8 bInterfaceSubClass;
00233 U8 bInterfaceProtocol;
00234 U8 iInterface;
00235 } S_usb_interface_descriptor;
00236
00237
00239 typedef struct {
00240 U8 bLength;
00241 U8 bDescriptorType;
00242 U8 bEndpointAddress;
00243 U8 bmAttributes;
00244 U16 wMaxPacketSize;
00245 U8 bInterval;
00246 } S_usb_endpoint_descriptor;
00247
00248
00250 typedef struct {
00251 U8 bLength;
00252 U8 bDescriptorType;
00253 U16 wlangid;
00254 } S_usb_language_id;
00255
00256
00257
00258
00259
00260
00261 typedef struct {
00262 U8 bLength;
00263 U8 bDescriptorType;
00264 U16 wstring[USB_MN_LENGTH];
00265 } S_usb_manufacturer_string_descriptor;
00266
00267
00268
00269
00270
00271
00272 typedef struct {
00273 U8 bLength;
00274 U8 bDescriptorType;
00275 U16 wstring[USB_PN_LENGTH];
00276 } S_usb_product_string_descriptor;
00277
00278
00279
00280
00281
00282 #if (USB_DEVICE_SN_USE==ENABLE)
00283
00284 typedef struct {
00285 U8 bLength;
00286 U8 bDescriptorType;
00287 #if (USE_DEVICE_SN_UNIQUE==ENABLE)
00288
00289 #else
00290 U16 wstring[USB_SN_LENGTH];
00291 #endif
00292 } S_usb_serial_number;
00293 #endif
00294
00295
00296
00297
00298 typedef struct
00299 {
00300 S_usb_configuration_descriptor cfg;
00301 S_usb_interface_descriptor ifc0;
00302 U8 CS_INTERFACE[19];
00303 S_usb_endpoint_descriptor ep3;
00304 S_usb_interface_descriptor ifc1;
00305 S_usb_endpoint_descriptor ep1;
00306 S_usb_endpoint_descriptor ep2;
00307 } S_usb_user_configuration_descriptor;
00308
00309
00310
00311
00312
00313
00314
00315 #endif
00316