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