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.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 64
00042 #define VENDOR_ID 0x03EB // Atmel vendor ID = 03EBh
00043 #define PRODUCT_ID 0x2013
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 1
00052 #define CONF_NB 1
00053 #define CONF_INDEX 0
00054 #define CONF_ATTRIBUTES USB_CONFIG_BUSPOWERED
00055 #define MAX_POWER 50 // 100 mA
00056
00057
00058 #define INTERFACE_NB 0
00059 #define ALTERNATE 0
00060 #define NB_ENDPOINT 2
00061 #define INTERFACE_CLASS 0x03 // HID Class
00062 #define INTERFACE_SUB_CLASS 0x00
00063 #define INTERFACE_PROTOCOL 0x00
00064 #define INTERFACE_INDEX 0
00065
00066
00067 #define ENDPOINT_NB_1 (EP_HID_IN | 0x80)
00068 #define EP_ATTRIBUTES_1 0x03 // BULK = 0x02, INTERUPT = 0x03
00069 #define EP_IN_LENGTH 8
00070 #define EP_SIZE_1 EP_IN_LENGTH
00071 #define EP_INTERVAL_1 20 //interrupt pooling from host
00072
00073
00074 #define ENDPOINT_NB_2 (EP_HID_OUT)
00075 #define EP_ATTRIBUTES_2 0x03 // BULK = 0x02, INTERUPT = 0x03
00076 #define EP_OUT_LENGTH 8
00077 #define EP_SIZE_2 EP_OUT_LENGTH
00078 #define EP_INTERVAL_2 20 //interrupt pooling from host
00079
00080 #define SIZE_OF_REPORT 0x35
00081 #define LENGTH_OF_REPORT_IN 0x08
00082 #define LENGTH_OF_REPORT_OUT 0x08
00083
00084 #define DEVICE_STATUS 0x00 // TBD
00085 #define INTERFACE_STATUS 0x00 // TBD
00086
00087 #define LANG_ID 0x00
00088
00089
00090
00091 #define HID 0x21
00092 #define REPORT 0x22
00093 #define SET_REPORT 0x02
00094 #define SET_HID_REPORT 0x03
00095
00096
00097 #define HID_DESCRIPTOR 0x21
00098 #define HID_BDC 0x1001
00099 #define HID_COUNTRY_CODE 0x00
00100 #define HID_CLASS_DESC_NB 0x01
00101 #define HID_DESCRIPTOR_TYPE 0x22
00102
00103
00104 #define USB_MN_LENGTH 5
00105 #define USB_MANUFACTURER_NAME \
00106 { Usb_unicode('A') \
00107 , Usb_unicode('T') \
00108 , Usb_unicode('M') \
00109 , Usb_unicode('E') \
00110 , Usb_unicode('L') \
00111 }
00112
00113 #define USB_PN_LENGTH 16
00114 #define USB_PRODUCT_NAME \
00115 { Usb_unicode('A') \
00116 ,Usb_unicode('V') \
00117 ,Usb_unicode('R') \
00118 ,Usb_unicode(' ') \
00119 ,Usb_unicode('U') \
00120 ,Usb_unicode('S') \
00121 ,Usb_unicode('B') \
00122 ,Usb_unicode(' ') \
00123 ,Usb_unicode('H') \
00124 ,Usb_unicode('I') \
00125 ,Usb_unicode('D') \
00126 ,Usb_unicode(' ') \
00127 ,Usb_unicode('D') \
00128 ,Usb_unicode('E') \
00129 ,Usb_unicode('M') \
00130 ,Usb_unicode('O') \
00131 }
00132
00133 #define USB_SN_LENGTH 0x05
00134 #define USB_SERIAL_NUMBER \
00135 { Usb_unicode('1') \
00136 ,Usb_unicode('.') \
00137 ,Usb_unicode('0') \
00138 ,Usb_unicode('.') \
00139 ,Usb_unicode('0') \
00140 }
00141
00142 #define LANGUAGE_ID 0x0409
00143
00144
00146 typedef struct
00147 {
00148 U8 bmRequestType;
00149 U8 bRequest;
00150 U16 wValue;
00151 U16 wIndex;
00152 U16 wLength;
00153 } S_UsbRequest;
00154
00156 typedef struct {
00157 U8 bLength;
00158 U8 bDescriptorType;
00159 U16 bscUSB;
00160 U8 bDeviceClass;
00161 U8 bDeviceSubClass;
00162 U8 bDeviceProtocol;
00163 U8 bMaxPacketSize0;
00164 U16 idVendor;
00165 U16 idProduct;
00166 U16 bcdDevice;
00167 U8 iManufacturer;
00168 U8 iProduct;
00169 U8 iSerialNumber;
00170 U8 bNumConfigurations;
00171 } S_usb_device_descriptor;
00172
00173
00175 typedef struct {
00176 U8 bLength;
00177 U8 bDescriptorType;
00178 U16 wTotalLength;
00179 U8 bNumInterfaces;
00180 U8 bConfigurationValue;
00181 U8 iConfiguration;
00182 U8 bmAttibutes;
00183 U8 MaxPower;
00184 } S_usb_configuration_descriptor;
00185
00186
00188 typedef struct {
00189 U8 bLength;
00190 U8 bDescriptorType;
00191 U8 bInterfaceNumber;
00192 U8 bAlternateSetting;
00193 U8 bNumEndpoints;
00194 U8 bInterfaceClass;
00195 U8 bInterfaceSubClass;
00196 U8 bInterfaceProtocol;
00197 U8 iInterface;
00198 } S_usb_interface_descriptor;
00199
00200
00202 typedef struct {
00203 U8 bLength;
00204 U8 bDescriptorType;
00205 U8 bEndpointAddress;
00206 U8 bmAttributes;
00207 U16 wMaxPacketSize;
00208 U8 bInterval;
00209 } S_usb_endpoint_descriptor;
00210
00211
00213 typedef struct {
00214 U8 bLength;
00215 U8 bDescriptorType;
00216 U16 bscUSB;
00217 U8 bDeviceClass;
00218 U8 bDeviceSubClass;
00219 U8 bDeviceProtocol;
00220 U8 bMaxPacketSize0;
00221 U8 bNumConfigurations;
00222 U8 bReserved;
00223 } S_usb_device_qualifier_descriptor;
00224
00225
00227 typedef struct {
00228 U8 bLength;
00229 U8 bDescriptorType;
00230 U16 wlangid;
00231 } S_usb_language_id;
00232
00233
00234
00235
00236
00237
00238 typedef struct {
00239 U8 bLength;
00240 U8 bDescriptorType;
00241 U16 wstring[USB_MN_LENGTH];
00242 } S_usb_manufacturer_string_descriptor;
00243
00244
00245
00246
00247
00248
00249 typedef struct {
00250 U8 bLength;
00251 U8 bDescriptorType;
00252 U16 wstring[USB_PN_LENGTH];
00253 } S_usb_product_string_descriptor;
00254
00255
00256
00257
00258
00259
00260 typedef struct {
00261 U8 bLength;
00262 U8 bDescriptorType;
00263 U16 wstring[USB_SN_LENGTH];
00264 } S_usb_serial_number;
00265
00266
00267
00268
00269 typedef struct {
00270 U8 bLength;
00271 U8 bDescriptorType;
00272 U16 bscHID;
00273 U8 bCountryCode;
00274 U8 bNumDescriptors;
00275 U8 bRDescriptorType;
00276 U16 wDescriptorLength;
00277 } S_usb_hid_descriptor;
00278
00279
00280
00281
00282
00283
00284 typedef struct
00285 {
00286 S_usb_configuration_descriptor cfg;
00287 S_usb_interface_descriptor ifc;
00288 S_usb_hid_descriptor hid;
00289 S_usb_endpoint_descriptor ep1;
00290 S_usb_endpoint_descriptor ep2;
00291 } S_usb_user_configuration_descriptor;
00292
00293
00294
00295
00296 #endif
00297