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_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_kbd.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          0      // each configuration has its own 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     64
00068 #define VENDOR_ID             VID_ATMEL
00069 #define PRODUCT_ID            PID_MegaHIDKeyboard
00070 #define RELEASE_NUMBER        0x1000
00071 #define MAN_INDEX             0x01
00072 #define PROD_INDEX            0x02   
00073 #if (USB_DEVICE_SN_USE==ENABLE)
00074 #define SN_INDEX              0x03
00075 #else
00076 #define SN_INDEX              0x00  // No serial number field
00077 #endif
00078 #define NB_CONFIGURATION      1
00079 
00080                // HID Mouse CONFIGURATION
00081 #define NB_INTERFACE       1           // Number of interfaces
00082 #define CONF_NB            1
00083 #define CONF_INDEX         0
00084 #if (USB_REMOTE_WAKEUP_FEATURE == ENABLED)
00085   #define CONF_ATTRIBUTES    (USB_CONFIG_BUSPOWERED | USB_CONFIG_REMOTEWAKEUP)
00086 #else
00087   #define CONF_ATTRIBUTES    USB_CONFIG_BUSPOWERED
00088 #endif
00089 #define MAX_POWER          50          // 100 mA
00090 
00091              // USB Interface descriptor Mouse
00092 #define INTERFACE_NB_KBD        0           // Interface's number
00093 #define ALTERNATE_KBD           0
00094 #define NB_ENDPOINT_KBD         1
00095 #define INTERFACE_CLASS_KBD     HID_CLASS // HID Class
00096 #define INTERFACE_SUB_CLASS_KBD NO_SUBCLASS
00097 #define INTERFACE_PROTOCOL_KBD  HID_PROTOCOL_KEYBOARD
00098 #define INTERFACE_INDEX_KBD     0
00099 
00100 #define DEVICE_STATUS         USB_DEVICE_STATUS_BUS_POWERED
00101 
00102 #define LANG_ID               0x00
00103 
00104 
00105             // USB Endpoint 1 descriptor FS
00106 #define ENDPOINT_NB_1       (EP_KBD_IN | USB_ENDPOINT_IN)
00107 #define EP_ATTRIBUTES_1     0x03              // BULK = 0x02, INTERUPT = 0x03
00108 #define EP_IN_LENGTH_1      8
00109 #define EP_SIZE_1           EP_IN_LENGTH_1
00110 #define EP_INTERVAL_1       0x02              // Interrupt polling interval from host
00111 
00112 
00113 #define USB_MN_LENGTH         5
00114 #define USB_MANUFACTURER_NAME \
00115 { Usb_unicode('A') \
00116 , Usb_unicode('T') \
00117 , Usb_unicode('M') \
00118 , Usb_unicode('E') \
00119 , Usb_unicode('L') \
00120 }
00121 
00122 #define USB_PN_LENGTH         21
00123 #define USB_PRODUCT_NAME \
00124 { Usb_unicode('A') \
00125  ,Usb_unicode('V') \
00126  ,Usb_unicode('R') \
00127  ,Usb_unicode(' ') \
00128  ,Usb_unicode('U') \
00129  ,Usb_unicode('S') \
00130  ,Usb_unicode('B') \
00131  ,Usb_unicode(' ') \
00132  ,Usb_unicode('K') \
00133  ,Usb_unicode('E') \
00134  ,Usb_unicode('Y') \
00135  ,Usb_unicode('B') \
00136  ,Usb_unicode('O') \
00137  ,Usb_unicode('A') \
00138  ,Usb_unicode('R') \
00139  ,Usb_unicode('D') \
00140  ,Usb_unicode(' ') \
00141  ,Usb_unicode('D') \
00142  ,Usb_unicode('E') \
00143  ,Usb_unicode('M') \
00144  ,Usb_unicode('O') \
00145 }
00146 
00147 #define USB_SN_LENGTH         0x05
00148 #define USB_SERIAL_NUMBER \
00149 { Usb_unicode('0') \
00150  ,Usb_unicode('0') \
00151  ,Usb_unicode('0') \
00152  ,Usb_unicode('0') \
00153  ,Usb_unicode('0') \
00154 }
00155 
00156 #define LANGUAGE_ID           0x0409
00157 
00158 
00160 typedef struct
00161 {
00162    U8      bmRequestType;        
00163    U8      bRequest;             
00164    U16     wValue;               
00165    U16     wIndex;               
00166    U16     wLength;              
00167 }  S_UsbRequest;
00168 
00170 typedef struct {
00171    U8      bLength;              
00172    U8      bDescriptorType;      
00173    U16     bscUSB;               
00174    U8      bDeviceClass;         
00175    U8      bDeviceSubClass;      
00176    U8      bDeviceProtocol;      
00177    U8      bMaxPacketSize0;      
00178    U16     idVendor;             
00179    U16     idProduct;            
00180    U16     bcdDevice;            
00181    U8      iManufacturer;        
00182    U8      iProduct;             
00183    U8      iSerialNumber;        
00184    U8      bNumConfigurations;   
00185 }  S_usb_device_descriptor;
00186 
00187 
00189 typedef struct {
00190    U8      bLength;              
00191    U8      bDescriptorType;      
00192    U16     wTotalLength;         
00193    U8      bNumInterfaces;       
00194    U8      bConfigurationValue;  
00195    U8      iConfiguration;       
00196    U8      bmAttibutes;          
00197    U8      MaxPower;             
00198 }  S_usb_configuration_descriptor;
00199 
00200 
00202 typedef struct {
00203    U8      bLength;               
00204    U8      bDescriptorType;       
00205    U8      bInterfaceNumber;      
00206    U8      bAlternateSetting;     
00207    U8      bNumEndpoints;         
00208    U8      bInterfaceClass;       
00209    U8      bInterfaceSubClass;    
00210    U8      bInterfaceProtocol;    
00211    U8      iInterface;            
00212 }  S_usb_interface_descriptor;
00213 
00214 
00216 typedef struct {
00217    U8      bLength;               
00218    U8      bDescriptorType;       
00219    U8      bEndpointAddress;      
00220    U8      bmAttributes;          
00221    U16     wMaxPacketSize;        
00222    U8      bInterval;             
00223 } S_usb_endpoint_descriptor;
00224 
00225 
00227 typedef struct {
00228    U8      bLength;               
00229    U8      bDescriptorType;       
00230    U16     wlangid;               
00231 }  S_usb_language_id;
00232 
00233 
00234 //_____ 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 _______________
00235 
00236 
00237 //struct usb_st_manufacturer
00238 typedef struct {
00239    U8  bLength;               // size of this descriptor in bytes
00240    U8  bDescriptorType;       // STRING descriptor type
00241    U16 wstring[USB_MN_LENGTH];// unicode characters
00242 } S_usb_manufacturer_string_descriptor;
00243 
00244 
00245 //_____ U S B   P R O D U C T   D E S C R I P T O R _________________________
00246 
00247 
00248 //struct usb_st_product
00249 typedef struct {
00250    U8  bLength;               // size of this descriptor in bytes
00251    U8  bDescriptorType;       // STRING descriptor type
00252    U16 wstring[USB_PN_LENGTH];// unicode characters
00253 } S_usb_product_string_descriptor;
00254 
00255 
00256 //_____ 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 _____________
00257 
00258 
00259 #if (USB_DEVICE_SN_USE==ENABLE)
00260 //struct usb_st_serial_number
00261 typedef struct {
00262    U8  bLength;               // size of this descriptor in bytes
00263    U8  bDescriptorType;       // STRING descriptor type
00264 #if (USE_DEVICE_SN_UNIQUE==ENABLE)
00265 
00266 #else   
00267    U16 wstring[USB_SN_LENGTH];// unicode characters
00268 #endif
00269 } S_usb_serial_number;
00270 #endif
00271 
00272 
00273 /*_____ U S B   H I D   D E S C R I P T O R __________________________________*/
00274 
00275 typedef struct {
00276   U8  bLength;               /* Size of this descriptor in bytes */
00277   U8  bDescriptorType;       /* HID descriptor type */
00278   U16 bscHID;                /* Binay Coded Decimal Spec. release */
00279   U8  bCountryCode;          /* Hardware target country */
00280   U8  bNumDescriptors;       /* Number of HID class descriptors to follow */
00281   U8  bRDescriptorType;      /* Report descriptor type */
00282   U16 wDescriptorLength;     /* Total length of Report descriptor */
00283 } S_usb_hid_descriptor;
00284 
00285 
00286 
00287 
00288 typedef struct
00289 {
00290    S_usb_configuration_descriptor cfg_kbd;
00291    S_usb_interface_descriptor     ifc_kbd;
00292    S_usb_hid_descriptor           hid_kbd;
00293    S_usb_endpoint_descriptor      ep1_kbd;
00294 } S_usb_user_configuration_descriptor;
00295 
00296 
00297 
00298 
00299 #endif
00300 

Generated on Fri Oct 31 15:59:42 2008 for ATMEL by  doxygen 1.5.3