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

Generated on Mon May 5 15:57:55 2008 for ATMEL by  doxygen 1.5.1-p1