usb.h 32 KB

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