1 //***************************************************************************** 2 // 3 // usb.h - Prototypes for the USB Interface Driver. 4 // 5 // Copyright (c) 2007-2011 Texas Instruments Incorporated. All rights reserved. 6 // Software License Agreement 7 // 8 // Texas Instruments (TI) is supplying this software for use solely and 9 // exclusively on TI's microcontroller products. The software is owned by 10 // TI and/or its suppliers, and is protected under applicable copyright 11 // laws. You may not combine this software with "viral" open-source 12 // software in order to form a larger program. 13 // 14 // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. 15 // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT 16 // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY 18 // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL 19 // DAMAGES, FOR ANY REASON WHATSOEVER. 20 // 21 // This is part of revision 8264 of the Stellaris Peripheral Driver Library. 22 // 23 //***************************************************************************** 24 25 #ifndef __USB_H__ 26 #define __USB_H__ 27 28 //***************************************************************************** 29 // 30 // If building with a C++ compiler, make all of the definitions in this header 31 // have a C binding. 32 // 33 //***************************************************************************** 34 #ifdef __cplusplus 35 extern "C" 36 { 37 #endif 38 39 //***************************************************************************** 40 // 41 // The following are values that can be passed to USBIntEnableControl() and 42 // USBIntDisableControl() as the ulFlags parameter, and are returned from 43 // USBIntStatusControl(). 44 // 45 //***************************************************************************** 46 #define USB_INTCTRL_ALL 0x000003FF // All control interrupt sources 47 #define USB_INTCTRL_STATUS 0x000000FF // Status Interrupts 48 #define USB_INTCTRL_VBUS_ERR 0x00000080 // VBUS Error 49 #define USB_INTCTRL_SESSION 0x00000040 // Session Start Detected 50 #define USB_INTCTRL_SESSION_END 0x00000040 // Session End Detected 51 #define USB_INTCTRL_DISCONNECT 0x00000020 // Disconnect Detected 52 #define USB_INTCTRL_CONNECT 0x00000010 // Device Connect Detected 53 #define USB_INTCTRL_SOF 0x00000008 // Start of Frame Detected 54 #define USB_INTCTRL_BABBLE 0x00000004 // Babble signaled 55 #define USB_INTCTRL_RESET 0x00000004 // Reset signaled 56 #define USB_INTCTRL_RESUME 0x00000002 // Resume detected 57 #define USB_INTCTRL_SUSPEND 0x00000001 // Suspend detected 58 #define USB_INTCTRL_MODE_DETECT 0x00000200 // Mode value valid 59 #define USB_INTCTRL_POWER_FAULT 0x00000100 // Power Fault detected 60 61 //***************************************************************************** 62 // 63 // The following are values that can be passed to USBIntEnableEndpoint() and 64 // USBIntDisableEndpoint() as the ulFlags parameter, and are returned from 65 // USBIntStatusEndpoint(). 66 // 67 //***************************************************************************** 68 #define USB_INTEP_ALL 0xFFFFFFFF // Host IN Interrupts 69 #define USB_INTEP_HOST_IN 0xFFFE0000 // Host IN Interrupts 70 #define USB_INTEP_HOST_IN_15 0x80000000 // Endpoint 15 Host IN Interrupt 71 #define USB_INTEP_HOST_IN_14 0x40000000 // Endpoint 14 Host IN Interrupt 72 #define USB_INTEP_HOST_IN_13 0x20000000 // Endpoint 13 Host IN Interrupt 73 #define USB_INTEP_HOST_IN_12 0x10000000 // Endpoint 12 Host IN Interrupt 74 #define USB_INTEP_HOST_IN_11 0x08000000 // Endpoint 11 Host IN Interrupt 75 #define USB_INTEP_HOST_IN_10 0x04000000 // Endpoint 10 Host IN Interrupt 76 #define USB_INTEP_HOST_IN_9 0x02000000 // Endpoint 9 Host IN Interrupt 77 #define USB_INTEP_HOST_IN_8 0x01000000 // Endpoint 8 Host IN Interrupt 78 #define USB_INTEP_HOST_IN_7 0x00800000 // Endpoint 7 Host IN Interrupt 79 #define USB_INTEP_HOST_IN_6 0x00400000 // Endpoint 6 Host IN Interrupt 80 #define USB_INTEP_HOST_IN_5 0x00200000 // Endpoint 5 Host IN Interrupt 81 #define USB_INTEP_HOST_IN_4 0x00100000 // Endpoint 4 Host IN Interrupt 82 #define USB_INTEP_HOST_IN_3 0x00080000 // Endpoint 3 Host IN Interrupt 83 #define USB_INTEP_HOST_IN_2 0x00040000 // Endpoint 2 Host IN Interrupt 84 #define USB_INTEP_HOST_IN_1 0x00020000 // Endpoint 1 Host IN Interrupt 85 86 #define USB_INTEP_DEV_OUT 0xFFFE0000 // Device OUT Interrupts 87 #define USB_INTEP_DEV_OUT_15 0x80000000 // Endpoint 15 Device OUT Interrupt 88 #define USB_INTEP_DEV_OUT_14 0x40000000 // Endpoint 14 Device OUT Interrupt 89 #define USB_INTEP_DEV_OUT_13 0x20000000 // Endpoint 13 Device OUT Interrupt 90 #define USB_INTEP_DEV_OUT_12 0x10000000 // Endpoint 12 Device OUT Interrupt 91 #define USB_INTEP_DEV_OUT_11 0x08000000 // Endpoint 11 Device OUT Interrupt 92 #define USB_INTEP_DEV_OUT_10 0x04000000 // Endpoint 10 Device OUT Interrupt 93 #define USB_INTEP_DEV_OUT_9 0x02000000 // Endpoint 9 Device OUT Interrupt 94 #define USB_INTEP_DEV_OUT_8 0x01000000 // Endpoint 8 Device OUT Interrupt 95 #define USB_INTEP_DEV_OUT_7 0x00800000 // Endpoint 7 Device OUT Interrupt 96 #define USB_INTEP_DEV_OUT_6 0x00400000 // Endpoint 6 Device OUT Interrupt 97 #define USB_INTEP_DEV_OUT_5 0x00200000 // Endpoint 5 Device OUT Interrupt 98 #define USB_INTEP_DEV_OUT_4 0x00100000 // Endpoint 4 Device OUT Interrupt 99 #define USB_INTEP_DEV_OUT_3 0x00080000 // Endpoint 3 Device OUT Interrupt 100 #define USB_INTEP_DEV_OUT_2 0x00040000 // Endpoint 2 Device OUT Interrupt 101 #define USB_INTEP_DEV_OUT_1 0x00020000 // Endpoint 1 Device OUT Interrupt 102 103 #define USB_INTEP_HOST_OUT 0x0000FFFE // Host OUT Interrupts 104 #define USB_INTEP_HOST_OUT_15 0x00008000 // Endpoint 15 Host OUT Interrupt 105 #define USB_INTEP_HOST_OUT_14 0x00004000 // Endpoint 14 Host OUT Interrupt 106 #define USB_INTEP_HOST_OUT_13 0x00002000 // Endpoint 13 Host OUT Interrupt 107 #define USB_INTEP_HOST_OUT_12 0x00001000 // Endpoint 12 Host OUT Interrupt 108 #define USB_INTEP_HOST_OUT_11 0x00000800 // Endpoint 11 Host OUT Interrupt 109 #define USB_INTEP_HOST_OUT_10 0x00000400 // Endpoint 10 Host OUT Interrupt 110 #define USB_INTEP_HOST_OUT_9 0x00000200 // Endpoint 9 Host OUT Interrupt 111 #define USB_INTEP_HOST_OUT_8 0x00000100 // Endpoint 8 Host OUT Interrupt 112 #define USB_INTEP_HOST_OUT_7 0x00000080 // Endpoint 7 Host OUT Interrupt 113 #define USB_INTEP_HOST_OUT_6 0x00000040 // Endpoint 6 Host OUT Interrupt 114 #define USB_INTEP_HOST_OUT_5 0x00000020 // Endpoint 5 Host OUT Interrupt 115 #define USB_INTEP_HOST_OUT_4 0x00000010 // Endpoint 4 Host OUT Interrupt 116 #define USB_INTEP_HOST_OUT_3 0x00000008 // Endpoint 3 Host OUT Interrupt 117 #define USB_INTEP_HOST_OUT_2 0x00000004 // Endpoint 2 Host OUT Interrupt 118 #define USB_INTEP_HOST_OUT_1 0x00000002 // Endpoint 1 Host OUT Interrupt 119 120 #define USB_INTEP_DEV_IN 0x0000FFFE // Device IN Interrupts 121 #define USB_INTEP_DEV_IN_15 0x00008000 // Endpoint 15 Device IN Interrupt 122 #define USB_INTEP_DEV_IN_14 0x00004000 // Endpoint 14 Device IN Interrupt 123 #define USB_INTEP_DEV_IN_13 0x00002000 // Endpoint 13 Device IN Interrupt 124 #define USB_INTEP_DEV_IN_12 0x00001000 // Endpoint 12 Device IN Interrupt 125 #define USB_INTEP_DEV_IN_11 0x00000800 // Endpoint 11 Device IN Interrupt 126 #define USB_INTEP_DEV_IN_10 0x00000400 // Endpoint 10 Device IN Interrupt 127 #define USB_INTEP_DEV_IN_9 0x00000200 // Endpoint 9 Device IN Interrupt 128 #define USB_INTEP_DEV_IN_8 0x00000100 // Endpoint 8 Device IN Interrupt 129 #define USB_INTEP_DEV_IN_7 0x00000080 // Endpoint 7 Device IN Interrupt 130 #define USB_INTEP_DEV_IN_6 0x00000040 // Endpoint 6 Device IN Interrupt 131 #define USB_INTEP_DEV_IN_5 0x00000020 // Endpoint 5 Device IN Interrupt 132 #define USB_INTEP_DEV_IN_4 0x00000010 // Endpoint 4 Device IN Interrupt 133 #define USB_INTEP_DEV_IN_3 0x00000008 // Endpoint 3 Device IN Interrupt 134 #define USB_INTEP_DEV_IN_2 0x00000004 // Endpoint 2 Device IN Interrupt 135 #define USB_INTEP_DEV_IN_1 0x00000002 // Endpoint 1 Device IN Interrupt 136 137 #define USB_INTEP_0 0x00000001 // Endpoint 0 Interrupt 138 139 //***************************************************************************** 140 // 141 // The following are values that are returned from USBSpeedGet(). 142 // 143 //***************************************************************************** 144 #define USB_UNDEF_SPEED 0x80000000 // Current speed is undefined 145 #define USB_FULL_SPEED 0x00000001 // Current speed is Full Speed 146 #define USB_LOW_SPEED 0x00000000 // Current speed is Low Speed 147 148 //***************************************************************************** 149 // 150 // The following are values that are returned from USBEndpointStatus(). The 151 // USB_HOST_* values are used when the USB controller is in host mode and the 152 // USB_DEV_* values are used when the USB controller is in device mode. 153 // 154 //***************************************************************************** 155 #define USB_HOST_IN_STATUS 0xFFFF0000 // Mask of all host IN interrupts 156 #define USB_HOST_IN_PID_ERROR 0x01000000 // Stall on this endpoint received 157 #define USB_HOST_IN_NOT_COMP 0x00100000 // Device failed to respond 158 #define USB_HOST_IN_STALL 0x00400000 // Stall on this endpoint received 159 #define USB_HOST_IN_DATA_ERROR 0x00080000 // CRC or bit-stuff error 160 // (ISOC Mode) 161 #define USB_HOST_IN_NAK_TO 0x00080000 // NAK received for more than the 162 // specified timeout period 163 #define USB_HOST_IN_ERROR 0x00040000 // Failed to communicate with a 164 // device 165 #define USB_HOST_IN_FIFO_FULL 0x00020000 // RX FIFO full 166 #define USB_HOST_IN_PKTRDY 0x00010000 // Data packet ready 167 #define USB_HOST_OUT_STATUS 0x0000FFFF // Mask of all host OUT interrupts 168 #define USB_HOST_OUT_NAK_TO 0x00000080 // NAK received for more than the 169 // specified timeout period 170 #define USB_HOST_OUT_NOT_COMP 0x00000080 // No response from device 171 // (ISOC mode) 172 #define USB_HOST_OUT_STALL 0x00000020 // Stall on this endpoint received 173 #define USB_HOST_OUT_ERROR 0x00000004 // Failed to communicate with a 174 // device 175 #define USB_HOST_OUT_FIFO_NE 0x00000002 // TX FIFO is not empty 176 #define USB_HOST_OUT_PKTPEND 0x00000001 // Transmit still being transmitted 177 #define USB_HOST_EP0_NAK_TO 0x00000080 // NAK received for more than the 178 // specified timeout period 179 #define USB_HOST_EP0_STATUS 0x00000040 // This was a status packet 180 #define USB_HOST_EP0_ERROR 0x00000010 // Failed to communicate with a 181 // device 182 #define USB_HOST_EP0_RX_STALL 0x00000004 // Stall on this endpoint received 183 #define USB_HOST_EP0_RXPKTRDY 0x00000001 // Receive data packet ready 184 #define USB_DEV_RX_SENT_STALL 0x00400000 // Stall was sent on this endpoint 185 #define USB_DEV_RX_DATA_ERROR 0x00080000 // CRC error on the data 186 #define USB_DEV_RX_OVERRUN 0x00040000 // OUT packet was not loaded due to 187 // a full FIFO 188 #define USB_DEV_RX_FIFO_FULL 0x00020000 // RX FIFO full 189 #define USB_DEV_RX_PKT_RDY 0x00010000 // Data packet ready 190 #define USB_DEV_TX_NOT_COMP 0x00000080 // Large packet split up, more data 191 // to come 192 #define USB_DEV_TX_SENT_STALL 0x00000020 // Stall was sent on this endpoint 193 #define USB_DEV_TX_UNDERRUN 0x00000004 // IN received with no data ready 194 #define USB_DEV_TX_FIFO_NE 0x00000002 // The TX FIFO is not empty 195 #define USB_DEV_TX_TXPKTRDY 0x00000001 // Transmit still being transmitted 196 #define USB_DEV_EP0_SETUP_END 0x00000010 // Control transaction ended before 197 // Data End seen 198 #define USB_DEV_EP0_SENT_STALL 0x00000004 // Stall was sent on this endpoint 199 #define USB_DEV_EP0_IN_PKTPEND 0x00000002 // Transmit data packet pending 200 #define USB_DEV_EP0_OUT_PKTRDY 0x00000001 // Receive data packet ready 201 202 //***************************************************************************** 203 // 204 // The following are values that can be passed to USBHostEndpointConfig() and 205 // USBDevEndpointConfigSet() as the ulFlags parameter. 206 // 207 //***************************************************************************** 208 #define USB_EP_AUTO_SET 0x00000001 // Auto set feature enabled 209 #define USB_EP_AUTO_REQUEST 0x00000002 // Auto request feature enabled 210 #define USB_EP_AUTO_CLEAR 0x00000004 // Auto clear feature enabled 211 #define USB_EP_DMA_MODE_0 0x00000008 // Enable DMA access using mode 0 212 #define USB_EP_DMA_MODE_1 0x00000010 // Enable DMA access using mode 1 213 #define USB_EP_MODE_ISOC 0x00000000 // Isochronous endpoint 214 #define USB_EP_MODE_BULK 0x00000100 // Bulk endpoint 215 #define USB_EP_MODE_INT 0x00000200 // Interrupt endpoint 216 #define USB_EP_MODE_CTRL 0x00000300 // Control endpoint 217 #define USB_EP_MODE_MASK 0x00000300 // Mode Mask 218 #define USB_EP_SPEED_LOW 0x00000000 // Low Speed 219 #define USB_EP_SPEED_FULL 0x00001000 // Full Speed 220 #define USB_EP_HOST_IN 0x00000000 // Host IN endpoint 221 #define USB_EP_HOST_OUT 0x00002000 // Host OUT endpoint 222 #define USB_EP_DEV_IN 0x00002000 // Device IN endpoint 223 #define USB_EP_DEV_OUT 0x00000000 // Device OUT endpoint 224 225 //***************************************************************************** 226 // 227 // The following are values that can be passed to USBHostPwrConfig() as 228 // the ulFlags parameter. 229 // 230 //***************************************************************************** 231 #define USB_HOST_PWRFLT_LOW 0x00000010 232 #define USB_HOST_PWRFLT_HIGH 0x00000030 233 #define USB_HOST_PWRFLT_EP_NONE 0x00000000 234 #define USB_HOST_PWRFLT_EP_TRI 0x00000140 235 #define USB_HOST_PWRFLT_EP_LOW 0x00000240 236 #define USB_HOST_PWRFLT_EP_HIGH 0x00000340 237 #ifndef DEPRECATED 238 #define USB_HOST_PWREN_LOW 0x00000002 239 #define USB_HOST_PWREN_HIGH 0x00000003 240 #define USB_HOST_PWREN_VBLOW 0x00000002 241 #define USB_HOST_PWREN_VBHIGH 0x00000003 242 #endif 243 #define USB_HOST_PWREN_MAN_LOW 0x00000000 244 #define USB_HOST_PWREN_MAN_HIGH 0x00000001 245 #define USB_HOST_PWREN_AUTOLOW 0x00000002 246 #define USB_HOST_PWREN_AUTOHIGH 0x00000003 247 #define USB_HOST_PWREN_FILTER 0x00010000 248 249 //***************************************************************************** 250 // 251 // The following are special values that can be passed to 252 // USBHostEndpointConfig() as the ulNAKPollInterval parameter. 253 // 254 //***************************************************************************** 255 #define MAX_NAK_LIMIT 31 // Maximum NAK interval 256 #define DISABLE_NAK_LIMIT 0 // No NAK timeouts 257 258 //***************************************************************************** 259 // 260 // This value specifies the maximum size of transfers on endpoint 0 as 64 261 // bytes. This value is fixed in hardware as the FIFO size for endpoint 0. 262 // 263 //***************************************************************************** 264 #define MAX_PACKET_SIZE_EP0 64 265 266 //***************************************************************************** 267 // 268 // These values are used to indicate which endpoint to access. 269 // 270 //***************************************************************************** 271 #define USB_EP_0 0x00000000 // Endpoint 0 272 #define USB_EP_1 0x00000010 // Endpoint 1 273 #define USB_EP_2 0x00000020 // Endpoint 2 274 #define USB_EP_3 0x00000030 // Endpoint 3 275 #define USB_EP_4 0x00000040 // Endpoint 4 276 #define USB_EP_5 0x00000050 // Endpoint 5 277 #define USB_EP_6 0x00000060 // Endpoint 6 278 #define USB_EP_7 0x00000070 // Endpoint 7 279 #define USB_EP_8 0x00000080 // Endpoint 8 280 #define USB_EP_9 0x00000090 // Endpoint 9 281 #define USB_EP_10 0x000000A0 // Endpoint 10 282 #define USB_EP_11 0x000000B0 // Endpoint 11 283 #define USB_EP_12 0x000000C0 // Endpoint 12 284 #define USB_EP_13 0x000000D0 // Endpoint 13 285 #define USB_EP_14 0x000000E0 // Endpoint 14 286 #define USB_EP_15 0x000000F0 // Endpoint 15 287 #define NUM_USB_EP 16 // Number of supported endpoints 288 289 //***************************************************************************** 290 // 291 // These macros allow conversion between 0-based endpoint indices and the 292 // USB_EP_x values required when calling various USB APIs. 293 // 294 //***************************************************************************** 295 #define INDEX_TO_USB_EP(x) ((x) << 4) 296 #define USB_EP_TO_INDEX(x) ((x) >> 4) 297 298 //***************************************************************************** 299 // 300 // The following are values that can be passed to USBFIFOConfigSet() as the 301 // ulFIFOSize parameter. 302 // 303 //***************************************************************************** 304 #define USB_FIFO_SZ_8 0x00000000 // 8 byte FIFO 305 #define USB_FIFO_SZ_16 0x00000001 // 16 byte FIFO 306 #define USB_FIFO_SZ_32 0x00000002 // 32 byte FIFO 307 #define USB_FIFO_SZ_64 0x00000003 // 64 byte FIFO 308 #define USB_FIFO_SZ_128 0x00000004 // 128 byte FIFO 309 #define USB_FIFO_SZ_256 0x00000005 // 256 byte FIFO 310 #define USB_FIFO_SZ_512 0x00000006 // 512 byte FIFO 311 #define USB_FIFO_SZ_1024 0x00000007 // 1024 byte FIFO 312 #define USB_FIFO_SZ_2048 0x00000008 // 2048 byte FIFO 313 #define USB_FIFO_SZ_4096 0x00000009 // 4096 byte FIFO 314 #define USB_FIFO_SZ_8_DB 0x00000010 // 8 byte double buffered FIFO 315 // (occupying 16 bytes) 316 #define USB_FIFO_SZ_16_DB 0x00000011 // 16 byte double buffered FIFO 317 // (occupying 32 bytes) 318 #define USB_FIFO_SZ_32_DB 0x00000012 // 32 byte double buffered FIFO 319 // (occupying 64 bytes) 320 #define USB_FIFO_SZ_64_DB 0x00000013 // 64 byte double buffered FIFO 321 // (occupying 128 bytes) 322 #define USB_FIFO_SZ_128_DB 0x00000014 // 128 byte double buffered FIFO 323 // (occupying 256 bytes) 324 #define USB_FIFO_SZ_256_DB 0x00000015 // 256 byte double buffered FIFO 325 // (occupying 512 bytes) 326 #define USB_FIFO_SZ_512_DB 0x00000016 // 512 byte double buffered FIFO 327 // (occupying 1024 bytes) 328 #define USB_FIFO_SZ_1024_DB 0x00000017 // 1024 byte double buffered FIFO 329 // (occupying 2048 bytes) 330 #define USB_FIFO_SZ_2048_DB 0x00000018 // 2048 byte double buffered FIFO 331 // (occupying 4096 bytes) 332 333 //***************************************************************************** 334 // 335 // This macro allow conversion from a FIFO size label as defined above to 336 // a number of bytes 337 // 338 //***************************************************************************** 339 #define USB_FIFO_SIZE_DB_FLAG 0x00000010 340 #define USB_FIFO_SZ_TO_BYTES(x) ((8 << ((x) & ~ USB_FIFO_SIZE_DB_FLAG)) * \ 341 (((x) & USB_FIFO_SIZE_DB_FLAG) ? 2 : 1)) 342 343 //***************************************************************************** 344 // 345 // The following are values that can be passed to USBEndpointDataSend() as the 346 // ulTransType parameter. 347 // 348 //***************************************************************************** 349 #define USB_TRANS_OUT 0x00000102 // Normal OUT transaction 350 #define USB_TRANS_IN 0x00000102 // Normal IN transaction 351 #define USB_TRANS_IN_LAST 0x0000010a // Final IN transaction (for 352 // endpoint 0 in device mode) 353 #define USB_TRANS_SETUP 0x0000110a // Setup transaction (for endpoint 354 // 0) 355 #define USB_TRANS_STATUS 0x00000142 // Status transaction (for endpoint 356 // 0) 357 358 //***************************************************************************** 359 // 360 // The following are values are returned by the USBModeGet function. 361 // 362 //***************************************************************************** 363 #define USB_DUAL_MODE_HOST 0x00000001 // Dual mode controller is in Host 364 // mode. 365 #define USB_DUAL_MODE_DEVICE 0x00000081 // Dual mode controller is in 366 // Device mode. 367 #define USB_DUAL_MODE_NONE 0x00000080 // Dual mode controller mode is not 368 // set. 369 #define USB_OTG_MODE_ASIDE_HOST 0x0000001d // OTG controller on the A side of 370 // the cable. 371 #define USB_OTG_MODE_ASIDE_NPWR 0x00000001 // OTG controller on the A side of 372 // the cable. 373 #define USB_OTG_MODE_ASIDE_SESS 0x00000009 // OTG controller on the A side of 374 // the cable Session Valid. 375 #define USB_OTG_MODE_ASIDE_AVAL 0x00000011 // OTG controller on the A side of 376 // the cable A valid. 377 #define USB_OTG_MODE_ASIDE_DEV 0x00000019 // OTG controller on the A side of 378 // the cable. 379 #define USB_OTG_MODE_BSIDE_HOST 0x0000009d // OTG controller on the B side of 380 // the cable. 381 #define USB_OTG_MODE_BSIDE_DEV 0x00000099 // OTG controller on the B side of 382 // the cable. 383 #define USB_OTG_MODE_BSIDE_NPWR 0x00000081 // OTG controller on the B side of 384 // the cable. 385 #define USB_OTG_MODE_NONE 0x00000080 // OTG controller mode is not set. 386 387 //***************************************************************************** 388 // 389 // Prototypes for the APIs. 390 // 391 //***************************************************************************** 392 extern unsigned long USBDevAddrGet(unsigned long ulBase); 393 extern void USBDevAddrSet(unsigned long ulBase, unsigned long ulAddress); 394 extern void USBDevConnect(unsigned long ulBase); 395 extern void USBDevDisconnect(unsigned long ulBase); 396 extern void USBDevEndpointConfigSet(unsigned long ulBase, 397 unsigned long ulEndpoint, 398 unsigned long ulMaxPacketSize, 399 unsigned long ulFlags); 400 extern void USBDevEndpointConfigGet(unsigned long ulBase, 401 unsigned long ulEndpoint, 402 unsigned long *pulMaxPacketSize, 403 unsigned long *pulFlags); 404 extern void USBDevEndpointDataAck(unsigned long ulBase, 405 unsigned long ulEndpoint, 406 tBoolean bIsLastPacket); 407 extern void USBDevEndpointStall(unsigned long ulBase, unsigned long ulEndpoint, 408 unsigned long ulFlags); 409 extern void USBDevEndpointStallClear(unsigned long ulBase, 410 unsigned long ulEndpoint, 411 unsigned long ulFlags); 412 extern void USBDevEndpointStatusClear(unsigned long ulBase, 413 unsigned long ulEndpoint, 414 unsigned long ulFlags); 415 extern unsigned long USBEndpointDataAvail(unsigned long ulBase, 416 unsigned long ulEndpoint); 417 extern void USBEndpointDMAEnable(unsigned long ulBase, unsigned long ulEndpoint, 418 unsigned long ulFlags); 419 extern void USBEndpointDMADisable(unsigned long ulBase, 420 unsigned long ulEndpoint, 421 unsigned long ulFlags); 422 extern long USBEndpointDataGet(unsigned long ulBase, unsigned long ulEndpoint, 423 unsigned char *pucData, unsigned long *pulSize); 424 extern long USBEndpointDataPut(unsigned long ulBase, unsigned long ulEndpoint, 425 unsigned char *pucData, unsigned long ulSize); 426 extern long USBEndpointDataSend(unsigned long ulBase, unsigned long ulEndpoint, 427 unsigned long ulTransType); 428 extern void USBEndpointDataToggleClear(unsigned long ulBase, 429 unsigned long ulEndpoint, 430 unsigned long ulFlags); 431 extern unsigned long USBEndpointStatus(unsigned long ulBase, 432 unsigned long ulEndpoint); 433 extern unsigned long USBFIFOAddrGet(unsigned long ulBase, 434 unsigned long ulEndpoint); 435 extern void USBFIFOConfigGet(unsigned long ulBase, unsigned long ulEndpoint, 436 unsigned long *pulFIFOAddress, 437 unsigned long *pulFIFOSize, 438 unsigned long ulFlags); 439 extern void USBFIFOConfigSet(unsigned long ulBase, unsigned long ulEndpoint, 440 unsigned long ulFIFOAddress, 441 unsigned long ulFIFOSize, unsigned long ulFlags); 442 extern void USBFIFOFlush(unsigned long ulBase, unsigned long ulEndpoint, 443 unsigned long ulFlags); 444 extern unsigned long USBFrameNumberGet(unsigned long ulBase); 445 extern unsigned long USBHostAddrGet(unsigned long ulBase, 446 unsigned long ulEndpoint, 447 unsigned long ulFlags); 448 extern void USBHostAddrSet(unsigned long ulBase, unsigned long ulEndpoint, 449 unsigned long ulAddr, unsigned long ulFlags); 450 extern void USBHostEndpointConfig(unsigned long ulBase, 451 unsigned long ulEndpoint, 452 unsigned long ulMaxPacketSize, 453 unsigned long ulNAKPollInterval, 454 unsigned long ulTargetEndpoint, 455 unsigned long ulFlags); 456 extern void USBHostEndpointDataAck(unsigned long ulBase, 457 unsigned long ulEndpoint); 458 extern void USBHostEndpointDataToggle(unsigned long ulBase, 459 unsigned long ulEndpoint, 460 tBoolean bDataToggle, 461 unsigned long ulFlags); 462 extern void USBHostEndpointStatusClear(unsigned long ulBase, 463 unsigned long ulEndpoint, 464 unsigned long ulFlags); 465 extern unsigned long USBHostHubAddrGet(unsigned long ulBase, 466 unsigned long ulEndpoint, 467 unsigned long ulFlags); 468 extern void USBHostHubAddrSet(unsigned long ulBase, unsigned long ulEndpoint, 469 unsigned long ulAddr, unsigned long ulFlags); 470 extern void USBHostPwrDisable(unsigned long ulBase); 471 extern void USBHostPwrEnable(unsigned long ulBase); 472 extern void USBHostPwrConfig(unsigned long ulBase, unsigned long ulFlags); 473 #ifndef DEPRECATED 474 #define USBHostPwrFaultConfig USBHostPwrConfig 475 #endif 476 extern void USBHostPwrFaultDisable(unsigned long ulBase); 477 extern void USBHostPwrFaultEnable(unsigned long ulBase); 478 extern void USBHostRequestIN(unsigned long ulBase, unsigned long ulEndpoint); 479 extern void USBHostRequestINClear(unsigned long ulBase, 480 unsigned long ulEndpoint); 481 extern void USBHostRequestStatus(unsigned long ulBase); 482 extern void USBHostReset(unsigned long ulBase, tBoolean bStart); 483 extern void USBHostResume(unsigned long ulBase, tBoolean bStart); 484 extern unsigned long USBHostSpeedGet(unsigned long ulBase); 485 extern void USBHostSuspend(unsigned long ulBase); 486 extern void USBIntDisableControl(unsigned long ulBase, 487 unsigned long ulIntFlags); 488 extern void USBIntEnableControl(unsigned long ulBase, 489 unsigned long ulIntFlags); 490 extern unsigned long USBIntStatusControl(unsigned long ulBase); 491 extern void USBIntDisableEndpoint(unsigned long ulBase, 492 unsigned long ulIntFlags); 493 extern void USBIntEnableEndpoint(unsigned long ulBase, 494 unsigned long ulIntFlags); 495 extern unsigned long USBIntStatusEndpoint(unsigned long ulBase); 496 extern void USBIntRegister(unsigned long ulBase, void(*pfnHandler)(void)); 497 extern void USBIntUnregister(unsigned long ulBase); 498 extern void USBOTGSessionRequest(unsigned long ulBase, tBoolean bStart); 499 extern unsigned long USBModeGet(unsigned long ulBase); 500 extern void USBEndpointDMAChannel(unsigned long ulBase, 501 unsigned long ulEndpoint, 502 unsigned long ulChannel); 503 extern void USBHostMode(unsigned long ulBase); 504 extern void USBDevMode(unsigned long ulBase); 505 extern void USBOTGMode(unsigned long ulBase); 506 extern void USBPHYPowerOff(unsigned long ulBase); 507 extern void USBPHYPowerOn(unsigned long ulBase); 508 509 //***************************************************************************** 510 // 511 // Several USB APIs have been renamed, with the original function name being 512 // deprecated. These defines and function protypes provide backward 513 // compatibility. 514 // 515 //***************************************************************************** 516 #ifndef DEPRECATED 517 //***************************************************************************** 518 // 519 // The following are values that can be passed to USBIntEnable() and 520 // USBIntDisable() as the ulIntFlags parameter, and are returned from 521 // USBIntStatus(). 522 // 523 //***************************************************************************** 524 #define USB_INT_ALL 0xFF030E0F // All Interrupt sources 525 #define USB_INT_STATUS 0xFF000000 // Status Interrupts 526 #define USB_INT_VBUS_ERR 0x80000000 // VBUS Error 527 #define USB_INT_SESSION_START 0x40000000 // Session Start Detected 528 #define USB_INT_SESSION_END 0x20000000 // Session End Detected 529 #define USB_INT_DISCONNECT 0x20000000 // Disconnect Detected 530 #define USB_INT_CONNECT 0x10000000 // Device Connect Detected 531 #define USB_INT_SOF 0x08000000 // Start of Frame Detected 532 #define USB_INT_BABBLE 0x04000000 // Babble signaled 533 #define USB_INT_RESET 0x04000000 // Reset signaled 534 #define USB_INT_RESUME 0x02000000 // Resume detected 535 #define USB_INT_SUSPEND 0x01000000 // Suspend detected 536 #define USB_INT_MODE_DETECT 0x00020000 // Mode value valid 537 #define USB_INT_POWER_FAULT 0x00010000 // Power Fault detected 538 #define USB_INT_HOST_IN 0x00000E00 // Host IN Interrupts 539 #define USB_INT_DEV_OUT 0x00000E00 // Device OUT Interrupts 540 #define USB_INT_HOST_IN_EP3 0x00000800 // Endpoint 3 Host IN Interrupt 541 #define USB_INT_HOST_IN_EP2 0x00000400 // Endpoint 2 Host IN Interrupt 542 #define USB_INT_HOST_IN_EP1 0x00000200 // Endpoint 1 Host IN Interrupt 543 #define USB_INT_DEV_OUT_EP3 0x00000800 // Endpoint 3 Device OUT Interrupt 544 #define USB_INT_DEV_OUT_EP2 0x00000400 // Endpoint 2 Device OUT Interrupt 545 #define USB_INT_DEV_OUT_EP1 0x00000200 // Endpoint 1 Device OUT Interrupt 546 #define USB_INT_HOST_OUT 0x0000000E // Host OUT Interrupts 547 #define USB_INT_DEV_IN 0x0000000E // Device IN Interrupts 548 #define USB_INT_HOST_OUT_EP3 0x00000008 // Endpoint 3 HOST_OUT Interrupt 549 #define USB_INT_HOST_OUT_EP2 0x00000004 // Endpoint 2 HOST_OUT Interrupt 550 #define USB_INT_HOST_OUT_EP1 0x00000002 // Endpoint 1 HOST_OUT Interrupt 551 #define USB_INT_DEV_IN_EP3 0x00000008 // Endpoint 3 DEV_IN Interrupt 552 #define USB_INT_DEV_IN_EP2 0x00000004 // Endpoint 2 DEV_IN Interrupt 553 #define USB_INT_DEV_IN_EP1 0x00000002 // Endpoint 1 DEV_IN Interrupt 554 #define USB_INT_EP0 0x00000001 // Endpoint 0 Interrupt 555 556 #define USBDevEndpointConfig USBDevEndpointConfigSet 557 extern void USBIntDisable(unsigned long ulBase, unsigned long ulIntFlags); 558 extern void USBIntEnable(unsigned long ulBase, unsigned long ulIntFlags); 559 extern unsigned long USBIntStatus(unsigned long ulBase); 560 #endif 561 562 //***************************************************************************** 563 // 564 // Mark the end of the C bindings section for C++ compilers. 565 // 566 //***************************************************************************** 567 #ifdef __cplusplus 568 } 569 #endif 570 571 #endif // __USB_H__ 572