usb_descriptors.h

Go to the documentation of this file.
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 //_____ I N C L U D E S ____________________________________________________
00022 
00023 #include "config.h"
00024 #include "modules/usb/device_chap9/usb_standard_request.h"
00025 #include "conf_usb.h"
00026 
00027 //_____ M A C R O S ________________________________________________________
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 //_____ U S B    D E F I N E _______________________________________________
00035 
00036                   // USB Device descriptor
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            0x2031 // PID of HID application : toggle LED
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                // CONFIGURATION
00051 #define NB_INTERFACE       1
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              // OTG Descriptor  : set feature to "1" if used, "0" otherwise
00058 #define OTG_BMATTRIBUTES  (HNP_SUPPORT | SRP_SUPPORT)
00059 
00060              // USB Interface descriptor Spider Basic
00061 #define INTERFACE_NB_SPIDER         0
00062 #define ALTERNATE_SPIDER            0
00063 #define NB_ENDPOINT_SPIDER          1
00064 #define INTERFACE_CLASS_SPIDER      HID_CLASS         // HID Class
00065 #define INTERFACE_SUB_CLASS_SPIDER  NO_SUBCLASS       // No Sub Class
00066 #define INTERFACE_PROTOCOL_SPIDER   MOUSE_PROTOCOL    // Mouse Protocol
00067 #define INTERFACE_INDEX_SPIDER      0
00068 
00069 #define SELF_POWERED          1
00070 #define DEVICE_STATUS         SELF_POWERED
00071 #define INTERFACE_STATUS      0x00 // TBD
00072 
00073             // USB Endpoint 1 descriptor FS
00074 #define ENDPOINT_NB_1       (EP_SPIDER_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       50             // Interrupt polling interval from host, in ms
00079 
00080 
00081             // HID specific
00082 #define HID                   0x21
00083 #define REPORT                0x22
00084 #define SET_REPORT                0x02
00085 
00086 #define HID_DESCRIPTOR        0x21
00087 #define HID_BDC               0x1001
00088 #define HID_COUNTRY_CODE      0x00
00089 #define HID_CLASS_DESC_NB     0x01
00090 #define HID_DESCRIPTOR_TYPE   0x22
00091 
00092 #define LANG_ID               0x00
00093 
00094 
00095 #define USB_MN_LENGTH         5
00096 #define USB_MANUFACTURER_NAME \
00097 { Usb_unicode('A') \
00098 , Usb_unicode('T') \
00099 , Usb_unicode('M') \
00100 , Usb_unicode('E') \
00101 , Usb_unicode('L') \
00102 }
00103 
00104 #define USB_PN_LENGTH         21
00105 #define USB_PRODUCT_NAME \
00106 { Usb_unicode('A') \
00107  ,Usb_unicode('V') \
00108  ,Usb_unicode('R') \
00109  ,Usb_unicode('U') \
00110  ,Usb_unicode('S') \
00111  ,Usb_unicode('B') \
00112  ,Usb_unicode(' ') \
00113  ,Usb_unicode('O') \
00114  ,Usb_unicode('T') \
00115  ,Usb_unicode('G') \
00116  ,Usb_unicode(' ') \
00117  ,Usb_unicode('M') \
00118  ,Usb_unicode('O') \
00119  ,Usb_unicode('U') \
00120  ,Usb_unicode('S') \
00121  ,Usb_unicode('E') \
00122  ,Usb_unicode(' ') \
00123  ,Usb_unicode('D') \
00124  ,Usb_unicode('E') \
00125  ,Usb_unicode('M') \
00126  ,Usb_unicode('O') \
00127 }
00128 
00129 #define USB_SN_LENGTH         0x0D
00130               // Serial Number should be at least 12 characters long
00131 #define USB_SERIAL_NUMBER \
00132 { Usb_unicode('1') \
00133  ,Usb_unicode('.') \
00134  ,Usb_unicode('0') \
00135  ,Usb_unicode('.') \
00136  ,Usb_unicode('0') \
00137  ,Usb_unicode('.') \
00138  ,Usb_unicode('0') \
00139  ,Usb_unicode('.') \
00140  ,Usb_unicode('0') \
00141  ,Usb_unicode('.') \
00142  ,Usb_unicode('0') \
00143  ,Usb_unicode('.') \
00144  ,Usb_unicode('A') \
00145 }
00146 
00147 #define LANGUAGE_ID           0x0409
00148 
00149 
00151 typedef struct
00152 {
00153    U8      bmRequestType;        
00154    U8      bRequest;             
00155    U16     wValue;               
00156    U16     wIndex;               
00157    U16     wLength;              
00158 }  S_UsbRequest;
00159 
00161 typedef struct {
00162    U8      bLength;              
00163    U8      bDescriptorType;      
00164    U16     bscUSB;               
00165    U8      bDeviceClass;         
00166    U8      bDeviceSubClass;      
00167    U8      bDeviceProtocol;      
00168    U8      bMaxPacketSize0;      
00169    U16     idVendor;             
00170    U16     idProduct;            
00171    U16     bcdDevice;            
00172    U8      iManufacturer;        
00173    U8      iProduct;             
00174    U8      iSerialNumber;        
00175    U8      bNumConfigurations;   
00176 }  S_usb_device_descriptor;
00177 
00178 
00180 typedef struct {
00181    U8      bLength;              
00182    U8      bDescriptorType;      
00183    U16     wTotalLength;         
00184    U8      bNumInterfaces;       
00185    U8      bConfigurationValue;  
00186    U8      iConfiguration;       
00187    U8      bmAttibutes;          
00188    U8      MaxPower;             
00189 }  S_usb_configuration_descriptor;
00190 
00192 typedef struct {
00193    U8      bLength;               
00194    U8      bDescriptorType;       
00195    U8      bmAttributes;          
00196 }  S_usb_otg_descriptor;
00197 
00199 typedef struct {
00200    U8      bLength;               
00201    U8      bDescriptorType;       
00202    U8      bInterfaceNumber;      
00203    U8      bAlternateSetting;     
00204    U8      bNumEndpoints;         
00205    U8      bInterfaceClass;       
00206    U8      bInterfaceSubClass;    
00207    U8      bInterfaceProtocol;    
00208    U8      iInterface;            
00209 }  S_usb_interface_descriptor;
00210 
00211 
00213 typedef struct {
00214    U8      bLength;               
00215    U8      bDescriptorType;       
00216    U8      bEndpointAddress;      
00217    U8      bmAttributes;          
00218    U16     wMaxPacketSize;        
00219    U8      bInterval;             
00220 } S_usb_endpoint_descriptor;
00221 
00222 
00224 typedef struct {
00225    U8      bLength;               
00226    U8      bDescriptorType;       
00227    U16     bscUSB;                
00228    U8      bDeviceClass;          
00229    U8      bDeviceSubClass;       
00230    U8      bDeviceProtocol;       
00231    U8      bMaxPacketSize0;       
00232    U8      bNumConfigurations;    
00233    U8      bReserved;             
00234 }  S_usb_device_qualifier_descriptor;
00235 
00236 
00238 typedef struct {
00239    U8      bLength;               
00240    U8      bDescriptorType;       
00241    U16     wlangid;               
00242 }  S_usb_language_id;
00243 
00244 
00245 //_____ U S B   M A N U F A C T U R E R   D E S C R I P T O R _______________
00246 
00247 
00248 //struct usb_st_manufacturer
00249 typedef struct {
00250    U8  bLength;               // size of this descriptor in bytes
00251    U8  bDescriptorType;       // STRING descriptor type
00252    U16 wstring[USB_MN_LENGTH];// unicode characters
00253 } S_usb_manufacturer_string_descriptor;
00254 
00255 
00256 //_____ U S B   P R O D U C T   D E S C R I P T O R _________________________
00257 
00258 
00259 //struct usb_st_product
00260 typedef struct {
00261    U8  bLength;               // size of this descriptor in bytes
00262    U8  bDescriptorType;       // STRING descriptor type
00263    U16 wstring[USB_PN_LENGTH];// unicode characters
00264 } S_usb_product_string_descriptor;
00265 
00266 
00267 //_____ U S B   S E R I A L   N U M B E R   D E S C R I P T O R _____________
00268 
00269 
00270 //struct usb_st_serial_number
00271 typedef struct {
00272    U8  bLength;               // size of this descriptor in bytes
00273    U8  bDescriptorType;       // STRING descriptor type
00274    U16 wstring[USB_SN_LENGTH];// unicode characters
00275 } S_usb_serial_number;
00276 
00277 
00278 /*_____ U S B   H I D   D E S C R I P T O R __________________________________*/
00279 
00280 typedef struct {
00281   U8  bLength;               // Size of this descriptor in bytes
00282   U8  bDescriptorType;       // HID descriptor type
00283   U16 bscHID;                // Binay Coded Decimal Spec. release
00284   U8  bCountryCode;          // Hardware target country
00285   U8  bNumDescriptors;       // Number of HID class descriptors to follow
00286   U8  bRDescriptorType;      // Report descriptor type
00287   U16 wDescriptorLength;     // Total length of Report descriptor
00288 } S_usb_hid_descriptor;
00289 
00290 
00291 typedef struct
00292 {
00293    S_usb_configuration_descriptor cfg_mouse;
00294    S_usb_otg_descriptor           otg_dsc;
00295    S_usb_interface_descriptor     ifc_mouse;
00296    S_usb_hid_descriptor           hid_mouse;
00297    S_usb_endpoint_descriptor      ep1_spider;
00298 } S_usb_user_configuration_descriptor;
00299 
00300 
00301 
00302 #endif
00303 

Generated on Mon Feb 19 09:31:47 2007 for Atmel by  doxygen 1.5.1-p1