- Main Page
- Modules
- Data Structures
- Files
- Related Pages

# 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, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 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_mouse.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_AT90USB128_64_MS
    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                // CONFIGURATION
    00081 #define NB_INTERFACE       1           // Number of interfaces
    00082 #define CONF_NB            1
    00083 #define CONF_INDEX         0
    00084 #define CONF_ATTRIBUTES    USB_CONFIG_BUSPOWERED
    00085 #define MAX_POWER          50          // 100 mA
    00086
    00087              // USB Mass Storage Interface descriptor
    00088 #define INTERFACE_NB        0          // Interface's number
    00089 #define ALTERNATE           0
    00090 #define NB_ENDPOINT         2
    00091 #define INTERFACE_CLASS     MS_CLASS     // Mass Storage Class
    00092 #define INTERFACE_SUB_CLASS MS_SUB_CLASS6 // SCSI transparent Command Set
    00093 #define INTERFACE_PROTOCOL  MS_PROTOCOL  // Bulk-Only Transport
    00094 #define INTERFACE_INDEX     0
    00095
    00096              // USB Endpoint 2 descriptor FS
    00097 #define ENDPOINT_NB_2       (EP_MS_IN | USB_ENDPOINT_IN)
    00098 #define EP_ATTRIBUTES_2     0x02          // BULK = 0x02, INTERUPT = 0x03
    00099 #define EP_IN_LENGTH        64
    00100 #define EP_SIZE_2           EP_IN_LENGTH
    00101 #define EP_INTERVAL_2       0x00
    00102
    00103
    00104              // USB Endpoint 3 descriptor FS
    00105 #define ENDPOINT_NB_3       EP_MS_OUT
    00106 #define EP_ATTRIBUTES_3     0x02          // BULK = 0x02, INTERUPT = 0x03
    00107 #define EP_IN_LENGTH        64
    00108 #define EP_SIZE_3           EP_IN_LENGTH
    00109 #define EP_INTERVAL_3       0x00
    00110
    00111 #define DEVICE_STATUS         USB_DEVICE_STATUS_BUS_POWERED
    00112
    00113 #define LANG_ID               0x00
    00114
    00115
    00116
    00117
    00118
    00119 #define USB_MN_LENGTH         5
    00120 #define USB_MANUFACTURER_NAME \
    00121 { Usb_unicode('A') \
    00122 , Usb_unicode('T') \
    00123 , Usb_unicode('M') \
    00124 , Usb_unicode('E') \
    00125 , Usb_unicode('L') \
    00126 }
    00127
    00128 #define USB_PN_LENGTH         22
    00129 #define USB_PRODUCT_NAME \
    00130 { Usb_unicode('A') \
    00131  ,Usb_unicode('V') \
    00132  ,Usb_unicode('R') \
    00133  ,Usb_unicode(' ') \
    00134  ,Usb_unicode('U') \
    00135  ,Usb_unicode('S') \
    00136  ,Usb_unicode('B') \
    00137  ,Usb_unicode(' ') \
    00138  ,Usb_unicode('M') \
    00139  ,Usb_unicode('S') \
    00140  ,Usb_unicode(' ') \
    00141  ,Usb_unicode('F') \
    00142  ,Usb_unicode('I') \
    00143  ,Usb_unicode('L') \
    00144  ,Usb_unicode('E') \
    00145  ,Usb_unicode(' ') \
    00146  ,Usb_unicode('S') \
    00147  ,Usb_unicode('Y') \
    00148  ,Usb_unicode('S') \
    00149  ,Usb_unicode('T') \
    00150  ,Usb_unicode('E') \
    00151  ,Usb_unicode('M') \
    00152 }
    00153
    00154 #define USB_SN_LENGTH         0x0D
    00155               // Serial Number should be at least 12 characters long
    00156 #define USB_SERIAL_NUMBER \
    00157 { Usb_unicode('0') \
    00158  ,Usb_unicode('0') \
    00159  ,Usb_unicode('0') \
    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 }
    00171
    00172 #define LANGUAGE_ID           0x0409
    00173
    00174
    00176 typedef struct
    00177 {
    00178    U8      bmRequestType;
    00179    U8      bRequest;
    00180    U16     wValue;
    00181    U16     wIndex;
    00182    U16     wLength;
    00183 }  S_UsbRequest;
    00184
    00186 typedef struct {
    00187    U8      bLength;
    00188    U8      bDescriptorType;
    00189    U16     bscUSB;
    00190    U8      bDeviceClass;
    00191    U8      bDeviceSubClass;
    00192    U8      bDeviceProtocol;
    00193    U8      bMaxPacketSize0;
    00194    U16     idVendor;
    00195    U16     idProduct;
    00196    U16     bcdDevice;
    00197    U8      iManufacturer;
    00198    U8      iProduct;
    00199    U8      iSerialNumber;
    00200    U8      bNumConfigurations;
    00201 }  S_usb_device_descriptor;
    00202
    00203
    00205 typedef struct {
    00206    U8      bLength;
    00207    U8      bDescriptorType;
    00208    U16     wTotalLength;
    00209    U8      bNumInterfaces;
    00210    U8      bConfigurationValue;
    00211    U8      iConfiguration;
    00212    U8      bmAttibutes;
    00213    U8      MaxPower;
    00214 }  S_usb_configuration_descriptor;
    00215
    00216
    00218 typedef struct {
    00219    U8      bLength;
    00220    U8      bDescriptorType;
    00221    U8      bInterfaceNumber;
    00222    U8      bAlternateSetting;
    00223    U8      bNumEndpoints;
    00224    U8      bInterfaceClass;
    00225    U8      bInterfaceSubClass;
    00226    U8      bInterfaceProtocol;
    00227    U8      iInterface;
    00228 }  S_usb_interface_descriptor;
    00229
    00230
    00232 typedef struct {
    00233    U8      bLength;
    00234    U8      bDescriptorType;
    00235    U8      bEndpointAddress;
    00236    U8      bmAttributes;
    00237    U16     wMaxPacketSize;
    00238    U8      bInterval;
    00239 } S_usb_endpoint_descriptor;
    00240
    00241
    00243 typedef struct {
    00244    U8      bLength;
    00245    U8      bDescriptorType;
    00246    U16     wlangid;
    00247 }  S_usb_language_id;
    00248
    00249
    00250 //_____ 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 _______________
    00251
    00252
    00253 //struct usb_st_manufacturer
    00254 typedef struct {
    00255    U8  bLength;               // size of this descriptor in bytes
    00256    U8  bDescriptorType;       // STRING descriptor type
    00257    U16 wstring[USB_MN_LENGTH];// unicode characters
    00258 } S_usb_manufacturer_string_descriptor;
    00259
    00260
    00261 //_____ U S B   P R O D U C T   D E S C R I P T O R _________________________
    00262
    00263
    00264 //struct usb_st_product
    00265 typedef struct {
    00266    U8  bLength;               // size of this descriptor in bytes
    00267    U8  bDescriptorType;       // STRING descriptor type
    00268    U16 wstring[USB_PN_LENGTH];// unicode characters
    00269 } S_usb_product_string_descriptor;
    00270
    00271
    00272 //_____ 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 _____________
    00273
    00274
    00275 #if (USB_DEVICE_SN_USE==ENABLE)
    00276 //struct usb_st_serial_number
    00277 typedef struct {
    00278    U8  bLength;               // size of this descriptor in bytes
    00279    U8  bDescriptorType;       // STRING descriptor type
    00280 #if (USE_DEVICE_SN_UNIQUE==ENABLE)
    00281
    00282 #else
    00283    U16 wstring[USB_SN_LENGTH];// unicode characters
    00284 #endif
    00285 } S_usb_serial_number;
    00286 #endif
    00287
    00288
    00289
    00290
    00291 typedef struct
    00292 {
    00293    S_usb_configuration_descriptor cfg_mouse;
    00294    S_usb_interface_descriptor     ifc_ms;
    00295    S_usb_endpoint_descriptor      ep1_ms;
    00296    S_usb_endpoint_descriptor      ep2_ms;
    00297 } S_usb_user_configuration_descriptor;
    00298
    00299
    00300
    00301
    00302 #endif
    00303