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

- File List
- Globals

# usb_descriptors.c

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
    00048 //_____ I N C L U D E S ____________________________________________________
    00049
    00050 #include "config.h"
    00051 #include "conf_usb.h"
    00052 #include "lib_mcu/usb/usb_drv.h"
    00053 #include "usb_descriptors.h"
    00054 #include "modules/usb/device_chap9/usb_standard_request.h"
    00055 #include "usb_specific_request.h"
    00056 #if ((USB_DEVICE_SN_USE==ENABLE) && (USE_DEVICE_SN_UNIQUE==ENABLE))
    00057 #include "lib_mcu/flash/flash_drv.h"
    00058 #endif
    00059
    00060 //_____ M A C R O S ________________________________________________________
    00061
    00062
    00063
    00064
    00065 //_____ D E F I N I T I O N ________________________________________________
    00066
    00067 // usb_user_device_descriptor
    00068 code S_usb_device_descriptor usb_dev_desc =
    00069 {
    00070   sizeof(usb_dev_desc)
    00071 , DESCRIPTOR_DEVICE
    00072 , Usb_write_word_enum_struc(USB_SPECIFICATION)
    00073 , DEVICE_CLASS
    00074 , DEVICE_SUB_CLASS
    00075 , DEVICE_PROTOCOL
    00076 , EP_CONTROL_LENGTH
    00077 , Usb_write_word_enum_struc(VENDOR_ID)
    00078 , Usb_write_word_enum_struc(PRODUCT_ID)
    00079 , Usb_write_word_enum_struc(RELEASE_NUMBER)
    00080 , MAN_INDEX
    00081 , PROD_INDEX
    00082 , SN_INDEX
    00083 , NB_CONFIGURATION
    00084 };
    00085
    00086 // usb_user_configuration_descriptor FS
    00087 code S_usb_user_configuration_descriptor usb_conf_desc = {
    00088  { sizeof(S_usb_configuration_descriptor)
    00089  , DESCRIPTOR_CONFIGURATION
    00090  , Usb_write_word_enum_struc(sizeof(S_usb_configuration_descriptor)\
    00091        +sizeof(S_usb_interface_descriptor)   \
    00092        +sizeof(S_usb_hid_descriptor)         \
    00093        +sizeof(S_usb_endpoint_descriptor)    \
    00094                               )
    00095  , NB_INTERFACE
    00096  , CONF_NB
    00097  , CONF_INDEX
    00098  , CONF_ATTRIBUTES
    00099  , MAX_POWER
    00100  }
    00101  ,
    00102  { sizeof(S_usb_interface_descriptor)
    00103  , DESCRIPTOR_INTERFACE
    00104  , INTERFACE_NB_MOUSE
    00105  , ALTERNATE_MOUSE
    00106  , NB_ENDPOINT_MOUSE
    00107  , INTERFACE_CLASS_MOUSE
    00108  , INTERFACE_SUB_CLASS_MOUSE
    00109  , INTERFACE_PROTOCOL_MOUSE
    00110  , INTERFACE_INDEX_MOUSE
    00111  }
    00112  ,
    00113  { sizeof(S_usb_hid_descriptor)
    00114  , DESCRIPTOR_HID
    00115  , HID_BDC
    00116  , HID_NO_COUNTRY_CODE
    00117  , HID_CLASS_DESC_NB_DEFAULT
    00118  , DESCRIPTOR_REPORT
    00119  , Usb_write_word_enum_struc(sizeof(S_usb_hid_report_descriptor_mouse))
    00120  }
    00121  ,
    00122  { sizeof(S_usb_endpoint_descriptor)
    00123  , DESCRIPTOR_ENDPOINT
    00124  , ENDPOINT_NB_1
    00125  , EP_ATTRIBUTES_1
    00126  , Usb_write_word_enum_struc(EP_SIZE_1)
    00127  , EP_INTERVAL_1
    00128  }
    00129 };
    00130
    00131
    00132
    00133                                       // usb_user_manufacturer_string_descriptor
    00134 code S_usb_manufacturer_string_descriptor usb_user_manufacturer_string_descriptor = {
    00135   sizeof(usb_user_manufacturer_string_descriptor)
    00136 , DESCRIPTOR_STRING
    00137 , USB_MANUFACTURER_NAME
    00138 };
    00139
    00140
    00141                                       // usb_user_product_string_descriptor
    00142
    00143 code S_usb_product_string_descriptor usb_user_product_string_descriptor = {
    00144   sizeof(usb_user_product_string_descriptor)
    00145 , DESCRIPTOR_STRING
    00146 , USB_PRODUCT_NAME
    00147 };
    00148
    00149
    00150                                       // usb_user_serial_number
    00151 #if (USB_DEVICE_SN_USE==ENABLE)
    00152 code S_usb_serial_number usb_user_serial_number = {
    00153 #if (USE_DEVICE_SN_UNIQUE==ENABLE)
    00154   sizeof(usb_user_serial_number)+4*SN_LENGTH
    00155 , DESCRIPTOR_STRING
    00156 #else
    00157 sizeof(usb_user_serial_number)
    00158 , DESCRIPTOR_STRING
    00159 , USB_SERIAL_NUMBER
    00160 #endif
    00161 };
    00162 #endif
    00163
    00164                                       // usb_user_language_id
    00165
    00166 code S_usb_language_id usb_user_language_id = {
    00167   sizeof(usb_user_language_id)
    00168 , DESCRIPTOR_STRING
    00169 , Usb_write_word_enum_struc(LANGUAGE_ID)
    00170 };
    00171
    00172 code S_usb_hid_report_descriptor_mouse usb_hid_report_descriptor_mouse = {{
    00173       0x05,0x01,          /* Usage Page (Generic Desktop)      */
    00174       0x09,0x02,          /* Usage (Mouse)                     */
    00175       0xA1,0x01,          /* Collection (Application)          */
    00176       0x09,0x01,          /* Usage (Pointer)                   */
    00177       0xA1,0x00,          /* Collection (Application)          */
    00178       0x05,0x09,          /* Usage Page (Button)               */
    00179       0x19,0x01,          /* Usage Minimum (1)                 */
    00180       0x29,0x03,          /* Usage Maximum (3)                 */
    00181       0x15,0x00,          /* Logical Minimum (0)               */
    00182       0x25,0x01,          /* Logical Maximum (1)               */
    00183       0x75,0x01,          /* Report Size (1)                   */
    00184       0x95,0x03,          /* Report Count (3)                  */
    00185       0x81,0x02,          /* Input (Data, Variable, Absolute)  */
    00186       0x75,0x05,          /* Report Size (5)                   */
    00187       0x95,0x01,          /* Report Count (1)                  */
    00188       0x81,0x01,          /* Input (Constant)                  */
    00189       0x05,0x01,          /* Usage Page (Generic Desktop Control)*/
    00190       0x09,0x30,          /* Usage X                           */
    00191       0x09,0x31,          /* Usage Y                           */
    00192       0x09,0x38,          /* Usage Wheel                       */
    00193       0x15,0x81,          /* Logical Minimum (-127)            */
    00194       0x25,0x7F,          /* Logical Maximum (127)             */
    00195       0x75,0x08,          /* Report Size (8)                   */
    00196       0x95,0x03,          /* Report Count (3)                  */
    00197       0x81,0x06,          /* Input (Data, Variable, Absolute)  */
    00198       0xC0,               /* End Collection                    */
    00199       0xC0                /* End Collection                    */
    00200 }};
    00201
    00202
    00203
    00204