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

# usb_descriptors.c

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
    00045 //_____ I N C L U D E S ____________________________________________________
    00046
    00047 #include "config.h"
    00048 #include "conf_usb.h"
    00049
    00050 #include "lib_mcu/usb/usb_drv.h"
    00051 #include "usb_descriptors.h"
    00052 #include "modules/usb/device_chap9/usb_standard_request.h"
    00053 #include "usb_specific_request.h"
    00054 #if ((USB_DEVICE_SN_USE==ENABLE) && (USE_DEVICE_SN_UNIQUE==ENABLE))
    00055 #include "lib_mcu/flash/flash_drv.h"
    00056 #endif
    00057
    00058 //_____ M A C R O S ________________________________________________________
    00059
    00060
    00061
    00062
    00063 //_____ D E F I N I T I O N ________________________________________________
    00064
    00065 // usb_user_device_descriptor
    00066 code S_usb_device_descriptor usb_dev_desc =
    00067 {
    00068   sizeof(usb_dev_desc)
    00069 , DESCRIPTOR_DEVICE
    00070 , Usb_write_word_enum_struc(USB_SPECIFICATION)
    00071 , DEVICE_CLASS
    00072 , DEVICE_SUB_CLASS
    00073 , DEVICE_PROTOCOL
    00074 , EP_CONTROL_LENGTH
    00075 , Usb_write_word_enum_struc(VENDOR_ID)
    00076 , Usb_write_word_enum_struc(PRODUCT_ID)
    00077 , Usb_write_word_enum_struc(RELEASE_NUMBER)
    00078 , MAN_INDEX
    00079 , PROD_INDEX
    00080 , SN_INDEX
    00081 , NB_CONFIGURATION
    00082 };
    00083
    00084 // usb_user_configuration_descriptor FS
    00085 code S_usb_user_configuration_descriptor usb_conf_desc = {
    00086  { sizeof(S_usb_configuration_descriptor)
    00087  , DESCRIPTOR_CONFIGURATION
    00088  , Usb_write_word_enum_struc(sizeof(S_usb_configuration_descriptor)\
    00089        +sizeof(S_usb_interface_descriptor)   \
    00090        +sizeof(S_usb_hid_descriptor)         \
    00091        +sizeof(S_usb_endpoint_descriptor)    \
    00092        +sizeof(S_usb_endpoint_descriptor))
    00093  , NB_INTERFACE
    00094  , CONF_NB
    00095  , CONF_INDEX
    00096  , CONF_ATTRIBUTES
    00097  , MAX_POWER
    00098  }
    00099  ,
    00100  { sizeof(S_usb_interface_descriptor)
    00101  , DESCRIPTOR_INTERFACE
    00102  , INTERFACE_NB
    00103  , ALTERNATE
    00104  , NB_ENDPOINT
    00105  , INTERFACE_CLASS
    00106  , INTERFACE_SUB_CLASS
    00107  , INTERFACE_PROTOCOL
    00108  , INTERFACE_INDEX
    00109  }
    00110  ,
    00111  { sizeof(S_usb_hid_descriptor)
    00112  , DESCRIPTOR_HID
    00113  , HID_BDC
    00114  , HID_NO_COUNTRY_CODE
    00115  , HID_CLASS_DESC_NB_DEFAULT
    00116  , DESCRIPTOR_REPORT
    00117  , Usb_write_word_enum_struc(sizeof(S_usb_hid_report_descriptor))
    00118  }
    00119  ,
    00120  { sizeof(S_usb_endpoint_descriptor)
    00121  , DESCRIPTOR_ENDPOINT
    00122  , ENDPOINT_NB_1
    00123  , EP_ATTRIBUTES_1
    00124  , Usb_write_word_enum_struc(EP_SIZE_1)
    00125  , EP_INTERVAL_1
    00126  }
    00127  ,
    00128   { sizeof(S_usb_endpoint_descriptor)
    00129  , DESCRIPTOR_ENDPOINT
    00130  , ENDPOINT_NB_2
    00131  , EP_ATTRIBUTES_2
    00132  , Usb_write_word_enum_struc(EP_SIZE_2)
    00133  , EP_INTERVAL_2
    00134  }
    00135 };
    00136
    00137
    00138
    00139                                       // usb_user_manufacturer_string_descriptor
    00140 code S_usb_manufacturer_string_descriptor usb_user_manufacturer_string_descriptor = {
    00141   sizeof(usb_user_manufacturer_string_descriptor)
    00142 , DESCRIPTOR_STRING
    00143 , USB_MANUFACTURER_NAME
    00144 };
    00145
    00146
    00147                                       // usb_user_product_string_descriptor
    00148
    00149 code S_usb_product_string_descriptor usb_user_product_string_descriptor = {
    00150   sizeof(usb_user_product_string_descriptor)
    00151 , DESCRIPTOR_STRING
    00152 , USB_PRODUCT_NAME
    00153 };
    00154
    00155
    00156                                       // usb_user_serial_number
    00157 #if (USB_DEVICE_SN_USE==ENABLE)
    00158 code S_usb_serial_number usb_user_serial_number = {
    00159 #if (USE_DEVICE_SN_UNIQUE==ENABLE)
    00160   sizeof(usb_user_serial_number)+4*SN_LENGTH
    00161 , DESCRIPTOR_STRING
    00162 #else
    00163 sizeof(usb_user_serial_number)
    00164 , DESCRIPTOR_STRING
    00165 , USB_SERIAL_NUMBER
    00166 #endif
    00167 };
    00168 #endif
    00169
    00170                                       // usb_user_language_id
    00171
    00172 code S_usb_language_id usb_user_language_id = {
    00173   sizeof(usb_user_language_id)
    00174 , DESCRIPTOR_STRING
    00175 , Usb_write_word_enum_struc(LANGUAGE_ID)
    00176 };
    00177
    00178
    00179 code S_usb_hid_report_descriptor usb_hid_report_descriptor = {{
    00180       0x06, 0xFF, 0xFF,         // 04|2   , Usage Page (vendordefined?)
    00181       0x09, 0x01,               // 08|1   , Usage      (vendordefined
    00182       0xA1, 0x01,               // A0|1   , Collection (Application)
    00183       // IN report
    00184       0x09, 0x02,               // 08|1   , Usage      (vendordefined)
    00185       0x09, 0x03,               // 08|1   , Usage      (vendordefined)
    00186       0x15, 0x00,               // 14|1   , Logical Minimum(0 for signed byte?)
    00187       0x26 ,0xFF,0x00,           // 24|1   , Logical Maximum(255 for signed byte?)
    00188       0x75, 0x08,               // 74|1   , Report Size(8) = field size in bits = 1 byte
    00189       0x95, LENGTH_OF_REPORT_IN,   // 94|1:ReportCount(size) = repeat count of previous item
    00190       0x81, 0x02,               // 80|1: IN report (Data,Variable, Absolute)
    00191       // OUT report
    00192       0x09, 0x04,               // 08|1   , Usage      (vendordefined)
    00193       0x09, 0x05,               // 08|1   , Usage      (vendordefined)
    00194       0x15, 0x00,               // 14|1   , Logical Minimum(0 for signed byte?)
    00195       0x26, 0xFF,0x00,           // 24|1   , Logical Maximum(255 for signed byte?)
    00196       0x75, 0x08,               // 74|1   , Report Size(8) = field size in bits = 1 byte
    00197       0x95, LENGTH_OF_REPORT_OUT,   // 94|1:ReportCount(size) = repeat count of previous item
    00198       0x91, 0x02,               // 90|1: OUT report (Data,Variable, Absolute)
    00199       // Feature report
    00200       0x09, 0x06,               // 08|1   , Usage      (vendordefined)
    00201       0x09, 0x07,               // 08|1   , Usage      (vendordefined)
    00202       0x15, 0x00,               // 14|1   , LogicalMinimum(0 for signed byte)
    00203       0x26, 0xFF,0x00,          // 24|1   , Logical Maximum(255 for signed byte)
    00204       0x75, 0x08,               // 74|1   , Report Size(8) =field size in bits = 1 byte
    00205       0x95, 0x04,               // 94|1:ReportCount
    00206       0xB1, 0x02,               // B0|1:   Feature report
    00207       0xC0                      // C0|0    , End Collection
    00208  }};
    00209