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_mouse.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 #if (USB_LOW_SPEED_DEVICE==ENABLE)
00068 #define EP_CONTROL_LENGTH 8
00069 #else
00070 #define EP_CONTROL_LENGTH 64
00071 #endif
00072 #define VENDOR_ID VID_ATMEL
00073 #define PRODUCT_ID PID_MegaHIDMouse
00074 #define RELEASE_NUMBER 0x1000
00075 #define MAN_INDEX 0x01
00076 #define PROD_INDEX 0x02
00077 #if (USB_DEVICE_SN_USE==ENABLE)
00078 #define SN_INDEX 0x03
00079 #else
00080 #define SN_INDEX 0x00 // No serial number field
00081 #endif
00082 #define NB_CONFIGURATION 1
00083
00084
00085 #define NB_INTERFACE 1 // Number of interfaces
00086 #define CONF_NB 1
00087 #define CONF_INDEX 0
00088 #if (USB_REMOTE_WAKEUP_FEATURE == ENABLED)
00089 #define CONF_ATTRIBUTES (USB_CONFIG_BUSPOWERED | USB_CONFIG_REMOTEWAKEUP)
00090 #else
00091 #define CONF_ATTRIBUTES USB_CONFIG_BUSPOWERED
00092 #endif
00093 #define MAX_POWER 50 // 100 mA
00094
00095
00096 #define INTERFACE_NB_MOUSE 0 // Interface's number
00097 #define ALTERNATE_MOUSE 0
00098 #define NB_ENDPOINT_MOUSE 1
00099 #define INTERFACE_CLASS_MOUSE HID_CLASS
00100 #define INTERFACE_SUB_CLASS_MOUSE NO_SUBCLASS // no Sub Class
00101 #define INTERFACE_PROTOCOL_MOUSE HID_PROTOCOL_MOUSE // Mouse
00102 #define INTERFACE_INDEX_MOUSE 0
00103
00104 #define DEVICE_STATUS USB_DEVICE_STATUS_BUS_POWERED
00105
00106 #define LANG_ID 0x00
00107
00108
00109
00110 #define ENDPOINT_NB_1 (EP_MOUSE_IN | USB_ENDPOINT_IN)
00111 #define EP_ATTRIBUTES_1 0x03 // BULK = 0x02, INTERUPT = 0x03
00112 #define EP_IN_LENGTH_1 8
00113 #define EP_SIZE_1 EP_IN_LENGTH_1
00114 #define EP_INTERVAL_1 0x02 // Interrupt polling interval from host
00115
00116
00117 #define USB_MN_LENGTH 5
00118 #define USB_MANUFACTURER_NAME \
00119 { Usb_unicode('A') \
00120 , Usb_unicode('T') \
00121 , Usb_unicode('M') \
00122 , Usb_unicode('E') \
00123 , Usb_unicode('L') \
00124 }
00125
00126 #define USB_PN_LENGTH 18
00127 #define USB_PRODUCT_NAME \
00128 { Usb_unicode('A') \
00129 ,Usb_unicode('V') \
00130 ,Usb_unicode('R') \
00131 ,Usb_unicode(' ') \
00132 ,Usb_unicode('U') \
00133 ,Usb_unicode('S') \
00134 ,Usb_unicode('B') \
00135 ,Usb_unicode(' ') \
00136 ,Usb_unicode('M') \
00137 ,Usb_unicode('O') \
00138 ,Usb_unicode('U') \
00139 ,Usb_unicode('S') \
00140 ,Usb_unicode('E') \
00141 ,Usb_unicode(' ') \
00142 ,Usb_unicode('D') \
00143 ,Usb_unicode('E') \
00144 ,Usb_unicode('M') \
00145 ,Usb_unicode('O') \
00146 }
00147
00148 #define USB_SN_LENGTH 0x05
00149 #define USB_SERIAL_NUMBER \
00150 { Usb_unicode('0') \
00151 ,Usb_unicode('0') \
00152 ,Usb_unicode('0') \
00153 ,Usb_unicode('0') \
00154 ,Usb_unicode('0') \
00155 }
00156
00157 #define LANGUAGE_ID 0x0409
00158
00159
00161 typedef struct
00162 {
00163 U8 bmRequestType;
00164 U8 bRequest;
00165 U16 wValue;
00166 U16 wIndex;
00167 U16 wLength;
00168 } S_UsbRequest;
00169
00171 typedef struct {
00172 U8 bLength;
00173 U8 bDescriptorType;
00174 U16 bscUSB;
00175 U8 bDeviceClass;
00176 U8 bDeviceSubClass;
00177 U8 bDeviceProtocol;
00178 U8 bMaxPacketSize0;
00179 U16 idVendor;
00180 U16 idProduct;
00181 U16 bcdDevice;
00182 U8 iManufacturer;
00183 U8 iProduct;
00184 U8 iSerialNumber;
00185 U8 bNumConfigurations;
00186 } S_usb_device_descriptor;
00187
00188
00190 typedef struct {
00191 U8 bLength;
00192 U8 bDescriptorType;
00193 U16 wTotalLength;
00194 U8 bNumInterfaces;
00195 U8 bConfigurationValue;
00196 U8 iConfiguration;
00197 U8 bmAttibutes;
00198 U8 MaxPower;
00199 } S_usb_configuration_descriptor;
00200
00201
00203 typedef struct {
00204 U8 bLength;
00205 U8 bDescriptorType;
00206 U8 bInterfaceNumber;
00207 U8 bAlternateSetting;
00208 U8 bNumEndpoints;
00209 U8 bInterfaceClass;
00210 U8 bInterfaceSubClass;
00211 U8 bInterfaceProtocol;
00212 U8 iInterface;
00213 } S_usb_interface_descriptor;
00214
00215
00217 typedef struct {
00218 U8 bLength;
00219 U8 bDescriptorType;
00220 U8 bEndpointAddress;
00221 U8 bmAttributes;
00222 U16 wMaxPacketSize;
00223 U8 bInterval;
00224 } S_usb_endpoint_descriptor;
00225
00226
00228 typedef struct {
00229 U8 bLength;
00230 U8 bDescriptorType;
00231 U16 wlangid;
00232 } S_usb_language_id;
00233
00234
00235
00236
00237
00238
00239 typedef struct {
00240 U8 bLength;
00241 U8 bDescriptorType;
00242 U16 wstring[USB_MN_LENGTH];
00243 } S_usb_manufacturer_string_descriptor;
00244
00245
00246
00247
00248
00249
00250 typedef struct {
00251 U8 bLength;
00252 U8 bDescriptorType;
00253 U16 wstring[USB_PN_LENGTH];
00254 } S_usb_product_string_descriptor;
00255
00256
00257
00258
00259
00260 #if (USB_DEVICE_SN_USE==ENABLE)
00261
00262 typedef struct {
00263 U8 bLength;
00264 U8 bDescriptorType;
00265 #if (USE_DEVICE_SN_UNIQUE==ENABLE)
00266
00267 #else
00268 U16 wstring[USB_SN_LENGTH];
00269 #endif
00270 } S_usb_serial_number;
00271 #endif
00272
00273
00274
00275
00276 typedef struct {
00277 U8 bLength;
00278 U8 bDescriptorType;
00279 U16 bscHID;
00280 U8 bCountryCode;
00281 U8 bNumDescriptors;
00282 U8 bRDescriptorType;
00283 U16 wDescriptorLength;
00284 } S_usb_hid_descriptor;
00285
00286
00287
00288
00289 typedef struct
00290 {
00291 S_usb_configuration_descriptor cfg_mouse;
00292 S_usb_interface_descriptor ifc_mouse;
00293 S_usb_hid_descriptor hid_mouse;
00294 S_usb_endpoint_descriptor ep1_mouse;
00295 } S_usb_user_configuration_descriptor;
00296
00297
00298
00299
00300 #endif
00301