Auzmendi Agustin / DISCO_F746NG_USBDevice
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers USBDescriptor.h Source File

USBDescriptor.h

00001 /* Copyright (c) 2010-2011 mbed.org, MIT License
00002 *
00003 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
00004 * and associated documentation files (the "Software"), to deal in the Software without
00005 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
00006 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
00007 * Software is furnished to do so, subject to the following conditions:
00008 *
00009 * The above copyright notice and this permission notice shall be included in all copies or
00010 * substantial portions of the Software.
00011 *
00012 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
00013 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00014 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
00015 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00016 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00017 */
00018 
00019 /* Standard descriptor types */
00020 #define DEVICE_DESCRIPTOR        (1)
00021 #define CONFIGURATION_DESCRIPTOR (2)
00022 #define STRING_DESCRIPTOR        (3)
00023 #define INTERFACE_DESCRIPTOR     (4)
00024 #define ENDPOINT_DESCRIPTOR      (5)
00025 #define QUALIFIER_DESCRIPTOR     (6)
00026 
00027 /* Standard descriptor lengths */
00028 #define DEVICE_DESCRIPTOR_LENGTH        (0x12)
00029 #define CONFIGURATION_DESCRIPTOR_LENGTH (0x09)
00030 #define INTERFACE_DESCRIPTOR_LENGTH     (0x09)
00031 #define ENDPOINT_DESCRIPTOR_LENGTH      (0x07)
00032 
00033 
00034 /*string offset*/
00035 #define STRING_OFFSET_LANGID            (0)
00036 #define STRING_OFFSET_IMANUFACTURER     (1)
00037 #define STRING_OFFSET_IPRODUCT          (2)
00038 #define STRING_OFFSET_ISERIAL           (3)
00039 #define STRING_OFFSET_ICONFIGURATION    (4)
00040 #define STRING_OFFSET_IINTERFACE        (5)
00041 
00042 /* USB Specification Release Number */
00043 #define USB_VERSION_1_0 (0x0101)
00044 #define USB_VERSION_2_0 (0x0200)
00045 
00046 /* Least/Most significant byte of short integer */
00047 #define LSB(n)  ((n)&0xff)
00048 #define MSB(n)  (((n)&0xff00)>>8)
00049 
00050 /* Convert physical endpoint number to descriptor endpoint number */
00051 #define PHY_TO_DESC(endpoint) (((endpoint)>>1) | (((endpoint) & 1) ? 0x80:0))
00052 
00053 /* bmAttributes in configuration descriptor */
00054 /* C_RESERVED must always be set */
00055 #define C_RESERVED      (1U<<7)
00056 #define C_SELF_POWERED  (1U<<6)
00057 #define C_REMOTE_WAKEUP (1U<<5)
00058 
00059 /* bMaxPower in configuration descriptor */
00060 #define C_POWER(mA)     ((mA)/2)
00061 
00062 /* bmAttributes in endpoint descriptor */
00063 #define E_CONTROL       (0x00)
00064 #define E_ISOCHRONOUS   (0x01)
00065 #define E_BULK          (0x02)
00066 #define E_INTERRUPT     (0x03)
00067 
00068 /* For isochronous endpoints only: */
00069 #define E_NO_SYNCHRONIZATION    (0x00)
00070 #define E_ASYNCHRONOUS          (0x04)
00071 #define E_ADAPTIVE              (0x08)
00072 #define E_SYNCHRONOUS           (0x0C)
00073 #define E_DATA                  (0x00)
00074 #define E_FEEDBACK              (0x10)
00075 #define E_IMPLICIT_FEEDBACK     (0x20)