Xmega Application Note


usb_descriptors.h

Go to the documentation of this file.
00001 /* This file has been prepared for Doxygen automatic documentation generation.*/
00049 #ifndef _USB_USERCONFIG_H_
00050 #define _USB_USERCONFIG_H_
00051 
00052 #include "config.h"
00053 #include "usb_standard_request.h"
00054 #include "conf_usb.h"
00055 
00056 /****************************** MACROS ****************************************/
00057 
00058 #define Usb_get_dev_desc_pointer()        (&(usb_dev_desc.bLength))
00059 #define Usb_get_dev_desc_length()         (sizeof (usb_dev_desc))
00060 #define Usb_get_conf_desc_pointer()       (&(usb_conf_desc.cfg.bLength))
00061 #define Usb_get_conf_desc_length()        (sizeof (usb_conf_desc))
00062 
00063 /****************************** DEFINES ***************************************/
00064 
00065 /* USB Device descriptor */
00066 #define USB_SPECIFICATION     0x0200
00067 #define DEVICE_CLASS          0x02   
00068 #define DEVICE_SUB_CLASS      0x00   
00069 #define DEVICE_PROTOCOL       0x00   
00070 #define EP_CONTROL_LENGTH     64
00071 #define VENDOR_ID             0x03EB 
00072 #define PRODUCT_ID            0x210D 
00073 #define RELEASE_NUMBER        0x0102
00074 #define LANG_INDEX            0x00
00075 #define MAN_INDEX             0x01
00076 #define PROD_INDEX            0x02
00077 #define SN_INDEX              0x03
00078 #define IF0_INDEX             0x04
00079 #define NB_CONFIGURATION      1
00080 
00081 
00082 /* CDC CONFIGURATION */
00083 #define NB_INTERFACE       2
00084 #define CONF_NB            1
00085 #define CONF_INDEX         0
00086 #define CONF_ATTRIBUTES    USB_CONFIG_BUSPOWERED
00087 #define MAX_POWER          250        /* 500 mA given in 2mA steps*/
00088 
00089 /* Interface 0 descriptor */
00090 #define INTERFACE0_NB        0
00091 #define ALTERNATE0           0
00092 #define NB_ENDPOINT0         1
00093 #define INTERFACE0_CLASS     0x02    /* CDC ACM Com */
00094 #define INTERFACE0_SUB_CLASS 0x02
00095 #define INTERFACE0_PROTOCOL  0x01
00096 #define INTERFACE0_INDEX     IF0_INDEX
00097 
00098 /* Interface 1 descriptor */
00099 #define INTERFACE1_NB        1
00100 #define ALTERNATE1           0
00101 #define NB_ENDPOINT1         2
00102 #define INTERFACE1_CLASS     0x0A    /* CDC ACM Data */
00103 #define INTERFACE1_SUB_CLASS 0
00104 #define INTERFACE1_PROTOCOL  0
00105 #define INTERFACE1_INDEX     IF0_INDEX
00106 
00107 /* USB Endpoint 3 descriptor */
00108 #define TX_EP_SIZE          0x20
00109 #define ENDPOINT_NB_3       EP_DIR_IN | INT_EP 
00110 #define EP_ATTRIBUTES_3     EP_ATTR_INTERUPT
00111 #define EP_SIZE_3           TX_EP_SIZE
00112 #define EP_INTERVAL_3       0xFF
00113 
00114 /* USB Endpoint 1 descriptor */
00115 #define ENDPOINT_NB_1       EP_DIR_IN | TX_EP
00116 #define EP_ATTRIBUTES_1     EP_ATTR_BULK
00117 #define EP_SIZE_1           0x20
00118 #define EP_INTERVAL_1       0x00
00119 
00120 /* USB Endpoint 2 descriptor */
00121 #define ENDPOINT_NB_2       EP_DIR_OUT | RX_EP
00122 #define EP_ATTRIBUTES_2     EP_ATTR_BULK
00123 #define EP_SIZE_2           0x20
00124 #define EP_INTERVAL_2       0x00
00125 
00126 
00127 #define DEVICE_STATUS         0x00
00128 #define INTERFACE_STATUS      0x00
00129 
00130 
00131 
00132 /* Strings for indexing */
00133 #define USB_MN_LENGTH         5
00134 #define USB_MANUFACTURER_NAME {'A','T','M','E','L'}
00135 
00136 #define USB_PN_LENGTH         18
00137 #define USB_PRODUCT_NAME      {'X','p','l','a','i','n',' ','U','S','B',' ','G','a','t','e','w','a','y'}
00138 
00139 #define USB_SN_LENGTH         8
00140 #define USB_SERIAL_NUMBER     {'0','0','0','0','0','0','0','0'}
00141 
00142 #define USB_IF0_LENGTH         11
00143 #define USB_IF0_DESCRIPT      {'S','e','r','i','a','l',' ','P','o','r','t'}
00144 
00145 #define LANGUAGE_ID           0x0409
00146 
00148 typedef struct {
00149         uint8_t      bmRequestType;        
00150         uint8_t      bRequest;             
00151         uint16_t     wValue;               
00152         uint16_t     wIndex;               
00153         uint16_t     wLength;              
00154 }  S_UsbRequest;
00155 
00156 
00158 typedef struct {
00159         uint8_t      bLength;              
00160         uint8_t      bDescriptorType;      
00161         uint16_t     bscUSB;               
00162         uint8_t      bDeviceClass;         
00163         uint8_t      bDeviceSubClass;      
00164         uint8_t      bDeviceProtocol;      
00165         uint8_t      bMaxPacketSize0;      
00166         uint16_t     idVendor;             
00167         uint16_t     idProduct;            
00168         uint16_t     bcdDevice;            
00169         uint8_t      iManufacturer;        
00170         uint8_t      iProduct;             
00171         uint8_t      iSerialNumber;        
00172         uint8_t      bNumConfigurations;   
00173 }  S_usb_device_descriptor;
00174 
00175 
00177 typedef struct {
00178         uint8_t      bLength;              
00179         uint8_t      bDescriptorType;      
00180         uint16_t     wTotalLength;         
00181         uint8_t      bNumInterfaces;       
00182         uint8_t      bConfigurationValue;  
00183         uint8_t      iConfiguration;       
00184         uint8_t      bmAttibutes;          
00185         uint8_t      MaxPower;             
00186 }  S_usb_configuration_descriptor;
00187 
00189 typedef struct {
00190         uint8_t      bLength;               
00191         uint8_t      bDescriptorType;       
00192         uint8_t      bFirstInterface;       
00193         uint8_t      bInterfaceCount;       
00194         uint8_t      bFunctionClass;        
00195         uint8_t      bFunctionSubClass;     
00196         uint8_t      bFunctionProtocol;     
00197         uint8_t      iFunction;             
00198 }  S_usb_interface_association_descriptor;
00199 
00201 typedef struct {
00202         uint8_t      bLength;               
00203         uint8_t      bDescriptorType;       
00204         uint8_t      bInterfaceNumber;      
00205         uint8_t      bAlternateSetting;     
00206         uint8_t      bNumEndpoints;         
00207         uint8_t      bInterfaceClass;       
00208         uint8_t      bInterfaceSubClass;    
00209         uint8_t      bInterfaceProtocol;    
00210         uint8_t      iInterface;            
00211 }  S_usb_interface_descriptor;
00212 
00213 
00215 typedef struct {
00216         uint8_t      bLength;               
00217         uint8_t      bDescriptorType;       
00218         uint8_t      bEndpointAddress;      
00219         uint8_t      bmAttributes;          
00220         uint16_t     wMaxPacketSize;        
00221         uint8_t      bInterval;             
00222 } S_usb_endpoint_descriptor;
00223 
00224 
00226 typedef struct {
00227         uint8_t      bLength;               
00228         uint8_t      bDescriptorType;       
00229         uint16_t     bscUSB;                
00230         uint8_t      bDeviceClass;          
00231         uint8_t      bDeviceSubClass;       
00232         uint8_t      bDeviceProtocol;       
00233         uint8_t      bMaxPacketSize0;       
00234         uint8_t      bNumConfigurations;    
00235         uint8_t      bReserved;             
00236 }  S_usb_device_qualifier_descriptor;
00237 
00238 
00240 typedef struct {
00241         uint8_t      bLength;               
00242         uint8_t      bDescriptorType;       
00243         uint16_t     wlangid;               
00244 }  S_usb_language_id;
00245 
00246 
00248 typedef struct {
00249         uint8_t  bLength;                   
00250         uint8_t  bDescriptorType;           
00251         uint16_t wstring[USB_MN_LENGTH];    
00252 } S_usb_manufacturer_string_descriptor;
00253 
00254 
00256 typedef struct {
00257         uint8_t  bLength;                   
00258         uint8_t  bDescriptorType;           
00259         uint16_t wstring[USB_PN_LENGTH];    
00260 } S_usb_product_string_descriptor;
00261 
00262 
00264 typedef struct {
00265         uint8_t  bLength;                   
00266         uint8_t  bDescriptorType;           
00267         uint16_t wstring[USB_SN_LENGTH];    
00268 } S_usb_serial_number;
00269 
00270 
00272 typedef struct {
00273         uint8_t  bLength;                   
00274         uint8_t  bDescriptorType;           
00275         uint16_t wstring[USB_IF0_LENGTH];   
00276 } S_usb_if0_descript;
00277 
00278 
00280 typedef struct {
00281         S_usb_configuration_descriptor cfg;
00282         S_usb_interface_descriptor     ifc0;
00283         uint8_t                        CS_INTERFACE[19];
00284         S_usb_endpoint_descriptor      ep3;
00285         S_usb_interface_descriptor     ifc1;
00286         S_usb_endpoint_descriptor      ep1;
00287         S_usb_endpoint_descriptor      ep2;
00288 } S_usb_user_configuration_descriptor;
00289 
00290 
00291 #endif
00292 
@DOC_TITLE@
Generated on Mon Jan 18 09:26:08 2010 for AVR1907 Xplain USB Gateway by doxygen 1.5.5