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.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          0x02      // CDC 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     32
00042 #define VENDOR_ID             0x03EB // Atmel vendor ID = 03EBh
00043 #define PRODUCT_ID            0x2018
00044 #define RELEASE_NUMBER        0x1000
00045 #define MAN_INDEX             0x00
00046 #define PROD_INDEX            0x00
00047 #define SN_INDEX              0x00
00048 #define NB_CONFIGURATION      1
00049 
00050                // CDC CONFIGURATION
00051 #define NB_INTERFACE       2
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              // Interface 0 descriptor
00058 #define INTERFACE0_NB        0
00059 #define ALTERNATE0           0
00060 #define NB_ENDPOINT0         1
00061 #define INTERFACE0_CLASS     0x02    // CDC ACM Com
00062 #define INTERFACE0_SUB_CLASS 0x02
00063 #define INTERFACE0_PROTOCOL  0x01
00064 #define INTERFACE0_INDEX     0
00065 
00066              // Interface 1 descriptor
00067 #define INTERFACE1_NB        1
00068 #define ALTERNATE1           0
00069 #define NB_ENDPOINT1         2
00070 #define INTERFACE1_CLASS     0x0A    // CDC ACM Data
00071 #define INTERFACE1_SUB_CLASS 0
00072 #define INTERFACE1_PROTOCOL  0
00073 #define INTERFACE1_INDEX     0
00074 
00075              // USB Endpoint 3 descriptor
00076              // Interrupt IN
00077 #define TX_EP_SIZE          0x20
00078 #define ENDPOINT_NB_3       0x80 | INT_EP
00079 #define EP_ATTRIBUTES_3     0x03          // BULK = 0x02, INTERUPT = 0x03
00080 #define EP_SIZE_3           TX_EP_SIZE
00081 #define EP_INTERVAL_3       0xFF //ms interrupt pooling from host
00082 
00083              // USB Endpoint 1 descriptor
00084              // Bulk IN
00085 #define ENDPOINT_NB_1       0x80 | TX_EP
00086 #define EP_ATTRIBUTES_1     0x02          // BULK = 0x02, INTERUPT = 0x03
00087 #define EP_SIZE_1           0x20
00088 #define EP_INTERVAL_1       0x00
00089 
00090              // USB Endpoint 2 descriptor
00091              //Bulk OUT  RX endpoint
00092 #define ENDPOINT_NB_2       RX_EP
00093 #define EP_ATTRIBUTES_2     0x02          // BULK = 0x02, INTERUPT = 0x03
00094 #define EP_SIZE_2           0x20
00095 #define EP_INTERVAL_2       0x00
00096 
00097 
00098 
00099 #define DEVICE_STATUS         0x00 // TBD
00100 #define INTERFACE_STATUS      0x00 // TBD
00101 
00102 #define LANG_ID               0x00
00103 
00104 
00105 
00106 
00107 #define USB_MN_LENGTH         5
00108 #define USB_MANUFACTURER_NAME \
00109 { Usb_unicode('A') \
00110 , Usb_unicode('T') \
00111 , Usb_unicode('M') \
00112 , Usb_unicode('E') \
00113 , Usb_unicode('L') \
00114 }
00115 
00116 #define USB_PN_LENGTH         16
00117 #define USB_PRODUCT_NAME \
00118 { Usb_unicode('A') \
00119  ,Usb_unicode('V') \
00120  ,Usb_unicode('R') \
00121  ,Usb_unicode(' ') \
00122  ,Usb_unicode('U') \
00123  ,Usb_unicode('S') \
00124  ,Usb_unicode('B') \
00125  ,Usb_unicode(' ') \
00126  ,Usb_unicode('C') \
00127  ,Usb_unicode('D') \
00128  ,Usb_unicode('C') \
00129  ,Usb_unicode(' ') \
00130  ,Usb_unicode('D') \
00131  ,Usb_unicode('E') \
00132  ,Usb_unicode('M') \
00133  ,Usb_unicode('O') \
00134 }
00135 
00136 #define USB_SN_LENGTH         0x05
00137 #define USB_SERIAL_NUMBER \
00138 {Usb_unicode('1') \
00139  ,Usb_unicode('.') \
00140  ,Usb_unicode('0') \
00141  ,Usb_unicode('.') \
00142  ,Usb_unicode('0') \
00143 }
00144 
00145 #define LANGUAGE_ID           0x0409
00146 
00147 
00149 typedef struct
00150 {
00151    U8      bmRequestType;        
00152    U8      bRequest;             
00153    U16     wValue;               
00154    U16     wIndex;               
00155    U16     wLength;              
00156 }  S_UsbRequest;
00157 
00159 typedef struct {
00160    U8      bLength;              
00161    U8      bDescriptorType;      
00162    U16     bscUSB;               
00163    U8      bDeviceClass;         
00164    U8      bDeviceSubClass;      
00165    U8      bDeviceProtocol;      
00166    U8      bMaxPacketSize0;      
00167    U16     idVendor;             
00168    U16     idProduct;            
00169    U16     bcdDevice;            
00170    U8      iManufacturer;        
00171    U8      iProduct;             
00172    U8      iSerialNumber;        
00173    U8      bNumConfigurations;   
00174 }  S_usb_device_descriptor;
00175 
00176 
00178 typedef struct {
00179    U8      bLength;              
00180    U8      bDescriptorType;      
00181    U16     wTotalLength;         
00182    U8      bNumInterfaces;       
00183    U8      bConfigurationValue;  
00184    U8      iConfiguration;       
00185    U8      bmAttibutes;          
00186    U8      MaxPower;             
00187 }  S_usb_configuration_descriptor;
00188 
00189 
00191 typedef struct {
00192    U8      bLength;               
00193    U8      bDescriptorType;       
00194    U8      bInterfaceNumber;      
00195    U8      bAlternateSetting;     
00196    U8      bNumEndpoints;         
00197    U8      bInterfaceClass;       
00198    U8      bInterfaceSubClass;    
00199    U8      bInterfaceProtocol;    
00200    U8      iInterface;            
00201 }  S_usb_interface_descriptor;
00202 
00203 
00205 typedef struct {
00206    U8      bLength;               
00207    U8      bDescriptorType;       
00208    U8      bEndpointAddress;      
00209    U8      bmAttributes;          
00210    U16     wMaxPacketSize;        
00211    U8      bInterval;             
00212 } S_usb_endpoint_descriptor;
00213 
00214 
00216 typedef struct {
00217    U8      bLength;               
00218    U8      bDescriptorType;       
00219    U16     bscUSB;                
00220    U8      bDeviceClass;          
00221    U8      bDeviceSubClass;       
00222    U8      bDeviceProtocol;       
00223    U8      bMaxPacketSize0;       
00224    U8      bNumConfigurations;    
00225    U8      bReserved;             
00226 }  S_usb_device_qualifier_descriptor;
00227 
00228 
00230 typedef struct {
00231    U8      bLength;               
00232    U8      bDescriptorType;       
00233    U16     wlangid;               
00234 }  S_usb_language_id;
00235 
00236 
00237 //_____ 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 _______________
00238 
00239 
00240 //struct usb_st_manufacturer
00241 typedef struct {
00242    U8  bLength;               // size of this descriptor in bytes
00243    U8  bDescriptorType;       // STRING descriptor type
00244    U16 wstring[USB_MN_LENGTH];// unicode characters
00245 } S_usb_manufacturer_string_descriptor;
00246 
00247 
00248 //_____ U S B   P R O D U C T   D E S C R I P T O R _________________________
00249 
00250 
00251 //struct usb_st_product
00252 typedef struct {
00253    U8  bLength;               // size of this descriptor in bytes
00254    U8  bDescriptorType;       // STRING descriptor type
00255    U16 wstring[USB_PN_LENGTH];// unicode characters
00256 } S_usb_product_string_descriptor;
00257 
00258 
00259 //_____ 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 _____________
00260 
00261 
00262 //struct usb_st_serial_number
00263 typedef struct {
00264    U8  bLength;               // size of this descriptor in bytes
00265    U8  bDescriptorType;       // STRING descriptor type
00266    U16 wstring[USB_SN_LENGTH];// unicode characters
00267 } S_usb_serial_number;
00268 
00269 
00270 /*_____ U S B   C D C  D E S C R I P T O R __________________________________*/
00271 
00272 typedef struct
00273 {
00274    S_usb_configuration_descriptor cfg;
00275    S_usb_interface_descriptor     ifc0;
00276    U8 CS_INTERFACE[19];
00277    S_usb_endpoint_descriptor      ep3;
00278    S_usb_interface_descriptor     ifc1;
00279    S_usb_endpoint_descriptor      ep1;
00280    S_usb_endpoint_descriptor      ep2;
00281 } S_usb_user_configuration_descriptor;
00282 
00283 
00284 
00285 
00286 
00287 
00288 
00289 #endif
00290 

Generated on Fri Jun 15 14:15:33 2007 for Atmel by  doxygen 1.5.1-p1