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