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 0x201D
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
00095 #define HID_DESCRIPTOR 0x21
00096 #define HID_BDC 0x1001
00097 #define HID_COUNTRY_CODE 0x00
00098 #define HID_CLASS_DESC_NB 0x01
00099 #define HID_DESCRIPTOR_TYPE 0x22
00100
00101
00102 #define USB_MN_LENGTH 5
00103 #define USB_MANUFACTURER_NAME \
00104 { Usb_unicode('A') \
00105 , Usb_unicode('T') \
00106 , Usb_unicode('M') \
00107 , Usb_unicode('E') \
00108 , Usb_unicode('L') \
00109 }
00110
00111 #define USB_PN_LENGTH 16
00112 #define USB_PRODUCT_NAME \
00113 { Usb_unicode('A') \
00114 ,Usb_unicode('V') \
00115 ,Usb_unicode('R') \
00116 ,Usb_unicode(' ') \
00117 ,Usb_unicode('U') \
00118 ,Usb_unicode('S') \
00119 ,Usb_unicode('B') \
00120 ,Usb_unicode(' ') \
00121 ,Usb_unicode('H') \
00122 ,Usb_unicode('I') \
00123 ,Usb_unicode('D') \
00124 ,Usb_unicode(' ') \
00125 ,Usb_unicode('D') \
00126 ,Usb_unicode('E') \
00127 ,Usb_unicode('M') \
00128 ,Usb_unicode('O') \
00129 }
00130
00131 #define USB_SN_LENGTH 0x05
00132 #define USB_SERIAL_NUMBER \
00133 { Usb_unicode('1') \
00134 ,Usb_unicode('.') \
00135 ,Usb_unicode('0') \
00136 ,Usb_unicode('.') \
00137 ,Usb_unicode('0') \
00138 }
00139
00140 #define LANGUAGE_ID 0x0409
00141
00142
00144 typedef struct
00145 {
00146 U8 bmRequestType;
00147 U8 bRequest;
00148 U16 wValue;
00149 U16 wIndex;
00150 U16 wLength;
00151 } S_UsbRequest;
00152
00154 typedef struct {
00155 U8 bLength;
00156 U8 bDescriptorType;
00157 U16 bscUSB;
00158 U8 bDeviceClass;
00159 U8 bDeviceSubClass;
00160 U8 bDeviceProtocol;
00161 U8 bMaxPacketSize0;
00162 U16 idVendor;
00163 U16 idProduct;
00164 U16 bcdDevice;
00165 U8 iManufacturer;
00166 U8 iProduct;
00167 U8 iSerialNumber;
00168 U8 bNumConfigurations;
00169 } S_usb_device_descriptor;
00170
00171
00173 typedef struct {
00174 U8 bLength;
00175 U8 bDescriptorType;
00176 U16 wTotalLength;
00177 U8 bNumInterfaces;
00178 U8 bConfigurationValue;
00179 U8 iConfiguration;
00180 U8 bmAttibutes;
00181 U8 MaxPower;
00182 } S_usb_configuration_descriptor;
00183
00184
00186 typedef struct {
00187 U8 bLength;
00188 U8 bDescriptorType;
00189 U8 bInterfaceNumber;
00190 U8 bAlternateSetting;
00191 U8 bNumEndpoints;
00192 U8 bInterfaceClass;
00193 U8 bInterfaceSubClass;
00194 U8 bInterfaceProtocol;
00195 U8 iInterface;
00196 } S_usb_interface_descriptor;
00197
00198
00200 typedef struct {
00201 U8 bLength;
00202 U8 bDescriptorType;
00203 U8 bEndpointAddress;
00204 U8 bmAttributes;
00205 U16 wMaxPacketSize;
00206 U8 bInterval;
00207 } S_usb_endpoint_descriptor;
00208
00209
00211 typedef struct {
00212 U8 bLength;
00213 U8 bDescriptorType;
00214 U16 bscUSB;
00215 U8 bDeviceClass;
00216 U8 bDeviceSubClass;
00217 U8 bDeviceProtocol;
00218 U8 bMaxPacketSize0;
00219 U8 bNumConfigurations;
00220 U8 bReserved;
00221 } S_usb_device_qualifier_descriptor;
00222
00223
00225 typedef struct {
00226 U8 bLength;
00227 U8 bDescriptorType;
00228 U16 wlangid;
00229 } S_usb_language_id;
00230
00231
00232
00233
00234
00235
00236 typedef struct {
00237 U8 bLength;
00238 U8 bDescriptorType;
00239 U16 wstring[USB_MN_LENGTH];
00240 } S_usb_manufacturer_string_descriptor;
00241
00242
00243
00244
00245
00246
00247 typedef struct {
00248 U8 bLength;
00249 U8 bDescriptorType;
00250 U16 wstring[USB_PN_LENGTH];
00251 } S_usb_product_string_descriptor;
00252
00253
00254
00255
00256
00257
00258 typedef struct {
00259 U8 bLength;
00260 U8 bDescriptorType;
00261 U16 wstring[USB_SN_LENGTH];
00262 } S_usb_serial_number;
00263
00264
00265
00266
00267 typedef struct {
00268 U8 bLength;
00269 U8 bDescriptorType;
00270 U16 bscHID;
00271 U8 bCountryCode;
00272 U8 bNumDescriptors;
00273 U8 bRDescriptorType;
00274 U16 wDescriptorLength;
00275 } S_usb_hid_descriptor;
00276
00277
00278
00279
00280
00281
00282 typedef struct
00283 {
00284 S_usb_configuration_descriptor cfg;
00285 S_usb_interface_descriptor ifc;
00286 S_usb_hid_descriptor hid;
00287 S_usb_endpoint_descriptor ep1;
00288 S_usb_endpoint_descriptor ep2;
00289 } S_usb_user_configuration_descriptor;
00290
00291
00292
00293
00294 #endif
00295