usb.h 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. //*****************************************************************************
  2. //
  3. // usb.h - Prototypes for the USB Interface Driver.
  4. //
  5. // Copyright (c) 2007-2020 Texas Instruments Incorporated. All rights reserved.
  6. // Software License Agreement
  7. //
  8. // Redistribution and use in source and binary forms, with or without
  9. // modification, are permitted provided that the following conditions
  10. // are met:
  11. //
  12. // Redistributions of source code must retain the above copyright
  13. // notice, this list of conditions and the following disclaimer.
  14. //
  15. // Redistributions in binary form must reproduce the above copyright
  16. // notice, this list of conditions and the following disclaimer in the
  17. // documentation and/or other materials provided with the
  18. // distribution.
  19. //
  20. // Neither the name of Texas Instruments Incorporated nor the names of
  21. // its 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. // This is part of revision 2.2.0.295 of the Tiva Peripheral Driver Library.
  37. //
  38. //*****************************************************************************
  39. #ifndef __DRIVERLIB_USB_H__
  40. #define __DRIVERLIB_USB_H__
  41. //*****************************************************************************
  42. //
  43. // If building with a C++ compiler, make all of the definitions in this header
  44. // have a C binding.
  45. //
  46. //*****************************************************************************
  47. #ifdef __cplusplus
  48. extern "C"
  49. {
  50. #endif
  51. //*****************************************************************************
  52. //
  53. // The following are values that can be passed to USBIntEnableControl() and
  54. // USBIntDisableControl() as the ui32Flags parameter, and are returned from
  55. // USBIntStatusControl().
  56. //
  57. //*****************************************************************************
  58. #define USB_INTCTRL_ALL 0x000003FF // All control interrupt sources
  59. #define USB_INTCTRL_STATUS 0x000000FF // Status Interrupts
  60. #define USB_INTCTRL_VBUS_ERR 0x00000080 // VBUS Error
  61. #define USB_INTCTRL_SESSION 0x00000040 // Session Start Detected
  62. #define USB_INTCTRL_SESSION_END 0x00000040 // Session End Detected
  63. #define USB_INTCTRL_DISCONNECT 0x00000020 // Disconnect Detected
  64. #define USB_INTCTRL_CONNECT 0x00000010 // Device Connect Detected
  65. #define USB_INTCTRL_SOF 0x00000008 // Start of Frame Detected
  66. #define USB_INTCTRL_BABBLE 0x00000004 // Babble signaled
  67. #define USB_INTCTRL_RESET 0x00000004 // Reset signaled
  68. #define USB_INTCTRL_RESUME 0x00000002 // Resume detected
  69. #define USB_INTCTRL_SUSPEND 0x00000001 // Suspend detected
  70. #define USB_INTCTRL_MODE_DETECT 0x00000200 // Mode value valid
  71. #define USB_INTCTRL_POWER_FAULT 0x00000100 // Power Fault detected
  72. //*****************************************************************************
  73. //
  74. // The following are values that can be passed to USBIntEnableEndpoint() and
  75. // USBIntDisableEndpoint() as the ui32Flags parameter, and are returned from
  76. // USBIntStatusEndpoint().
  77. //
  78. //*****************************************************************************
  79. #define USB_INTEP_ALL 0xFFFFFFFF // Host IN Interrupts
  80. #define USB_INTEP_HOST_IN 0xFFFE0000 // Host IN Interrupts
  81. #define USB_INTEP_HOST_IN_15 0x80000000 // Endpoint 15 Host IN Interrupt
  82. #define USB_INTEP_HOST_IN_14 0x40000000 // Endpoint 14 Host IN Interrupt
  83. #define USB_INTEP_HOST_IN_13 0x20000000 // Endpoint 13 Host IN Interrupt
  84. #define USB_INTEP_HOST_IN_12 0x10000000 // Endpoint 12 Host IN Interrupt
  85. #define USB_INTEP_HOST_IN_11 0x08000000 // Endpoint 11 Host IN Interrupt
  86. #define USB_INTEP_HOST_IN_10 0x04000000 // Endpoint 10 Host IN Interrupt
  87. #define USB_INTEP_HOST_IN_9 0x02000000 // Endpoint 9 Host IN Interrupt
  88. #define USB_INTEP_HOST_IN_8 0x01000000 // Endpoint 8 Host IN Interrupt
  89. #define USB_INTEP_HOST_IN_7 0x00800000 // Endpoint 7 Host IN Interrupt
  90. #define USB_INTEP_HOST_IN_6 0x00400000 // Endpoint 6 Host IN Interrupt
  91. #define USB_INTEP_HOST_IN_5 0x00200000 // Endpoint 5 Host IN Interrupt
  92. #define USB_INTEP_HOST_IN_4 0x00100000 // Endpoint 4 Host IN Interrupt
  93. #define USB_INTEP_HOST_IN_3 0x00080000 // Endpoint 3 Host IN Interrupt
  94. #define USB_INTEP_HOST_IN_2 0x00040000 // Endpoint 2 Host IN Interrupt
  95. #define USB_INTEP_HOST_IN_1 0x00020000 // Endpoint 1 Host IN Interrupt
  96. #define USB_INTEP_DEV_OUT 0xFFFE0000 // Device OUT Interrupts
  97. #define USB_INTEP_DEV_OUT_15 0x80000000 // Endpoint 15 Device OUT Interrupt
  98. #define USB_INTEP_DEV_OUT_14 0x40000000 // Endpoint 14 Device OUT Interrupt
  99. #define USB_INTEP_DEV_OUT_13 0x20000000 // Endpoint 13 Device OUT Interrupt
  100. #define USB_INTEP_DEV_OUT_12 0x10000000 // Endpoint 12 Device OUT Interrupt
  101. #define USB_INTEP_DEV_OUT_11 0x08000000 // Endpoint 11 Device OUT Interrupt
  102. #define USB_INTEP_DEV_OUT_10 0x04000000 // Endpoint 10 Device OUT Interrupt
  103. #define USB_INTEP_DEV_OUT_9 0x02000000 // Endpoint 9 Device OUT Interrupt
  104. #define USB_INTEP_DEV_OUT_8 0x01000000 // Endpoint 8 Device OUT Interrupt
  105. #define USB_INTEP_DEV_OUT_7 0x00800000 // Endpoint 7 Device OUT Interrupt
  106. #define USB_INTEP_DEV_OUT_6 0x00400000 // Endpoint 6 Device OUT Interrupt
  107. #define USB_INTEP_DEV_OUT_5 0x00200000 // Endpoint 5 Device OUT Interrupt
  108. #define USB_INTEP_DEV_OUT_4 0x00100000 // Endpoint 4 Device OUT Interrupt
  109. #define USB_INTEP_DEV_OUT_3 0x00080000 // Endpoint 3 Device OUT Interrupt
  110. #define USB_INTEP_DEV_OUT_2 0x00040000 // Endpoint 2 Device OUT Interrupt
  111. #define USB_INTEP_DEV_OUT_1 0x00020000 // Endpoint 1 Device OUT Interrupt
  112. #define USB_INTEP_HOST_OUT 0x0000FFFE // Host OUT Interrupts
  113. #define USB_INTEP_HOST_OUT_15 0x00008000 // Endpoint 15 Host OUT Interrupt
  114. #define USB_INTEP_HOST_OUT_14 0x00004000 // Endpoint 14 Host OUT Interrupt
  115. #define USB_INTEP_HOST_OUT_13 0x00002000 // Endpoint 13 Host OUT Interrupt
  116. #define USB_INTEP_HOST_OUT_12 0x00001000 // Endpoint 12 Host OUT Interrupt
  117. #define USB_INTEP_HOST_OUT_11 0x00000800 // Endpoint 11 Host OUT Interrupt
  118. #define USB_INTEP_HOST_OUT_10 0x00000400 // Endpoint 10 Host OUT Interrupt
  119. #define USB_INTEP_HOST_OUT_9 0x00000200 // Endpoint 9 Host OUT Interrupt
  120. #define USB_INTEP_HOST_OUT_8 0x00000100 // Endpoint 8 Host OUT Interrupt
  121. #define USB_INTEP_HOST_OUT_7 0x00000080 // Endpoint 7 Host OUT Interrupt
  122. #define USB_INTEP_HOST_OUT_6 0x00000040 // Endpoint 6 Host OUT Interrupt
  123. #define USB_INTEP_HOST_OUT_5 0x00000020 // Endpoint 5 Host OUT Interrupt
  124. #define USB_INTEP_HOST_OUT_4 0x00000010 // Endpoint 4 Host OUT Interrupt
  125. #define USB_INTEP_HOST_OUT_3 0x00000008 // Endpoint 3 Host OUT Interrupt
  126. #define USB_INTEP_HOST_OUT_2 0x00000004 // Endpoint 2 Host OUT Interrupt
  127. #define USB_INTEP_HOST_OUT_1 0x00000002 // Endpoint 1 Host OUT Interrupt
  128. #define USB_INTEP_DEV_IN 0x0000FFFE // Device IN Interrupts
  129. #define USB_INTEP_DEV_IN_15 0x00008000 // Endpoint 15 Device IN Interrupt
  130. #define USB_INTEP_DEV_IN_14 0x00004000 // Endpoint 14 Device IN Interrupt
  131. #define USB_INTEP_DEV_IN_13 0x00002000 // Endpoint 13 Device IN Interrupt
  132. #define USB_INTEP_DEV_IN_12 0x00001000 // Endpoint 12 Device IN Interrupt
  133. #define USB_INTEP_DEV_IN_11 0x00000800 // Endpoint 11 Device IN Interrupt
  134. #define USB_INTEP_DEV_IN_10 0x00000400 // Endpoint 10 Device IN Interrupt
  135. #define USB_INTEP_DEV_IN_9 0x00000200 // Endpoint 9 Device IN Interrupt
  136. #define USB_INTEP_DEV_IN_8 0x00000100 // Endpoint 8 Device IN Interrupt
  137. #define USB_INTEP_DEV_IN_7 0x00000080 // Endpoint 7 Device IN Interrupt
  138. #define USB_INTEP_DEV_IN_6 0x00000040 // Endpoint 6 Device IN Interrupt
  139. #define USB_INTEP_DEV_IN_5 0x00000020 // Endpoint 5 Device IN Interrupt
  140. #define USB_INTEP_DEV_IN_4 0x00000010 // Endpoint 4 Device IN Interrupt
  141. #define USB_INTEP_DEV_IN_3 0x00000008 // Endpoint 3 Device IN Interrupt
  142. #define USB_INTEP_DEV_IN_2 0x00000004 // Endpoint 2 Device IN Interrupt
  143. #define USB_INTEP_DEV_IN_1 0x00000002 // Endpoint 1 Device IN Interrupt
  144. #define USB_INTEP_0 0x00000001 // Endpoint 0 Interrupt
  145. //*****************************************************************************
  146. //
  147. // The following are values that are returned from USBSpeedGet().
  148. //
  149. //*****************************************************************************
  150. #define USB_UNDEF_SPEED 0x80000000 // Current speed is undefined
  151. #define USB_HIGH_SPEED 0x00000002 // Current speed is High Speed
  152. #define USB_FULL_SPEED 0x00000001 // Current speed is Full Speed
  153. #define USB_LOW_SPEED 0x00000000 // Current speed is Low Speed
  154. //*****************************************************************************
  155. //
  156. // The following are values that are returned from USBEndpointStatus(). The
  157. // USB_HOST_* values are used when the USB controller is in host mode and the
  158. // USB_DEV_* values are used when the USB controller is in device mode.
  159. //
  160. //*****************************************************************************
  161. #define USB_HOST_IN_STATUS 0x114F0000 // Mask of all host IN interrupts
  162. #define USB_HOST_IN_PID_ERROR 0x10000000 // Stall on this endpoint received
  163. #define USB_HOST_IN_NOT_COMP 0x01000000 // Device failed to respond
  164. #define USB_HOST_IN_STALL 0x00400000 // Stall on this endpoint received
  165. #define USB_HOST_IN_DATA_ERROR 0x00080000 // CRC or bit-stuff error
  166. // (ISOC Mode)
  167. #define USB_HOST_IN_NAK_TO 0x00080000 // NAK received for more than the
  168. // specified timeout period
  169. #define USB_HOST_IN_ERROR 0x00040000 // Failed to communicate with a
  170. // device
  171. #define USB_HOST_IN_FIFO_FULL 0x00020000 // RX FIFO full
  172. #define USB_HOST_IN_PKTRDY 0x00010000 // Data packet ready
  173. #define USB_HOST_OUT_STATUS 0x000000A7 // Mask of all host OUT interrupts
  174. #define USB_HOST_OUT_NAK_TO 0x00000080 // NAK received for more than the
  175. // specified timeout period
  176. #define USB_HOST_OUT_NOT_COMP 0x00000080 // No response from device
  177. // (ISOC mode)
  178. #define USB_HOST_OUT_STALL 0x00000020 // Stall on this endpoint received
  179. #define USB_HOST_OUT_ERROR 0x00000004 // Failed to communicate with a
  180. // device
  181. #define USB_HOST_OUT_FIFO_NE 0x00000002 // TX FIFO is not empty
  182. #define USB_HOST_OUT_PKTPEND 0x00000001 // Transmit still being transmitted
  183. #define USB_HOST_EP0_NAK_TO 0x00000080 // NAK received for more than the
  184. // specified timeout period
  185. #define USB_HOST_EP0_STATUS 0x00000040 // This was a status packet
  186. #define USB_HOST_EP0_ERROR 0x00000010 // Failed to communicate with a
  187. // device
  188. #define USB_HOST_EP0_RX_STALL 0x00000004 // Stall on this endpoint received
  189. #define USB_HOST_EP0_RXPKTRDY 0x00000001 // Receive data packet ready
  190. #define USB_DEV_RX_PID_ERROR 0x01000000 // PID error in isochronous
  191. // transfer
  192. #define USB_DEV_RX_SENT_STALL 0x00400000 // Stall was sent on this endpoint
  193. #define USB_DEV_RX_DATA_ERROR 0x00080000 // CRC error on the data
  194. #define USB_DEV_RX_OVERRUN 0x00040000 // OUT packet was not loaded due to
  195. // a full FIFO
  196. #define USB_DEV_RX_FIFO_FULL 0x00020000 // RX FIFO full
  197. #define USB_DEV_RX_PKT_RDY 0x00010000 // Data packet ready
  198. #define USB_DEV_TX_NOT_COMP 0x00000080 // Large packet split up, more data
  199. // to come
  200. #define USB_DEV_TX_SENT_STALL 0x00000020 // Stall was sent on this endpoint
  201. #define USB_DEV_TX_UNDERRUN 0x00000004 // IN received with no data ready
  202. #define USB_DEV_TX_FIFO_NE 0x00000002 // The TX FIFO is not empty
  203. #define USB_DEV_TX_TXPKTRDY 0x00000001 // Transmit still being transmitted
  204. #define USB_DEV_EP0_SETUP_END 0x00000010 // Control transaction ended before
  205. // Data End seen
  206. #define USB_DEV_EP0_SENT_STALL 0x00000004 // Stall was sent on this endpoint
  207. #define USB_DEV_EP0_IN_PKTPEND 0x00000002 // Transmit data packet pending
  208. #define USB_DEV_EP0_OUT_PKTRDY 0x00000001 // Receive data packet ready
  209. //*****************************************************************************
  210. //
  211. // The following are values that can be passed to USBHostEndpointConfig() and
  212. // USBDevEndpointConfigSet() as the ui32Flags parameter.
  213. //
  214. //*****************************************************************************
  215. #define USB_EP_AUTO_SET 0x00000001 // Auto set feature enabled
  216. #define USB_EP_AUTO_REQUEST 0x00000002 // Auto request feature enabled
  217. #define USB_EP_AUTO_CLEAR 0x00000004 // Auto clear feature enabled
  218. #define USB_EP_DMA_MODE_0 0x00000008 // Enable DMA access using mode 0
  219. #define USB_EP_DMA_MODE_1 0x00000010 // Enable DMA access using mode 1
  220. #define USB_EP_DIS_NYET 0x00000020 // Disable NYET response for
  221. // high-speed Bulk and Interrupt
  222. // endpoints in device mode.
  223. #define USB_EP_MODE_ISOC 0x00000000 // Isochronous endpoint
  224. #define USB_EP_MODE_BULK 0x00000100 // Bulk endpoint
  225. #define USB_EP_MODE_INT 0x00000200 // Interrupt endpoint
  226. #define USB_EP_MODE_CTRL 0x00000300 // Control endpoint
  227. #define USB_EP_MODE_MASK 0x00000300 // Mode Mask
  228. #define USB_EP_SPEED_LOW 0x00000000 // Low Speed
  229. #define USB_EP_SPEED_FULL 0x00001000 // Full Speed
  230. #define USB_EP_SPEED_HIGH 0x00004000 // High Speed
  231. #define USB_EP_HOST_IN 0x00000000 // Host IN endpoint
  232. #define USB_EP_HOST_OUT 0x00002000 // Host OUT endpoint
  233. #define USB_EP_DEV_IN 0x00002000 // Device IN endpoint
  234. #define USB_EP_DEV_OUT 0x00000000 // Device OUT endpoint
  235. //*****************************************************************************
  236. //
  237. // The following are values that can be passed to USBHostPwrConfig() as the
  238. // ui32Flags parameter.
  239. //
  240. //*****************************************************************************
  241. #define USB_HOST_PWRFLT_LOW 0x00000010
  242. #define USB_HOST_PWRFLT_HIGH 0x00000030
  243. #define USB_HOST_PWRFLT_EP_NONE 0x00000000
  244. #define USB_HOST_PWRFLT_EP_TRI 0x00000140
  245. #define USB_HOST_PWRFLT_EP_LOW 0x00000240
  246. #define USB_HOST_PWRFLT_EP_HIGH 0x00000340
  247. #define USB_HOST_PWREN_MAN_LOW 0x00000000
  248. #define USB_HOST_PWREN_MAN_HIGH 0x00000001
  249. #define USB_HOST_PWREN_AUTOLOW 0x00000002
  250. #define USB_HOST_PWREN_AUTOHIGH 0x00000003
  251. #define USB_HOST_PWREN_FILTER 0x00010000
  252. //*****************************************************************************
  253. //
  254. // The following are the valid values that can be passed to the
  255. // USBHostLPMConfig() function in the ui32Config parameter.
  256. //
  257. //*****************************************************************************
  258. #define USB_HOST_LPM_RMTWAKE 0x00000100
  259. #define USB_HOST_LPM_L1 0x00000001
  260. //*****************************************************************************
  261. //
  262. // The following are the valid values that can be passed to the
  263. // USBDevLPMConfig() function in the ui32Config parameter.
  264. //
  265. //*****************************************************************************
  266. #define USB_DEV_LPM_NAK 0x00000010
  267. #define USB_DEV_LPM_NONE 0x00000000
  268. #define USB_DEV_LPM_EN 0x0000000c
  269. #define USB_DEV_LPM_EXTONLY 0x00000004
  270. //*****************************************************************************
  271. //
  272. // The following are the valid values that are returned from the
  273. // USBLPMLinkStateGet() function.
  274. //
  275. //*****************************************************************************
  276. #define USB_DEV_LPM_LS_RMTWAKE 0x00000100
  277. #define USB_DEV_LPM_LS_L1 0x00000001
  278. //*****************************************************************************
  279. //
  280. // The following are the valid values that are passed to the USBLPMIntEnable()
  281. // or USBLPMIntDisable() functions or are returned from the USBLPMIntStatus()
  282. // function.
  283. //
  284. //*****************************************************************************
  285. #define USB_INTLPM_ERROR 0x00000020
  286. #define USB_INTLPM_RESUME 0x00000010
  287. #define USB_INTLPM_INCOMPLETE 0x00000008
  288. #define USB_INTLPM_ACK 0x00000004
  289. #define USB_INTLPM_NYET 0x00000002
  290. #define USB_INTLPM_STALL 0x00000001
  291. //*****************************************************************************
  292. //
  293. // The following are the valid values that are passed to the USBClockEnable()
  294. // functions.
  295. //
  296. //*****************************************************************************
  297. #define USB_CLOCK_INTERNAL 0x00000200
  298. #define USB_CLOCK_EXTERNAL 0x00000300
  299. //*****************************************************************************
  300. //
  301. // The configuration options used with the USBULPIConfig() API.
  302. //
  303. //*****************************************************************************
  304. #define USB_ULPI_EXTVBUS 0x00000001
  305. #define USB_ULPI_EXTVBUS_IND 0x00000002
  306. //*****************************************************************************
  307. //
  308. // The following are special values that can be passed to
  309. // USBHostEndpointConfig() as the ui32NAKPollInterval parameter.
  310. //
  311. //*****************************************************************************
  312. #define MAX_NAK_LIMIT 31 // Maximum NAK interval
  313. #define DISABLE_NAK_LIMIT 0 // No NAK timeouts
  314. //*****************************************************************************
  315. //
  316. // This value specifies the maximum size of transfers on endpoint 0 as 64
  317. // bytes. This value is fixed in hardware as the FIFO size for endpoint 0.
  318. //
  319. //*****************************************************************************
  320. #define MAX_PACKET_SIZE_EP0 64
  321. //*****************************************************************************
  322. //
  323. // These values are used to indicate which endpoint to access.
  324. //
  325. //*****************************************************************************
  326. #define USB_EP_0 0x00000000 // Endpoint 0
  327. #define USB_EP_1 0x00000010 // Endpoint 1
  328. #define USB_EP_2 0x00000020 // Endpoint 2
  329. #define USB_EP_3 0x00000030 // Endpoint 3
  330. #define USB_EP_4 0x00000040 // Endpoint 4
  331. #define USB_EP_5 0x00000050 // Endpoint 5
  332. #define USB_EP_6 0x00000060 // Endpoint 6
  333. #define USB_EP_7 0x00000070 // Endpoint 7
  334. #define NUM_USB_EP 8 // Number of supported endpoints
  335. //*****************************************************************************
  336. //
  337. // These macros allow conversion between 0-based endpoint indices and the
  338. // USB_EP_x values required when calling various USB APIs.
  339. //
  340. //*****************************************************************************
  341. #define IndexToUSBEP(x) ((x) << 4)
  342. #define USBEPToIndex(x) ((x) >> 4)
  343. //*****************************************************************************
  344. //
  345. // The following are values that can be passed to USBFIFOConfigSet() as the
  346. // ui32FIFOSize parameter.
  347. //
  348. //*****************************************************************************
  349. #define USB_FIFO_SZ_8 0x00000000 // 8 byte FIFO
  350. #define USB_FIFO_SZ_16 0x00000001 // 16 byte FIFO
  351. #define USB_FIFO_SZ_32 0x00000002 // 32 byte FIFO
  352. #define USB_FIFO_SZ_64 0x00000003 // 64 byte FIFO
  353. #define USB_FIFO_SZ_128 0x00000004 // 128 byte FIFO
  354. #define USB_FIFO_SZ_256 0x00000005 // 256 byte FIFO
  355. #define USB_FIFO_SZ_512 0x00000006 // 512 byte FIFO
  356. #define USB_FIFO_SZ_1024 0x00000007 // 1024 byte FIFO
  357. #define USB_FIFO_SZ_2048 0x00000008 // 2048 byte FIFO
  358. //*****************************************************************************
  359. //
  360. // This macro allow conversion from a FIFO size label as defined above to
  361. // a number of bytes
  362. //
  363. //*****************************************************************************
  364. #define USBFIFOSizeToBytes(x) (8 << (x))
  365. //*****************************************************************************
  366. //
  367. // The following are values that can be passed to USBEndpointDataSend() as the
  368. // ui32TransType parameter.
  369. //
  370. //*****************************************************************************
  371. #define USB_TRANS_OUT 0x00000102 // Normal OUT transaction
  372. #define USB_TRANS_IN 0x00000102 // Normal IN transaction
  373. #define USB_TRANS_IN_LAST 0x0000010a // Final IN transaction (for
  374. // endpoint 0 in device mode)
  375. #define USB_TRANS_SETUP 0x0000110a // Setup transaction (for endpoint
  376. // 0)
  377. #define USB_TRANS_STATUS 0x00000142 // Status transaction (for endpoint
  378. // 0)
  379. //*****************************************************************************
  380. //
  381. // The following are values are returned by the USBModeGet function.
  382. //
  383. //*****************************************************************************
  384. #define USB_DUAL_MODE_HOST 0x00000001 // Dual mode controller is in Host
  385. // mode.
  386. #define USB_DUAL_MODE_DEVICE 0x00000081 // Dual mode controller is in
  387. // Device mode.
  388. #define USB_DUAL_MODE_NONE 0x00000080 // Dual mode controller mode is not
  389. // set.
  390. #define USB_OTG_MODE_ASIDE_HOST 0x0000001d // OTG controller on the A side of
  391. // the cable.
  392. #define USB_OTG_MODE_ASIDE_NPWR 0x00000001 // OTG controller on the A side of
  393. // the cable.
  394. #define USB_OTG_MODE_ASIDE_SESS 0x00000009 // OTG controller on the A side of
  395. // the cable Session Valid.
  396. #define USB_OTG_MODE_ASIDE_AVAL 0x00000011 // OTG controller on the A side of
  397. // the cable A valid.
  398. #define USB_OTG_MODE_ASIDE_DEV 0x00000019 // OTG controller on the A side of
  399. // the cable.
  400. #define USB_OTG_MODE_BSIDE_HOST 0x0000009d // OTG controller on the B side of
  401. // the cable.
  402. #define USB_OTG_MODE_BSIDE_DEV 0x00000099 // OTG controller on the B side of
  403. // the cable.
  404. #define USB_OTG_MODE_BSIDE_NPWR 0x00000081 // OTG controller on the B side of
  405. // the cable.
  406. #define USB_OTG_MODE_NONE 0x00000080 // OTG controller mode is not set.
  407. //*****************************************************************************
  408. //
  409. // The values for the USBDMAChannelIntEnable() and USBDMAChannelIntStatus()
  410. // APIs.
  411. //
  412. //*****************************************************************************
  413. #define USB_DMA_INT_CH8 0x00000080
  414. #define USB_DMA_INT_CH7 0x00000040
  415. #define USB_DMA_INT_CH6 0x00000020
  416. #define USB_DMA_INT_CH5 0x00000010
  417. #define USB_DMA_INT_CH4 0x00000008
  418. #define USB_DMA_INT_CH3 0x00000004
  419. #define USB_DMA_INT_CH2 0x00000002
  420. #define USB_DMA_INT_CH1 0x00000001
  421. //*****************************************************************************
  422. //
  423. // The values for the USBDMAChannelStatus() API.
  424. //
  425. //*****************************************************************************
  426. #define USB_DMA_STATUS_ERROR 0x00000100
  427. //*****************************************************************************
  428. //
  429. // The valid return values for the USBControllerVersion() API.
  430. //
  431. //*****************************************************************************
  432. #define USB_CONTROLLER_VER_0 0x00000000 // This is for Blizzard class
  433. // devices.
  434. #define USB_CONTROLLER_VER_1 0x00000001 // This is for Snowflake class
  435. // devices.
  436. //*****************************************************************************
  437. //
  438. // The valid return values for the USBDMAModeSet() and USBDMAModeGet() APIs or
  439. // USBDMAChannelConfig().
  440. //
  441. //*****************************************************************************
  442. #define USB_DMA_CFG_BURST_NONE 0x00000000
  443. #define USB_DMA_CFG_BURST_4 0x00000200
  444. #define USB_DMA_CFG_BURST_8 0x00000400
  445. #define USB_DMA_CFG_BURST_16 0x00000600
  446. #define USB_DMA_CFG_INT_EN 0x00000008
  447. #define USB_DMA_CFG_MODE_0 0x00000000
  448. #define USB_DMA_CFG_MODE_1 0x00000004
  449. #define USB_DMA_CFG_DIR_RX 0x00000000
  450. #define USB_DMA_CFG_DIR_TX 0x00000002
  451. #define USB_DMA_CFG_EN 0x00000001
  452. //*****************************************************************************
  453. //
  454. // The following are values that can be passed to USBModeConfig() as the
  455. // ui3Mode parameter.
  456. //
  457. //*****************************************************************************
  458. #define USB_MODE_HOST_VBUS 0x00000004
  459. #define USB_MODE_HOST 0x00000002
  460. #define USB_MODE_DEV_VBUS 0x00000005
  461. #define USB_MODE_DEV 0x00000003
  462. #define USB_MODE_OTG 0x00000000
  463. //*****************************************************************************
  464. //
  465. // Prototypes for the APIs.
  466. //
  467. //*****************************************************************************
  468. extern uint32_t USBDevAddrGet(uint32_t ui32Base);
  469. extern void USBDevAddrSet(uint32_t ui32Base, uint32_t ui32Address);
  470. extern void USBDevConnect(uint32_t ui32Base);
  471. extern void USBDevDisconnect(uint32_t ui32Base);
  472. extern void USBDevEndpointConfigSet(uint32_t ui32Base, uint32_t ui32Endpoint,
  473. uint32_t ui32MaxPacketSize,
  474. uint32_t ui32Flags);
  475. extern void USBDevEndpointConfigGet(uint32_t ui32Base, uint32_t ui32Endpoint,
  476. uint32_t *pui32MaxPacketSize,
  477. uint32_t *pui32Flags);
  478. extern void USBDevEndpointDataAck(uint32_t ui32Base, uint32_t ui32Endpoint,
  479. bool bIsLastPacket);
  480. extern void USBDevEndpointStall(uint32_t ui32Base, uint32_t ui32Endpoint,
  481. uint32_t ui32Flags);
  482. extern void USBDevEndpointStallClear(uint32_t ui32Base, uint32_t ui32Endpoint,
  483. uint32_t ui32Flags);
  484. extern void USBDevEndpointStatusClear(uint32_t ui32Base, uint32_t ui32Endpoint,
  485. uint32_t ui32Flags);
  486. extern uint32_t USBEndpointDataAvail(uint32_t ui32Base, uint32_t ui32Endpoint);
  487. extern void USBEndpointDMAEnable(uint32_t ui32Base, uint32_t ui32Endpoint,
  488. uint32_t ui32Flags);
  489. extern void USBEndpointDMADisable(uint32_t ui32Base, uint32_t ui32Endpoint,
  490. uint32_t ui32Flags);
  491. extern void USBEndpointDMAConfigSet(uint32_t ui32Base, uint32_t ui32Endpoint,
  492. uint32_t ui32Config);
  493. extern int32_t USBEndpointDataGet(uint32_t ui32Base, uint32_t ui32Endpoint,
  494. uint8_t *pui8Data, uint32_t *pui32Size);
  495. extern int32_t USBEndpointDataPut(uint32_t ui32Base, uint32_t ui32Endpoint,
  496. uint8_t *pui8Data, uint32_t ui32Size);
  497. extern int32_t USBEndpointDataSend(uint32_t ui32Base, uint32_t ui32Endpoint,
  498. uint32_t ui32TransType);
  499. extern void USBEndpointDataToggleClear(uint32_t ui32Base,
  500. uint32_t ui32Endpoint,
  501. uint32_t ui32Flags);
  502. extern void USBEndpointPacketCountSet(uint32_t ui32Base, uint32_t ui32Endpoint,
  503. uint32_t ui32Count);
  504. extern uint32_t USBEndpointStatus(uint32_t ui32Base, uint32_t ui32Endpoint);
  505. extern uint32_t USBFIFOAddrGet(uint32_t ui32Base, uint32_t ui32Endpoint);
  506. extern void USBFIFOConfigGet(uint32_t ui32Base, uint32_t ui32Endpoint,
  507. uint32_t *pui32FIFOAddress,
  508. uint32_t *pui32FIFOSize, uint32_t ui32Flags);
  509. extern void USBFIFOConfigSet(uint32_t ui32Base, uint32_t ui32Endpoint,
  510. uint32_t ui32FIFOAddress, uint32_t ui32FIFOSize,
  511. uint32_t ui32Flags);
  512. extern void USBFIFOFlush(uint32_t ui32Base, uint32_t ui32Endpoint,
  513. uint32_t ui32Flags);
  514. extern uint32_t USBFrameNumberGet(uint32_t ui32Base);
  515. extern uint32_t USBHostAddrGet(uint32_t ui32Base, uint32_t ui32Endpoint,
  516. uint32_t ui32Flags);
  517. extern void USBHostAddrSet(uint32_t ui32Base, uint32_t ui32Endpoint,
  518. uint32_t ui32Addr, uint32_t ui32Flags);
  519. extern void USBHostEndpointConfig(uint32_t ui32Base, uint32_t ui32Endpoint,
  520. uint32_t ui32MaxPacketSize,
  521. uint32_t ui32NAKPollInterval,
  522. uint32_t ui32TargetEndpoint,
  523. uint32_t ui32Flags);
  524. extern void USBHostEndpointDataAck(uint32_t ui32Base,
  525. uint32_t ui32Endpoint);
  526. extern void USBHostEndpointDataToggle(uint32_t ui32Base, uint32_t ui32Endpoint,
  527. bool bDataToggle, uint32_t ui32Flags);
  528. extern void USBHostEndpointStatusClear(uint32_t ui32Base,
  529. uint32_t ui32Endpoint,
  530. uint32_t ui32Flags);
  531. extern uint32_t USBHostHubAddrGet(uint32_t ui32Base, uint32_t ui32Endpoint,
  532. uint32_t ui32Flags);
  533. extern void USBHostHubAddrSet(uint32_t ui32Base, uint32_t ui32Endpoint,
  534. uint32_t ui32Addr, uint32_t ui32Flags);
  535. extern void USBHostPwrDisable(uint32_t ui32Base);
  536. extern void USBHostPwrEnable(uint32_t ui32Base);
  537. extern void USBHostPwrConfig(uint32_t ui32Base, uint32_t ui32Flags);
  538. extern void USBHostPwrFaultDisable(uint32_t ui32Base);
  539. extern void USBHostPwrFaultEnable(uint32_t ui32Base);
  540. extern void USBHostRequestIN(uint32_t ui32Base, uint32_t ui32Endpoint);
  541. extern void USBHostRequestINClear(uint32_t ui32Base, uint32_t ui32Endpoint);
  542. extern void USBHostRequestStatus(uint32_t ui32Base);
  543. extern void USBHostReset(uint32_t ui32Base, bool bStart);
  544. extern void USBHostResume(uint32_t ui32Base, bool bStart);
  545. extern uint32_t USBHostSpeedGet(uint32_t ui32Base);
  546. extern void USBHostSuspend(uint32_t ui32Base);
  547. extern void USBIntDisableControl(uint32_t ui32Base, uint32_t ui32IntFlags);
  548. extern void USBIntEnableControl(uint32_t ui32Base, uint32_t ui32IntFlags);
  549. extern uint32_t USBIntStatusControl(uint32_t ui32Base);
  550. extern void USBIntDisableEndpoint(uint32_t ui32Base, uint32_t ui32IntFlags);
  551. extern void USBIntEnableEndpoint(uint32_t ui32Base, uint32_t ui32IntFlags);
  552. extern uint32_t USBIntStatusEndpoint(uint32_t ui32Base);
  553. extern void USBIntRegister(uint32_t ui32Base, void (*pfnHandler)(void));
  554. extern void USBIntUnregister(uint32_t ui32Base);
  555. extern void USBOTGSessionRequest(uint32_t ui32Base, bool bStart);
  556. extern uint32_t USBModeGet(uint32_t ui32Base);
  557. extern void USBEndpointDMAChannel(uint32_t ui32Base, uint32_t ui32Endpoint,
  558. uint32_t ui32Channel);
  559. extern uint32_t USBControllerVersion(uint32_t ui32Base);
  560. extern uint32_t USBDMAChannelIntStatus(uint32_t ui32Base);
  561. extern void USBDMAChannelConfigSet(uint32_t ui32Base, uint32_t ui32Channel,
  562. uint32_t ui32Endpoint, uint32_t ui32Config);
  563. extern void USBDMAChannelAddressSet(uint32_t ui32Base, uint32_t ui32Channel,
  564. void *pvAddress);
  565. extern void *USBDMAChannelAddressGet(uint32_t ui32Base, uint32_t ui32Channel);
  566. extern void USBDMAChannelCountSet(uint32_t ui32Base, uint32_t ui32Count,
  567. uint32_t ui32Channel);
  568. extern uint32_t USBDMAChannelCountGet(uint32_t ui32Base, uint32_t ui32Channel);
  569. extern uint32_t USBDMANumChannels(uint32_t ui32Base);
  570. extern void USBDMAChannelAssign(uint32_t ui32Base, uint32_t ui32Endpoint,
  571. uint32_t ui32Channel, uint32_t ui32Flags);
  572. extern void USBDMAChannelIntEnable(uint32_t ui32Base, uint32_t ui32Channel);
  573. extern void USBDMAChannelIntDisable(uint32_t ui32Base, uint32_t ui32Channel);
  574. extern void USBDMAChannelEnable(uint32_t ui32Base, uint32_t ui32Channel);
  575. extern void USBDMAChannelDisable(uint32_t ui32Base, uint32_t ui32Channel);
  576. extern uint32_t USBDMAChannelStatus(uint32_t ui32Base, uint32_t ui32Channel);
  577. extern void USBDMAChannelStatusClear(uint32_t ui32Base, uint32_t ui32Channel,
  578. uint32_t ui32Status);
  579. extern void USBHostEndpointSpeed(uint32_t ui32Base, uint32_t ui32Endpoint,
  580. uint32_t ui32Flags);
  581. extern void USBHostEndpointPing(uint32_t ui32Base, uint32_t ui32Endpoint,
  582. bool bEnable);
  583. extern void USBHostLPMSend(uint32_t ui32Base, uint32_t ui32Address,
  584. uint32_t uiEndpoint);
  585. extern void USBHostLPMConfig(uint32_t ui32Base, uint32_t ui32ResumeTime,
  586. uint32_t ui32Config);
  587. extern bool USBLPMRemoteWakeEnabled(uint32_t ui32Base);
  588. extern void USBHostLPMResume(uint32_t ui32Base);
  589. extern void USBDevLPMRemoteWake(uint32_t ui32Base);
  590. extern void USBDevLPMConfig(uint32_t ui32Base, uint32_t ui32Config);
  591. extern void USBDevLPMEnable(uint32_t ui32Base);
  592. extern void USBDevLPMDisable(uint32_t ui32Base);
  593. extern uint32_t USBLPMLinkStateGet(uint32_t ui32Base);
  594. extern uint32_t USBLPMEndpointGet(uint32_t ui32Base);
  595. extern uint32_t USBLPMIntStatus(uint32_t ui32Base);
  596. extern void USBLPMIntDisable(uint32_t ui32Base, uint32_t ui32Ints);
  597. extern void USBLPMIntEnable(uint32_t ui32Base, uint32_t ui32Ints);
  598. extern void USBHighSpeed(uint32_t ui32Base, bool bEnable);
  599. extern uint32_t USBDevSpeedGet(uint32_t ui32Base);
  600. extern void USBClockEnable(uint32_t ui32Base, uint32_t ui32Div,
  601. uint32_t ui32Flags);
  602. extern void USBClockDisable(uint32_t ui32Base);
  603. extern void USBULPIConfig(uint32_t ui32Base, uint32_t ui32Config);
  604. extern void USBULPIEnable(uint32_t ui32Base);
  605. extern void USBULPIDisable(uint32_t ui32Base);
  606. extern uint8_t USBULPIRegRead(uint32_t ui32Base, uint8_t ui8Reg);
  607. extern void USBULPIRegWrite(uint32_t ui32Base, uint8_t ui8Reg,
  608. uint8_t ui8Data);
  609. extern void USBHostMode(uint32_t ui32Base);
  610. extern void USBDevMode(uint32_t ui32Base);
  611. extern void USBOTGMode(uint32_t ui32Base);
  612. extern void USBModeConfig(uint32_t ui32Base, uint32_t ui32Mode);
  613. extern void USBPHYPowerOff(uint32_t ui32Base);
  614. extern void USBPHYPowerOn(uint32_t ui32Base);
  615. extern uint32_t USBNumEndpointsGet(uint32_t ui32Base);
  616. //*****************************************************************************
  617. //
  618. // Mark the end of the C bindings section for C++ compilers.
  619. //
  620. //*****************************************************************************
  621. #ifdef __cplusplus
  622. }
  623. #endif
  624. #endif // __DRIVERLIB_USB_H__