- Main Page
- Modules
- Data Structures
- Files

Functions
USB MUSB Functions
USB

## Functions
CSL_Status | USB_init (CSL_UsbConfig *usbConfig)
CSL_Status | USB_resetDev (CSL_UsbDevNum devNum)
CSL_Status | USB_initEndptObj (CSL_UsbDevNum devNum, pUsbEpHandle hEp, CSL_UsbEpNum epNum, CSL_UsbXferType xferType, Uint16 maxPktSize, Uint16 evMask, CSL_USB_EVENT_ISR fxn)
CSL_UsbEventMask | USB_getEvents (pUsbEpHandle hEp, CSL_Status *status)
CSL_UsbEventMask | USB_peekEvents (pUsbEpHandle hEp, CSL_Status *status)
CSL_Status | USB_getSetupPacket (CSL_UsbDevNum devNum, CSL_UsbSetupStruct *usbSetup, Bool readFromFifo)
CSL_Status | USB_postTransaction (pUsbEpHandle hEp, Uint16 byteCnt, void *data, CSL_UsbIoFlags flags)
CSL_UsbBoolean | USB_isTransactionDone (pUsbEpHandle hEp, CSL_Status *status)
CSL_UsbByteCount | USB_bytesRemaining (pUsbEpHandle hEp, CSL_Status *status)
CSL_Status | USB_stallEndpt (pUsbEpHandle hEp)
CSL_Status | USB_clearEndptStall (pUsbEpHandle hEp)
CSL_UsbBoolean | USB_getEndptStall (pUsbEpHandle hEp, CSL_Status *status)
pUsbEpHandle | USB_epNumToHandle (CSL_UsbDevNum devNum, Uint16 endpt)
CSL_Status | USB_abortTransaction (pUsbEpHandle hEp)
CSL_Status | USB_abortAllTransaction (CSL_UsbDevNum devNum)
CSL_Status | USB_connectDev (CSL_UsbDevNum devNum)
CSL_Status | USB_disconnectDev (CSL_UsbDevNum devNum)
CSL_Status | USB_setRemoteWakeup (CSL_UsbDevNum devNum, CSL_UsbBoolean rmtWkpStat)
CSL_UsbBoolean | USB_getRemoteWakeupStat (CSL_UsbDevNum devNum)
CSL_Status | USB_issueRemoteWakeup (CSL_UsbDevNum devNum, Bool resumeBitVal)
CSL_Status | USB_setDevAddr (CSL_UsbDevNum devNum, Uint16 addr)
CSL_UsbFrameNum | USB_getFrameNo (CSL_UsbDevNum devNum)
CSL_Status | USB_suspendDevice (CSL_UsbDevNum devNum)
CSL_Status | USB_selfwakeup (CSL_UsbDevNum devNum, Uint32 wakeupDelay)
void | USB_initPLL (void)
CSL_Status | USB_setParams (CSL_UsbDevNum devNum, pUsbEpHandle hEpObj[], Uint16 pSofTmrCnt)
WORD | USB_getMaxPower (CSL_UsbDevNum devNum)
void | USB_setFullSpeedMode (Uint16 ep0DataSize)
Uint16 | USB_getDataCountReadFromFifo (pUsbEpHandle hEp)
Uint16 | USB_findFifoSize (Uint16 maxPktSize, CSL_UsbXferType xferType)
CSL_Status | USB_coreEventProcessEp0 (pUsbContext pContext)
static CSL_Status | USB_swapWords (Uint16 *dataBuffer, Uint32 dataLength)
static void | USB_initDma (void)
static CSL_Status | USB_initQueueManager (CSL_UsbHostPktDescr *hpdtx, Uint32 *pLinkingRam)
static void | USB_dmaPopQue (Uint16 queueNum)
static void | USB_dmaRxStart (DWORD dwEndpoint)
static CSL_Status | USB_confDmaRx (CSL_UsbHostPktDescr *hpdrx, Uint32 packetsize, Uint16 *pRxBuffer)
static CSL_Status | USB_confDmaTx (CSL_UsbHostPktDescr *hpdtx, Uint32 packetsize, Uint16 *pTxBuffer, Bool swapWords)
static void | USB_dmaRxStop (DWORD dwEndpoint, Uint16 *pRxBuffer, Uint32 packetsize, Bool swapWords)
static void | USB_dmaTxStart (DWORD dwEndpoint)
static void | USB_dmaTxStop (DWORD dwEndpoint)
static CSL_Status | USB_handleTx (pUsbContext pContext, DWORD dwEndpoint)
static CSL_Status | USB_handleRx (pUsbContext pContext, DWORD dwEndpoint)
static CSL_Status | USB_processEP0Out (pUsbContext pContext)
static CSL_Status | USB_processEP0In (pUsbContext pContext)
static void | USB_handleRxIntr (pUsbContext pContext)
static void | USB_handleTxIntr (pUsbContext pContext)
static Bool | USB_checkSpeed (pUsbContext pContext, CSL_UsbBusSpeed *pBusSpeed)
static void | USB_readEP0Buf (pUsbContext pContext, DWORD *pBuf)
static void | USB_setConfiguration (CSL_UsbDevNum devNum, Uint16 confVal)
static Bool | USB_isValidDataInFifoOut (pUsbEpStatus peps)
static void | USB_flushFifo (DWORD dwEndpoint, Bool fifoDirFlag)

## Function Documentation

CSL_Status USB_abortAllTransaction | ( | CSL_UsbDevNum | devNum | ) |

============================================================================
USB_abortAllTransaction

Description
This function terminates all the data transfer in progress and free up the endpoints to post new data transfer requests.

Arguments

                hEp         Handle to an initialized endpoint object.

Return Value CSL_Status

- CSL_SOK - Returned for success
- CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
USB_postTransaction function should be called successfully

Post Condition
Aborts all transactions in progress

Modifies
USB registers

Example

     			Uint16    dadaBuf[256];

     			pUsbEpHandle    hEp;
                CSL_Status      status;

    			status = USB_postTransaction(hEp, 256, dataBuf, CSL_USB_IOFLAG_NONE);
    			.....
    			.....
    			status = USB_abortAllTransaction(CSL_USB0);

============================================================================

References CSL_USB_ENDPOINT_COUNT, and USB_abortTransaction().

Referenced by AC_Ctrl(), and MSC_Ctrl().

CSL_Status USB_abortTransaction | ( | pUsbEpHandle | hEp | ) |

============================================================================
USB_abortTransaction

Description
This function terminates the data transfer in progress and free up the endpoint to post a new data transfer request.

Arguments

                hEp         Handle to an initialized endpoint object.

Return Value CSL_Status

- CSL_SOK - Returned for success
- CSL_ESYS_BADHANDLE - Invalid end point handle
- CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
USB_postTransaction function should be called successfully

Post Condition
Terminates data transfer in progress

Modifies
USB registers

Example

     			Uint16    dadaBuf[256];

     			pUsbEpHandle    hEp;
                CSL_Status      status;

    			status = USB_postTransaction(hEp, 256, dataBuf, CSL_USB_IOFLAG_NONE);
    			.....
    			.....
    			status = USB_abortTransaction(hEp);

============================================================================

References CSL_USB_EP0, CSL_USB_IN_EP0, CSL_UsbEpStatus::dwEndpoint, CSL_UsbEpObj::epNum, CSL_UsbTransfer::fComplete, CSL_UsbEpStatus::fInitialized, CSL_UsbContext::pEpStatus, CSL_UsbEpStatus::pTransfer, and usbRegisters.

Referenced by MSC_HandleStateReset(), MSC_reqBotMscReset(), and USB_abortAllTransaction().

CSL_UsbByteCount USB_bytesRemaining | ( | pUsbEpHandle | hEp,
|  | CSL_Status * | status
| ) |  |

============================================================================
USB_bytesRemaining

Description
This API returns number of bytes waiting to be transferred from the previously posted data transfer request.

Arguments

                hEp         Handle to an initialized endpoint object.
                status      Status of the function call

Return Value CSL_UsbByteCount
Number of bytes waiting to be transferred

Pre Condition
Post transaction API should be called successfully

Post Condition
1. Returns the number of bytes waiting
2. Function call status is returned in status variable

- CSL_SOK - Returned for success
- CSL_ESYS_BADHANDLE - Invalid end point handle
- CSL_ESYS_INVPARAMS - Invalid parameter

Modifies
status variable

Example

     			void      (*evtHandler)();
     			Uint16    dadaBuf[256];

     			pUsbEpHandle   hEp;
                CSL_Status     status;
                Uint16         byteCount;

                status = USB_initEndptObj(CSL_USB0,
                                          hEp,
                                          CSL_USB_OUT_EP0,
                                          CSL_USB_CTRL,
                                          0x40,
                                          CSL_USB_EVENT_RESET,
                                          evtHandler);

    			status = USB_postTransaction(hEp, 256, dataBuf, CSL_USB_IOFLAG_NONE);
    			...
    			...
    			byteCount = USB_bytesRemaining(hEp ,&status);

============================================================================

References CSL_UsbTransfer::cbBuffer, CSL_UsbTransfer::cbTransferred, CSL_USB_IN_EP0, CSL_UsbEpObj::epNum, CSL_UsbContext::pEpStatus, and CSL_UsbEpStatus::pTransfer.

Referenced by CDC_bulkInHandler(), CDC_bulkOutHandler(), and CDC_putData().

static Bool USB_checkSpeed | ( | pUsbContext | pContext,
|  | CSL_UsbBusSpeed * | pBusSpeed
| ) |  | `[inline, static]`

============================================================================
USB_checkSpeed

Description
This function checks the USB bus speed

Arguments

     	        pContext      -   USB context structure pointer
     	        pBusSpeed     -   USB Bus speed variable pointer

Return Value

- TRUE - Bus speed is valid
- FALSE - Bus speed is invalid

Pre Condition
USB_initEndptObj function should be called successfully

Post Condition
Checks the USB bus speed

Modifies
Bus speed variable

Example

    			void  (*evtHandler)();

    			pUsbEpHandle      hEp;
    			CSL_Status        status;
    			Bool              busSpeedStat;
    			CSL_UsbContext    gUsbContext;
    			CSL_UsbBusSpeed   *pBusSpeed

    			status = USB_initEndptObj(CSL_USB0,
    									  hEp,
    									  CSL_USB_IN_EP0,
    									  CSL_USB_CTRL,
    									  0x40,
    									  CSL_USB_EVENT_RESET,
    									  evtHandler);
    			....
    			....
    			busSpeedStat = USB_checkSpeed(&gUsbContext, &gUsbContext.busSpeed);

============================================================================

References CSL_USB_BS_FULL_SPEED, and CSL_USB_BS_HIGH_SPEED.

Referenced by USB_init().

CSL_Status USB_clearEndptStall | ( | pUsbEpHandle | hEp | ) |

============================================================================
USB_clearEndptStall

Description
This function clears an end point stall

Arguments

                hEp         Handle to an initialized endpoint object.

Return Value CSL_Status

- CSL_SOK - Returned for success
- CSL_ESYS_BADHANDLE - Invalid end point handle
- CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
USB_initEndptObj and USB_stallEndpt should be called successfully

Post Condition
Clears an end point stall

Modifies
USB control registers

Example

      			void      (*evtHandler)();

     			pUsbEpHandle   hEp;
                CSL_Status     status;

                status = USB_initEndptObj(CSL_USB0,
                                          hEp,
                                          CSL_USB_OUT_EP0,
                                          CSL_USB_CTRL,
                                          0x40,
                                          CSL_USB_EVENT_RESET,
                                          evtHandler);

    			....
    			....
    			status = USB_stallEndpt(hEp);
    			....
    			....
    			status = USB_clearEndptStall(hEp);

============================================================================

References CSL_USB_ENDPOINT_COUNT, CSL_USB_EP0, CSL_USB_IN_EP0, CSL_UsbEpStatus::dwEndpoint, CSL_UsbEpObj::epNum, CSL_UsbEpStatus::fInitialized, CSL_UsbEpStatus::fStalled, CSL_UsbContext::pEpStatus, and usbRegisters.

Referenced by AC_reqClearFeature(), CDC_reqClearFeature(), MSC_reqClearFeature(), and USB_coreEventProcessEp0().

static CSL_Status USB_confDmaRx | ( | CSL_UsbHostPktDescr * | hpdrx,
|  | Uint32 | packetsize,
|  | Uint16 * | pRxBuffer
| ) |  | `[inline, static]`

============================================================================
USB_confDmaRx

Description
Configures Dma for Data receive

Arguments

     	        hpdrx         - Dma host packet descriptor pointer
     	        packetsize    - Size of the packet to receive (In Bytes)
     	        pRxBuffer     - Receive Data Buffer pointer

Return Value CSL_Status

- CSL_SOK - Reset successful
- CSL_ESYS_INVPARAMS - Invalid parameters

Pre Condition
USB_initDma and USB_initQueueManager should be called successfully

Post Condition
Receives the data from an end point

Modifies
USB Dma registers

Example

    			#define CSL_USB_DATA_SIZE    (256)
    			Uint16    usbDataBuf[CSL_USB_DATA_SIZE];

    			CSL_UsbHostPacketDescriptor    hpdrx;

    			USB_initDma();
    			USB_initQueueManager(&hpdrx);
    			....
    			....
    			USB_confDmaRx(&hpdrx, CSL_USB_DATA_SIZE, usbDataBuf);

============================================================================

References CSL_UsbHostPktDescr::Buffer0InfoWord0, CSL_UsbHostPktDescr::Buffer0InfoWord1, CSL_USB_16BIT_REG_MASK, IRQ_globalDisable(), IRQ_globalRestore(), CSL_UsbHostPktDescr::LinkingWord, CSL_UsbHostPktDescr::OriginalBuffer0InfoWord0, CSL_UsbHostPktDescr::OriginalBuffer0InfoWord1, CSL_UsbHostPktDescr::PacketInfoWord0, CSL_UsbHostPktDescr::PacketInfoWord1, and CSL_UsbHostPktDescr::PacketInfoWord2.

static CSL_Status USB_confDmaTx | ( | CSL_UsbHostPktDescr * | hpdtx,
|  | Uint32 | packetsize,
|  | Uint16 * | pTxBuffer,
|  | Bool | swapWords
| ) |  | `[inline, static]`

============================================================================
USB_confDmaTx

Description
Configures Dma for Data USB data transfer. For C5505 PG1.4 and earlier versions of the DSP, word swap is required for the data buffer before transferring the data. Parameter 'swapWords' provides facility to request for the word swap for the data buffer.

Arguments

     	        hpdtx         - Dma host packet descriptor pointer
     	        packetsize    - Size of the packet to transmit (In Bytes)
     	        pTxBuffer     - Data Buffer pointer
    			swapWords     - Flag to request for word swap

Return Value CSL_Status

- CSL_SOK - Reset successful
- CSL_ESYS_INVPARAMS - Invalid parameters

Pre Condition
USB_initDma and USB_initQueueManager should be called successfully

Post Condition
transmits data to an end point

Modifies
USB Dma registers

Example

    			#define CSL_USB_DATA_SIZE    (256)
    			Uint16    usbDataBuf[CSL_USB_DATA_SIZE];

    			CSL_UsbHostPacketDescriptor    hpdtx;

    			USB_initDma();
    			USB_initQueueManager(&hpdrx);
    			....
    			....
    			USB_confDmaTx(&hpdrx, CSL_USB_DATA_SIZE, usbDataBuf);

============================================================================

References CSL_UsbHostPktDescr::Buffer0InfoWord0, CSL_UsbHostPktDescr::Buffer0InfoWord1, CSL_USB_16BIT_REG_MASK, IRQ_globalDisable(), IRQ_globalRestore(), CSL_UsbHostPktDescr::LinkingWord, CSL_UsbHostPktDescr::OriginalBuffer0InfoWord0, CSL_UsbHostPktDescr::OriginalBuffer0InfoWord1, CSL_UsbHostPktDescr::PacketInfoWord0, CSL_UsbHostPktDescr::PacketInfoWord1, CSL_UsbHostPktDescr::PacketInfoWord2, and USB_swapWords().

CSL_Status USB_connectDev | ( | CSL_UsbDevNum | devNum | ) |

============================================================================
USB_connectDev

Description
This function connects the USB module to upstream port

Arguments

                devNum        USB device number, Only USB0 is active currently.

Return Value CSL_Status

- CSL_SOK - Returned for success
- CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
USB init function should be called successfully.

Post Condition
Connects the USB module

Modifies
USB FADDR_POWER register

Example

                CSL_UsbConfig      usbConfig;
                CSL_Status         status;

                usbConfig.maxCurrent = 50;
                .....
                .....
                status = USB_init(&usbConfig);
                ....
                ....
                status = USB_connectDev(CSL_USB0);

============================================================================

References usbRegisters.

Referenced by AC_Open(), CDC_Setup(), and MSC_Setup().

CSL_Status USB_coreEventProcessEp0 | ( | pUsbContext | pContext | ) |

deviceDescPtr = (Uint16 *)deviceDesc;

cfgDescPtr = cfgDesc;

cfgDescPtr = cfgDesc;

cfgDescPtr = cfgDescFS;

cfgDescPtr = cfgDescFS;

strDescPtr = (Uint16 *)strDesc[0];

strDescPtr = (Uint16 *)strDesc[1];

strDescPtr = (Uint16 *)strDesc[2];

strDescPtr = (Uint16 *)strDesc[3];

deviceQualDescPtr = (Uint16 *)deviceQualDesc;

References CSL_UsbSetupStruct::bmRequestType, CSL_UsbSetupStruct::bRequest, CSL_UsbContext::cfgDescFSPtr, CSL_UsbContext::cfgDescPtr, CSL_USB_CLEAR_FEATURE, CSL_USB_CONFIGURATION_DESCRIPTOR_TYPE, CSL_USB_DEVICE_DESCRIPTOR_TYPE, CSL_USB_DEVICE_QUAL_DESCRIPTOR_TYPE, CSL_USB_EP0, CSL_USB_FEATURE_ENDPOINT_STALL, CSL_USB_FEATURE_REMOTE_WAKEUP, CSL_USB_GET_CONFIGURATION, CSL_USB_GET_DESCRIPTOR, CSL_USB_GET_INTERFACE, CSL_USB_GET_STATUS, CSL_USB_IN_TRANSFER, CSL_USB_IOFLAG_CAT, CSL_USB_IOFLAG_LNK, CSL_USB_IOFLAG_NONE, CSL_USB_IOFLAG_NOSHORT, CSL_USB_OTHERSPEED_CFG_DESCRIPTOR_TYPE, CSL_USB_REQUEST_TYPE_DEVICE_STATUS, CSL_USB_SET_ADDRESS, CSL_USB_SET_CONFIGURATION, CSL_USB_SET_FEATURE, CSL_USB_SET_INTERFACE, CSL_USB_STRING_DESCRIPTOR_TYPE, CSL_UsbContext::ctrlInEpObj, CSL_UsbContext::ctrlOutEpObj, CSL_UsbContext::devAddr, CSL_UsbContext::deviceDescPtr, CSL_UsbContext::deviceQualDescPtr, CSL_UsbContext::hEpObjArray, CSL_UsbContext::strDescPtr, USB_clearEndptStall(), USB_epNumToHandle(), USB_getEndptStall(), USB_getRemoteWakeupStat(), USB_getSetupPacket(), USB_postTransaction(), USB_setConfiguration(), USB_setDevAddr(), USB_setRemoteWakeup(), USB_stallEndpt(), usbRegisters, CSL_UsbContext::usbSetup, CSL_UsbSetupStruct::wIndex, CSL_UsbSetupStruct::wLength, and CSL_UsbSetupStruct::wValue.

CSL_Status USB_disconnectDev | ( | CSL_UsbDevNum | devNum | ) |

============================================================================
USB_disconnectDev

Description
This function disconnects the USB module from the upstream port

Arguments

                devNum        USB device number, Only USB0 is active currently.

Return Value CSL_Status

- CSL_SOK - Returned for success
- CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
USB_connectDev should be called successfully

Post Condition
Disconnects the USB module.

Modifies
USB FADDR_POWER register

Example

     			CSL_Status    status;

                status = USB_connectDev(CSL_USB0);
                ....
                ....
                status = USB_disconnectDev(CSL_USB0);

============================================================================

References usbRegisters.

Referenced by AC_Close(), CDC_Close(), and MSC_Close().

static void USB_dmaPopQue | ( | Uint16 | queueNum | ) | `[inline, static]`

============================================================================
USB_dmaPopQue

Description
Function to popup the DMA queue. DMA descriptors will be removed from the queue.

Arguments

     	        queueNum   - Queue number

Return Value CSL_Status

- CSL_SOK - Reset successful
- CSL_ESYS_INVPARAMS - Invalid parameters

Pre Condition
None

Post Condition
Popup the queue

Modifies
USB Queue manager registers

Example

    			USB_dmaPopQue(24);

============================================================================

static void USB_dmaRxStart | ( | DWORD | dwEndpoint | ) | `[inline, static]`

============================================================================
USB_dmaRxStart

Description
Starts Dma Receive

Arguments

     			dwEndpoint    - Endpoint number that is configured for Rx

Return Value None

Pre Condition
USB_confDmaRx should be called successfully

Post Condition
Starts Dma data receive

Modifies
Data buffer

Example

    			#define CSL_USB_DATA_SIZE    (256)
    			Uint16    usbDataBuf[CSL_USB_DATA_SIZE];

    			CSL_UsbHostPacketDescriptor    hpdrx;

    			USB_initDma();
    			USB_initQueueManager(&hpdrx);
    			....
    			....
    			USB_confDmaRx(&hpdrx, CSL_USB_DATA_SIZE, usbDataBuf);
    			....
    			....
    			USB_dmaRxStart();

============================================================================

Referenced by USB_handleRx().

static void USB_dmaRxStop | ( | DWORD | dwEndpoint,
|  | Uint16 * | pRxBuffer,
|  | Uint32 | packetsize,
|  | Bool | swapWords
| ) |  | `[inline, static]`

============================================================================
USB_dmaRxStop

Description
Stops Dma data Receive operation. For C5505 PG1.4 and earlier versions of the DSP, wordswap is required for the data buffer after completing the data reception. Parameter 'swapWords' provides facility to request for the word swap for the data buffer.

Arguments

    			dwEndpoint   - Endpoint number that is configured for Rx
     			pRxBuffer    -   DMA Receive data buffer
    			packetsize   -   Size of the data received (In Bytes)
    			swapWords    -   Flag to swap the words in the Rx buffer

Return Value None

Pre Condition
USB_dmaRxStart should be called successfully

Post Condition
Starts Dma data receive

Modifies
USB Registers

Example

    			#define CSL_USB_DATA_SIZE    (256)
    			Uint16    usbDataBuf[CSL_USB_DATA_SIZE];

    			CSL_UsbHostPacketDescriptor    hpdrx;

    			USB_confDmaRx(&hpdrx, CSL_USB_DATA_SIZE, usbDataBuf);
    			....
    			....
    			USB_dmaRxStart();
    			...
    			...
    			USB_dmaRxStop();

============================================================================

References USB_swapWords().

static void USB_dmaTxStart | ( | DWORD | dwEndpoint | ) | `[inline, static]`

============================================================================
USB_dmaTxStart

Description
Starts Dma data transmit. DMA should be configure for the data transmit operation before calling this function. Data will be transmitted by the DMA as per the configured values.

Arguments

     			dwEndpoint    - Endpoint number that is configured for Tx

Return Value None

Pre Condition
USB_confDmaTx should be called successfully

Post Condition
Starts Dma data transfer

Modifies
USB FIFO registers

Example

    			#define CSL_USB_DATA_SIZE    (256)
    			Uint16    usbDataBuf[CSL_USB_DATA_SIZE];

    			CSL_UsbHostPacketDescriptor    hpdtx;

    			USB_initDma();
    			USB_initQueueManager(&hpdtx);
    			....
    			....
    			USB_confDmaTx(&hpdtx, CSL_USB_DATA_SIZE, usbDataBuf);
    			....
    			....
    			USB_dmaTxStart();

============================================================================

Referenced by USB_handleTx().

static void USB_dmaTxStop | ( | DWORD | dwEndpoint | ) | `[inline, static]`

============================================================================
USB_dmaTxStop

Description
Stops Dma data transmit.

Arguments

     			dwEndpoint    - Endpoint number that is configured for Tx

Return Value None

Pre Condition
USB_dmaTxStart should be called successfully

Post Condition
Stops Dma data receive

Modifies
USB registers

Example

    			#define CSL_USB_DATA_SIZE    (256)
    			Uint16    usbDataBuf[CSL_USB_DATA_SIZE];

    			CSL_UsbHostPacketDescriptor    hpdtx;

    			USB_confDmaTx(&hpdtx, CSL_USB_DATA_SIZE, usbDataBuf);
    			....
    			....
    			USB_dmaTxStart();
    			...
    			...
    			USB_dmaTxStop();

============================================================================

pUsbEpHandle USB_epNumToHandle | ( | CSL_UsbDevNum | devNum,
|  | Uint16 | endpt
| ) |  |

============================================================================
USB_epNumToHandle

Description
This function returns handle to an end point

Arguments

                devNum        USB device number, Only USB0 is active currently.
                endPt         16-bit endpoint number as specified
     						  in the USB specification.
     						  0x00 -> Endpt 0 Out.
     						  0x01 -> Endpt 1 Out.
              				  0x80 -> Endpt 0 In.
              				  0x81 -> Endpt 1 In.

Return Value pUsbEpHandle
Handle to the endpoint object if a valid endpoint object exists, else NULL object.

Pre Condition
USB_init function should be called successfully

Post Condition
returns End point handle

Modifies
None

Example

                CSL_UsbConfig    usbConfig;
                CSL_Status       status;
                pUsbEpHandle     hEp;

                usbConfig.maxCurrent = 50;
                .....
                .....
                status = USB_init(&usbConfig);
                .....
                hEp = USB_epNumToHandle(CSL_USB0, CSL_USB_IN_TRANSFER);

============================================================================

References CSL_USB_ENDPOINT_COUNT, CSL_USB_EP0, CSL_USB_EP1, CSL_USB_EP2, CSL_USB_EP3, CSL_USB_EP4, CSL_USB_IN_EP0, CSL_USB_IN_EP1, CSL_USB_IN_EP2, CSL_USB_IN_EP3, CSL_USB_IN_EP4, CSL_USB_IN_TRANSFER, CSL_USB_OUT_EP0, CSL_USB_OUT_EP1, CSL_USB_OUT_EP2, CSL_USB_OUT_EP3, and CSL_USB_OUT_EP4.

Referenced by AC_reqClearFeature(), AC_reqGetStatus(), AC_reqSetFeature(), CDC_bulkOutHandler(), CDC_reqClearFeature(), CDC_reqGetStatus(), CDC_reqSetFeature(), MSC_reqClearFeature(), MSC_reqGetStatus(), MSC_reqSetFeature(), and USB_coreEventProcessEp0().

static void USB_flushFifo | ( | DWORD | dwEndpoint,
|  | Bool | fifoDirFlag
| ) |  | `[inline, static]`

============================================================================
USB_flushFifo

Description
Function to flush the Tx and Rx FIFO of the USB

Arguments

     	        dwEndpoint  - End point to which FIFO flush is required
     	        fifoDirFlag - Flag to indicate the FIFO direction
     	                      1 - Tx FIFO, 0 - Rx FIFO

Return Value None

Pre Condition
None

Post Condition
Flushes Tx/Rx FIFO

Modifies
None

Example

                //Flush Tx FIFO
    			USB_flushFifo (CSL_USB_EP1, 1);

                //Flush Rx FIFO
    			USB_flushFifo (CSL_USB_EP2, 0);

============================================================================

References CSL_USB_EP0.

Uint16 USB_getDataCountReadFromFifo | ( | pUsbEpHandle | hEp | ) |

============================================================================
USB_getDataCountReadFromFifo

Description
This function returns the most recent data count read from the FIFO. This function is supposed to use for the OUT end point. This function always return 0 for IN end point.

Arguments

                hEp         Handle to an initialized endpoint object.

Return Value Data count read from FIFO

Pre Condition
End point object should be initialized

Post Condition
Terminates data transfer in progress

Modifies
USB registers

Example

     			void  (*evtHandler)();

     			pUsbEpHandle     hEp;
                CSL_Status       status;
                Uint16           fifoDataCount;

                status = USB_initEndptObj(CSL_USB0,
                                          hEp,
                                          CSL_USB_OUT_EP0,
                                          CSL_USB_CTRL,
                                          0x40,
                                          CSL_USB_EVENT_RESET,
                                          evtHandler);

                fifoDataCount = USB_getEvents(hEp);

============================================================================

References CSL_USB_IN_EP0, CSL_UsbEpStatus::dataReadFromFifo, CSL_UsbEpObj::epNum, and CSL_UsbContext::pEpStatus.

Referenced by CDC_bulkOutHandler(), and MSC_verifyCBW().

CSL_UsbBoolean USB_getEndptStall | ( | pUsbEpHandle | hEp,
|  | CSL_Status * | status
| ) |  |

============================================================================
USB_getEndptStall

Description
This function checks if an endpoint is stalled.

Arguments

                hEp         Handle to an initialized endpoint object.
                status      Status of the function call

Return Value CSL_UsbBoolean

- CSL_USB_TRUE - If the end point is stalled.
- CSL_USB_FALSE - If the end point is not stalled

Pre Condition
Init End point API should be called successfully

Post Condition
1. Returns the end point stall status
2. Function call status is returned in status variable

- CSL_SOK - Returned for success
- CSL_ESYS_BADHANDLE - Invalid end point handle
- CSL_ESYS_INVPARAMS - Invalid parameter

Modifies
status variable

Example

     			void      (*evtHandler)();

     			pUsbEpHandle      hEp;
                CSL_Status        status;
    			CSL_UsbBoolean    epStall;

                status = USB_initEndptObj(CSL_USB0,
                                          hEp,
                                          CSL_USB_OUT_EP0,
                                          CSL_USB_CTRL,
                                          0x40,
                                          CSL_USB_EVENT_RESET,
                                          evtHandler);
    			...
    			...
    			epStall = USB_getEndptStall(hEp, &status);

============================================================================

References CSL_USB_ENDPOINT_COUNT, CSL_USB_IN_EP0, CSL_UsbEpStatus::dwEndpoint, CSL_UsbEpObj::epNum, CSL_UsbEpStatus::fStalled, and CSL_UsbContext::pEpStatus.

Referenced by AC_reqGetStatus(), CDC_reqGetStatus(), MSC_reqGetStatus(), and USB_coreEventProcessEp0().

CSL_UsbEventMask USB_getEvents | ( | pUsbEpHandle | hEp,
|  | CSL_Status * | status
| ) |  |

============================================================================
USB_getEvents

Description
This API reads and clears all the pending USB_EVENTS associated with a particular USB endpoint.

Arguments

                hEp         Handle to an initialized endpoint object.
                status      Status of the function call

Return Value CSL_UsbEventMask
ORed combination of all the pending USB_EVENTS associated with a particular endpoint.

Pre Condition
End point object should be initialized

Post Condition
1. Clears and returns the end point events
2. Function call status is returned in status variable

- CSL_SOK - Returned for success
- CSL_ESYS_BADHANDLE - Invalid end point handle

Modifies
status variable

Example

     			void  (*evtHandler)();

     			pUsbEpHandle     hEp;
                CSL_Status       status;

                status = USB_initEndptObj(CSL_USB0,
                                          hEp,
                                          CSL_USB_OUT_EP0,
                                          CSL_USB_CTRL,
                                          0x40,
                                          CSL_USB_EVENT_RESET,
                                          evtHandler);
                USB_getEvents(hEp,
                              &status);

============================================================================

References CSL_USB_EVENT_NONE, CSL_USB_IN_EP0, CSL_UsbEpObj::epNum, CSL_UsbContext::pEpStatus, and CSL_UsbEpStatus::wUSBEvents.

Referenced by AC_Ctrl(), AC_Iso(), MSC_Bulk(), and MSC_Ctrl().

CSL_UsbFrameNum USB_getFrameNo | ( | CSL_UsbDevNum | devNum | ) |

============================================================================
USB_getFrameNo

Description
This function reads current USB frame number

Arguments

                devNum        USB device number, Only USB0 is active currently.

Return Value CSL_UsbFrameNum
Current USB frame number

Pre Condition
USB init should be called successfully

Post Condition
Returns the frame number

Modifies
None

Example

                CSL_UsbConfig      usbConfig;
                CSL_Status         status;
                Uint16             addr;

                usbConfig.maxCurrent = 50;
                .....
                .....
                status = USB_init(&usbConfig);
                ....
                ....
                status = USB_getFrameNo(CSL_USB0);

============================================================================

References usbRegisters.

WORD USB_getMaxPower | ( | CSL_UsbDevNum | devNum | ) |

============================================================================
USB_getMaxPower

Description
This function returns the maximum current drawn by the device. This is to inform the host about the device power requirement. This value is passed to the host through the configuration descriptor.

Arguments

     	        None

Return Value Maximum current drawn by the device

Pre Condition
USB_init function should be called successfully

Post Condition
Returns the maximum current drawn by the device

Modifies
None

Example

                CSL_UsbConfig      usbConfig;
                CSL_Status         status;
                Uint16             maxPower;

                usbConfig.maxCurrent = 50;
                .....
                .....
                status = USB_init(&usbConfig);
                .....
                maxPower = USB_getMaxPower(CSL_USB0);

============================================================================

References CSL_USB_INVALID_MAXPOWER, and CSL_UsbContext::maxCurrent.

Referenced by MSC_initCtrlDesc().

CSL_UsbBoolean USB_getRemoteWakeupStat | ( | CSL_UsbDevNum | devNum | ) |

============================================================================
USB_getRemoteWakeupStat

Description
This function returns the remote wake up feature status.

Arguments

                devNum        USB device number, Only USB0 is active currently.

Return Value CSL_UsbBoolean

- CSL_USB_TRUE - Remote wakeup feature is enabled.
- CSL_USB_FALSE - Remote wakeup feature is disabled.

Pre Condition
USB_setRemoteWakeup function should be called successfully

Post Condition
Returns remote wakeup status

Modifies
None

Example

                CSL_Status        status;
                CSL_UsbBoolean    rmtWkpStat

                status = USB_setRemoteWakeup(CSL_USB0, CSL_USB_TRUE);

                if(status == CSL_SOK)
                {
    		        rmtWkpStat = USB_getRemoteWakeupStat(CSL_USB0);
    			}

============================================================================

References CSL_UsbContext::remoteWkpStat.

Referenced by AC_reqGetStatus(), CDC_reqGetStatus(), MSC_reqGetStatus(), and USB_coreEventProcessEp0().

CSL_Status USB_getSetupPacket | ( | CSL_UsbDevNum | devNum,
|  | CSL_UsbSetupStruct * | usbSetup,
|  | Bool | readFromFifo
| ) |  |

============================================================================
USB_getSetupPacket

Description
This function read the setup packet from the setup data buffer. This function can be used to read the setup packet from the FIFO or we can read the setup packet from the USB context structure. We can choose one of two options using readFromFifo parameter. If readFromFifo is TRUE setup packet is read from the FIFO. If readFromFifo is FALSE setup packet is read from the context structure. Setup packet should be read from FIFO when this function is called from interrupt handler(In this case read packet is stored in context structure) and setup packet should be read from USB context structure when this function is called from MSC layer.

Arguments

                devNum        USB device number
                usbSetup      Pointer to setup structure

Return Value CSL_Status

- CSL_SOK - Returned for success
- CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
USB Init should be called successfully

Post Condition
USB setup structure is populated

Modifies
None

Example

                CSL_UsbSetupStruct    usbSetup;
                CSL_Status            status;
                CSL_UsbConfig         usbConfig

                status = USB_init(&usbConfig);
                ....
                ....
                status = USB_getSetupPacket(CSL_USB0, &usbSetup , TRUE);

============================================================================

References CSL_UsbSetupStruct::bmRequestType, CSL_UsbSetupStruct::bRequest, CSL_UsbContext::cbOutEP0DataReceived, CSL_USB_SETUP_PACKET_LEN, CSL_UsbSetupStruct::newPacket, usbRegisters, CSL_UsbContext::usbSetup, CSL_UsbSetupStruct::wIndex, CSL_UsbSetupStruct::wLength, and CSL_UsbSetupStruct::wValue.

Referenced by AC_Ctrl(), CDC_eventHandler(), MSC_Ctrl(), and USB_coreEventProcessEp0().

static CSL_Status USB_handleRx | ( | pUsbContext | pContext,
|  | DWORD | dwEndpoint
| ) |  | `[inline, static]`

============================================================================
USB_handleRx

Description
Receives the data over the non-control end points This function can read the data in polled mode or using CPPI DMA. For the DMA mode operation opmode needs to be set to DMA using USB_init() API and CPPI DMA needs to be configured for USB Rx operation using USB_confDmaRx() API before calling this function.

USB DMA will be used when the data to be received is 64 or 512 bytes. CPU will be used to receive any other length of data.

Data to be recived will be read from the Rx FIFO one packet at a time. Legth of the packet will be decided based on the maximum packet size assigned to the Rx FIFO. In case of poll mode operation complete transfer callback function will be invoked after reading all the packets from the Rx FIFO. In case of DMA mode operation complete transfer callback will be invoked for each packet read. Complete transfer callback function is supposed to wait for DMA transfer completion.

Number of bytes read from FIFO in each transaction will be stored in 'pTransfer->prevTxferLen'. This value will be 64 or 512 when DMA mode is enabled and DMA is used for the data transfer. Other cases indicates that CPU mode is enabled or CPU is used for data transfer.

Arguments

     	        pContext      -   USB context structure pointer
     	        dwEndpoint    -   End point number

Return Value CSL_Status

- CSL_SOK - Returned for success
- CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
USB_initEndptObj function should be called successfully

Post Condition
Reads data from an end point

Modifies
USB Data buffer

Example

    			void  (*evtHandler)();

    			pUsbEpHandle      hEp;
    			CSL_Status        status;
    			CSL_UsbContext    gUsbContext;

    			status = USB_initEndptObj(CSL_USB0,
    									  hEp,
    									  CSL_USB_OUT_EP2,
    									  CSL_USB_BULK,
    									  0x40,
    									  CSL_USB_EVENT_RESET,
    									  evtHandler);
    			....
    			....
    			status = USB_handleRx(&gUsbContext, CSL_USB_EP2);

============================================================================

References CSL_UsbTransfer::cbBuffer, CSL_UsbTransfer::cbTransferred, CSL_UsbContext::completeTransferCallback, CSL_USB_ISO, CSL_USB_MIN, CSL_UsbEpStatus::dwPacketSizeAssigned, CSL_UsbTransfer::fComplete, CSL_UsbContext::fWaitingOnFlagB, CSL_UsbContext::opMode, CSL_UsbContext::pEpStatus, CSL_UsbEpStatus::pFifoAddr, CSL_UsbTransfer::prevTxferLen, CSL_UsbEpStatus::pTransfer, CSL_UsbTransfer::pvBuffer, USB_dmaRxStart(), and CSL_UsbEpStatus::xferType.

static void USB_handleRxIntr | ( | pUsbContext | pContext | ) | `[inline, static]`

============================================================================
USB_handleRxIntr

Description
This function handles USb receive interrupts. This function is provided to be used with MSC module. For standalone MUSB operation this function is not required This function works only if EP2 configured for Rx

Arguments

     	        pContext      -   USB context structure pointer

Return Value None

Pre Condition
USB_initEndptObj function should be called successfully

Post Condition
Handles Rx interrupt

Modifies
USb registers

Example

    			void  (*evtHandler)();

    			pUsbEpHandle      hEp;
    			CSL_Status        status;
    			CSL_UsbContext    gUsbContext;

    			status = USB_initEndptObj(CSL_USB0,
    									  hEp,
    									  CSL_USB_IN_EP0,
    									  CSL_USB_CTRL,
    									  0x40,
    									  CSL_USB_EVENT_RESET,
    									  evtHandler);
    			....
    			....
    			status = USB_handleRxIntr(&gUsbContext);

============================================================================

References CSL_USB_EP2, CSL_USB_ISO, CSL_UsbContext::fSetupPktCmd, CSL_UsbContext::fWaitingOnFlagB, CSL_UsbContext::pEpStatus, and CSL_UsbEpStatus::xferType.

static CSL_Status USB_handleTx | ( | pUsbContext | pContext,
|  | DWORD | dwEndpoint
| ) |  | `[inline, static]`

============================================================================
USB_handleTx

Description
Transmits the data over the non-control end points. This function can transmit the data in polled mode or using CPPI DMA. For the DMA mode operation opmode needs to be set to DMA using USB_init() API and CPPI DMA needs to be configured for USB Tx operation using USB_confDmaTx() API before calling this function.

USB DMA will be used when the data to be transferred is 64 or 512 bytes. CPU will be used to transfer any other length of data.

Data to be sent will be copied to the Tx FIFO one packet at a time. Legth of the packet will be decided based on the maximum packet size assigned to the Tx FIFO. In case of poll mode operation complete transfer callback function will be invoked after copying all the packets to the Tx FIFO. In case of DMA mode operation complete transfer callback will be invoked for each packet transferred. Complete transfer callback function is supposed to wait for DMA transfer completion.

Number of bytes written to FIFO in each transaction will be stored in 'pTransfer->prevTxferLen'. This value will be 64 or 512 when DMA mode is enabled and DMA is used for the data transfer. Other cases indicates that CPU mode is enabled or CPU is used for data transfer.

Arguments

     	        pContext      -   USB context structure pointer
     	        dwEndpoint    -   End point number

Return Value CSL_Status

- CSL_SOK - Returned for success
- CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
USB_initEndptObj function should be called successfully

Post Condition
Writes data to an end point

Modifies
USB FIFO registers

Example

    			void  (*evtHandler)();

    			pUsbEpHandle      hEp;
    			CSL_Status        status;
    			CSL_UsbContext    gUsbContext;

    			status = USB_initEndptObj(CSL_USB0,
    									  hEp,
    									  CSL_USB_IN_EP1,
    									  CSL_USB_BULK,
    									  0x40,
    									  CSL_USB_EVENT_RESET,
    									  evtHandler);
    			....
    			....
    			status = USB_handleTx(&gUsbContext, CSL_USB_EP1);

============================================================================

References CSL_UsbTransfer::cbBuffer, CSL_UsbTransfer::cbTransferred, CSL_UsbContext::completeTransferCallback, CSL_USB_IOFLAG_NOT, CSL_USB_ISO, CSL_USB_MIN, CSL_UsbEpStatus::dwPacketSizeAssigned, CSL_UsbTransfer::fComplete, CSL_UsbEpStatus::fStalled, CSL_UsbContext::fWaitingOnFlagA, CSL_UsbTransfer::ioFlags, CSL_UsbContext::opMode, CSL_UsbContext::pEpStatus, CSL_UsbEpStatus::pFifoAddr, CSL_UsbTransfer::prevTxferLen, CSL_UsbEpStatus::pTransfer, CSL_UsbTransfer::pvBuffer, USB_dmaTxStart(), and CSL_UsbEpStatus::xferType.

static void USB_handleTxIntr | ( | pUsbContext | pContext | ) | `[inline, static]`

============================================================================
USB_handleTxIntr

Description
This function handles USB transmit interrupts.

Arguments

     	        pContext      -   USB context structure pointer

Return Value None

Pre Condition
USB_initEndptObj function should be called successfully

Post Condition
Handles Tx interrupt

Modifies
USb registers

Example

    			void  (*evtHandler)();

    			pUsbEpHandle      hEp;
    			CSL_Status        status;
    			CSL_UsbContext    gUsbContext;

    			status = USB_initEndptObj(CSL_USB0,
    									  hEp,
    									  CSL_USB_IN_EP0,
    									  CSL_USB_CTRL,
    									  0x40,
    									  CSL_USB_EVENT_RESET,
    									  evtHandler);
    			....
    			....
    			status = USB_handleTxIntr(&gUsbContext);

============================================================================

References CSL_USB_EP1.

CSL_Status USB_init | ( | CSL_UsbConfig * | usbConfig | ) |

============================================================================
USB_init

Description
This function initializes USB module

Arguments

                usbConfig        USB Config structure

Return Value CSL_Status

- CSL_SOK - Returned for success
- CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
None

Post Condition
Initializes the USB module

Modifies
USB context structure

Example

                CSL_UsbConfig      usbConfig;
                CSL_Status         status;

                usbConfig.maxCurrent = 50;
                .....
                .....
                status = USB_init(&usbConfig);

============================================================================

References CSL_UsbConfig::appSuspendCallBack, CSL_UsbConfig::appWakeupCallBack, CSL_UsbContext::busSpeed, CSL_UsbContext::cableState, CSL_UsbContext::cbOutEP0Buf, CSL_UsbContext::cbOutEP0DataReceived, CSL_UsbConfig::completeTransferCallback, CSL_UsbContext::completeTransferCallback, CSL_USB_BS_HIGH_SPEED, CSL_USB_CLOCKSTOP_REG_DEF_VAL, CSL_USB_DELAY, CSL_USB_DEVICE_DETACH, CSL_USB_ENDPOINT_COUNT, CSL_USB_EP0, CSL_USB_EP0_IDLE, CSL_USB_EP0_PACKET_SIZE, CSL_USB_EP1, CSL_USB_EP1_PACKET_SIZE_FS, CSL_USB_EP1_PACKET_SIZE_HS, CSL_USB_EP2, CSL_USB_EP2_PACKET_SIZE_FS, CSL_USB_EP2_PACKET_SIZE_HS, CSL_USB_EP3, CSL_USB_EP3_PACKET_SIZE_FS, CSL_USB_EP3_PACKET_SIZE_HS, CSL_USB_EP4, CSL_USB_EP4_PACKET_SIZE_FS, CSL_USB_EP4_PACKET_SIZE_HS, CSL_USB_EVENT_NONE, CSL_USB_IN_EP_FIFO_START, CSL_USB_PER_RESTCOUNT, CSL_USB_SYS_CTRL_REG_DEF_VAL, CSL_UsbConfig::devNum, CSL_UsbEpStatus::dwEndpoint, CSL_UsbEpStatus::dwPacketSizeAssigned, CSL_UsbContext::ep0State, CSL_UsbTransfer::fComplete, CSL_UsbContext::fEP0BUFAvailable, CSL_UsbContext::fEP1InBUFAvailable, CSL_UsbContext::fInitialized, CSL_UsbEpStatus::fInitialized, CSL_UsbContext::fMUSBIsReady, CSL_UsbContext::fOutPhaseCmd, CSL_UsbEpStatus::fSelected, CSL_UsbContext::fSendHandshake, CSL_UsbContext::fSetupPktCmd, CSL_UsbEpStatus::fStalled, CSL_UsbContext::fWaitingOnEP0BUFAvail, CSL_UsbContext::fWaitingOnEP1InBUFAvail, CSL_UsbContext::fWaitingOnFlagA, CSL_UsbContext::fWaitingOnFlagB, CSL_UsbEpStatus::hEventHandler, CSL_UsbConfig::maxCurrent, CSL_UsbContext::maxCurrent, CSL_UsbContext::opMode, CSL_UsbConfig::opMode, CSL_UsbContext::pEpStatus, CSL_UsbEpStatus::pFifoAddr, CSL_UsbContext::pFIFOBaseAddress, CSL_UsbEpStatus::pTransfer, CSL_UsbContext::remoteWkpStat, CSL_UsbConfig::startTransferCallback, CSL_UsbContext::startTransferCallback, CSL_UsbContext::suspendCallBackFxn, sysCtrlRegs, USB_checkSpeed(), usbRegisters, CSL_UsbContext::wakeupCallBackFxn, and CSL_UsbEpStatus::wUSBEvents.

static void USB_initDma | ( | void |  | ) | `[inline, static]`

============================================================================
USB_initDma

Description
Initializes the Dma

Arguments

    			None

Return Value None

Pre Condition
USB_init should be called successfully

Post Condition
Initializes USB Dma

Modifies
USB Dma registers

Example

    			CSL_UsbConfig      usbConfig;
    			CSL_Status         status;

    			usbConfig.maxCurrent = 50;
    			.....
    			.....
    			status = USB_init(&usbConfig);
    			....
    			....
    			USB_initDma();

============================================================================

References CSL_USB_DMA_SCHED_CTRL1_DEFVAL, CSL_USB_ENTRYLSW_DEFVAL, CSL_USB_RXGCR1_DEFVAL, CSL_USB_RXGCR2_DEFVAL, IRQ_globalDisable(), and IRQ_globalRestore().

CSL_Status USB_initEndptObj | ( | CSL_UsbDevNum | devNum,
|  | pUsbEpHandle | hEp,
|  | CSL_UsbEpNum | epNum,
|  | CSL_UsbXferType | xferType,
|  | Uint16 | maxPktSize,
|  | Uint16 | evMask,
|  | CSL_USB_EVENT_ISR | fxn
| ) |  |

============================================================================
USB_initEndptObj

Description
This function initializes an endpoint object.

Arguments

                devNum        USB device number, Only USB0 is active currently.
                hEp           Handle to an endpoint object to be initialized.
                epNum         End point number
                xferType      Type of data transfer to be supported by the endpoint
                maxPktSize    Max data packet size supported by the endpoint.
                evMask        ORed combination of USB Interrupt Events to
     					  	  be broadcasted to the associated event handler
    			fxn           Associated event handler routine.

Return Value CSL_Status

- CSL_SOK - Returned for success
- CSL_ESYS_BADHANDLE - Invalid end point handle
- CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
USB init and USB_epNumToHandle functions should be called successfully

Post Condition
Initializes an end point object

Modifies
End point object structure

Example

                void      (*evtHandler)();

                CSL_UsbConfig      usbConfig;
                CSL_Status         status;
                pUsbEpHandle       hEp;

                usbConfig.maxCurrent = 50;
                .....
                .....
                status = USB_init(&usbConfig);
                .....
                hEp = USB_epNumToHandle(CSL_USB0, CSL_USB_IN_TRANSFER);
                .....
                .....
                status = USB_initEndptObj(CSL_USB0,
                                          hEp,
                                          CSL_USB_OUT_EP0,
                                          CSL_USB_CTRL,
                                          0x40,
                                          CSL_USB_EVENT_RESET,
                                          evtHandler);

============================================================================

References CSL_USB_EP0, CSL_USB_FIFO_SIZE, CSL_USB_IN_EP0, CSL_USB_IN_EP1, CSL_USB_IN_EP2, CSL_USB_IN_EP3, CSL_USB_IN_EP4, CSL_USB_ISO, CSL_USB_OUT_EP1, CSL_USB_OUT_EP2, CSL_USB_OUT_EP3, CSL_USB_OUT_EP4, CSL_UsbEpStatus::dataReadFromFifo, CSL_UsbEpObj::epNum, CSL_UsbEpObj::eventMask, CSL_UsbEpStatus::fSelected, CSL_UsbEpObj::fxn, CSL_UsbEpStatus::hEventHandler, CSL_UsbEpObj::maxPktSiz, CSL_UsbContext::pEpStatus, usbRegisters, CSL_UsbEpStatus::xferType, and CSL_UsbEpObj::xferType.

Referenced by AC_Open(), CDC_Setup(), and MSC_Setup().

void USB_initPLL | ( | void |  | ) |

============================================================================
USB_initPLL

Description
Initializes PLL for USB operation. This function initializes the PLL to 100 MHz. For configuring PLL to any other frequency use PLL module.

Arguments

                       None

Return Value None

Pre Condition
None

Post Condition
Initializes PLL

Modifies
PLL registers

Example

    			USB_initPLL();

============================================================================

References CSL_USB_PLL_PLLCNTL1_DEFVAL, CSL_USB_PLL_PLLCNTL2_DEFVAL, CSL_USB_PLL_PLLINCNTL_DEFVAL, CSL_USB_PLL_PLLOUTCNTL_DEFVAL, CSL_USB_PLL_TIMEOUT, and sysCtrlRegs.

static CSL_Status USB_initQueueManager | ( | CSL_UsbHostPktDescr * | hpdtx,
|  | Uint32 * | pLinkingRam
| ) |  | `[inline, static]`

============================================================================
USB_initQueueManager

Description
Initializes the Dma queue manager.

Arguments

     	        hpdtx         - Dma host packet transmit descriptor pointer
    			pLinkingRam   - Pointer to linking RAM data buffer

Return Value CSL_Status

- CSL_SOK - Reset successful
- CSL_ESYS_INVPARAMS - Invalid parameters

Pre Condition
USB_initDma should be called successfully

Post Condition
Initializes queue manager

Modifies
USB Queue manager registers

Example

    			CSL_UsbHostPacketDescriptor    hpdtx;

    			USB_initDma();
    			USB_initQueueManager(&hpdrx);

============================================================================

References CSL_USB_16BIT_REG_MASK, CSL_USB_16BIT_REG_SHIFT, CSL_USB_LRAM0SIZE_DEFVAL, CSL_USB_QMEMRCTRL2_DEFVAL, IRQ_globalDisable(), and IRQ_globalRestore().

CSL_Status USB_issueRemoteWakeup | ( | CSL_UsbDevNum | devNum,
|  | Bool | resumeBitVal
| ) |  |

============================================================================
USB_issueRemoteWakeup

Description
This function issues a remote wakeup signal to the host. NOTE: For remote wakeup protocol application program needs to call this function two times. In the first call resumeBitVal should be TRUE and in the second call resumeBitVal should be FALSE. Application should give a delay of 2 - 15 mSecs between the two calls. This is to avoid delays internal to the CSL module

Arguments

                devNum           USB device number, Only USB0 is active currently.
                resumeBitVal     Value of the resume bit - TRUE or FALSE

Return Value CSL_Status

- CSL_SOK - Returned for success
- CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
USB_setRemoteWakeup function should be called successfully

Post Condition
Issues a remote wake up signal.

Modifies
USB FADDR POWER register

Example

                CSL_Status    status;

                status = USB_setRemoteWakeup(CSL_USB0, CSL_USB_TRUE);

                if(status == CSL_SOK)
                {
    		        status = USB_issueRemoteWakeup(CSL_USB0);
    			}

============================================================================

Set/Reset USB Resume bit

References CSL_UsbContext::remoteWkpStat, and usbRegisters.

CSL_UsbBoolean USB_isTransactionDone | ( | pUsbEpHandle | hEp,
|  | CSL_Status * | status
| ) |  |

============================================================================
USB_isTransactionDone

Description
This function returns the status of the previously posted data transfer request.

Arguments

                hEp         Handle to an initialized endpoint object.
                status      Status of the function call

Return Value CSL_UsbBoolean

- CSL_USB_TRUE - If the previously posted transfer is completed.
- CSL_USB_FALSE - If the previously posted transfer is not completed.

Pre Condition
Post transaction API should be called successfully

Post Condition
1. Returns the previous transaction status
2. Function call status is returned in status variable

- CSL_SOK - Returned for success
- CSL_ESYS_BADHANDLE - Invalid end point handle
- CSL_ESYS_INVPARAMS - Invalid parameter

Modifies
status variable

Example

     			void      (*evtHandler)();
     			Uint16    dadaBuf[256];

     			pUsbEpHandle      hEp;
                CSL_Status        status;
                CSL_UsbBoolean    tscStatus;

                status = USB_initEndptObj(CSL_USB0,
                                          hEp,
                                          CSL_USB_OUT_EP0,
                                          CSL_USB_CTRL,
                                          0x40,
                                          CSL_USB_EVENT_RESET,
                                          evtHandler);

    			status = USB_postTransaction(hEp, 256, dataBuf, CSL_USB_IOFLAG_NONE);
    			...
    			...
    			tscStatus = USB_isTransactionDone(hEp ,&status);

============================================================================

References CSL_USB_IN_EP0, CSL_UsbEpObj::epNum, CSL_UsbTransfer::fComplete, CSL_UsbContext::pEpStatus, and CSL_UsbEpStatus::pTransfer.

Referenced by CDC_bulkInHandler(), CDC_bulkOutHandler(), CDC_putData(), MSC_ExecuteRead(), MSC_ExecuteWrite(), MSC_HandleStateSendCSW(), MSC_HandleStateSendData(), MSC_HandleStateSendStall(), and MSC_HandleStateWaitForCBW().

static Bool USB_isValidDataInFifoOut | ( | pUsbEpStatus | peps | ) | `[inline, static]`

============================================================================
USB_isValidDataInFifoOut

Description
This function checks validity of the data in the output FIFO

Arguments

     	        peps      -   End point status structure pointer

Return Value

- TRUE - FIFO out has valid data
- FALSE - FIFO out no has valid data

Pre Condition
USB_initEndptObj function should be called successfully

Post Condition
Checks the data in FIFO Out

Modifies
None

Example

    			void  (*evtHandler)();

    			pUsbEpHandle      hEp;
    			CSL_Status        status;
    			Bool              fifoStatus;
    			CSL_UsbContext    gUsbContext;
    			pUsbEpStatus      peps;

    			status = USB_initEndptObj(CSL_USB0,
    									  hEp,
    									  CSL_USB_IN_EP0,
    									  CSL_USB_CTRL,
    									  0x40,
    									  CSL_USB_EVENT_RESET,
    									  evtHandler);
    			....
    			....
    			fifoStatus = USB_isValidDataInFifoOut(peps);

============================================================================

References CSL_USB_EP2, CSL_USB_ISO, CSL_UsbEpStatus::dataReadFromFifo, CSL_UsbEpStatus::dwEndpoint, and CSL_UsbEpStatus::xferType.

Referenced by CDC_bulkOutHandler().

CSL_UsbEventMask USB_peekEvents | ( | pUsbEpHandle | hEp,
|  | CSL_Status * | status
| ) |  |

============================================================================
USB_peekEvents

Description
This function read all the pending USB_EVENTS associated with a particular USB endpoint

Arguments

                hEp         Handle to an initialized endpoint object.
                status      Status of the function call

Return Value CSL_UsbEventMask
ORed combination of all the pending USB_EVENTS associated with a particular endpoint.

Pre Condition
End point object should be initialized

Post Condition
1. Returns the end point events
2. Function call status is returned in status variable

- CSL_SOK - Returned for success
- CSL_ESYS_BADHANDLE - Invalid end point handle

Modifies
status variable

Example

     			void  (*evtHandler)();

     			CSL_UsbEpObj    epObj;
                CSL_Status      status;

                status = USB_initEndptObj(CSL_USB0,
                                          &epObj,
                                          CSL_USB_OUT_EP0,
                                          CSL_USB_CTRL,
                                          0x40,
                                          CSL_USB_EVENT_RESET,
                                          evtHandler);
                USB_peekEvents(&epObj,
                               &status);

============================================================================

References CSL_USB_EVENT_NONE, CSL_USB_IN_EP0, CSL_UsbEpObj::epNum, CSL_UsbContext::pEpStatus, and CSL_UsbEpStatus::wUSBEvents.

CSL_Status USB_postTransaction | ( | pUsbEpHandle | hEp,
|  | Uint16 | byteCnt,
|  | void * | data,
|  | CSL_UsbIoFlags | flags
| ) |  |

============================================================================
USB_postTransaction

Description
This function transmits and receives USB data through an endpoint.

Arguments

                hEp         Handle to an initialized endpoint object.
                byteCnt     Total number of bytes in the buffer pointed by *data
                Data        Pointer to a data buffer
                flags       ORed combination of USB Data Transfer Flags

Return Value CSL_Status

- CSL_SOK - Returned for success
- CSL_ESYS_BADHANDLE - Invalid end point handle
- CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
USB init end point should be called successfully

Post Condition
Starts the data transfer

Modifies
USB FIFO registers/data buffer

Example

     			void      (*evtHandler)();
     			Uint16    dadaBuf[256];

     			pUsbEpHandle    hEp;
                CSL_Status      status;

                status = USB_initEndptObj(CSL_USB0,
                                          hEp,
                                          CSL_USB_OUT_EP0,
                                          CSL_USB_CTRL,
                                          0x40,
                                          CSL_USB_EVENT_RESET,
                                          evtHandler);

    			status = USB_postTransaction(hEp, 256, dataBuf, CSL_USB_IOFLAG_NONE);

============================================================================

References CSL_UsbTransfer::cbBuffer, CSL_UsbTransfer::cbTransferred, CSL_USB_BULK, CSL_USB_EP0, CSL_USB_IN_EP0, CSL_USB_IN_EP1, CSL_USB_IN_EP2, CSL_USB_IN_EP3, CSL_USB_IN_EP4, CSL_USB_IN_TRANSFER, CSL_USB_ISO, CSL_USB_OUT_EP0, CSL_USB_OUT_EP1, CSL_USB_OUT_EP2, CSL_USB_OUT_EP3, CSL_USB_OUT_EP4, CSL_USB_OUT_TRANSFER, CSL_UsbTransfer::dwEndpoint, CSL_UsbEpStatus::dwEndpoint, CSL_UsbTransfer::dwFlags, CSL_UsbEpObj::epNum, CSL_UsbTransfer::fComplete, CSL_UsbContext::fInitialized, CSL_UsbContext::fMUSBIsReady, CSL_UsbTransfer::ioFlags, CSL_UsbContext::pEpStatus, CSL_UsbEpStatus::pTransfer, CSL_UsbTransfer::pvBuffer, CSL_UsbContext::startTransferCallback, CSL_UsbEpStatus::xferType, and CSL_UsbEpObj::xferType.

Referenced by AC_Ctrl(), AC_Iso(), AC_reqGetConfiguration(), AC_reqGetCurrent(), AC_reqGetDescriptor(), AC_reqGetInterface(), AC_reqGetMaximum(), AC_reqGetMaxLUN(), AC_reqGetMinimum(), AC_reqGetResolution(), AC_reqGetStatus(), AC_reqSetCurrent(), CDC_bulkInHandler(), CDC_bulkOutHandler(), CDC_eventHandler(), CDC_putData(), CDC_reqGetConfiguration(), CDC_reqGetInterface(), CDC_reqGetMaxLUN(), CDC_reqGetStatus(), MSC_Ctrl(), MSC_ExecuteRead(), MSC_ExecuteWrite(), MSC_handleDataDirMisMatch(), MSC_HandleInquiry(), MSC_HandleModeSense10(), MSC_HandleModeSense6(), MSC_HandlePreventAllowMediaRemoval(), MSC_HandleReadCapacity(), MSC_HandleRequestSense(), MSC_HandleStartStopUnit(), MSC_HandleStateReset(), MSC_HandleStateSendCSW(), MSC_HandleStateSendData(), MSC_HandleStateSendingShortPkt(), MSC_HandleStateSendStall(), MSC_HandleStateWaitForCBW(), MSC_HandleTestUnitReady(), MSC_HandleVerify10(), MSC_reqGetConfiguration(), MSC_reqGetDescriptor(), MSC_reqGetInterface(), MSC_reqGetMaxLUN(), MSC_reqGetStatus(), MSC_sendCswWithPhaseError(), and USB_coreEventProcessEp0().

static CSL_Status USB_processEP0In | ( | pUsbContext | pContext | ) | `[inline, static]`

============================================================================
USB_processEP0In

Description
Writes data to End point 0

Arguments

     	        pContext      -   USB context structure pointer

Return Value CSL_Status

- CSL_SOK - Returned for success
- CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
USB_initEndptObj function should be called successfully

Post Condition
Writes data to end point0

Modifies
Ep0 FIFO registers

Example

    			void  (*evtHandler)();

    			pUsbEpHandle      hEp;
    			CSL_Status        status;
    			CSL_UsbContext    gUsbContext;

    			status = USB_initEndptObj(CSL_USB0,
    									  hEp,
    									  CSL_USB_IN_EP0,
    									  CSL_USB_CTRL,
    									  0x40,
    									  CSL_USB_EVENT_RESET,
    									  evtHandler);
    			....
    			....
    			status = USB_processEP0In(&gUsbContext);

============================================================================

References CSL_UsbTransfer::cbBuffer, CSL_UsbTransfer::cbTransferred, CSL_UsbContext::completeTransferCallback, CSL_USB_EP0, CSL_USB_EP0_IDLE, CSL_USB_MAX_EP0_FIFO_LEN, CSL_USB_MIN, CSL_UsbEpStatus::dwPacketSizeAssigned, CSL_UsbContext::ep0State, CSL_UsbTransfer::fComplete, CSL_UsbContext::fEP0BUFAvailable, CSL_UsbContext::fWaitingOnEP0BUFAvail, CSL_UsbContext::pEpStatus, CSL_UsbTransfer::prevTxferLen, CSL_UsbEpStatus::pTransfer, and CSL_UsbTransfer::pvBuffer.

static CSL_Status USB_processEP0Out | ( | pUsbContext | pContext | ) | `[inline, static]`

============================================================================
USB_processEP0Out

Description
Reads the data from End point 0

Arguments

     	        pContext      -   USB context structure pointer

Return Value CSL_Status

- CSL_SOK - Returned for success
- CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
USB_initEndptObj function should be called successfully

Post Condition
Reads data from end point0

Modifies
Ep0 data buffer

Example

    			void  (*evtHandler)();

    			pUsbEpHandle      hEp;
    			CSL_Status        status;
    			CSL_UsbContext    gUsbContext;

    			status = USB_initEndptObj(CSL_USB0,
    									  hEp,
    									  CSL_USB_OUT_EP0,
    									  CSL_USB_CTRL,
    									  0x40,
    									  CSL_USB_EVENT_RESET,
    									  evtHandler);
    			....
    			....
    			status = USB_processEP0Out(&gUsbContext);

============================================================================

References CSL_UsbTransfer::cbBuffer, CSL_UsbContext::cbOutEP0Buf, CSL_UsbTransfer::cbTransferred, CSL_UsbContext::completeTransferCallback, CSL_USB_EP0, CSL_USB_MIN, CSL_UsbContext::dwOutEP0Buf, CSL_UsbTransfer::fComplete, CSL_UsbContext::fOutPhaseCmd, CSL_UsbContext::pEpStatus, CSL_UsbTransfer::prevTxferLen, CSL_UsbEpStatus::pTransfer, and CSL_UsbTransfer::pvBuffer.

static void USB_readEP0Buf | ( | pUsbContext | pContext,
|  | DWORD * | pBuf
| ) |  | `[inline, static]`

============================================================================
USB_readEP0Buf

Description
This function reads the End point0 buffer

Arguments

     	        pContext      -   USB context structure pointer
     	        pBusSpeed     -   USB Bus speed variable pointer

Return Value None

Pre Condition
USB_initEndptObj function should be called successfully

Post Condition
Reads Ep0 data

Modifies
Ep0 Buffer

Example

    			void  (*evtHandler)();

    			pUsbEpHandle      hEp;
    			CSL_Status        status;
    			CSL_UsbContext    gUsbContext;
    			CSL_UsbBusSpeed   *pBusSpeed

    			status = USB_initEndptObj(CSL_USB0,
    									  hEp,
    									  CSL_USB_IN_EP0,
    									  CSL_USB_CTRL,
    									  0x40,
    									  CSL_USB_EVENT_RESET,
    									  evtHandler);
    			....
    			....
    			status = USB_readEP0Buf(&gUsbContext, &gUsbContext.dwOutEP0Buf);

============================================================================

References CSL_UsbContext::cbOutEP0DataReceived, CSL_USB_MAX_EP0_FIFO_LEN, and CSL_UsbContext::dwOutEP0Buf.

CSL_Status USB_resetDev | ( | CSL_UsbDevNum | devNum | ) |

============================================================================
USB_resetDev

Description
This function resets the USB device

Arguments

                devNum        USB device number, Only USB0 is active currently.

Return Value CSL_Status

- CSL_SOK - Returned for success
- CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
USB_init should be called successfully

Post Condition
Resets the USB device

Modifies
USB registers

Example

                CSL_UsbConfig      usbConfig;
                CSL_Status         status;

                usbConfig.maxCurrent = 50;
                .....
                .....
                status = USB_init(&usbConfig);
                ....
                ....
                status = USB_resetDev(CSL_USB0);

============================================================================

References CSL_USB_EP0, CSL_USB_EP1, CSL_USB_EP2, CSL_USB_EP3, CSL_USB_EP4, CSL_USB_INTMSKSETR1_DEFVAL, CSL_USB_INTMSKSETR2_DEFVAL, CSL_USB_INTRUSB_INTRUSBE_DEFVAL, CSL_UsbContext::fMUSBIsReady, and usbRegisters.

CSL_Status USB_selfwakeup | ( | CSL_UsbDevNum | devNum,
|  | Uint32 | wakeupDelay
| ) |  |

============================================================================
USB_selfwakeup

Description
This function issues a self wakeup signal on the bus. This function can be mapped to an external event like pressing a button on the EVM. After responding to that event through a call back, USB device send a wakeup signal on the bus. NOTE: Application needs to send a delay as a parameter to this function. According to USB wakeup specification an approximate delay of 10mSecs(Min 2 to Max 15 mSecs) is required to send a wakeup signal on the bus. This delay is introduced between setting the resume bit to '1' and restting it to '0'. Application needs to decide a delay such that it is maximum enough to satisfy USB wakeup protocol and minimum to satisfy the USB driver performance.

Arguments

                devNum        USB device number, Only USB0 is active currently.
                wakeupDelay   Delay between Resume bit set and reset

Return Value CSL_Status

- CSL_SOK - Returned for success
- CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
USB init be called successfully and an external event should occur.

Post Condition
Send a wakeup signal on the bus.

Modifies
USB FADDR_POWER register

Example

                CSL_UsbConfig      usbConfig;
                CSL_Status         status;
                Uint16             addr;
                Uint32             wakeupDelay;

                usbConfig.maxCurrent = 50;
                .....
                .....
                status = USB_init(&usbConfig);
                ....
                ....
                //This function call should be mapped to an external event
                wakeupDelay = 1000000;
                status = USB_selfwakeup(CSL_USB0, wakeupDelay);

============================================================================

Set USB Resume bit

Reset the resume bit

References usbRegisters, and CSL_UsbContext::wakeupCallBackFxn.

static void USB_setConfiguration | ( | CSL_UsbDevNum | devNum,
|  | Uint16 | confVal
| ) |  | `[inline, static]`

============================================================================
USB_setConfiguration

Description
This function sets the end point configuration This is provided to use with MSC module This function is not required for standalone MUSB testing

Arguments

     	        pContext      -   USB context structure pointer
     	        pBusSpeed     -   USB Bus speed variable pointer

Return Value None

Pre Condition
USB_initEndptObj function should be called successfully

Post Condition
Checks the USB bus speed

Modifies
Bus speed variable

Example

    			void  (*evtHandler)();

    			pUsbEpHandle      hEp;
    			CSL_Status        status;
    			CSL_UsbContext    gUsbContext;
    			CSL_UsbBusSpeed   *pBusSpeed

    			status = USB_initEndptObj(CSL_USB0,
    									  hEp,
    									  CSL_USB_IN_EP0,
    									  CSL_USB_CTRL,
    									  0x40,
    									  CSL_USB_EVENT_RESET,
    									  evtHandler);
    			....
    			....
    			status = USB_setConfiguration(CSL_USB0, 0x02);

============================================================================

References CSL_USB_EP1, CSL_USB_EP2, CSL_USB_EP3, and CSL_USB_EP4.

Referenced by AC_reqSetConfiguration(), CDC_reqSetConfiguration(), CDC_reqSetInterface(), MSC_reqSetConfiguration(), MSC_reqSetInterface(), and USB_coreEventProcessEp0().

CSL_Status USB_setDevAddr | ( | CSL_UsbDevNum | devNum,
|  | Uint16 | addr
| ) |  |

============================================================================
USB_setDevAddr

Description
This function sets the device Address to USB controller

Arguments

                devNum        USB device number, Only USB0 is active currently.
                addr          Address to set

Return Value CSL_Status

- CSL_SOK - Returned for success
- CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
USB_init should be called successfully

Post Condition
Configures device address registers

Modifies
Device address registers

Example

                CSL_UsbConfig      usbConfig;
                CSL_Status         status;
                Uint16             addr;

                usbConfig.maxCurrent = 50;
                .....
                .....
                status = USB_init(&usbConfig);
                ....
                ....
                status = USB_setDevAddr(CSL_USB0, addr);

============================================================================

References usbRegisters.

Referenced by AC_reqSetAddress(), CDC_reqSetAddress(), MSC_reqSetAddress(), and USB_coreEventProcessEp0().

void USB_setFullSpeedMode | ( | Uint16 | ep0DataSize | ) |

============================================================================
USB_setFullSpeedMode

Description
This function is used to set the USB controller into full speed mode ep0DataSize is the size of the EP0 FIFO. This value should be within the range of values recommended by the USB specification.

Arguments

     	        None

Return Value None

Pre Condition
USB Init should be called successfully

Post Condition
USB will be set for full speed mode

Modifies
USB registers

Example

                CSL_UsbSetupStruct    usbSetup;
                CSL_Status            status;
                CSL_UsbConfig         usbConfig

                status = USB_init(&usbConfig);
                ....
                ....
                USB_setFullSpeedMode(0x20);

============================================================================

References CSL_USB_EP0, CSL_UsbEpStatus::dwPacketSizeAssigned, CSL_UsbContext::pEpStatus, and usbRegisters.

Referenced by CDC_OpenFullspeed(), and MSC_OpenFullspeed().

CSL_Status USB_setParams | ( | CSL_UsbDevNum | devNum,
|  | pUsbEpHandle | hEpObj[],
|  | Uint16 | pSofTmrCnt
| ) |  |

============================================================================
USB_setParams

Description
This function initializes the global end point handle array

Arguments

                devNum        USB device number, Only USB0 is active currently.
                hEpObj        Pointer to a array of endpoint handle.
                pSofTmrCnt    8-bit counter value for the pre SOF timer.

Return Value CSL_Status

- CSL_SOK - Returned for success
- CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
None

Post Condition
Initializes global end point handle array

Modifies
Global end point handle array

Example

    			CSL_UsbEpObj    hEpObjArray[CSL_USB_ENDPOINT_COUNT];
    			CSL_Status      status;

    			status = USB_setParams(CSL_USB0, &hEpObjArray, 0);

============================================================================

References CSL_USB_ENDPOINT_COUNT.

Referenced by AC_Ctrl(), AC_Open(), CDC_Setup(), MSC_Ctrl(), and MSC_Setup().

CSL_Status USB_setRemoteWakeup | ( | CSL_UsbDevNum | devNum,
|  | CSL_UsbBoolean | rmtWkpStat
| ) |  |

============================================================================
USB_setRemoteWakeup

Description
This function sets or clears Remote Wakeup Feature.

Arguments

                devNum        USB device number, Only USB0 is active currently.
                rmtWkpStat    Remote wake up status flag

Return Value CSL_Status

- CSL_SOK - Returned for success
- CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
USB init function should be called successfully.

Post Condition
Sets the remote wake up status

Modifies
Remote wakeup status variable in the USB global context structure

Example

                CSL_UsbConfig      usbConfig;
                CSL_Status         status;

                usbConfig.maxCurrent = 50;
                .....
                .....
                status = USB_init(&usbConfig);
                ....
                ....
                status = USB_setRemoteWakeup(CSL_USB0, CSL_USB_TRUE);

============================================================================

References CSL_UsbContext::remoteWkpStat.

Referenced by AC_reqClearFeature(), AC_reqSetFeature(), CDC_reqClearFeature(), CDC_reqSetFeature(), MSC_reqClearFeature(), MSC_reqSetFeature(), and USB_coreEventProcessEp0().

CSL_Status USB_stallEndpt | ( | pUsbEpHandle | hEp | ) |

============================================================================
USB_stallEndpt

Description
This function stalls an end point

Arguments

                hEp         Handle to an initialized endpoint object.

Return Value CSL_Status

- CSL_SOK - Returned for success
- CSL_ESYS_BADHANDLE - Invalid end point handle
- CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
End point init function should be called successfully

Post Condition
Stalls an end point associated with the passed handle

Modifies
USB control registers

Example

     			void      (*evtHandler)();

     			pUsbEpHandle   hEp;
                CSL_Status     status;

                status = USB_initEndptObj(CSL_USB0,
                                          hEp,
                                          CSL_USB_OUT_EP0,
                                          CSL_USB_CTRL,
                                          0x40,
                                          CSL_USB_EVENT_RESET,
                                          evtHandler);			...
    			...
    			status = USB_stallEndpt(hEp);

============================================================================

References CSL_USB_EP0, CSL_USB_IN_EP0, CSL_UsbEpStatus::dwEndpoint, CSL_UsbEpObj::epNum, CSL_UsbEpStatus::fInitialized, CSL_UsbEpStatus::fStalled, CSL_UsbContext::pEpStatus, and usbRegisters.

Referenced by AC_Ctrl(), AC_reqSetFeature(), CDC_reqSetFeature(), MSC_Ctrl(), MSC_ExecuteRead(), MSC_handleDataDirMisMatch(), MSC_HandleModeSense10(), MSC_HandleModeSense6(), MSC_HandlePreventAllowMediaRemoval(), MSC_HandleStartStopUnit(), MSC_HandleStateSendingShortPkt(), MSC_HandleStateWaitForCBW(), MSC_HandleTestUnitReady(), MSC_HandleVerify10(), MSC_reqSetFeature(), and USB_coreEventProcessEp0().

CSL_Status USB_suspendDevice | ( | CSL_UsbDevNum | devNum | ) |

============================================================================
USB_suspendDevice

Description
This function suspends the USB device. This function informs the application about the device suspend through a call back function.

Arguments

                devNum        USB device number, Only USB0 is active currently.

Return Value CSL_Status

- CSL_SOK - Returned for success
- CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
USB init be called successfully.

Post Condition
Puts the USB device into suspend mode.

Modifies
USB FADDR_POWER register

Example

                CSL_UsbConfig      usbConfig;
                CSL_Status         status;
                Uint16             addr;

                usbConfig.maxCurrent = 50;
                .....
                .....
                status = USB_init(&usbConfig);
                ....
                ....
                status = USB_suspendDevice(CSL_USB0);

============================================================================

References CSL_UsbContext::suspendCallBackFxn, and usbRegisters.

static CSL_Status USB_swapWords | ( | Uint16 * | dataBuffer,
|  | Uint32 | dataLength
| ) |  | `[inline, static]`

===========================================================================
USB_swapWords

Description
This function swaps words in a given buffer

Arguments

                dataBuffer    Pointer to the buffer which words needs to be swapped
                dataLength    Length of data to be word swapped (In words)

Return Value CSL_Status

- CSL_SOK - Reset successful
- CSL_ESYS_INVPARAMS - Invalid parameters

Pre Condition
None

Post Condition
None

Modifies
Order of data in the given buffer

Example

                #define USB_PACKET_SIZE (256)

                Uint16        usbBuf [USB_PACKET_SIZE];
                CSL_Status    status;

                status = USB_swapWords (usbBuf, USB_PACKET_SIZE);

===========================================================================

Referenced by USB_confDmaTx(), and USB_dmaRxStop().