Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
usb_common.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause */
2
3/***************************************************************************
4 *
5 *
6 * Copyright(c) 2015,2016 Intel Corporation.
7 * Copyright(c) 2017 PHYTEC Messtechnik GmbH
8 * Copyright(c) 2018 Nordic Semiconductor ASA
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 *
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in
18 * the documentation and/or other materials provided with the
19 * distribution.
20 * * Neither the name of Intel Corporation nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 *
36 ***************************************************************************/
37
45#include <version.h>
46#include <usb/usb_ch9.h>
47
48#ifndef ZEPHYR_INCLUDE_USB_USB_COMMON_H_
49#define ZEPHYR_INCLUDE_USB_USB_COMMON_H_
50
51/*
52 * This header and macros below are deprecated in 2.7 release.
53 * Please replace with macros from Chapter 9 header, include/usb/usb_ch9.h
54 */
55#warning "<usb/usb_common.h> header is deprecated, use <usb/usb_ch9.h> instead"
56
57#define BCD(x) __DEPRECATED_MACRO USB_DEC_TO_BCD(dec)
58
59/* Descriptor size in bytes */
60#define USB_DEVICE_DESC_SIZE __DEPRECATED_MACRO 18
61#define USB_CONFIGURATION_DESC_SIZE __DEPRECATED_MACRO 9
62#define USB_INTERFACE_DESC_SIZE __DEPRECATED_MACRO 9
63#define USB_ENDPOINT_DESC_SIZE __DEPRECATED_MACRO 7
64#define USB_STRING_DESC_SIZE __DEPRECATED_MACRO 4
65#define USB_HID_DESC_SIZE __DEPRECATED_MACRO 9
66#define USB_DFU_DESC_SIZE __DEPRECATED_MACRO 9
67#define USB_DEVICE_QUAL_DESC_SIZE __DEPRECATED_MACRO 10
68#define USB_INTERFACE_ASSOC_DESC_SIZE __DEPRECATED_MACRO 8
69
70/* Descriptor type */
71#define USB_DEVICE_DESC __DEPRECATED_MACRO 0x01U
72#define USB_CONFIGURATION_DESC __DEPRECATED_MACRO 0x02U
73#define USB_STRING_DESC __DEPRECATED_MACRO 0x03U
74#define USB_INTERFACE_DESC __DEPRECATED_MACRO 0x04U
75#define USB_ENDPOINT_DESC __DEPRECATED_MACRO 0x05U
76#define USB_DEVICE_QUAL_DESC __DEPRECATED_MACRO 0x06U
77#define USB_OTHER_SPEED __DEPRECATED_MACRO 0x07U
78#define USB_INTERFACE_POWER __DEPRECATED_MACRO 0x08U
79#define USB_INTERFACE_ASSOC_DESC __DEPRECATED_MACRO 0x0BU
80#define USB_DEVICE_CAPABILITY_DESC __DEPRECATED_MACRO 0x10U
81#define USB_HID_DESC __DEPRECATED_MACRO 0x21U
82#define USB_HID_REPORT_DESC __DEPRECATED_MACRO 0x22U
83#define USB_CS_INTERFACE_DESC __DEPRECATED_MACRO 0x24U
84#define USB_CS_ENDPOINT_DESC __DEPRECATED_MACRO 0x25U
85#define USB_DFU_FUNCTIONAL_DESC __DEPRECATED_MACRO 0x21U
86#define USB_ASSOCIATION_DESC __DEPRECATED_MACRO 0x0BU
87#define USB_BINARY_OBJECT_STORE_DESC __DEPRECATED_MACRO 0x0FU
88
89/* Useful define */
90#define USB_1_1 __DEPRECATED_MACRO 0x0110
91#define USB_2_0 __DEPRECATED_MACRO 0x0200
92/* Set USB version to 2.1 so that the host will request the BOS descriptor */
93#define USB_2_1 __DEPRECATED_MACRO 0x0210
94
95#define BCDDEVICE_RELNUM __DEPRECATED_MACRO USB_BCD_DRN
96
97/* Highest value of Frame Number in SOF packets. */
98#define USB_SOF_MAX __DEPRECATED_MACRO 2047
99
100/* bmAttributes:
101 * D7:Reserved, always 1,
102 * D6:Self-Powered -> 1,
103 * D5:Remote Wakeup -> 0,
104 * D4...0:Reserved -> 0
105 */
106#define USB_CONFIGURATION_ATTRIBUTES_REMOTE_WAKEUP __DEPRECATED_MACRO BIT(5)
107#define USB_CONFIGURATION_ATTRIBUTES_SELF_POWERED __DEPRECATED_MACRO BIT(6)
108#define USB_CONFIGURATION_ATTRIBUTES BIT(7) __DEPRECATED_MACRO \
109 | ((COND_CODE_1(CONFIG_USB_SELF_POWERED, \
110 (USB_CONFIGURATION_ATTRIBUTES_SELF_POWERED), (0))) \
111 | (COND_CODE_1(CONFIG_USB_DEVICE_REMOTE_WAKEUP, \
112 (USB_CONFIGURATION_ATTRIBUTES_REMOTE_WAKEUP), (0))))
113
114/* Classes */
115#define AUDIO_CLASS __DEPRECATED_MACRO 0x01
116#define COMMUNICATION_DEVICE_CLASS __DEPRECATED_MACRO 0x02
117#define COMMUNICATION_DEVICE_CLASS_DATA __DEPRECATED_MACRO 0x0A
118#define HID_CLASS __DEPRECATED_MACRO 0x03
119#define MASS_STORAGE_CLASS __DEPRECATED_MACRO 0x08
120#define WIRELESS_DEVICE_CLASS __DEPRECATED_MACRO 0xE0
121#define MISC_CLASS __DEPRECATED_MACRO 0xEF
122#define CUSTOM_CLASS __DEPRECATED_MACRO 0xFF
123#define DFU_DEVICE_CLASS __DEPRECATED_MACRO 0xFE
124
125/* Sub-classes */
126#define CDC_NCM_SUBCLASS __DEPRECATED_MACRO 0x0d
127#define BOOT_INTERFACE_SUBCLASS __DEPRECATED_MACRO 0x01
128#define SCSI_TRANSPARENT_SUBCLASS __DEPRECATED_MACRO 0x06
129#define DFU_INTERFACE_SUBCLASS __DEPRECATED_MACRO 0x01
130#define RF_SUBCLASS __DEPRECATED_MACRO 0x01
131#define CUSTOM_SUBCLASS __DEPRECATED_MACRO 0xFF
132/* Misc subclasses */
133#define MISC_RNDIS_SUBCLASS __DEPRECATED_MACRO 0x04
134
135/* Protocols */
136#define V25TER_PROTOCOL __DEPRECATED_MACRO 0x01
137#define MOUSE_PROTOCOL __DEPRECATED_MACRO 0x02
138#define BULK_ONLY_PROTOCOL __DEPRECATED_MACRO 0x50
139#define DFU_RUNTIME_PROTOCOL __DEPRECATED_MACRO 0x01
140#define DFU_MODE_PROTOCOL __DEPRECATED_MACRO 0x02
141#define BLUETOOTH_PROTOCOL __DEPRECATED_MACRO 0x01
142/* CDC ACM protocols */
143#define ACM_VENDOR_PROTOCOL __DEPRECATED_MACRO 0xFF
144/* Misc protocols */
145#define MISC_ETHERNET_PROTOCOL __DEPRECATED_MACRO 0x01
146
147#endif /* ZEPHYR_INCLUDE_USB_USB_COMMON_H_ */
USB Chapter 9 structures and definitions.