00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _USB_USERCONFIG_H_
00019 #define _USB_USERCONFIG_H_
00020
00021
00022
00023 #include "config.h"
00024 #include "modules/usb/device_chap9/usb_standard_request.h"
00025 #include "conf_usb.h"
00026
00027
00028
00029 #define Usb_get_dev_desc_pointer() (&(usb_dev_desc.bLength))
00030 #define Usb_get_dev_desc_length() (sizeof (usb_dev_desc))
00031 #define Usb_get_conf_desc_pointer() (&(usb_conf_desc.cfg_mouse.bLength))
00032 #define Usb_get_conf_desc_length() (sizeof (usb_conf_desc))
00033
00034
00035
00036
00037 #define USB_SPECIFICATION 0x0200
00038 #define DEVICE_CLASS 0 // each configuration has its own class
00039 #define DEVICE_SUB_CLASS 0 // each configuration has its own sub-class
00040 #define DEVICE_PROTOCOL 0 // each configuration has its own protocol
00041 #define EP_CONTROL_LENGTH 8
00042 #define VENDOR_ID 0x03EB // Atmel vendor ID = 03EBh
00043 #define PRODUCT_ID 0x202A
00044 #define RELEASE_NUMBER 0x1000
00045 #define MAN_INDEX 0x01
00046 #define PROD_INDEX 0x02
00047 #define SN_INDEX 0x03
00048 #define NB_CONFIGURATION 1
00049
00050
00051 #define NB_INTERFACE 2
00052 #define CONF_NB 1
00053 #define CONF_INDEX 0
00054 #define CONF_ATTRIBUTES USB_CONFIG_SELFPOWERED
00055 #define MAX_POWER 50 // 100 mA
00056
00057
00058 #define INTERFACE_NB_MOUSE 0
00059 #define ALTERNATE_MOUSE 0
00060 #define NB_ENDPOINT_MOUSE 1
00061 #define INTERFACE_CLASS_MOUSE 0x03 // HID Class
00062 #define INTERFACE_SUB_CLASS_MOUSE 0x00 // No Sub Class
00063 #define INTERFACE_PROTOCOL_MOUSE 0x02 // Mouse
00064 #define INTERFACE_INDEX_MOUSE 0
00065
00066 #define SELF_POWERED 1
00067 #define DEVICE_STATUS SELF_POWERED
00068 #define INTERFACE_STATUS 0x00 // TBD
00069
00070 #define LANG_ID 0x00
00071
00072
00073
00074 #define ENDPOINT_NB_1 (EP_MOUSE_IN | 0x80)
00075 #define EP_ATTRIBUTES_1 0x03 // BULK = 0x02, INTERUPT = 0x03
00076 #define EP_IN_LENGTH_1 8
00077 #define EP_SIZE_1 EP_IN_LENGTH_1
00078 #define EP_INTERVAL_1 0x08 // Interrupt polling interval from host
00079
00080 #define INTERFACE_NB 1
00081 #define ALTERNATE 0
00082 #define NB_ENDPOINT 2
00083 #define INTERFACE_CLASS 0x08 // Mass Storage Class
00084 #define INTERFACE_SUB_CLASS 0x06 // SCSI transparent Command Set
00085 #define INTERFACE_PROTOCOL 0x50 // Bulk-Only Transport
00086 #define INTERFACE_INDEX 0
00087
00088
00089 #define ENDPOINT_NB_2 (EP_MS_IN | 0x80)
00090 #define EP_ATTRIBUTES_2 0x02 // BULK = 0x02, INTERUPT = 0x03
00091 #define EP_IN_LENGTH 64
00092 #define EP_SIZE_2 EP_IN_LENGTH
00093 #define EP_INTERVAL_2 0x00
00094
00095
00096
00097 #define ENDPOINT_NB_3 EP_MS_OUT
00098 #define EP_ATTRIBUTES_3 0x02 // BULK = 0x02, INTERUPT = 0x03
00099 #define EP_IN_LENGTH 64
00100 #define EP_SIZE_3 EP_IN_LENGTH
00101 #define EP_INTERVAL_3 0x00
00102
00103
00104 #define HID 0x21
00105 #define REPORT 0x22
00106 #define SET_REPORT 0x02
00107
00108 #define HID_DESCRIPTOR 0x21
00109 #define HID_BDC 0x1001
00110 #define HID_COUNTRY_CODE 0x00
00111 #define HID_CLASS_DESC_NB 0x01
00112 #define HID_DESCRIPTOR_TYPE 0x22
00113
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 18
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('M') \
00136 ,Usb_unicode('O') \
00137 ,Usb_unicode('U') \
00138 ,Usb_unicode('S') \
00139 ,Usb_unicode('E') \
00140 ,Usb_unicode(' ') \
00141 ,Usb_unicode('D') \
00142 ,Usb_unicode('E') \
00143 ,Usb_unicode('M') \
00144 ,Usb_unicode('O') \
00145 }
00146
00147 #define USB_SN_LENGTH 0x05
00148 #define USB_SERIAL_NUMBER \
00149 { Usb_unicode('1') \
00150 ,Usb_unicode('.') \
00151 ,Usb_unicode('0') \
00152 ,Usb_unicode('.') \
00153 ,Usb_unicode('0') \
00154 }
00155
00156 #define LANGUAGE_ID 0x0409
00157
00158
00160 typedef struct
00161 {
00162 U8 bmRequestType;
00163 U8 bRequest;
00164 U16 wValue;
00165 U16 wIndex;
00166 U16 wLength;
00167 } S_UsbRequest;
00168
00170 typedef struct {
00171 U8 bLength;
00172 U8 bDescriptorType;
00173 U16 bscUSB;
00174 U8 bDeviceClass;
00175 U8 bDeviceSubClass;
00176 U8 bDeviceProtocol;
00177 U8 bMaxPacketSize0;
00178 U16 idVendor;
00179 U16 idProduct;
00180 U16 bcdDevice;
00181 U8 iManufacturer;
00182 U8 iProduct;
00183 U8 iSerialNumber;
00184 U8 bNumConfigurations;
00185 } S_usb_device_descriptor;
00186
00187
00189 typedef struct {
00190 U8 bLength;
00191 U8 bDescriptorType;
00192 U16 wTotalLength;
00193 U8 bNumInterfaces;
00194 U8 bConfigurationValue;
00195 U8 iConfiguration;
00196 U8 bmAttibutes;
00197 U8 MaxPower;
00198 } S_usb_configuration_descriptor;
00199
00200
00202 typedef struct {
00203 U8 bLength;
00204 U8 bDescriptorType;
00205 U8 bInterfaceNumber;
00206 U8 bAlternateSetting;
00207 U8 bNumEndpoints;
00208 U8 bInterfaceClass;
00209 U8 bInterfaceSubClass;
00210 U8 bInterfaceProtocol;
00211 U8 iInterface;
00212 } S_usb_interface_descriptor;
00213
00214
00216 typedef struct {
00217 U8 bLength;
00218 U8 bDescriptorType;
00219 U8 bEndpointAddress;
00220 U8 bmAttributes;
00221 U16 wMaxPacketSize;
00222 U8 bInterval;
00223 } S_usb_endpoint_descriptor;
00224
00225
00227 typedef struct {
00228 U8 bLength;
00229 U8 bDescriptorType;
00230 U16 bscUSB;
00231 U8 bDeviceClass;
00232 U8 bDeviceSubClass;
00233 U8 bDeviceProtocol;
00234 U8 bMaxPacketSize0;
00235 U8 bNumConfigurations;
00236 U8 bReserved;
00237 } S_usb_device_qualifier_descriptor;
00238
00239
00241 typedef struct {
00242 U8 bLength;
00243 U8 bDescriptorType;
00244 U16 wlangid;
00245 } S_usb_language_id;
00246
00247
00248
00249
00250
00251
00252 typedef struct {
00253 U8 bLength;
00254 U8 bDescriptorType;
00255 U16 wstring[USB_MN_LENGTH];
00256 } S_usb_manufacturer_string_descriptor;
00257
00258
00259
00260
00261
00262
00263 typedef struct {
00264 U8 bLength;
00265 U8 bDescriptorType;
00266 U16 wstring[USB_PN_LENGTH];
00267 } S_usb_product_string_descriptor;
00268
00269
00270
00271
00272
00273
00274 typedef struct {
00275 U8 bLength;
00276 U8 bDescriptorType;
00277 U16 wstring[USB_SN_LENGTH];
00278 } S_usb_serial_number;
00279
00280
00281
00282
00283 typedef struct {
00284 U8 bLength;
00285 U8 bDescriptorType;
00286 U16 bscHID;
00287 U8 bCountryCode;
00288 U8 bNumDescriptors;
00289 U8 bRDescriptorType;
00290 U16 wDescriptorLength;
00291 } S_usb_hid_descriptor;
00292
00293
00294
00295
00296 typedef struct
00297 {
00298 S_usb_configuration_descriptor cfg_mouse;
00299 S_usb_interface_descriptor ifc_mouse;
00300 S_usb_hid_descriptor hid_mouse;
00301 S_usb_endpoint_descriptor ep1_mouse;
00302 S_usb_interface_descriptor ifc_ms;
00303 S_usb_endpoint_descriptor ep1_ms;
00304 S_usb_endpoint_descriptor ep2_ms;
00305 } S_usb_user_configuration_descriptor;
00306
00307
00308
00309
00310 #endif
00311