Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
usb_def.h
00001 /** 00002 * @file usb_def.h 00003 * @brief USB defines 00004 * 00005 * DAPLink Interface Firmware 00006 * Copyright (c) 2009-2016, ARM Limited, All Rights Reserved 00007 * SPDX-License-Identifier: Apache-2.0 00008 * 00009 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00010 * not use this file except in compliance with the License. 00011 * You may obtain a copy of the License at 00012 * 00013 * http://www.apache.org/licenses/LICENSE-2.0 00014 * 00015 * Unless required by applicable law or agreed to in writing, software 00016 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00017 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00018 * See the License for the specific language governing permissions and 00019 * limitations under the License. 00020 */ 00021 00022 #ifndef __USB_DEF_H__ 00023 #define __USB_DEF_H__ 00024 00025 #pragma anon_unions 00026 00027 #include <stdint.h> 00028 #include <stddef.h> 00029 00030 #ifndef NULL 00031 #ifdef __cplusplus 00032 #define NULL 0 00033 #else 00034 #define NULL ((void *) 0) 00035 #endif 00036 #endif 00037 00038 #ifndef EOF 00039 #define EOF (-1) 00040 #endif 00041 00042 #ifndef __size_t 00043 #define __size_t 1 00044 typedef unsigned int size_t; 00045 #endif 00046 00047 typedef signed char S8; 00048 typedef unsigned char U8; 00049 typedef short S16; 00050 typedef unsigned short U16; 00051 typedef int S32; 00052 typedef unsigned int U32; 00053 typedef long long S64; 00054 typedef unsigned long long U64; 00055 typedef unsigned char BIT; 00056 typedef unsigned int BOOL; 00057 00058 #ifndef __TRUE 00059 #define __TRUE 1 00060 #endif 00061 #ifndef __FALSE 00062 #define __FALSE 0 00063 #endif 00064 00065 00066 /* bmRequestType.Dir */ 00067 #define REQUEST_HOST_TO_DEVICE 0 00068 #define REQUEST_DEVICE_TO_HOST 1 00069 00070 /* bmRequestType.Type */ 00071 #define REQUEST_STANDARD 0 00072 #define REQUEST_CLASS 1 00073 #define REQUEST_VENDOR 2 00074 #define REQUEST_RESERVED 3 00075 00076 /* bmRequestType.Recipient */ 00077 #define REQUEST_TO_DEVICE 0 00078 #define REQUEST_TO_INTERFACE 1 00079 #define REQUEST_TO_ENDPOINT 2 00080 #define REQUEST_TO_OTHER 3 00081 00082 /* bmRequestType Definition */ 00083 typedef __packed struct _REQUEST_TYPE { 00084 U8 Recipient : 5; /* D4..0: Recipient */ 00085 U8 Type : 2; /* D6..5: Type */ 00086 U8 Dir : 1; /* D7: Data Phase Txsfer Direction */ 00087 } REQUEST_TYPE; 00088 00089 /* USB Standard Request Codes */ 00090 #define USB_REQUEST_GET_STATUS 0 00091 #define USB_REQUEST_CLEAR_FEATURE 1 00092 #define USB_REQUEST_SET_FEATURE 3 00093 #define USB_REQUEST_SET_ADDRESS 5 00094 #define USB_REQUEST_GET_DESCRIPTOR 6 00095 #define USB_REQUEST_SET_DESCRIPTOR 7 00096 #define USB_REQUEST_GET_CONFIGURATION 8 00097 #define USB_REQUEST_SET_CONFIGURATION 9 00098 #define USB_REQUEST_GET_INTERFACE 10 00099 #define USB_REQUEST_SET_INTERFACE 11 00100 #define USB_REQUEST_SYNC_FRAME 12 00101 00102 /* USB GET_STATUS Bit Values */ 00103 #define USB_GETSTATUS_SELF_POWERED 0x01 00104 #define USB_GETSTATUS_REMOTE_WAKEUP 0x02 00105 #define USB_GETSTATUS_ENDPOINT_STALL 0x01 00106 00107 /* USB Standard Feature selectors */ 00108 #define USB_FEATURE_ENDPOINT_STALL 0 00109 #define USB_FEATURE_REMOTE_WAKEUP 1 00110 00111 /* USB Default Control Pipe Setup Packet */ 00112 typedef __packed struct _USB_SETUP_PACKET { 00113 REQUEST_TYPE bmRequestType; /* bmRequestType */ 00114 U8 bRequest; /* bRequest */ 00115 __packed union { 00116 U16 wValue; /* wValue */ 00117 __packed struct { 00118 U8 wValueL; 00119 U8 wValueH; 00120 }; 00121 }; 00122 __packed union { 00123 U16 wIndex; /* wIndex */ 00124 __packed struct { 00125 U8 wIndexL; 00126 U8 wIndexH; 00127 }; 00128 }; 00129 U16 wLength; /* wLength */ 00130 } USB_SETUP_PACKET; 00131 00132 00133 /* USB Descriptor Types */ 00134 #define USB_DEVICE_DESCRIPTOR_TYPE 1 00135 #define USB_CONFIGURATION_DESCRIPTOR_TYPE 2 00136 #define USB_STRING_DESCRIPTOR_TYPE 3 00137 #define USB_INTERFACE_DESCRIPTOR_TYPE 4 00138 #define USB_ENDPOINT_DESCRIPTOR_TYPE 5 00139 #define USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE 6 00140 #define USB_OTHER_SPEED_CONFIG_DESCRIPTOR_TYPE 7 00141 #define USB_INTERFACE_POWER_DESCRIPTOR_TYPE 8 00142 #define USB_OTG_DESCRIPTOR_TYPE 9 00143 #define USB_DEBUG_DESCRIPTOR_TYPE 10 00144 #define USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE 11 00145 #define USB_BINARY_OBJECT_STORE_DESCRIPTOR_TYPE 15 00146 #define USB_DEVICE_CAPABILITY_DESCRIPTOR_TYPE 16 00147 00148 /* USB Device Classes */ 00149 #define USB_DEVICE_CLASS_RESERVED 0x00 00150 #define USB_DEVICE_CLASS_AUDIO 0x01 00151 #define USB_DEVICE_CLASS_COMMUNICATIONS 0x02 00152 #define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03 00153 #define USB_DEVICE_CLASS_MONITOR 0x04 00154 #define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05 00155 #define USB_DEVICE_CLASS_POWER 0x06 00156 #define USB_DEVICE_CLASS_PRINTER 0x07 00157 #define USB_DEVICE_CLASS_STORAGE 0x08 00158 #define USB_DEVICE_CLASS_HUB 0x09 00159 #define USB_DEVICE_CLASS_MISCELLANEOUS 0xEF 00160 #define USB_DEVICE_CLASS_APPLICATION_SPECIFIC 0xFE 00161 #define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF 00162 00163 /* bmAttributes in Configuration Descriptor */ 00164 #define USB_CONFIG_POWERED_MASK 0x40 00165 #define USB_CONFIG_BUS_POWERED 0x80 00166 #define USB_CONFIG_SELF_POWERED 0xC0 00167 #define USB_CONFIG_REMOTE_WAKEUP 0x20 00168 00169 /* bMaxPower in Configuration Descriptor */ 00170 #define USB_CONFIG_POWER_MA(mA) ((mA)/2) 00171 00172 /* bEndpointAddress in Endpoint Descriptor */ 00173 #define USB_ENDPOINT_DIRECTION_MASK 0x80 00174 #define USB_ENDPOINT_OUT(addr) ((addr) | 0x00) 00175 #define USB_ENDPOINT_IN(addr) ((addr) | 0x80) 00176 00177 /* bmAttributes in Endpoint Descriptor */ 00178 #define USB_ENDPOINT_TYPE_MASK 0x03 00179 #define USB_ENDPOINT_TYPE_CONTROL 0x00 00180 #define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01 00181 #define USB_ENDPOINT_TYPE_BULK 0x02 00182 #define USB_ENDPOINT_TYPE_INTERRUPT 0x03 00183 #define USB_ENDPOINT_SYNC_MASK 0x0C 00184 #define USB_ENDPOINT_SYNC_NO_SYNCHRONIZATION 0x00 00185 #define USB_ENDPOINT_SYNC_ASYNCHRONOUS 0x04 00186 #define USB_ENDPOINT_SYNC_ADAPTIVE 0x08 00187 #define USB_ENDPOINT_SYNC_SYNCHRONOUS 0x0C 00188 #define USB_ENDPOINT_USAGE_MASK 0x30 00189 #define USB_ENDPOINT_USAGE_DATA 0x00 00190 #define USB_ENDPOINT_USAGE_FEEDBACK 0x10 00191 #define USB_ENDPOINT_USAGE_IMPLICIT_FEEDBACK 0x20 00192 #define USB_ENDPOINT_USAGE_RESERVED 0x30 00193 00194 /* bDevCapabilityType in Device Capability Descriptor */ 00195 #define USB_DEVICE_CAPABILITY_WIRELESS_USB 1 00196 #define USB_DEVICE_CAPABILITY_USB_2_0_EXTENSION 2 00197 #define USB_DEVICE_CAPABILITY_SUPERSPEED_USB 3 00198 #define USB_DEVICE_CAPABILITY_CONTAINER_ID 4 00199 #define USB_DEVICE_CAPABILITY_PLATFORM 5 00200 #define USB_DEVICE_CAPABILITY_POWER_DELIVERY_CAPABILITY 6 00201 #define USB_DEVICE_CAPABILITY_BATTERY_INFO_CAPABILITY 7 00202 #define USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_CAPABILITY 8 00203 #define USB_DEVICE_CAPABILITY_PD_PROVIDER_PORT_CAPABILITY 9 00204 #define USB_DEVICE_CAPABILITY_SUPERSPEED_PLUS 10 00205 #define USB_DEVICE_CAPABILITY_PRECISION_TIME_MEASUREMENT 11 00206 #define USB_DEVICE_CAPABILITY_WIRELESS_USB_EXT 12 00207 00208 /* USB Standard Device Descriptor */ 00209 typedef __packed struct _USB_DEVICE_DESCRIPTOR { 00210 U8 bLength; 00211 U8 bDescriptorType; 00212 U16 bcdUSB; 00213 U8 bDeviceClass; 00214 U8 bDeviceSubClass; 00215 U8 bDeviceProtocol; 00216 U8 bMaxPacketSize0; 00217 U16 idVendor; 00218 U16 idProduct; 00219 U16 bcdDevice; 00220 U8 iManufacturer; 00221 U8 iProduct; 00222 U8 iSerialNumber; 00223 U8 bNumConfigurations; 00224 } USB_DEVICE_DESCRIPTOR; 00225 00226 /* USB 2.0 Device Qualifier Descriptor */ 00227 typedef __packed struct _USB_DEVICE_QUALIFIER_DESCRIPTOR { 00228 U8 bLength; 00229 U8 bDescriptorType; 00230 U16 bcdUSB; 00231 U8 bDeviceClass; 00232 U8 bDeviceSubClass; 00233 U8 bDeviceProtocol; 00234 U8 bMaxPacketSize0; 00235 U8 bNumConfigurations; 00236 U8 bReserved; 00237 } USB_DEVICE_QUALIFIER_DESCRIPTOR; 00238 00239 /* USB Standard Configuration Descriptor */ 00240 typedef __packed struct _USB_CONFIGURATION_DESCRIPTOR { 00241 U8 bLength; 00242 U8 bDescriptorType; 00243 U16 wTotalLength; 00244 U8 bNumInterfaces; 00245 U8 bConfigurationValue; 00246 U8 iConfiguration; 00247 U8 bmAttributes; 00248 U8 bMaxPower; 00249 } USB_CONFIGURATION_DESCRIPTOR; 00250 00251 /* USB Standard Interface Descriptor */ 00252 typedef __packed struct _USB_INTERFACE_DESCRIPTOR { 00253 U8 bLength; 00254 U8 bDescriptorType; 00255 U8 bInterfaceNumber; 00256 U8 bAlternateSetting; 00257 U8 bNumEndpoints; 00258 U8 bInterfaceClass; 00259 U8 bInterfaceSubClass; 00260 U8 bInterfaceProtocol; 00261 U8 iInterface; 00262 } USB_INTERFACE_DESCRIPTOR; 00263 00264 /* USB Standard Endpoint Descriptor */ 00265 typedef __packed struct _USB_ENDPOINT_DESCRIPTOR { 00266 U8 bLength; 00267 U8 bDescriptorType; 00268 U8 bEndpointAddress; 00269 U8 bmAttributes; 00270 U16 wMaxPacketSize; 00271 U8 bInterval; 00272 } USB_ENDPOINT_DESCRIPTOR; 00273 00274 /* USB String Descriptor */ 00275 typedef __packed struct _USB_STRING_DESCRIPTOR { 00276 U8 bLength; 00277 U8 bDescriptorType; 00278 U16 bString/*[]*/; 00279 } USB_STRING_DESCRIPTOR; 00280 00281 /* USB Common Descriptor */ 00282 typedef __packed struct _USB_COMMON_DESCRIPTOR { 00283 U8 bLength; 00284 U8 bDescriptorType; 00285 } USB_COMMON_DESCRIPTOR; 00286 00287 /* USB Interface Association Descriptor */ 00288 typedef __packed struct _USB_INTERFACE_ASSOCIATION_DESCRIPTOR { 00289 U8 bLength; 00290 U8 bDescriptorType; 00291 U8 bFirstInterface; 00292 U8 bInterfaceCount; 00293 U8 bFunctionClass; 00294 U8 bFunctionSubclass; 00295 U8 bFunctionProtocol; 00296 U8 iFunction; 00297 } USB_INTERFACE_ASSOCIATION_DESCRIPTOR; 00298 00299 /* USB Binary Object Store Descriptor */ 00300 typedef __packed struct _USB_BINARY_OBJECT_STORE_DESCRIPTOR { 00301 U8 bLength; 00302 U8 bDescriptorType; 00303 U16 wTotalLength; 00304 U8 bNumDeviceCaps; 00305 } USB_BINARY_OBJECT_STORE_DESCRIPTOR; 00306 00307 /* Union Functional Descriptor */ 00308 typedef __packed struct _UNION_FUNCTIONAL_DESCRIPTOR { 00309 U8 bLength; 00310 U8 bDescriptorType; 00311 U8 bDescriptorSubtype; 00312 U8 bMasterInterface; 00313 U8 bSlaveInterface0; 00314 } UNION_FUNCTIONAL_DESCRIPTOR; 00315 00316 typedef __packed struct _WINUSB_FUNCTION_SUBSET_HEADER { 00317 U16 wLength; 00318 U16 wDescriptorType; 00319 U8 bFirstInterface; 00320 U8 bReserved; 00321 } WINUSB_FUNCTION_SUBSET_HEADER; 00322 00323 /* USB Device Capability Descriptor */ 00324 typedef __packed struct _USB_DEVICE_CAPABILITY_DESCRIPTOR { 00325 U8 bLength; 00326 U8 bDescriptorType; 00327 U8 bDevCapabilityType; 00328 } USB_DEVICE_CAPABILITY_DESCRIPTOR; 00329 00330 #endif /* __USB_DEF_H__ */
Generated on Tue Jul 12 2022 15:37:26 by
1.7.2