00001 #ifndef _USB_DESCRIPTORS_H_
00002 #define _USB_DESCRIPTORS_H_
00003
00004
00005
00006 #include "config.h"
00007 #include "usb_standard_request.h"
00008
00009
00010
00011 #define Usb_get_dev_desc_pointer() (&(usb_dev_desc.bLength))
00012 #define Usb_get_dev_desc_length() (sizeof (usb_dev_desc))
00013 #define Usb_get_conf_desc_pointer() (&(usb_conf_desc.cfg_mouse.bLength))
00014 #define Usb_get_conf_desc_length() (sizeof (usb_conf_desc))
00015
00016
00017
00018 #define USB_DEVICE_SN_USE DISABLE // DISABLE
00019 #define USE_DEVICE_SN_UNIQUE DISABLE // ignore if USB_DEVICE_SN_USE = DISABLE
00020
00021 #define NB_ENDPOINTS 2
00022 #define EP_MOUSE_IN 1
00023
00024 #define Usb_unicode(a) ((U16)(a))
00025
00026
00027 #define HID_CLASS 0x03
00028 #define HID_SUB_CLASS_BOOT 0x01
00029 #define HID_PROTOCOL_KEYBOARD 0x01
00030 #define HID_PROTOCOL_MOUSE 0x02
00031 #define DESCRIPTOR_HID 0x21
00032 #define DESCRIPTOR_REPORT 0x22
00033 #define DESCRIPTOR_PHYSICAL 0x23
00034 #define HID_BDC 0x0111
00035 #define HID_CLASS_DESC_NB_DEFAULT 0x01
00036 #define HID_NO_COUNTRY_CODE 0 // Not Supported
00037
00038
00039
00040 #define USB_SPECIFICATION 0x0200
00041 #define DEVICE_CLASS 0 // each configuration has its own class
00042 #define DEVICE_SUB_CLASS 0 // each configuration has its own sub-class
00043 #define DEVICE_PROTOCOL 0 // each configuration has its own protocol
00044 #define EP_CONTROL_LENGTH 64
00045 #define VENDOR_ID VID_ATMEL
00046 #define PRODUCT_ID PID_MegaHIDMouse
00047 #define RELEASE_NUMBER 0x1000
00048 #define MAN_INDEX 0x01
00049 #define PROD_INDEX 0x02
00050 #if (USB_DEVICE_SN_USE==ENABLE)
00051 #define SN_INDEX 0x03
00052 #else
00053 #define SN_INDEX 0x00 // No serial number field
00054 #endif
00055 #define NB_CONFIGURATION 1
00056
00057
00058 #define NB_INTERFACE 1 // Number of interfaces
00059 #define CONF_NB 1
00060 #define CONF_INDEX 0
00061 #define CONF_ATTRIBUTES (USB_CONFIG_BUSPOWERED | USB_CONFIG_REMOTEWAKEUP)
00062 #define MAX_POWER 50 // 100 mA
00063
00064
00065 #define INTERFACE_NB_MOUSE 0 // Interface's number
00066 #define ALTERNATE_MOUSE 0
00067 #define NB_ENDPOINT_MOUSE 1
00068 #define INTERFACE_CLASS_MOUSE HID_CLASS
00069 #define INTERFACE_SUB_CLASS_MOUSE NO_SUBCLASS // no Sub Class
00070 #define INTERFACE_PROTOCOL_MOUSE HID_PROTOCOL_MOUSE // Mouse
00071 #define INTERFACE_INDEX_MOUSE 0
00072
00073 #define DEVICE_STATUS USB_DEVICE_STATUS_BUS_POWERED
00074
00075 #define LANG_ID 0x00
00076
00077
00078
00079 #define ENDPOINT_NB_1 (EP_MOUSE_IN | USB_ENDPOINT_IN)
00080 #define EP_ATTRIBUTES_1 0x03 // BULK = 0x02, INTERUPT = 0x03
00081 #define EP_IN_LENGTH_1 8
00082 #define EP_SIZE_1 EP_IN_LENGTH_1
00083 #define EP_INTERVAL_1 0x02 // Interrupt polling interval from host
00084
00085
00086 #define USB_MN_LENGTH 5
00087 #define USB_MANUFACTURER_NAME \
00088 { Usb_unicode('M') \
00089 , Usb_unicode('A') \
00090 , Usb_unicode('N') \
00091 , Usb_unicode('Y') \
00092 , Usb_unicode('A') \
00093 }
00094
00095 #define USB_PN_LENGTH 18
00096 #define USB_PRODUCT_NAME \
00097 { Usb_unicode('C') \
00098 ,Usb_unicode('A') \
00099 ,Usb_unicode('R') \
00100 ,Usb_unicode('B') \
00101 ,Usb_unicode('O') \
00102 ,Usb_unicode('N') \
00103 ,Usb_unicode('E') \
00104 ,Usb_unicode('R') \
00105 ,Usb_unicode('O') \
00106 ,Usb_unicode(' ') \
00107 ,Usb_unicode('Q') \
00108 ,Usb_unicode('U') \
00109 ,Usb_unicode('E') \
00110 ,Usb_unicode('R') \
00111 ,Usb_unicode('I') \
00112 ,Usb_unicode('D') \
00113 ,Usb_unicode('O') \
00114 ,Usb_unicode('!') \
00115 }
00116
00117 #define USB_SN_LENGTH 0x05
00118 #define USB_SERIAL_NUMBER \
00119 { Usb_unicode('0') \
00120 ,Usb_unicode('0') \
00121 ,Usb_unicode('0') \
00122 ,Usb_unicode('0') \
00123 ,Usb_unicode('0') \
00124 }
00125
00126 #define LANGUAGE_ID 0x0409
00127
00128
00130 typedef struct
00131 {
00132 U8 bmRequestType;
00133 U8 bRequest;
00134 U16 wValue;
00135 U16 wIndex;
00136 U16 wLength;
00137 } S_UsbRequest;
00138
00140 typedef struct {
00141 U8 bLength;
00142 U8 bDescriptorType;
00143 U16 bscUSB;
00144 U8 bDeviceClass;
00145 U8 bDeviceSubClass;
00146 U8 bDeviceProtocol;
00147 U8 bMaxPacketSize0;
00148 U16 idVendor;
00149 U16 idProduct;
00150 U16 bcdDevice;
00151 U8 iManufacturer;
00152 U8 iProduct;
00153 U8 iSerialNumber;
00154 U8 bNumConfigurations;
00155 } S_usb_device_descriptor;
00156
00157
00159 typedef struct {
00160 U8 bLength;
00161 U8 bDescriptorType;
00162 U16 wTotalLength;
00163 U8 bNumInterfaces;
00164 U8 bConfigurationValue;
00165 U8 iConfiguration;
00166 U8 bmAttibutes;
00167 U8 MaxPower;
00168 } S_usb_configuration_descriptor;
00169
00170
00172 typedef struct {
00173 U8 bLength;
00174 U8 bDescriptorType;
00175 U8 bInterfaceNumber;
00176 U8 bAlternateSetting;
00177 U8 bNumEndpoints;
00178 U8 bInterfaceClass;
00179 U8 bInterfaceSubClass;
00180 U8 bInterfaceProtocol;
00181 U8 iInterface;
00182 } S_usb_interface_descriptor;
00183
00184
00186 typedef struct {
00187 U8 bLength;
00188 U8 bDescriptorType;
00189 U8 bEndpointAddress;
00190 U8 bmAttributes;
00191 U16 wMaxPacketSize;
00192 U8 bInterval;
00193 } S_usb_endpoint_descriptor;
00194
00195
00197 typedef struct {
00198 U8 bLength;
00199 U8 bDescriptorType;
00200 U16 wlangid;
00201 } S_usb_language_id;
00202
00203
00204
00205
00206
00207
00208 typedef struct {
00209 U8 bLength;
00210 U8 bDescriptorType;
00211 U16 wstring[USB_MN_LENGTH];
00212 } S_usb_manufacturer_string_descriptor;
00213
00214
00215
00216
00217
00218
00219 typedef struct {
00220 U8 bLength;
00221 U8 bDescriptorType;
00222 U16 wstring[USB_PN_LENGTH];
00223 } S_usb_product_string_descriptor;
00224
00225
00226
00227
00228
00229 #if (USB_DEVICE_SN_USE==ENABLE)
00230
00231 typedef struct {
00232 U8 bLength;
00233 U8 bDescriptorType;
00234 #if (USE_DEVICE_SN_UNIQUE==ENABLE)
00235
00236 #else
00237 U16 wstring[USB_SN_LENGTH];
00238 #endif
00239 } S_usb_serial_number;
00240 #endif
00241
00242
00243
00244
00245 typedef struct {
00246 U8 bLength;
00247 U8 bDescriptorType;
00248 U16 bscHID;
00249 U8 bCountryCode;
00250 U8 bNumDescriptors;
00251 U8 bRDescriptorType;
00252 U16 wDescriptorLength;
00253 } S_usb_hid_descriptor;
00254
00255
00256
00257
00258 typedef struct
00259 {
00260 S_usb_configuration_descriptor cfg_mouse;
00261 S_usb_interface_descriptor ifc_mouse;
00262 S_usb_hid_descriptor hid_mouse;
00263 S_usb_endpoint_descriptor ep1_mouse;
00264 } S_usb_user_configuration_descriptor;
00265
00266
00267
00268
00269 #endif
00270