Mbed OS Reference
Loading...
Searching...
No Matches
USBDescriptor.h
1/*
2 * Copyright (c) 2018-2019, Arm Limited and affiliates.
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef USBDESCRIPTOR_H
19#define USBDESCRIPTOR_H
20
21/* Standard descriptor types */
22#define DEVICE_DESCRIPTOR (1)
23#define CONFIGURATION_DESCRIPTOR (2)
24#define STRING_DESCRIPTOR (3)
25#define INTERFACE_DESCRIPTOR (4)
26#define ENDPOINT_DESCRIPTOR (5)
27#define QUALIFIER_DESCRIPTOR (6)
28
29/* Standard descriptor lengths */
30#define DEVICE_DESCRIPTOR_LENGTH (0x12)
31#define CONFIGURATION_DESCRIPTOR_LENGTH (0x09)
32#define INTERFACE_DESCRIPTOR_LENGTH (0x09)
33#define ENDPOINT_DESCRIPTOR_LENGTH (0x07)
34
35
36/*string offset*/
37#define STRING_OFFSET_LANGID (0)
38#define STRING_OFFSET_IMANUFACTURER (1)
39#define STRING_OFFSET_IPRODUCT (2)
40#define STRING_OFFSET_ISERIAL (3)
41#define STRING_OFFSET_ICONFIGURATION (4)
42#define STRING_OFFSET_IINTERFACE (5)
43
44/* USB Specification Release Number */
45#define USB_VERSION_2_0 (0x0200)
46
47/* Least/Most significant byte of short integer */
48#define LSB(n) ((n)&0xff)
49#define MSB(n) (((n)&0xff00)>>8)
50
51/* bmAttributes in configuration descriptor */
52/* C_RESERVED must always be set */
53#define C_RESERVED (1U<<7)
54#define C_SELF_POWERED (1U<<6)
55#define C_REMOTE_WAKEUP (1U<<5)
56
57/* bMaxPower in configuration descriptor */
58#define C_POWER(mA) ((mA)/2)
59
60/* bmAttributes in endpoint descriptor */
61#define E_CONTROL (0x00)
62#define E_ISOCHRONOUS (0x01)
63#define E_BULK (0x02)
64#define E_INTERRUPT (0x03)
65
66/* For isochronous endpoints only: */
67#define E_NO_SYNCHRONIZATION (0x00)
68#define E_ASYNCHRONOUS (0x04)
69#define E_ADAPTIVE (0x08)
70#define E_SYNCHRONOUS (0x0C)
71#define E_DATA (0x00)
72#define E_FEEDBACK (0x10)
73#define E_IMPLICIT_FEEDBACK (0x20)
74
75#endif