usb_descriptors.h

Go to the documentation of this file.
00001 /*This file is prepared for Doxygen automatic documentation generation.*/
00016 
00017 /* Copyright (c) 2009 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  * 4. This software may only be redistributed and used in connection with an Atmel
00033  * AVR product.
00034  *
00035  * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
00036  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00037  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY AND
00038  * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
00039  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00040  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00041  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00042  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00043  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00044  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00045  */
00046 
00047 #ifndef _USB_DESCRIPTORS_H_
00048 #define _USB_DESCRIPTORS_H_
00049 
00050 //_____ I N C L U D E S ____________________________________________________
00051 
00052 #include "config.h"
00053 #include "modules/usb/device_chap9/usb_standard_request.h"
00054 #include "conf_usb.h"
00055 
00056 //_____ M A C R O S ________________________________________________________
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_mouse.bLength))
00061 #define Usb_get_conf_desc_length()        (sizeof (usb_conf_desc))
00062 
00063 //_____ U S B    D E F I N E _______________________________________________
00064 
00065                   // USB Device descriptor
00066 #define USB_SPECIFICATION     0x0200
00067 #define DEVICE_CLASS          0      // each configuration has its own class
00068 #define DEVICE_SUB_CLASS      0      // each configuration has its own sub-class
00069 #define DEVICE_PROTOCOL       0      // each configuration has its own protocol
00070 #define EP_CONTROL_LENGTH     64
00071 #define VENDOR_ID             VID_ATMEL
00072 #define PRODUCT_ID            PID_AT90USB128_64_MS
00073 #define RELEASE_NUMBER        0x1000
00074 #define MAN_INDEX             0x01
00075 #define PROD_INDEX            0x02   
00076 #if (USB_DEVICE_SN_USE==ENABLE)
00077 #define SN_INDEX              0x03
00078 #else
00079 #define SN_INDEX              0x00  // No serial number field
00080 #endif
00081 #define NB_CONFIGURATION      1
00082 
00083                // CONFIGURATION
00084 #define NB_INTERFACE       1           // Number of interfaces
00085 #define CONF_NB            1
00086 #define CONF_INDEX         0
00087 #define CONF_ATTRIBUTES    USB_CONFIG_BUSPOWERED
00088 #define MAX_POWER          50          // 100 mA
00089 
00090              // USB Mass Storage Interface descriptor
00091 #define INTERFACE_NB        0          // Interface's number
00092 #define ALTERNATE           0
00093 #define NB_ENDPOINT         2
00094 #define INTERFACE_CLASS     MS_CLASS     // Mass Storage Class
00095 #define INTERFACE_SUB_CLASS MS_SUB_CLASS6 // SCSI transparent Command Set
00096 #define INTERFACE_PROTOCOL  MS_PROTOCOL  // Bulk-Only Transport
00097 #define INTERFACE_INDEX     0
00098 
00099              // USB Endpoint 2 descriptor FS
00100 #define ENDPOINT_NB_2       (EP_MS_IN | USB_ENDPOINT_IN)
00101 #define EP_ATTRIBUTES_2     0x02          // BULK = 0x02, INTERUPT = 0x03
00102 #define EP_IN_LENGTH        64
00103 #define EP_SIZE_2           EP_IN_LENGTH
00104 #define EP_INTERVAL_2       0x00          
00105 
00106 
00107              // USB Endpoint 3 descriptor FS
00108 #define ENDPOINT_NB_3       EP_MS_OUT
00109 #define EP_ATTRIBUTES_3     0x02          // BULK = 0x02, INTERUPT = 0x03
00110 #define EP_IN_LENGTH        64
00111 #define EP_SIZE_3           EP_IN_LENGTH
00112 #define EP_INTERVAL_3       0x00          
00113 
00114 #define DEVICE_STATUS         USB_DEVICE_STATUS_BUS_POWERED
00115 
00116 #define LANG_ID               0x00
00117 
00118 
00119 
00120 
00121 
00122 #define USB_MN_LENGTH         5
00123 #define USB_MANUFACTURER_NAME \
00124 { Usb_unicode('A') \
00125 , Usb_unicode('T') \
00126 , Usb_unicode('M') \
00127 , Usb_unicode('E') \
00128 , Usb_unicode('L') \
00129 }
00130 
00131 #define USB_PN_LENGTH         22
00132 #define USB_PRODUCT_NAME \
00133 { Usb_unicode('A') \
00134  ,Usb_unicode('V') \
00135  ,Usb_unicode('R') \
00136  ,Usb_unicode(' ') \
00137  ,Usb_unicode('U') \
00138  ,Usb_unicode('S') \
00139  ,Usb_unicode('B') \
00140  ,Usb_unicode(' ') \
00141  ,Usb_unicode('M') \
00142  ,Usb_unicode('S') \
00143  ,Usb_unicode(' ') \
00144  ,Usb_unicode('F') \
00145  ,Usb_unicode('I') \
00146  ,Usb_unicode('L') \
00147  ,Usb_unicode('E') \
00148  ,Usb_unicode(' ') \
00149  ,Usb_unicode('S') \
00150  ,Usb_unicode('Y') \
00151  ,Usb_unicode('S') \
00152  ,Usb_unicode('T') \
00153  ,Usb_unicode('E') \
00154  ,Usb_unicode('M') \
00155 }
00156 
00157 #define USB_SN_LENGTH         0x0D
00158               // Serial Number should be at least 12 characters long
00159 #define USB_SERIAL_NUMBER \
00160 { Usb_unicode('0') \
00161  ,Usb_unicode('0') \
00162  ,Usb_unicode('0') \
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 }
00174 
00175 #define LANGUAGE_ID           0x0409
00176 
00177 
00179 typedef struct
00180 {
00181    U8      bmRequestType;        
00182    U8      bRequest;             
00183    U16     wValue;               
00184    U16     wIndex;               
00185    U16     wLength;              
00186 }  S_UsbRequest;
00187 
00189 typedef struct {
00190    U8      bLength;              
00191    U8      bDescriptorType;      
00192    U16     bscUSB;               
00193    U8      bDeviceClass;         
00194    U8      bDeviceSubClass;      
00195    U8      bDeviceProtocol;      
00196    U8      bMaxPacketSize0;      
00197    U16     idVendor;             
00198    U16     idProduct;            
00199    U16     bcdDevice;            
00200    U8      iManufacturer;        
00201    U8      iProduct;             
00202    U8      iSerialNumber;        
00203    U8      bNumConfigurations;   
00204 }  S_usb_device_descriptor;
00205 
00206 
00208 typedef struct {
00209    U8      bLength;              
00210    U8      bDescriptorType;      
00211    U16     wTotalLength;         
00212    U8      bNumInterfaces;       
00213    U8      bConfigurationValue;  
00214    U8      iConfiguration;       
00215    U8      bmAttibutes;          
00216    U8      MaxPower;             
00217 }  S_usb_configuration_descriptor;
00218 
00219 
00221 typedef struct {
00222    U8      bLength;               
00223    U8      bDescriptorType;       
00224    U8      bInterfaceNumber;      
00225    U8      bAlternateSetting;     
00226    U8      bNumEndpoints;         
00227    U8      bInterfaceClass;       
00228    U8      bInterfaceSubClass;    
00229    U8      bInterfaceProtocol;    
00230    U8      iInterface;            
00231 }  S_usb_interface_descriptor;
00232 
00233 
00235 typedef struct {
00236    U8      bLength;               
00237    U8      bDescriptorType;       
00238    U8      bEndpointAddress;      
00239    U8      bmAttributes;          
00240    U16     wMaxPacketSize;        
00241    U8      bInterval;             
00242 } S_usb_endpoint_descriptor;
00243 
00244 
00246 typedef struct {
00247    U8      bLength;               
00248    U8      bDescriptorType;       
00249    U16     wlangid;               
00250 }  S_usb_language_id;
00251 
00252 
00253 //_____ 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 _______________
00254 
00255 
00256 //struct usb_st_manufacturer
00257 typedef struct {
00258    U8  bLength;               // size of this descriptor in bytes
00259    U8  bDescriptorType;       // STRING descriptor type
00260    U16 wstring[USB_MN_LENGTH];// unicode characters
00261 } S_usb_manufacturer_string_descriptor;
00262 
00263 
00264 //_____ U S B   P R O D U C T   D E S C R I P T O R _________________________
00265 
00266 
00267 //struct usb_st_product
00268 typedef struct {
00269    U8  bLength;               // size of this descriptor in bytes
00270    U8  bDescriptorType;       // STRING descriptor type
00271    U16 wstring[USB_PN_LENGTH];// unicode characters
00272 } S_usb_product_string_descriptor;
00273 
00274 
00275 //_____ 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 _____________
00276 
00277 
00278 #if (USB_DEVICE_SN_USE==ENABLE)
00279 //struct usb_st_serial_number
00280 typedef struct {
00281    U8  bLength;               // size of this descriptor in bytes
00282    U8  bDescriptorType;       // STRING descriptor type
00283 #if (USE_DEVICE_SN_UNIQUE==ENABLE)
00284 
00285 #else   
00286    U16 wstring[USB_SN_LENGTH];// unicode characters
00287 #endif
00288 } S_usb_serial_number;
00289 #endif
00290 
00291 
00292 
00293 
00294 typedef struct
00295 {
00296    S_usb_configuration_descriptor cfg_mouse;
00297    S_usb_interface_descriptor     ifc_ms;
00298    S_usb_endpoint_descriptor      ep1_ms;
00299    S_usb_endpoint_descriptor      ep2_ms;
00300 } S_usb_user_configuration_descriptor;
00301 
00302 
00303 
00304 
00305 #endif
00306 

Generated on Wed Sep 23 09:17:02 2009 for ATMEL by  doxygen 1.5.3