Port of Keils USBCDC example, compiles ok. Gets stuck at init
Embed:
(wiki syntax)
Show/hide line numbers
usb.h
00001 /*---------------------------------------------------------------------------- 00002 * U S B - K e r n e l 00003 *---------------------------------------------------------------------------- 00004 * Name: usb.h 00005 * Purpose: USB Definitions 00006 * Version: V1.20 00007 *---------------------------------------------------------------------------- 00008 * This software is supplied "AS IS" without any warranties, express, 00009 * implied or statutory, including but not limited to the implied 00010 * warranties of fitness for purpose, satisfactory quality and 00011 * noninfringement. Keil extends you a royalty-free right to reproduce 00012 * and distribute executable files created using this software for use 00013 * on NXP Semiconductors LPC family microcontroller devices only. Nothing 00014 * else gives you the right to use this software. 00015 * 00016 * Copyright (c) 2009 Keil - An ARM Company. All rights reserved. 00017 *---------------------------------------------------------------------------*/ 00018 00019 #ifndef __USB_H__ 00020 #define __USB_H__ 00021 00022 00023 typedef __packed union { 00024 uint16_t W; 00025 __packed struct { 00026 uint8_t L; 00027 uint8_t H; 00028 } WB; 00029 } WORD_BYTE; 00030 00031 00032 /* bmRequestType.Dir */ 00033 #define REQUEST_HOST_TO_DEVICE 0 00034 #define REQUEST_DEVICE_TO_HOST 1 00035 00036 /* bmRequestType.Type */ 00037 #define REQUEST_STANDARD 0 00038 #define REQUEST_CLASS 1 00039 #define REQUEST_VENDOR 2 00040 #define REQUEST_RESERVED 3 00041 00042 /* bmRequestType.Recipient */ 00043 #define REQUEST_TO_DEVICE 0 00044 #define REQUEST_TO_INTERFACE 1 00045 #define REQUEST_TO_ENDPOINT 2 00046 #define REQUEST_TO_OTHER 3 00047 00048 /* bmRequestType Definition */ 00049 typedef __packed union _REQUEST_TYPE { 00050 __packed struct _BM { 00051 uint8_t Recipient : 5; 00052 uint8_t Type : 2; 00053 uint8_t Dir : 1; 00054 } BM; 00055 uint8_t B; 00056 } REQUEST_TYPE; 00057 00058 /* USB Standard Request Codes */ 00059 #define USB_REQUEST_GET_STATUS 0 00060 #define USB_REQUEST_CLEAR_FEATURE 1 00061 #define USB_REQUEST_SET_FEATURE 3 00062 #define USB_REQUEST_SET_ADDRESS 5 00063 #define USB_REQUEST_GET_DESCRIPTOR 6 00064 #define USB_REQUEST_SET_DESCRIPTOR 7 00065 #define USB_REQUEST_GET_CONFIGURATION 8 00066 #define USB_REQUEST_SET_CONFIGURATION 9 00067 #define USB_REQUEST_GET_INTERFACE 10 00068 #define USB_REQUEST_SET_INTERFACE 11 00069 #define USB_REQUEST_SYNC_FRAME 12 00070 00071 /* USB GET_STATUS Bit Values */ 00072 #define USB_GETSTATUS_SELF_POWERED 0x01 00073 #define USB_GETSTATUS_REMOTE_WAKEUP 0x02 00074 #define USB_GETSTATUS_ENDPOINT_STALL 0x01 00075 00076 /* USB Standard Feature selectors */ 00077 #define USB_FEATURE_ENDPOINT_STALL 0 00078 #define USB_FEATURE_REMOTE_WAKEUP 1 00079 00080 /* USB Default Control Pipe Setup Packet */ 00081 typedef __packed struct _USB_SETUP_PACKET { 00082 REQUEST_TYPE bmRequestType; 00083 uint8_t bRequest; 00084 WORD_BYTE wValue; 00085 WORD_BYTE wIndex; 00086 uint16_t wLength; 00087 } USB_SETUP_PACKET; 00088 00089 00090 /* USB Descriptor Types */ 00091 #define USB_DEVICE_DESCRIPTOR_TYPE 1 00092 #define USB_CONFIGURATION_DESCRIPTOR_TYPE 2 00093 #define USB_STRING_DESCRIPTOR_TYPE 3 00094 #define USB_INTERFACE_DESCRIPTOR_TYPE 4 00095 #define USB_ENDPOINT_DESCRIPTOR_TYPE 5 00096 #define USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE 6 00097 #define USB_OTHER_SPEED_CONFIG_DESCRIPTOR_TYPE 7 00098 #define USB_INTERFACE_POWER_DESCRIPTOR_TYPE 8 00099 #define USB_OTG_DESCRIPTOR_TYPE 9 00100 #define USB_DEBUG_DESCRIPTOR_TYPE 10 00101 #define USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE 11 00102 00103 /* USB Device Classes */ 00104 #define USB_DEVICE_CLASS_RESERVED 0x00 00105 #define USB_DEVICE_CLASS_AUDIO 0x01 00106 #define USB_DEVICE_CLASS_COMMUNICATIONS 0x02 00107 #define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03 00108 #define USB_DEVICE_CLASS_MONITOR 0x04 00109 #define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05 00110 #define USB_DEVICE_CLASS_POWER 0x06 00111 #define USB_DEVICE_CLASS_PRINTER 0x07 00112 #define USB_DEVICE_CLASS_STORAGE 0x08 00113 #define USB_DEVICE_CLASS_HUB 0x09 00114 #define USB_DEVICE_CLASS_MISCELLANEOUS 0xEF 00115 #define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF 00116 00117 /* bmAttributes in Configuration Descriptor */ 00118 #define USB_CONFIG_POWERED_MASK 0x40 00119 #define USB_CONFIG_BUS_POWERED 0x80 00120 #define USB_CONFIG_SELF_POWERED 0xC0 00121 #define USB_CONFIG_REMOTE_WAKEUP 0x20 00122 00123 /* bMaxPower in Configuration Descriptor */ 00124 #define USB_CONFIG_POWER_MA(mA) ((mA)/2) 00125 00126 /* bEndpointAddress in Endpoint Descriptor */ 00127 #define USB_ENDPOINT_DIRECTION_MASK 0x80 00128 #define USB_ENDPOINT_OUT(addr) ((addr) | 0x00) 00129 #define USB_ENDPOINT_IN(addr) ((addr) | 0x80) 00130 00131 /* bmAttributes in Endpoint Descriptor */ 00132 #define USB_ENDPOINT_TYPE_MASK 0x03 00133 #define USB_ENDPOINT_TYPE_CONTROL 0x00 00134 #define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01 00135 #define USB_ENDPOINT_TYPE_BULK 0x02 00136 #define USB_ENDPOINT_TYPE_INTERRUPT 0x03 00137 #define USB_ENDPOINT_SYNC_MASK 0x0C 00138 #define USB_ENDPOINT_SYNC_NO_SYNCHRONIZATION 0x00 00139 #define USB_ENDPOINT_SYNC_ASYNCHRONOUS 0x04 00140 #define USB_ENDPOINT_SYNC_ADAPTIVE 0x08 00141 #define USB_ENDPOINT_SYNC_SYNCHRONOUS 0x0C 00142 #define USB_ENDPOINT_USAGE_MASK 0x30 00143 #define USB_ENDPOINT_USAGE_DATA 0x00 00144 #define USB_ENDPOINT_USAGE_FEEDBACK 0x10 00145 #define USB_ENDPOINT_USAGE_IMPLICIT_FEEDBACK 0x20 00146 #define USB_ENDPOINT_USAGE_RESERVED 0x30 00147 00148 /* USB Standard Device Descriptor */ 00149 typedef __packed struct _USB_DEVICE_DESCRIPTOR { 00150 uint8_t bLength; 00151 uint8_t bDescriptorType; 00152 uint16_t bcdUSB; 00153 uint8_t bDeviceClass; 00154 uint8_t bDeviceSubClass; 00155 uint8_t bDeviceProtocol; 00156 uint8_t bMaxPacketSize0; 00157 uint16_t idVendor; 00158 uint16_t idProduct; 00159 uint16_t bcdDevice; 00160 uint8_t iManufacturer; 00161 uint8_t iProduct; 00162 uint8_t iSerialNumber; 00163 uint8_t bNumConfigurations; 00164 } USB_DEVICE_DESCRIPTOR; 00165 00166 /* USB 2.0 Device Qualifier Descriptor */ 00167 typedef __packed struct _USB_DEVICE_QUALIFIER_DESCRIPTOR { 00168 uint8_t bLength; 00169 uint8_t bDescriptorType; 00170 uint16_t bcdUSB; 00171 uint8_t bDeviceClass; 00172 uint8_t bDeviceSubClass; 00173 uint8_t bDeviceProtocol; 00174 uint8_t bMaxPacketSize0; 00175 uint8_t bNumConfigurations; 00176 uint8_t bReserved; 00177 } USB_DEVICE_QUALIFIER_DESCRIPTOR; 00178 00179 /* USB Standard Configuration Descriptor */ 00180 typedef __packed struct _USB_CONFIGURATION_DESCRIPTOR { 00181 uint8_t bLength; 00182 uint8_t bDescriptorType; 00183 uint16_t wTotalLength; 00184 uint8_t bNumInterfaces; 00185 uint8_t bConfigurationValue; 00186 uint8_t iConfiguration; 00187 uint8_t bmAttributes; 00188 uint8_t bMaxPower; 00189 } USB_CONFIGURATION_DESCRIPTOR; 00190 00191 /* USB Standard Interface Descriptor */ 00192 typedef __packed struct _USB_INTERFACE_DESCRIPTOR { 00193 uint8_t bLength; 00194 uint8_t bDescriptorType; 00195 uint8_t bInterfaceNumber; 00196 uint8_t bAlternateSetting; 00197 uint8_t bNumEndpoints; 00198 uint8_t bInterfaceClass; 00199 uint8_t bInterfaceSubClass; 00200 uint8_t bInterfaceProtocol; 00201 uint8_t iInterface; 00202 } USB_INTERFACE_DESCRIPTOR; 00203 00204 /* USB Standard Endpoint Descriptor */ 00205 typedef __packed struct _USB_ENDPOINT_DESCRIPTOR { 00206 uint8_t bLength; 00207 uint8_t bDescriptorType; 00208 uint8_t bEndpointAddress; 00209 uint8_t bmAttributes; 00210 uint16_t wMaxPacketSize; 00211 uint8_t bInterval; 00212 } USB_ENDPOINT_DESCRIPTOR; 00213 00214 /* USB String Descriptor */ 00215 typedef __packed struct _USB_STRING_DESCRIPTOR { 00216 uint8_t bLength; 00217 uint8_t bDescriptorType; 00218 uint16_t bString/*[]*/; 00219 } USB_STRING_DESCRIPTOR; 00220 00221 /* USB Common Descriptor */ 00222 typedef __packed struct _USB_COMMON_DESCRIPTOR { 00223 uint8_t bLength; 00224 uint8_t bDescriptorType; 00225 } USB_COMMON_DESCRIPTOR; 00226 00227 00228 #endif /* __USB_H__ */
Generated on Thu Jul 14 2022 04:45:41 by
1.7.2