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 
00053 #include "lib_mcu/usb/usb_drv.h"
00054 #include "usb_descriptors.h"
00055 #include "modules/usb/device_chap9/usb_standard_request.h"
00056 #include "usb_specific_request.h"
00057 #if ((USB_DEVICE_SN_USE==ENABLE) && (USE_DEVICE_SN_UNIQUE==ENABLE))
00058 #include "lib_mcu/flash/flash_drv.h"
00059 #endif
00060 
00061 //_____ M A C R O S ________________________________________________________
00062 
00063 
00064 
00065 
00066 //_____ D E F I N I T I O N ________________________________________________
00067 
00068 // usb_user_device_descriptor
00069 code S_usb_device_descriptor usb_dev_desc =
00070 {
00071   sizeof(usb_dev_desc)
00072 , DESCRIPTOR_DEVICE
00073 , Usb_write_word_enum_struc(USB_SPECIFICATION)
00074 , DEVICE_CLASS
00075 , DEVICE_SUB_CLASS
00076 , DEVICE_PROTOCOL
00077 , EP_CONTROL_LENGTH
00078 , Usb_write_word_enum_struc(VENDOR_ID)
00079 , Usb_write_word_enum_struc(PRODUCT_ID)
00080 , Usb_write_word_enum_struc(RELEASE_NUMBER)
00081 , MAN_INDEX
00082 , PROD_INDEX
00083 , SN_INDEX
00084 , NB_CONFIGURATION
00085 };
00086 
00087 // usb_user_configuration_descriptor FS
00088 code S_usb_user_configuration_descriptor usb_conf_desc = {
00089  { sizeof(S_usb_configuration_descriptor)
00090  , DESCRIPTOR_CONFIGURATION
00091  , Usb_write_word_enum_struc(sizeof(S_usb_configuration_descriptor)\
00092        +sizeof(S_usb_interface_descriptor)   \
00093        +sizeof(S_usb_hid_descriptor)         \
00094        +sizeof(S_usb_endpoint_descriptor)    \
00095        +sizeof(S_usb_interface_descriptor)   \
00096        +sizeof(S_usb_endpoint_descriptor)    \
00097        +sizeof(S_usb_endpoint_descriptor)    \
00098        +sizeof(S_usb_interface_descriptor)   \
00099        +sizeof(S_usb_hid_descriptor)         \
00100        +sizeof(S_usb_endpoint_descriptor)    \
00101        +sizeof(S_usb_endpoint_descriptor))
00102  , NB_INTERFACE
00103  , CONF_NB
00104  , CONF_INDEX
00105  , CONF_ATTRIBUTES
00106  , MAX_POWER
00107  }
00108  ,
00109  { sizeof(S_usb_interface_descriptor)
00110  , DESCRIPTOR_INTERFACE
00111  , INTERFACE_NB_MOUSE
00112  , ALTERNATE_MOUSE
00113  , NB_ENDPOINT_MOUSE
00114  , INTERFACE_CLASS_MOUSE
00115  , INTERFACE_SUB_CLASS_MOUSE
00116  , INTERFACE_PROTOCOL_MOUSE
00117  , INTERFACE_INDEX_MOUSE
00118  }
00119  ,
00120  { sizeof(S_usb_hid_descriptor)
00121  , DESCRIPTOR_HID
00122  , HID_BDC
00123  , HID_NO_COUNTRY_CODE
00124  , HID_CLASS_DESC_NB_DEFAULT
00125  , DESCRIPTOR_REPORT
00126  , Usb_write_word_enum_struc(sizeof(S_usb_hid_report_descriptor_mouse))
00127  }
00128  ,
00129  { sizeof(S_usb_endpoint_descriptor)
00130  , DESCRIPTOR_ENDPOINT
00131  , ENDPOINT_NB_1
00132  , EP_ATTRIBUTES_1
00133  , Usb_write_word_enum_struc(EP_SIZE_1)
00134  , EP_INTERVAL_1
00135  }
00136 ,
00137  { sizeof(S_usb_interface_descriptor)
00138  , DESCRIPTOR_INTERFACE
00139  , INTERFACE_NB
00140  , ALTERNATE
00141  , NB_ENDPOINT
00142  , INTERFACE_CLASS
00143  , INTERFACE_SUB_CLASS
00144  , INTERFACE_PROTOCOL
00145  , INTERFACE_INDEX
00146  }
00147  ,
00148  { sizeof(S_usb_endpoint_descriptor)
00149  , DESCRIPTOR_ENDPOINT
00150  , ENDPOINT_NB_2
00151  , EP_ATTRIBUTES_2
00152  , Usb_write_word_enum_struc(EP_SIZE_2)
00153  , EP_INTERVAL_2
00154  }
00155  ,
00156  { sizeof(S_usb_endpoint_descriptor)
00157  , DESCRIPTOR_ENDPOINT
00158  , ENDPOINT_NB_3
00159  , EP_ATTRIBUTES_3
00160  , Usb_write_word_enum_struc(EP_SIZE_3)
00161  , EP_INTERVAL_3
00162  }
00163  ,
00164  { sizeof(S_usb_interface_descriptor)
00165  , DESCRIPTOR_INTERFACE
00166  , INTERFACE_NB_HID
00167  , ALTERNATE
00168  , NB_ENDPOINT
00169  , INTERFACE_CLASS_HID
00170  , INTERFACE_SUB_CLASS_HID
00171  , INTERFACE_PROTOCOL_HID
00172  , INTERFACE_INDEX
00173  }
00174  ,
00175  { sizeof(S_usb_hid_descriptor)
00176  , DESCRIPTOR_HID
00177  , HID_BDC
00178  , HID_NO_COUNTRY_CODE
00179  , HID_CLASS_DESC_NB_DEFAULT
00180  , DESCRIPTOR_REPORT
00181  , Usb_write_word_enum_struc(sizeof(S_usb_hid_report_descriptor))
00182  }
00183  ,
00184  { sizeof(S_usb_endpoint_descriptor)
00185  , DESCRIPTOR_ENDPOINT
00186  , ENDPOINT_NB_4
00187  , EP_ATTRIBUTES_4
00188  , Usb_write_word_enum_struc(EP_SIZE_4)
00189  , EP_INTERVAL_5
00190  }
00191  ,
00192   { sizeof(S_usb_endpoint_descriptor)
00193  , DESCRIPTOR_ENDPOINT
00194  , ENDPOINT_NB_5
00195  , EP_ATTRIBUTES_5
00196  , Usb_write_word_enum_struc(EP_SIZE_5)
00197  , EP_INTERVAL_5
00198  }
00199 
00200 };
00201 
00202 
00203 
00204                                       // usb_user_manufacturer_string_descriptor
00205 code S_usb_manufacturer_string_descriptor usb_user_manufacturer_string_descriptor = {
00206   sizeof(usb_user_manufacturer_string_descriptor)
00207 , DESCRIPTOR_STRING
00208 , USB_MANUFACTURER_NAME
00209 };
00210 
00211 
00212                                       // usb_user_product_string_descriptor
00213 
00214 code S_usb_product_string_descriptor usb_user_product_string_descriptor = {
00215   sizeof(usb_user_product_string_descriptor)
00216 , DESCRIPTOR_STRING
00217 , USB_PRODUCT_NAME
00218 };
00219 
00220 
00221                                       // usb_user_serial_number
00222 #if (USB_DEVICE_SN_USE==ENABLE)
00223 code S_usb_serial_number usb_user_serial_number = {
00224 #if (USE_DEVICE_SN_UNIQUE==ENABLE)
00225   sizeof(usb_user_serial_number)+4*SN_LENGTH
00226 , DESCRIPTOR_STRING
00227 #else
00228 sizeof(usb_user_serial_number)
00229 , DESCRIPTOR_STRING
00230 , USB_SERIAL_NUMBER
00231 #endif
00232 };
00233 #endif
00234 
00235                                       // usb_user_language_id
00236 
00237 code S_usb_language_id usb_user_language_id = {
00238   sizeof(usb_user_language_id)
00239 , DESCRIPTOR_STRING
00240 , Usb_write_word_enum_struc(LANGUAGE_ID)
00241 };
00242 
00243 code S_usb_hid_report_descriptor_mouse usb_hid_report_descriptor_mouse = {{
00244       0x05,0x01,          /* Usage Page (Generic Desktop)      */
00245       0x09,0x02,          /* Usage (Mouse)                     */
00246       0xA1,0x01,          /* Collection (Application)          */
00247       0x09,0x01,          /* Usage (Pointer)                   */
00248       0xA1,0x00,          /* Collection (Application)          */
00249       0x05,0x09,          /* Usage Page (Button)               */
00250       0x19,0x01,          /* Usage Minimum (1)                 */
00251       0x29,0x03,          /* Usage Maximum (3)                 */
00252       0x15,0x00,          /* Logical Minimum (0)               */
00253       0x25,0x01,          /* Logical Maximum (1)               */
00254       0x75,0x01,          /* Report Size (1)                   */
00255       0x95,0x03,          /* Report Count (3)                  */
00256       0x81,0x02,          /* Input (Data, Variable, Absolute)  */
00257       0x75,0x05,          /* Report Size (5)                   */
00258       0x95,0x01,          /* Report Count (1)                  */
00259       0x81,0x01,          /* Input (Constant)                  */
00260       0x05,0x01,          /* Usage Page (Generic Desktop Control)*/
00261       0x09,0x30,          /* Usage X                           */
00262       0x09,0x31,          /* Usage Y                           */
00263       0x09,0x38,          /* Usage Wheel                       */
00264       0x15,0x81,          /* Logical Minimum (-127)            */
00265       0x25,0x7F,          /* Logical Maximum (127)             */
00266       0x75,0x08,          /* Report Size (8)                   */
00267       0x95,0x03,          /* Report Count (3)                  */
00268       0x81,0x06,          /* Input (Data, Variable, Absolute)  */
00269       0xC0,               /* End Collection                    */
00270       0xC0                /* End Collection                    */
00271 }};
00272 
00273 
00274 code S_usb_hid_report_descriptor usb_hid_report_descriptor = {{
00275       0x06, 0xFF, 0xFF,         // 04|2   , Usage Page (vendordefined?)
00276       0x09, 0x01,               // 08|1   , Usage      (vendordefined
00277       0xA1, 0x01,               // A0|1   , Collection (Application)
00278       // IN report
00279       0x09, 0x02,               // 08|1   , Usage      (vendordefined)
00280       0x09, 0x03,               // 08|1   , Usage      (vendordefined)
00281       0x15, 0x00,               // 14|1   , Logical Minimum(0 for signed byte?)
00282       0x26 ,0xFF,0x00,           // 24|1   , Logical Maximum(255 for signed byte?)
00283       0x75, 0x08,               // 74|1   , Report Size(8) = field size in bits = 1 byte
00284       0x95, LENGTH_OF_REPORT_IN,   // 94|1:ReportCount(size) = repeat count of previous item
00285       0x81, 0x02,               // 80|1: IN report (Data,Variable, Absolute)
00286       // OUT report
00287       0x09, 0x04,               // 08|1   , Usage      (vendordefined)
00288       0x09, 0x05,               // 08|1   , Usage      (vendordefined)
00289       0x15, 0x00,               // 14|1   , Logical Minimum(0 for signed byte?)
00290       0x26, 0xFF,0x00,           // 24|1   , Logical Maximum(255 for signed byte?)
00291       0x75, 0x08,               // 74|1   , Report Size(8) = field size in bits = 1 byte
00292       0x95, LENGTH_OF_REPORT_OUT,   // 94|1:ReportCount(size) = repeat count of previous item
00293       0x91, 0x02,               // 90|1: OUT report (Data,Variable, Absolute)
00294       // Feature report
00295       0x09, 0x06,               // 08|1   , Usage      (vendordefined)
00296       0x09, 0x07,               // 08|1   , Usage      (vendordefined)
00297       0x15, 0x00,               // 14|1   , LogicalMinimum(0 for signed byte)
00298       0x26, 0xFF,0x00,          // 24|1   , Logical Maximum(255 for signed byte)
00299       0x75, 0x08,               // 74|1   , Report Size(8) =field size in bits = 1 byte
00300       0x95, 0x04,               // 94|1:ReportCount
00301       0xB1, 0x02,               // B0|1:   Feature report
00302       0xC0                      // C0|0    , End Collection
00303  }};
00304 

Generated on Wed Sep 23 09:33:18 2009 for ATMEL by  doxygen 1.5.3