usb.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. #ifndef USB_H_
  2. #define USB_H_
  3. //*****************************************************************************
  4. //
  5. // These macros allow conversion between 0-based endpoint indices and the
  6. // USB_EP_x values required when calling various USB APIs.
  7. //
  8. //*****************************************************************************
  9. #define INDEX_TO_USB_EP(x) ((x) << 4)
  10. #define USB_EP_TO_INDEX(x) ((x) >> 4)
  11. //*****************************************************************************
  12. //
  13. // The following are values that can be passed to USBFIFOConfigSet() as the
  14. // uFIFOSize parameter.
  15. //
  16. //*****************************************************************************
  17. #define USB_FIFO_SZ_8 0x00000000 // 8 byte FIFO
  18. #define USB_FIFO_SZ_16 0x00000001 // 16 byte FIFO
  19. #define USB_FIFO_SZ_32 0x00000002 // 32 byte FIFO
  20. #define USB_FIFO_SZ_64 0x00000003 // 64 byte FIFO
  21. #define USB_FIFO_SZ_128 0x00000004 // 128 byte FIFO
  22. #define USB_FIFO_SZ_256 0x00000005 // 256 byte FIFO
  23. #define USB_FIFO_SZ_512 0x00000006 // 512 byte FIFO
  24. #define USB_FIFO_SZ_1024 0x00000007 // 1024 byte FIFO
  25. //*****************************************************************************
  26. //
  27. // This macro allow conversion from a FIFO size label as defined above to
  28. // a number of bytes
  29. //
  30. //*****************************************************************************
  31. #define USB_FIFO_SIZE_DB_FLAG 0x00000010
  32. #define USB_FIFO_SZ_TO_BYTES(x) ((8 << ((x) & ~ USB_FIFO_SIZE_DB_FLAG)) * \
  33. (((x) & USB_FIFO_SIZE_DB_FLAG) ? 2 : 1))
  34. //*****************************************************************************
  35. //
  36. //! The maximum number of independent interfaces that any single device
  37. //! implementation can support. Independent interfaces means interface
  38. //! descriptors with different bInterfaceNumber values - several interface
  39. //! descriptors offering different alternative settings but the same interface
  40. //! number count as a single interface.
  41. //
  42. //*****************************************************************************
  43. #define USB_MAX_INTERFACES_PER_DEVICE 8
  44. //*****************************************************************************
  45. //
  46. //! Following macro directives can be used for the configuring the USB device.
  47. //! Note that these directives map directly to the hardware bit definitions and
  48. //! cannot be modified to any other value.
  49. //
  50. //*****************************************************************************
  51. #define USBD_PWR_BUS_PWR (0x0000u) //Device is bus powered
  52. #define USBD_PWR_SELF_PWR (0x0004u) //Device is self powered
  53. #define USBD_DATA_ENDIAN_LITTLE (0x0000u) //Little Endian Data (RM48x)
  54. #define USBD_DATA_ENDIAN_BIG (0x0080u) //Bit Endian Data
  55. #define USBD_DMA_ENDIAN_LITTLE (0x0000u) //DMA is Little Endian
  56. #define USBD_DMA_ENDIAN_BIG (0x0040u) //DMA is Big Endian
  57. //*****************************************************************************
  58. //
  59. //! Following macro directives can be used for the configuring the Endpoints
  60. //! Note that these directives map directly to the hardware bit definitions and
  61. //! cannot be modified to any other value.
  62. //
  63. //*****************************************************************************
  64. #define USBD_EP_DIR_IN (0x0010u) //IN Endpoint
  65. #define USBD_EP_DIR_OUT (0x0000u) //OUT Endpoint
  66. #define USB_EP_DEV_IN USBD_EP_DIR_IN //IN Endpoint
  67. #define USB_EP_DEV_OUT USBD_EP_DIR_OUT //OUT Endpoint
  68. #define USB_TRANS_IN USBD_EP_DIR_IN //IN Endpoint
  69. #define USB_TRANS_OUT USBD_EP_DIR_OUT //OUT Endpoint
  70. #define USB_EP_DIR_IN USBD_EP_DIR_IN
  71. #define USB_EP_DIR_OUT USBD_EP_DIR_OUT
  72. #define USB_TRANS_IN_LAST 0 //Used to indicate the last transaction
  73. //(NOT USED in this port of USB)
  74. #define USBD_TXRX_EP_VALID_VALID (0x8000u) //EP is valid & configured
  75. #define USBD_TXRX_EP_VALID_NOTVALID (0x0000u) //EP is not valid & not configured
  76. #define USBD_TXRX_EP_ISO_ISO (0x0800u) //EP is of ISO type
  77. #define USBD_TXRX_EP_ISO_NONISO (0x0000u) //EP is either Bulk/Interrup/Control
  78. #define USBD_TXRX_EP_DB_ENABLED (0x4000u) //EP has double buffering enabled
  79. // For IN EPs DB should be enabled only in DMA mode */
  80. #define USBD_TXRX_EP_DB_DISABLED (0x0000u) //EP has double buffering disabled
  81. //*****************************************************************************
  82. //
  83. //! Following macro directives are to be used for enabling/disabling interrupts
  84. //! Note that these directives map directly to the hardware bit definitions and
  85. //! cannot be modified to any other value.
  86. //
  87. //*****************************************************************************
  88. #define USBD_INT_EN_SOF_IE (0x0080u) //Start-of-Frame Interrupt
  89. #define USBD_INT_EN_EPN_RX_IE (0x0020u) //Non-EP0 RX Interrupt
  90. #define USBD_INT_EN_EPN_TX_IE (0x0010u) //Non-EP0 TX Interrupt
  91. #define USBD_INT_EN_DS_CHG_IE (0x0008u) //Device State change interrupt
  92. #define USBD_INT_EN_EP0_IE (0x0001u) //EP0 Interrupt
  93. #define USBD_INT_EN_ALL (USBD_IRQ_EN_SOF_IE | \
  94. USBD_IRQ_EN_EPN_RX_IE | \
  95. USBD_IRQ_EN_EPN_TX_IE | \
  96. USBD_IRQ_EN_DS_CHG_IE | \
  97. USBD_IRQ_EN_EP0_IE)
  98. //*****************************************************************************
  99. //
  100. //! Following macro directives are to be used for decoding the interrupt source
  101. //! Note that these directives map directly to the hardware bit definitions and
  102. //! cannot be modified to any other value.
  103. //
  104. //*****************************************************************************
  105. #define USBD_INT_SRC_TXN_DONE (0x0400u) //non-EP0 TX done interrupt
  106. #define USBD_INT_SRC_RXN_CNT (0x0200u) //non-EP0 RX Count
  107. #define USBD_INT_SRC_RXN_EOT (0x0100u) //non-EP0 RX end of transfer
  108. #define USBD_INT_SRC_SOF (0x0080u) //Start-of-frame interrupt
  109. #define USBD_INT_SRC_EPN_RX (0x0020u) //non-EP0 RX interrupt
  110. #define USBD_INT_SRC_EPN_TX (0x0010u) //non-EP0 TX interrupt
  111. #define USBD_INT_SRC_DS_CHG (0x0008u) //Device State change interrupt
  112. #define USBD_INT_SRC_SETUP (0x0004u) //Setup interrupt
  113. #define USBD_INT_SRC_EP0_RX (0x0002u) //EP0 RX Interrupt
  114. #define USBD_INT_SRC_EP0_TX (0x0001u) //EP0 TX Interrupt
  115. //*****************************************************************************
  116. //
  117. // These values are used to indicate which endpoint to access.
  118. //
  119. //*****************************************************************************
  120. #define USB_EP_0 0x00000000 // Endpoint 0
  121. #define USB_EP_1 0x00000010 // Endpoint 1
  122. #define USB_EP_2 0x00000020 // Endpoint 2
  123. #define USB_EP_3 0x00000030 // Endpoint 3
  124. #define USB_EP_4 0x00000040 // Endpoint 4
  125. #define USB_EP_5 0x00000050 // Endpoint 5
  126. #define USB_EP_6 0x00000060 // Endpoint 6
  127. #define USB_EP_7 0x00000070 // Endpoint 7
  128. #define USB_EP_8 0x00000080 // Endpoint 8
  129. #define USB_EP_9 0x00000090 // Endpoint 9
  130. #define USB_EP_10 0x000000A0 // Endpoint 10
  131. #define USB_EP_11 0x000000B0 // Endpoint 11
  132. #define USB_EP_12 0x000000C0 // Endpoint 12
  133. #define USB_EP_13 0x000000D0 // Endpoint 13
  134. #define USB_EP_14 0x000000E0 // Endpoint 14
  135. #define USB_EP_15 0x000000F0 // Endpoint 15
  136. #define NUM_USB_EP 16 // Number of supported endpoints
  137. //*****************************************************************************
  138. //
  139. // The following are values that can be passed to USBHostEndpointConfig() and
  140. // USBDevEndpointConfigSet() as the ulFlags parameter.
  141. //
  142. //*****************************************************************************
  143. #define USB_EP_AUTO_SET 0x00000001u // Auto set feature enabled
  144. #define USB_EP_AUTO_REQUEST 0x00000002u // Auto request feature enabled
  145. #define USB_EP_AUTO_CLEAR 0x00000004u // Auto clear feature enabled
  146. #define USB_EP_DMA_MODE_0 0x00000008u // Enable DMA access using mode 0
  147. #define USB_EP_DMA_MODE_1 0x00000010u // Enable DMA access using mode 1
  148. #define USB_EP_MODE_ISOC 0x00000000u // Isochronous endpoint
  149. #define USB_EP_MODE_BULK 0x00000100u // Bulk endpoint
  150. #define USB_EP_MODE_INT 0x00000200u // Interrupt endpoint
  151. #define USB_EP_MODE_CTRL 0x00000300u // Control endpoint
  152. #define USB_EP_MODE_MASK 0x00000300u // Mode Mask
  153. #define USB_EP_SPEED_LOW 0x00000000u // Low Speed
  154. #define USB_EP_SPEED_FULL 0x00001000u // Full Speed
  155. //*****************************************************************************
  156. //
  157. // The following are values that are returned from USBEndpointStatus(). The
  158. // USB_HOST_* values are used when the USB controller is in host mode and the
  159. // USB_DEV_* values are used when the USB controller is in device mode.
  160. //
  161. //*****************************************************************************
  162. #define USB_DEV_EP0_OUT_PKTRDY 0x00000001u // Receive data packet ready
  163. #define USB_DEV_RX_PKT_RDY 0x00010000u // Data packet ready
  164. #define USB_DEV_TX_TXPKTRDY 0x00000001u
  165. #define USB_DEV_TX_FIFO_NE 0x00000002u
  166. //*****************************************************************************
  167. //
  168. // This value specifies the maximum size of transfers on endpoint 0 as 64
  169. // bytes. This value is fixed in hardware as the FIFO size for endpoint 0.
  170. //
  171. //*****************************************************************************
  172. #define MAX_PACKET_SIZE_EP0 64
  173. //*****************************************************************************
  174. //
  175. // Macros for hardware access, both direct and via the bit-band region.
  176. //
  177. //*****************************************************************************
  178. #define HWREG(x) (*((volatile unsigned int *)(x)))
  179. //*****************************************************************************
  180. //
  181. //! Initialize the USB Device
  182. //!
  183. //! \param ulBase specifies the USB module base address.
  184. //! \param usFlags specifies the bus/self powered and endianness for data & dma.
  185. //! Should be a combination of the following flags
  186. //! USBD_PWR_BUS_PWR or USBD_PWR_SELF_PWR
  187. //! USBD_DATA_ENDIAN_LITTLE or USBD_DATA_ENDIAN_BIG
  188. //! USBD_DMA_ENDIAN_LITTLE or USBD_DMA_ENDIAN_BIG
  189. //! \param usFifoPtr specifies the start of the EP0 FIFO.
  190. //!
  191. //! This function will initialize the USB Device controller specified by the
  192. //! \e ulBase parameter.
  193. //!
  194. //! \return None
  195. //!
  196. //! Note This function does not intiate a device connect (pull ups are
  197. //! not enabled). Also the EP0 is intialized with FIFO size of 64Bytes.
  198. //!
  199. //
  200. //*****************************************************************************
  201. void USBDevInit(uint32 ulBase, uint16 usFlags, uint16 usFifoPtr);
  202. //*****************************************************************************
  203. //
  204. //! Initialize the USB Device's EP0
  205. //!
  206. //! \param ulBase specifies the USB module base address.
  207. //! \param usSize FIFO size. Supported values are USB_FIFO_SZ_8/USB_FIFO_SZ_16/
  208. //! USB_FIFO_SZ_32/USB_FIFO_SZ_64.
  209. //! \param usFifoPtr specifies the start of the EP0 FIFO.
  210. //!
  211. //! This function will initialize the USB Device controller specified by the
  212. //! \e ulBase parameter. The \e uFlags parameter is not used by this
  213. //! implementation.
  214. //!
  215. //! \return None
  216. //!
  217. //
  218. //*****************************************************************************
  219. void USBDevEp0Config(uint32 ulBase, uint16 usSize, uint16 usFifoPtr);
  220. //*****************************************************************************
  221. //
  222. //! Disable control interrupts on a given USB device controller.
  223. //!
  224. //! \param ulBase specifies the USB module base address.
  225. //! \param usFlags specifies which control interrupts to disable.
  226. //!
  227. //! This function will disable the interrupts for the USB device controller
  228. //! specified by the \e ulBase parameter. The \e usFlags parameter specifies
  229. //! which control interrupts to disable. The flags passed in the \e usFlags
  230. //! parameters should be the definitions that start with \b USBD_INT_EN_*
  231. //!
  232. //! \return None.
  233. //
  234. //*****************************************************************************
  235. void USBIntDisable(uint32 ulBase, uint16 usFlags);
  236. //*****************************************************************************
  237. //
  238. //! Enable control interrupts on a given USB device controller.
  239. //!
  240. //! \param ulBase specifies the USB module base address.
  241. //! \param usFlags specifies which control interrupts to enable.
  242. //!
  243. //! This function will enable the control interrupts for the USB device controller
  244. //! specified by the \e ulBase parameter. The \e usFlags parameter specifies
  245. //! which control interrupts to enable. The flags passed in the \e usFlags
  246. //! parameters should be the definitions that start with \b USBD_INT_EN_* and
  247. //! not any other \b USB_INT flags.
  248. //!
  249. //! \return None.
  250. //
  251. //*****************************************************************************
  252. void USBIntEnable(uint32 ulBase, uint16 usFlags);
  253. //*****************************************************************************
  254. //
  255. //! Returns the control interrupt status on a given USB device controller.
  256. //!
  257. //! \param ulBase specifies the USB module base address.
  258. //!
  259. //! This function will read interrupt status for a USB device controller.
  260. //! The bit values returned should be compared against the \b USBD_INT_SRC_*
  261. //! values.
  262. //!
  263. //! \return Returns the status of the control interrupts for a USB device controller.
  264. //
  265. //*****************************************************************************
  266. uint16 USBIntStatus(uint32 ulBase);
  267. //*****************************************************************************
  268. //
  269. //! Stalls the specified endpoint in device mode.
  270. //!
  271. //! \param ulBase specifies the USB module base address.
  272. //! \param usEndpoint specifies the endpoint to stall.
  273. //! \param usFlags specifies whether to stall the IN or OUT endpoint.
  274. //!
  275. //! This function will cause to endpoint number passed in to go into a stall
  276. //! condition. If the \e usFlags parameter is \b USB_EP_DEV_IN then the stall
  277. //! will be issued on the IN portion of this endpoint. If the \e usFlags
  278. //! parameter is \b USB_EP_DEV_OUT then the stall will be issued on the OUT
  279. //! portion of this endpoint.
  280. //!
  281. //! \note This function should only be called in device mode.
  282. //!
  283. //! \return None.
  284. //
  285. //*****************************************************************************
  286. void USBDevEndpointStall(uint32 ulBase, uint16 usEndpoint, uint16 usFlags);
  287. //*****************************************************************************
  288. //
  289. //! Clears the stall condition on the specified endpoint in device mode.
  290. //!
  291. //! \param ulBase specifies the USB module base address.
  292. //! \param usEndpoint specifies which endpoint to remove the stall condition.
  293. //! \param usFlags specifies whether to remove the stall condition from the IN
  294. //! or the OUT portion of this endpoint.
  295. //!
  296. //! This function will cause the endpoint number passed in to exit the stall
  297. //! condition. If the \e usFlags parameter is \b USB_EP_DEV_IN then the stall
  298. //! will be cleared on the IN portion of this endpoint. If the \e usFlags
  299. //! parameter is \b USB_EP_DEV_OUT then the stall will be cleared on the OUT
  300. //! portion of this endpoint.
  301. //!
  302. //! \note This function should only be called in device mode.
  303. //!
  304. //! \return None.
  305. //
  306. //*****************************************************************************
  307. void USBDevEndpointStallClear(uint32 ulBase, uint16 usEndpoint, uint16 usFlags);
  308. //*****************************************************************************
  309. //
  310. //! Connects the USB device controller to the bus in device mode.
  311. //!
  312. //! \param ulBase specifies the USB module base address.
  313. //!
  314. //! This function will cause the soft connect feature of the USB device controller to
  315. //! be enabled. Call USBDisconnect() to remove the USB device from the bus.
  316. //!
  317. //!
  318. //! \return None.
  319. //
  320. //*****************************************************************************
  321. void USBDevConnect(uint32 ulBase);
  322. //*****************************************************************************
  323. //
  324. //! Removes the USB device controller from the bus in device mode.
  325. //!
  326. //! \param ulBase specifies the USB module base address.
  327. //!
  328. //! This function will cause the soft disconnect feature of the USB device controller to
  329. //! remove the device from the USB bus. A call to USBDevConnect() is needed to
  330. //! reconnect to the bus.
  331. //!
  332. //!
  333. //! \return None.
  334. //
  335. //*****************************************************************************
  336. void USBDevDisconnect(uint32 ulBase);
  337. //*****************************************************************************
  338. //
  339. //! Sets the address in device mode.
  340. //!
  341. //! \param ulBase specifies the USB module base address.
  342. //! \param ulAddress is the address to use for a device.
  343. //!
  344. //! This function will set the device address on the USB bus. This address was
  345. //! likely received via a SET ADDRESS command from the host controller.
  346. //!
  347. //! \note This function is not available on this controller. This is maintained
  348. //! for compatibility.
  349. //!
  350. //! \return None.
  351. //
  352. //*****************************************************************************
  353. void USBDevAddrSet(uint32 ulBase, uint32 ulAddress);
  354. //*****************************************************************************
  355. //
  356. //! Determine the number of bytes of data available in a given endpoint's FIFO.
  357. //!
  358. //! \param ulBase specifies the USB module base address.
  359. //! \param usEndpoint is the endpoint to access.
  360. //!
  361. //! This function will return the number of bytes of data currently available
  362. //! in the FIFO for the given receive (OUT) endpoint. It may be used prior to
  363. //! calling USBEndpointDataGet() to determine the size of buffer required to
  364. //! hold the newly-received packet.
  365. //!
  366. //! \return This call will return the number of bytes available in a given
  367. //! endpoint FIFO.
  368. //
  369. //*****************************************************************************
  370. uint16 USBEndpointDataAvail(uint32 ulBase, uint16 usEndpoint);
  371. //*****************************************************************************
  372. //
  373. //! Retrieves data from the given endpoint's FIFO.
  374. //!
  375. //! \param ulBase specifies the USB module base address.
  376. //! \param usEndpoint is the endpoint to access.
  377. //! \param pucData is a pointer to the data area used to return the data from
  378. //! the FIFO.
  379. //! \param pulSize is initially the size of the buffer passed into this call
  380. //! via the \e pucData parameter. It will be set to the amount of data
  381. //! returned in the buffer.
  382. //!
  383. //! This function will return the data from the FIFO for the given endpoint.
  384. //! The \e pulSize parameter should indicate the size of the buffer passed in
  385. //! the \e pulData parameter. The data in the \e pulSize parameter will be
  386. //! changed to match the amount of data returned in the \e pucData parameter.
  387. //! If a zero byte packet was received this call will not return a error but
  388. //! will instead just return a zero in the \e pulSize parameter. The only
  389. //! error case occurs when there is no data packet available.
  390. //!
  391. //! \return This call will return 0, or -1 if no packet was received.
  392. //
  393. //*****************************************************************************
  394. uint32 USBEndpointDataGet(uint32 ulBase, uint16 usEndpoint, uint8 *pucData, uint32 *pulSize);
  395. //*****************************************************************************
  396. //
  397. //! Retrieves the setup packet from EP0 Setup FIFO
  398. //!
  399. //! \param ulBase specifies the USB module base address.
  400. //! \param sPkt Pointer to the data area for storing the setup packet.
  401. //! Atleast 8 bytes should be available.
  402. //! \param pusPktSize On return this contains the size of the setup packet (8Bytes)
  403. //!
  404. //! This function will retrieves the 8Byte long setup packet from the EP0 setup
  405. //! FIFO.
  406. //!
  407. //! \return None.
  408. //
  409. //*****************************************************************************
  410. void USBDevGetSetupPacket (uint32 ulBase, uint8 * sPkt, uint16 * pusPktSize);
  411. //*****************************************************************************
  412. //
  413. //! Acknowledge that data was read from the given endpoint's FIFO in device
  414. //! mode.
  415. //!
  416. //! \param ulBase specifies the USB module base address.
  417. //! \param usEndpoint is the endpoint to access.
  418. //! \param bIsLastPacket This parameter is not used.
  419. //!
  420. //! This function acknowledges that the data was read from the endpoint's FIFO.
  421. //! The \e bIsLastPacket parameter is set to a \b true value if this is the
  422. //! last in a series of data packets on endpoint zero. The \e bIsLastPacket
  423. //! parameter is not used for endpoints other than endpoint zero. This call
  424. //! can be used if processing is required between reading the data and
  425. //! acknowledging that the data has been read.
  426. //!
  427. //!
  428. //! \return None.
  429. //
  430. //*****************************************************************************
  431. void USBDevEndpointDataAck(uint32 ulBase, uint16 usEndpoint, uint8 bIsLastPacket);
  432. //*****************************************************************************
  433. //
  434. //! Puts data into the given endpoint's FIFO.
  435. //!
  436. //! \param ulBase specifies the USB module base address.
  437. //! \param usEndpoint is the endpoint to access.
  438. //! \param pucData is a pointer to the data area used as the source for the
  439. //! data to put into the FIFO.
  440. //! \param ulSize is the amount of data to put into the FIFO.
  441. //!
  442. //! This function will put the data from the \e pucData parameter into the FIFO
  443. //! for this endpoint. If a packet is already pending for transmission then
  444. //! this call will not put any of the data into the FIFO and will return -1.
  445. //! Care should be taken to not write more data than can fit into the FIFO
  446. //! allocated by the call to USBFIFOConfig().
  447. //!
  448. //! \return This call will return 0 on success, or -1 to indicate that the FIFO
  449. //! is in use and cannot be written.
  450. //
  451. //*****************************************************************************
  452. uint32 USBEndpointDataPut(uint32 ulBase, uint16 usEndpoint,uint8 *pucData, uint32 ulSize);
  453. //*****************************************************************************
  454. //
  455. //! Starts the transfer of data from an endpoint's FIFO.
  456. //!
  457. //! \param ulBase specifies the USB module base address.
  458. //! \param usEndpoint is the endpoint to access.
  459. //! \param ulTransType Not used.
  460. //!
  461. //! This function will start the transfer of data from the FIFO for a given
  462. //! endpoint.
  463. //!
  464. //! \return This call will return 0 on success, or -1 if a transmission is
  465. //! already in progress.
  466. //
  467. //*****************************************************************************
  468. uint32 USBEndpointDataSend(uint32 ulBase, uint16 usEndpoint, uint32 ulTransType);
  469. //*****************************************************************************
  470. //
  471. //! Resets the USB Device Controller
  472. //!
  473. //! \param void
  474. //!
  475. //! \return None.
  476. //
  477. //! \note Since the USB Device reset is handled by the host, this is a dummy
  478. //! function & maintained for compatibility purpose.
  479. //
  480. //*****************************************************************************
  481. void USBReset(void);
  482. //*****************************************************************************
  483. //
  484. //! Sets the FIFO configuration for an endpoint.
  485. //!
  486. //! \param ulBase specifies the USB module base address.
  487. //! \param usEndpoint is the endpoint to access.
  488. //! \param uFIFOAddress is the starting address for the FIFO.
  489. //! \param uFIFOSize is the size of the FIFO in bytes.
  490. //! \param uFlags specifies what information to set in the FIFO configuration.
  491. //!
  492. //! This function will set the starting FIFO RAM address and size of the FIFO
  493. //! for a given endpoint. Endpoint zero does not have a dynamically
  494. //! configurable FIFO so this function should not be called for endpoint zero.
  495. //! The \e uFIFOSize parameter should be one of the values in the
  496. //! \b USB_FIFO_SZ_ values. If the endpoint is going to use double buffering
  497. //! it should use the values with the \b _DB at the end of the value. For
  498. //! example, use \b USB_FIFO_SZ_16_DB to configure an endpoint to have a 16
  499. //! byte double buffered FIFO. If a double buffered FIFO is used, then the
  500. //! actual size of the FIFO will be twice the size indicated by the
  501. //! \e uFIFOSize parameter. This means that the \b USB_FIFO_SZ_16_DB value
  502. //! will use 32 bytes of the USB controller's FIFO memory.
  503. //!
  504. //! The \e uFIFOAddress value should be a multiple of 8 bytes and directly
  505. //! indicates the starting address in the USB controller's FIFO RAM. For
  506. //! example, a value of 64 indicates that the FIFO should start 64 bytes into
  507. //! the USB controller's FIFO memory. The \e uFlags value specifies whether
  508. //! the endpoint's OUT or IN FIFO should be configured. If in host mode, use
  509. //! \b USB_EP_HOST_OUT or \b USB_EP_HOST_IN, and if in device mode use
  510. //! \b USB_EP_DEV_OUT or \b USB_EP_DEV_IN.
  511. //!
  512. //! \return None.
  513. //
  514. //*****************************************************************************
  515. void USBFIFOConfigSet(uint32 ulBase, uint32 usEndpoint, uint32 uFIFOAddress, uint32 uFIFOSize, uint16 uFlags);
  516. //*****************************************************************************
  517. //
  518. //! Gets the current configuration for an endpoint.
  519. //!
  520. //! \param ulBase specifies the USB module base address.
  521. //! \param usEndpoint is the endpoint to access.
  522. //! \param pulMaxPacketSize is a pointer which will be written with the
  523. //! maximum packet size for this endpoint.
  524. //! \param puFlags is a pointer which will be written with the current
  525. //! endpoint settings. On entry to the function, this pointer must contain
  526. //! either \b USB_EP_DEV_IN or \b USB_EP_DEV_OUT to indicate whether the IN or
  527. //! OUT endpoint is to be queried.
  528. //!
  529. //! This function will return the basic configuration for an endpoint in device
  530. //! mode. The values returned in \e *pulMaxPacketSize and \e *puFlags are
  531. //! equivalent to the \e ulMaxPacketSize and \e uFlags previously passed to
  532. //! USBDevEndpointConfigSet() for this endpoint.
  533. //!
  534. //! \note This function should only be called in device mode.
  535. //!
  536. //! \return None.
  537. //
  538. //*****************************************************************************
  539. void USBDevEndpointConfigGet(uint32 ulBase, uint16 usEndpoint, uint32*pulMaxPacketSize, uint32*puFlags);
  540. //*****************************************************************************
  541. //
  542. //! Sets the configuration for an endpoint.
  543. //!
  544. //! \param ulBase specifies the USB module base address.
  545. //! \param usEndpoint is the endpoint to access.
  546. //! \param ulMaxPacketSize is the maximum packet size for this endpoint.
  547. //! \param uFlags are used to configure other endpoint settings.
  548. //!
  549. //! This function will set the basic configuration for an endpoint in device
  550. //! mode. Endpoint zero does not have a dynamic configuration, so this
  551. //! function should not be called for endpoint zero. The \e uFlags parameter
  552. //! determines some of the configuration while the other parameters provide the
  553. //! rest.
  554. //!
  555. //! The \b USB_EP_MODE_ flags define what the type is for the given endpoint.
  556. //!
  557. //! - \b USB_EP_MODE_CTRL is a control endpoint.
  558. //! - \b USB_EP_MODE_ISOC is an isochronous endpoint.
  559. //! - \b USB_EP_MODE_BULK is a bulk endpoint.
  560. //! - \b USB_EP_MODE_INT is an interrupt endpoint.
  561. //!
  562. //!
  563. //! \note This function should only be called in device mode.
  564. //!
  565. //! \return None.
  566. //
  567. //*****************************************************************************
  568. void USBDevEndpointConfigSet(uint32 ulBase, uint16 usEndpoint, uint32 ulMaxPacketSize, uint16 uFlags);
  569. void USBDevSetDevCfg(uint32 ulBase);
  570. void USBDevClearDevCfg(uint32 ulBase);
  571. uint16 USBDevGetEPnStat(uint32 ulBase);
  572. void USBDevPullEnableDisable(uint32 ulBase, uint32 ulSet);
  573. void USBIntStatusClear (uint16 uFlag);
  574. uint16 USBDevGetDevStat(uint32 ulBase);
  575. void USBDevCfgUnlock(uint32 ulBase);
  576. void USBDevCfgLock(uint32 ulBase);
  577. #endif /*USB_H_*/