Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers USBDescriptor.h Source File

USBDescriptor.h

00001 /*
00002  * Copyright (c) 2018-2019, Arm Limited and affiliates.
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef USBDESCRIPTOR_H
00019 #define USBDESCRIPTOR_H
00020 
00021 /* Standard descriptor types */
00022 #define DEVICE_DESCRIPTOR        (1)
00023 #define CONFIGURATION_DESCRIPTOR (2)
00024 #define STRING_DESCRIPTOR        (3)
00025 #define INTERFACE_DESCRIPTOR     (4)
00026 #define ENDPOINT_DESCRIPTOR      (5)
00027 #define QUALIFIER_DESCRIPTOR     (6)
00028 
00029 /* Standard descriptor lengths */
00030 #define DEVICE_DESCRIPTOR_LENGTH        (0x12)
00031 #define CONFIGURATION_DESCRIPTOR_LENGTH (0x09)
00032 #define INTERFACE_DESCRIPTOR_LENGTH     (0x09)
00033 #define ENDPOINT_DESCRIPTOR_LENGTH      (0x07)
00034 
00035 
00036 /*string offset*/
00037 #define STRING_OFFSET_LANGID            (0)
00038 #define STRING_OFFSET_IMANUFACTURER     (1)
00039 #define STRING_OFFSET_IPRODUCT          (2)
00040 #define STRING_OFFSET_ISERIAL           (3)
00041 #define STRING_OFFSET_ICONFIGURATION    (4)
00042 #define STRING_OFFSET_IINTERFACE        (5)
00043 
00044 /* USB Specification Release Number */
00045 #define USB_VERSION_2_0 (0x0200)
00046 
00047 /* Least/Most significant byte of short integer */
00048 #define LSB(n)  ((n)&0xff)
00049 #define MSB(n)  (((n)&0xff00)>>8)
00050 
00051 /* bmAttributes in configuration descriptor */
00052 /* C_RESERVED must always be set */
00053 #define C_RESERVED      (1U<<7)
00054 #define C_SELF_POWERED  (1U<<6)
00055 #define C_REMOTE_WAKEUP (1U<<5)
00056 
00057 /* bMaxPower in configuration descriptor */
00058 #define C_POWER(mA)     ((mA)/2)
00059 
00060 /* bmAttributes in endpoint descriptor */
00061 #define E_CONTROL       (0x00)
00062 #define E_ISOCHRONOUS   (0x01)
00063 #define E_BULK          (0x02)
00064 #define E_INTERRUPT     (0x03)
00065 
00066 /* For isochronous endpoints only: */
00067 #define E_NO_SYNCHRONIZATION    (0x00)
00068 #define E_ASYNCHRONOUS          (0x04)
00069 #define E_ADAPTIVE              (0x08)
00070 #define E_SYNCHRONOUS           (0x0C)
00071 #define E_DATA                  (0x00)
00072 #define E_FEEDBACK              (0x10)
00073 #define E_IMPLICIT_FEEDBACK     (0x20)
00074 
00075 #endif