usb_descriptors.h

Go to the documentation of this file.
00001 /*This file has been prepared for Doxygen automatic documentation generation.*/
00016 
00017 /* Copyright (c) 2007, Atmel Corporation All rights reserved.
00018  *
00019  * Redistribution and use in source and binary forms, with or without
00020  * modification, are permitted provided that the following conditions are met:
00021  *
00022  * 1. Redistributions of source code must retain the above copyright notice,
00023  * this list of conditions and the following disclaimer.
00024  *
00025  * 2. Redistributions in binary form must reproduce the above copyright notice,
00026  * this list of conditions and the following disclaimer in the documentation
00027  * and/or other materials provided with the distribution.
00028  *
00029  * 3. The name of ATMEL may not be used to endorse or promote products derived
00030  * from this software without specific prior written permission.
00031  *
00032  * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED
00033  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00034  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND
00035  * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
00036  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00037  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00038  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00039  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00040  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00041  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00042  */
00043 
00044 #ifndef _USB_DESCRIPTORS_H_
00045 #define _USB_DESCRIPTORS_H_
00046 
00047 //_____ I N C L U D E S ____________________________________________________
00048 
00049 #include "config.h"
00050 #include "modules/usb/device_chap9/usb_standard_request.h"
00051 #include "conf_usb.h"
00052 
00053 //_____ M A C R O S ________________________________________________________
00054 
00055 #define Usb_unicode(a)         ((U16)(a))
00056 #define Usb_get_dev_desc_pointer()        (&(usb_dev_desc.bLength))
00057 #define Usb_get_dev_desc_length()         (sizeof (usb_dev_desc))
00058 #define Usb_get_conf_desc_pointer()       (&(usb_conf_desc.cfg_temp.bLength))
00059 #define Usb_get_conf_desc_length()        (sizeof (usb_conf_desc))
00060 
00061 //_____ U S B    D E F I N E _______________________________________________
00062 
00063                   // USB Device descriptor
00064 #define USB_SPECIFICATION     0x0200
00065 #define DEVICE_CLASS          0      
00066 #define DEVICE_SUB_CLASS      0      
00067 #define DEVICE_PROTOCOL       0      
00068 #define EP_CONTROL_LENGTH     64
00069 #define VENDOR_ID             VID_ATMEL
00070 #define PRODUCT_ID            0x0000
00071 #define RELEASE_NUMBER        0x1000
00072 #define MAN_INDEX             0x01
00073 #define PROD_INDEX            0x02   
00074 #if (USB_DEVICE_SN_USE==ENABLE)
00075 #define SN_INDEX              0x03
00076 #else
00077 #define SN_INDEX              0x00  // No serial number field
00078 #endif
00079 #define NB_CONFIGURATION      1
00080 
00081                // CONFIGURATION
00082 #define NB_INTERFACE       2           // Number of interfaces
00083 #define CONF_NB            1     
00084 #define CONF_INDEX         0
00085 #define CONF_ATTRIBUTES    USB_CONFIG_BUSPOWERED
00086 #define MAX_POWER          50    // 100 mA
00087 
00088              // USB Interface descriptor gen
00089 #define INTERFACE_NB_TEMP        0            
00090 #define ALTERNATE_TEMP           0            
00091 #define NB_ENDPOINT_TEMP         2            
00092 #define INTERFACE_CLASS_TEMP     NO_CLASS     
00093 #define INTERFACE_SUB_CLASS_TEMP NO_SUBCLASS  
00094 #define INTERFACE_PROTOCOL_TEMP  NO_PROTOCOL  
00095 #define INTERFACE_INDEX_TEMP     0
00096 
00097             // USB Endpoint 1 descriptor FS
00098 #define ENDPOINT_NB_TEMP1       (EP_TEMP_IN | USB_ENDPOINT_IN)
00099 #define EP_ATTRIBUTES_TEMP1     0x02              // BULK = 0x02, INTERUPT = 0x03
00100 #define EP_IN_LENGTH_TEMP1      64
00101 #define EP_SIZE_TEMP1           EP_IN_LENGTH_TEMP1
00102 #define EP_INTERVAL_TEMP1       0x00              // Interrupt polling interval from host
00103 
00104             // USB Endpoint 2 descriptor FS
00105 #define ENDPOINT_NB_TEMP2       EP_TEMP_OUT
00106 #define EP_ATTRIBUTES_TEMP2     0x02              // BULK = 0x02, INTERUPT = 0x03
00107 #define EP_IN_LENGTH_TEMP2      64
00108 #define EP_SIZE_TEMP2           EP_IN_LENGTH_TEMP2
00109 #define EP_INTERVAL_TEMP2       0x00              // Interrupt polling interval from host
00110 
00111              // USB Second Interface descriptor gen
00112 #define INTERFACE_NB_SECOND_TEMP        1        
00113 #define ALTERNATE_SECOND_TEMP           0        
00114 #define NB_ENDPOINT_SECOND_TEMP         1        
00115 #define INTERFACE_CLASS_SECOND_TEMP     0x00     
00116 #define INTERFACE_SUB_CLASS_SECOND_TEMP 0x55     
00117 #define INTERFACE_PROTOCOL_SECOND_TEMP  0xAA     
00118 #define INTERFACE_INDEX_SECOND_TEMP     0
00119 
00120             // USB Endpoint 2 descriptor FS
00121 #define ENDPOINT_NB_TEMP3       (EP_TEMP_INT_IN | USB_ENDPOINT_IN)
00122 #define EP_ATTRIBUTES_TEMP3     0x03              // BULK = 0x02, INTERUPT = 0x03
00123 #define EP_IN_LENGTH_TEMP3      64
00124 #define EP_SIZE_TEMP3           EP_IN_LENGTH_TEMP2
00125 #define EP_INTERVAL_TEMP3       20              // Interrupt polling interval from host
00126 
00127 
00128 #define DEVICE_STATUS         USB_DEVICE_STATUS_BUS_POWERED
00129 
00130 #define LANG_ID               0x00
00131 
00132 
00133 #define USB_MN_LENGTH         5
00134 #define USB_MANUFACTURER_NAME \
00135 { Usb_unicode('A') \
00136 , Usb_unicode('T') \
00137 , Usb_unicode('M') \
00138 , Usb_unicode('E') \
00139 , Usb_unicode('L') \
00140 }
00141 
00142 #define USB_PN_LENGTH         14
00143 #define USB_PRODUCT_NAME \
00144 { Usb_unicode('A') \
00145  ,Usb_unicode('V') \
00146  ,Usb_unicode('R') \
00147  ,Usb_unicode(' ') \
00148  ,Usb_unicode('U') \
00149  ,Usb_unicode('S') \
00150  ,Usb_unicode('B') \
00151  ,Usb_unicode(' ') \
00152  ,Usb_unicode('D') \
00153  ,Usb_unicode('E') \
00154  ,Usb_unicode('V') \
00155  ,Usb_unicode('I') \
00156  ,Usb_unicode('C') \
00157  ,Usb_unicode('E') \
00158 }
00159 
00160 #define USB_SN_LENGTH         0x0D
00161               // Serial Number should be at least 12 characters long
00162 #define USB_SERIAL_NUMBER \
00163 { Usb_unicode('0') \
00164  ,Usb_unicode('0') \
00165  ,Usb_unicode('0') \
00166  ,Usb_unicode('0') \
00167  ,Usb_unicode('0') \
00168  ,Usb_unicode('0') \
00169  ,Usb_unicode('0') \
00170  ,Usb_unicode('0') \
00171  ,Usb_unicode('0') \
00172  ,Usb_unicode('0') \
00173  ,Usb_unicode('0') \
00174  ,Usb_unicode('0') \
00175  ,Usb_unicode('0') \
00176 }
00177 
00178 #define LANGUAGE_ID           0x0409
00179 
00180 
00182 typedef struct
00183 {
00184    U8      bmRequestType;        
00185    U8      bRequest;             
00186    U16     wValue;               
00187    U16     wIndex;               
00188    U16     wLength;              
00189 }  S_UsbRequest;
00190 
00192 typedef struct {
00193    U8      bLength;              
00194    U8      bDescriptorType;      
00195    U16     bscUSB;               
00196    U8      bDeviceClass;         
00197    U8      bDeviceSubClass;      
00198    U8      bDeviceProtocol;      
00199    U8      bMaxPacketSize0;      
00200    U16     idVendor;             
00201    U16     idProduct;            
00202    U16     bcdDevice;            
00203    U8      iManufacturer;        
00204    U8      iProduct;             
00205    U8      iSerialNumber;        
00206    U8      bNumConfigurations;   
00207 }  S_usb_device_descriptor;
00208 
00209 
00211 typedef struct {
00212    U8      bLength;              
00213    U8      bDescriptorType;      
00214    U16     wTotalLength;         
00215    U8      bNumInterfaces;       
00216    U8      bConfigurationValue;  
00217    U8      iConfiguration;       
00218    U8      bmAttibutes;          
00219    U8      MaxPower;             
00220 }  S_usb_configuration_descriptor;
00221 
00222 
00224 typedef struct {
00225    U8      bLength;               
00226    U8      bDescriptorType;       
00227    U8      bInterfaceNumber;      
00228    U8      bAlternateSetting;     
00229    U8      bNumEndpoints;         
00230    U8      bInterfaceClass;       
00231    U8      bInterfaceSubClass;    
00232    U8      bInterfaceProtocol;    
00233    U8      iInterface;            
00234 }  S_usb_interface_descriptor;
00235 
00236 
00238 typedef struct {
00239    U8      bLength;               
00240    U8      bDescriptorType;       
00241    U8      bEndpointAddress;      
00242    U8      bmAttributes;          
00243    U16     wMaxPacketSize;        
00244    U8      bInterval;             
00245 } S_usb_endpoint_descriptor;
00246 
00247 
00249 typedef struct {
00250    U8      bLength;               
00251    U8      bDescriptorType;       
00252    U16     wlangid;               
00253 }  S_usb_language_id;
00254 
00255 
00256 //_____ 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 _______________
00257 
00258 
00259 //struct usb_st_manufacturer
00260 typedef struct {
00261    U8  bLength;               // size of this descriptor in bytes
00262    U8  bDescriptorType;       // STRING descriptor type
00263    U16 wstring[USB_MN_LENGTH];// unicode characters
00264 } S_usb_manufacturer_string_descriptor;
00265 
00266 
00267 //_____ U S B   P R O D U C T   D E S C R I P T O R _________________________
00268 
00269 
00270 //struct usb_st_product
00271 typedef struct {
00272    U8  bLength;               // size of this descriptor in bytes
00273    U8  bDescriptorType;       // STRING descriptor type
00274    U16 wstring[USB_PN_LENGTH];// unicode characters
00275 } S_usb_product_string_descriptor;
00276 
00277 
00278 //_____ 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 _____________
00279 
00280 
00281 #if (USB_DEVICE_SN_USE==ENABLE)
00282 //struct usb_st_serial_number
00283 typedef struct {
00284    U8  bLength;               // size of this descriptor in bytes
00285    U8  bDescriptorType;       // STRING descriptor type
00286 #if (USE_DEVICE_SN_UNIQUE==ENABLE)
00287 
00288 #else   
00289    U16 wstring[USB_SN_LENGTH];// unicode characters
00290 #endif
00291 } S_usb_serial_number;
00292 #endif
00293 
00294 
00295 
00296 
00297 // Configuration descriptor template
00298 // The device has two interfaces
00299 // - First interface has 2 bulk endpoints
00300 // - Second interface has 1 interrupt IN endpoint
00301 typedef struct
00302 {
00303    S_usb_configuration_descriptor cfg_temp;
00304    S_usb_interface_descriptor     ifc_temp;
00305    S_usb_endpoint_descriptor      ep1_temp;
00306    S_usb_endpoint_descriptor      ep2_temp;
00307    S_usb_interface_descriptor     ifc_second_temp;
00308    S_usb_endpoint_descriptor      ep3_temp;
00309 } S_usb_user_configuration_descriptor;
00310 
00311 
00312 
00313 
00314 #endif
00315 

Generated on Mon Nov 3 10:08:23 2008 for ATMEL by  doxygen 1.5.3