Functions
USB CDC Functions
CDC

Functions

CSL_Status CDC_Open (pCdcAppClassHandle pAppClassHandle)
CSL_Status CDC_OpenFullspeed (pCdcAppClassHandle pAppClassHandle)
static CSL_Status CDC_Setup (pCdcAppClassHandle pAppClassHandle, Bool usbSpeedCfg)
CSL_Status CDC_Close (pCdcAppClassHandle pAppClassHandle)
Uint16 CDC_GetactivityFlagStatus (void *pCDC)
Uint16 CDC_GetsuspendFlagStatus (void *pCDC)
CSL_CdcRequestRet CDC_eventHandler (pUsbContext pContext, CSL_CdcClassStruct *hCdcClass)
CSL_Status CDC_bulkOutHandler (pUsbContext pContext, CSL_CdcInitStructApp *cdcAppHandle)
CSL_Status CDC_bulkInHandler (pUsbContext pContext, CSL_CdcInitStructApp *cdcAppHandle)
Uint16 CDC_getData (pUsbContext pContext, CSL_CdcInitStructApp *cdcAppHandle, Uint16 *data)
Uint16 CDC_putData (pUsbContext pContext, CSL_CdcInitStructApp *cdcAppHandle, Uint16 *data, Uint16 size)
static CSL_CdcRequestRet CDC_reqSetAddress (CSL_UsbDevNum devNum, CSL_UsbSetupStruct *usbSetup, pUsbEpHandle hInEp, pUsbEpHandle hOutEp, void *pCdc)
static CSL_CdcRequestRet CDC_reqSetConfiguration (CSL_UsbDevNum devNum, CSL_UsbSetupStruct *usbSetup, pUsbEpHandle hInEp, pUsbEpHandle hOutEp, void *pCdc)
static CSL_CdcRequestRet CDC_reqClearFeature (CSL_UsbDevNum devNum, CSL_UsbSetupStruct *usbSetup, pUsbEpHandle hInEp, pUsbEpHandle hOutEp, void *pCdc)
static CSL_CdcRequestRet CDC_reqGetStatus (CSL_UsbDevNum devNum, CSL_UsbSetupStruct *usbSetup, pUsbEpHandle hInEp, pUsbEpHandle hOutEp, void *pCdc)
static CSL_CdcRequestRet CDC_reqSetFeature (CSL_UsbDevNum devNum, CSL_UsbSetupStruct *usbSetup, pUsbEpHandle hInEp, pUsbEpHandle hOutEp, void *pCdc)
static CSL_CdcRequestRet CDC_reqGetConfiguration (CSL_UsbDevNum devNum, CSL_UsbSetupStruct *usbSetup, pUsbEpHandle hInEp, pUsbEpHandle hOutEp, void *pCdc)
static CSL_CdcRequestRet CDC_reqGetMaxLUN (CSL_UsbDevNum devNum, CSL_UsbSetupStruct *usbSetup, pUsbEpHandle hInEp, pUsbEpHandle hOutEp, void *pCdc)
static CSL_CdcRequestRet CDC_reqGetInterface (CSL_UsbDevNum devNum, CSL_UsbSetupStruct *usbSetup, pUsbEpHandle hInEp, pUsbEpHandle hOutEp, void *pCdc)
static CSL_CdcRequestRet CDC_reqSetInterface (CSL_UsbDevNum devNum, CSL_UsbSetupStruct *usbSetup, pUsbEpHandle hInEp, pUsbEpHandle hOutEp, void *pCdc)

Function Documentation

CSL_Status CDC_bulkInHandler ( pUsbContext  pContext,
CSL_CdcInitStructApp cdcAppHandle 
)

============================================================================
CDC_bulkInHandler

Description
This function handles all the CDC ACM bulk IN data transactions

Arguments

			pContext		 Pointer to the USBContext structure
            hCdcClass        Handle to the CDC Class Obj
     

Return Value - Status of the processing (CSL_Status)

  • CSL_SOK (0) Success
  • CSL_ESYS_FAIL (-1) Generic failure
  • CSL_ESYS_BADHANDLE (-5) Handle passed to CSL was invalid
  • CSL_ESYS_INVPARAMS (-6) Invalid parameters

Pre Condition
CDC module should be opened using CDC_Open/CDC_OpenFullspeed function

Post Condition
Returns request processing status

Modifies
None

Example

			CSL_CdcInitStructApp    cdcAppHandle;
			CSL_CdcClassStruct      cdcClassStruct;
			CSL_Status              status;

			// Assign values to all the members in cdcAppHandle struct
			cdcAppHandle.pCdcObj = &cdcClassStruct;
			.....
			.....
			status = CDC_Open(pAppClassHandle);
			....
			....
			
			in USB ISR:
			....
			....
			if (pContext->dwIntSourceL & (1<<CSL_CDC_BULK_IN_EP))
			{
				// Handle the CDC BULK IN
				///CDC_bulkInHandler(pContext, &CDC_AppHandle);
			}
			....
			....
     

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

References CSL_USB_IN_TRANSFER, CSL_UsbContext::hEpObjArray, CSL_CdcInitStructApp::txBufferPtr, CSL_CdcInitStructApp::txWorkBufPtr, USB_bytesRemaining(), USB_isTransactionDone(), and USB_postTransaction().

CSL_Status CDC_bulkOutHandler ( pUsbContext  pContext,
CSL_CdcInitStructApp cdcAppHandle 
)

============================================================================
CDC_bulkOutHandler

Description
This function handles all the CDC ACM bulk OUT data transactions

Arguments

			pContext		 Pointer to the USBContext structure
            hCdcClass        Handle to the CDC Class Obj
     

Return Value - Status of the processing (CSL_Status)

  • CSL_SOK (0) Success
  • CSL_ESYS_FAIL (-1) Generic failure
  • CSL_ESYS_BADHANDLE (-5) Handle passed to CSL was invalid
  • CSL_ESYS_INVPARAMS (-6) Invalid parameters

Pre Condition
CDC module should be opened using CDC_Open/CDC_OpenFullspeed function

Post Condition
Returns request processing status

Modifies
None

Example

			CSL_CdcInitStructApp    cdcAppHandle;
			CSL_CdcClassStruct      cdcClassStruct;
			CSL_Status              status;

			// Assign values to all the members in cdcAppHandle struct
			cdcAppHandle.pCdcObj = &cdcClassStruct;
			.....
			.....
			status = CDC_Open(pAppClassHandle);
			....
			....
			
			in USB ISR:
			....
			....
			if (pContext->dwIntSourceL & (1<<(CSL_CDC_BULK_OUT_EP+CSL_USB_IN_EP0)))
			{
				// Handle the CDC BULK OUT
				CDC_bulkOutHandler(pContext, &CDC_AppHandle);
			}
			....
			....
     

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

References CSL_USB_OUT_TRANSFER, CSL_UsbContext::hEpObjArray, CSL_UsbContext::pEpStatus, CSL_CdcInitStructApp::rxBufferPtr, USB_bytesRemaining(), USB_epNumToHandle(), USB_getDataCountReadFromFifo(), USB_isTransactionDone(), USB_isValidDataInFifoOut(), and USB_postTransaction().

CSL_Status CDC_Close ( pCdcAppClassHandle  pAppClassHandle)

============================================================================
CDC_Close

Description
This function Opens the Cdc module.

Arguments

            pAppClassHandle       Application handle to the CDC Class Obj
     

Return Value CSL_Status

  • CSL_SOK - Returned for success
  • CSL_ESYS_BADHANDLE - Invalid Cdc class handle

Pre Condition
CDC module should be opened using CDC_Open/CDC_OpenFullspeed function

Post Condition
Closes the Cdc module

Modifies
Cdc and Ctl handles

Example

			CSL_CdcInitStructApp    cdcAppHandle;
			pCdcAppClassHandle      pAppClassHandle;
			Uint16                  cdcAppBuffer[420];
			CSL_Status              status;

			pAppClassHandle = &cdcAppHandle;

			// Assign values to all the members in cdcAppHandle struct
			cdcAppHandle.pCdcObj = &cdcAppBuffer[0];
			.....
			.....
			status = CDC_Open(pAppClassHandle);
			....
			....
			status = CDC_Close(pAppClassHandle);
     

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

============================================================================
CDC_Close

Description
This function close the Cdc module.

Arguments

            pAppClassHandle       Application handle to the CDC Class Obj
     

Return Value CSL_Status

  • CSL_SOK - Returned for success
  • CSL_ESYS_BADHANDLE - Invalid Cdc class handle

Pre Condition
CDC module should be opened using CDC_Open/CDC_OpenFullspeed function

Post Condition
Closes the Cdc module

Modifies
Cdc and Ctl handles

Example

			CSL_CdcInitStructApp    cdcAppHandle;
			pCdcAppClassHandle      pAppClassHandle;
			Uint16                  cdcAppBuffer[420];
			CSL_Status              status;

			pAppClassHandle = &cdcAppHandle;

			// Assign values to all the members in cdcAppHandle struct
			cdcAppHandle.pCdcObj = &cdcAppBuffer[0];
			.....
			.....
			status = CDC_Open(pAppClassHandle);
			....
			....
			status = CDC_Close(pAppClassHandle);
     

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

References CSL_CdcClassStruct::ctrlHandle, CSL_CdcCtrlObject::devNum, CSL_CdcInitStructApp::pCdcObj, and USB_disconnectDev().

CSL_CdcRequestRet CDC_eventHandler ( pUsbContext  pContext,
CSL_CdcClassStruct hCdcClass 
)

============================================================================
CDC_eventHandler

Description
This function handles all the CDC ACM related requests

Arguments

			pContext		 Pointer to the USBContext structure
            hCdcClass        Handle to the CDC Class Obj
     

Return Value - Status of the request (CSL_CdcRequestRet)

  • CSL_CDC_REQUEST_DONE (0) - CDC request process done
  • CSL_CDC_REQUEST_STALL (1) - STALL the control endpoint
  • CSL_CDC_REQUEST_SEND_ACK (2) - Prepare to receive 0 length OUT packet
  • CSL_CDC_REQUEST_DATA_IN (0) - Notify handler when IN data has been transmitted
  • CSL_CDC_REQUEST_DATA_OUT (0) - Notify handler when OUT data has been received

Pre Condition
CDC module should be opened using CDC_Open/CDC_OpenFullspeed function

Post Condition
Returns request processing status

Modifies
None

Example

			CSL_CdcInitStructApp    cdcAppHandle;
			CSL_CdcClassStruct      cdcClassStruct;
			CSL_Status              status;

			// Assign values to all the members in cdcAppHandle struct
			cdcAppHandle.pCdcObj = &cdcClassStruct;
			.....
			.....
			status = CDC_Open(pAppClassHandle);
			....
			....
			
			in USB ISR:
			....
			....
			if(pContext->dwIntSourceL & CSL_USB_TX_RX_INT_EP0)
			{
				// call USB core EP0 event handler to process
				USB_coreEventProcessEp0(pContext);

				// call the CDC event handler for further processing
				CDC_eventHandler(pContext, &cdcClassStruct);
			}
			....
			....
     

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

References CSL_UsbSetupStruct::bmRequestType, CSL_UsbSetupStruct::bRequest, CSL_CdcClassStruct::cdcHandle, CSL_CdcObject::controlLineState, CSL_CDC_REQUEST_GET_COMM_FEATURE, CSL_CDC_REQUEST_GET_ENCAPSULATED_RESPONSE, CSL_CDC_REQUEST_GET_LINE_CODING, CSL_CDC_REQUEST_SEND_ENCAPSULATED_COMMAND, CSL_CDC_REQUEST_SET_COMM_FEATURE, CSL_CDC_REQUEST_SET_CONTROL_LINE_STATE, CSL_CDC_REQUEST_SET_LINE_CODING, CSL_USB_EP0, CSL_USB_IOFLAG_NONE, CSL_USB_IOFLAG_NOSHORT, CSL_UsbContext::hEpObjArray, CSL_CdcObject::lineCoding, USB_getSetupPacket(), USB_postTransaction(), usbRegisters, CSL_UsbContext::usbSetup, CSL_UsbSetupStruct::wIndex, CSL_UsbSetupStruct::wLength, and CSL_UsbSetupStruct::wValue.

Uint16 CDC_GetactivityFlagStatus ( void *  pCDC)

============================================================================
CDC_GetactivityFlagStatus

Description
This function gives the status of the activity Flag

Arguments

            pCDC        Handle to the CDC Class Obj
     

Return Value - Status of the activity flag

  • '1' - If the activity is present
  • '0' - If the activity is not present

Pre Condition
CDC module should be opened using CDC_Open/CDC_OpenFullspeed function

Post Condition
Returns Activity flag status

Modifies
None

Example

			Uint16                  activityFlagStat;
			CSL_CdcInitStructApp    cdcAppHandle;
			pCdcAppClassHandle      pAppClassHandle;
			Uint16                  cdcAppBuffer[420];
			CSL_Status              status;

			pAppClassHandle = &cdcAppHandle;

			// Assign values to all the members in cdcAppHandle struct
			cdcAppHandle.pCdcObj = &cdcAppBuffer[0];
			.....
			.....
			status = CDC_Open(pAppClassHandle);
			....
			....
			activityFlagStat = CDC_GetactivityFlagStatus(pAppClassHandle->pCdcObj);
     

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

============================================================================
CDC_GetactivityFlagStatus

Description
This function gives the status of the activity Flag

Arguments

            pCDC        Handle to the CDC Class Obj
     

Return Value - Status of the activity flag

  • '1' - If the activity is present
  • '0' - If the activity is not present

Pre Condition
CDC module should be opened using CDC_Open/CDC_OpenFullspeed function

Post Condition
Returns Activity flag status

Modifies
None

Example

			Uint16                  activityFlagStat;
			CSL_MCdcInitStructApp    cdcAppHandle;
			pCdcAppClassHandle      pAppClassHandle;
			Uint16                  cdcAppBuffer[420];
			CSL_Status              status;

			pAppClassHandle = &cdcAppHandle;

			// Assign values to all the members in cdcAppHandle struct
			cdcAppHandle.pCdcObj = &cdcAppBuffer[0];
			.....
			.....
			status = CDC_Open(pAppClassHandle);
			....
			....
			activityFlagStat = CDC_GetactivityFlagStatus(pAppClassHandle->pCdcObj);
     

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

References CSL_CdcObject::activityPresentFlag, and CSL_CdcClassStruct::cdcHandle.

Uint16 CDC_getData ( pUsbContext  pContext,
CSL_CdcInitStructApp cdcAppHandle,
Uint16 *  data 
)

============================================================================
CDC_getData

Description
This function receives data from the BULK OUT

Arguments

			pContext		 Pointer to the USBContext structure
            hCdcClass        Handle to the CDC Class Obj
			data			the data to be transmitted
     

Return Value - number of byte received

  • 0 - means the BULK OUT has no data avaiable
  • N > 0 - means N byte data has been received

Pre Condition
CDC module should be opened using CDC_Open/CDC_OpenFullspeed function

Post Condition
Returns request processing status

Modifies
None

Example

			CSL_CdcInitStructApp    cdcAppHandle;
			CSL_CdcClassStruct      cdcClassStruct;
			CSL_Status              status;
			Uint16					uartData[80]
			Uint16					uartdataSize;

			// Assign values to all the members in cdcAppHandle struct
			cdcAppHandle.pCdcObj = &cdcClassStruct;
			.....
			.....
			status = CDC_Open(pAppClassHandle);
			....
			....
			// Echo the input from the host back to the host
			// Get data from the host
			uartDataSize = CDC_getData(pContext, &CDC_AppHandle, uartData);
			// Echo it back, if there is an input
			if (uartDataSize>0)
			{
				do 
				{
					// CDC_putData will return 0 if the TX is not ready for the transaction
					retNum = CDC_putData(pContext, &CDC_AppHandle, uartData, uartDataSize);
				} while (retNum==0);
			}
			....
			....
     

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

References CSL_CdcInitStructApp::rxBufferPtr.

Uint16 CDC_GetsuspendFlagStatus ( void *  pCDC)

============================================================================
CDC_GetsuspendFlagStatus

Description
This function gives the status of the suspend Flag

Arguments

            pCDC        Handle to the CDC Class Obj
     

Return Value - Status of the suspend flag

  • '1' - If the device is suspended
  • '0' - If the device is not suspended

Pre Condition
CDC module should be opened using CDC_Open/CDC_OpenFullspeed function

Post Condition
Returns suspend flag status

Modifies
None

Example

			Uint16                  suspendFlagStat;
			CSL_CdcInitStructApp    cdcAppHandle;
			pCdcAppClassHandle      pAppClassHandle;
			Uint16                  cdcAppBuffer[420];
			CSL_Status              status;

			pAppClassHandle = &cdcAppHandle;

			// Assign values to all the members in cdcAppHandle struct
			cdcAppHandle.pCdcObj = &cdcAppBuffer[0];
			.....
			.....
			status = CDC_Open(pAppClassHandle);
			....
			....
			suspendFlagStat = CDC_GetsuspendFlagStatus(pAppClassHandle->pCdcObj);
     

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

References CSL_CdcClassStruct::ctrlHandle, and CSL_CdcCtrlObject::suspendFlag.

CSL_Status CDC_Open ( pCdcAppClassHandle  pAppClassHandle)

============================================================================
CDC_Open

Description
This function Opens the Cdc module. It initializes Cdc and Ctrl handles with the data given by the application.

NOTE: THIS FUNCTION CONFIGURES USB CDC MODULE IN HIGH SPEED MODE

Arguments

		    pAppClassHandle      Application handle to the CDC Class Obj
     

Return Value CSL_Status

  • CSL_SOK - Returned for success
  • CSL_ESYS_BADHANDLE - Invalid Cdc handle
  • CSL_ESYS_BADMEDIA - Media is Bad - Format needed
  • CSL_ESYS_MEDIA_NOTPRESENT - Media is not present

Pre Condition
None

Post Condition
Initializes Cdc and Ctrl handles

Modifies
Cdc and Ctrl handle data

Example

			CSL_CdcInitStructApp    cdcAppHandle;
			pCdcAppClassHandle      pAppClassHandle;
			Uint16                  cdcAppBuffer[420];
			CSL_Status              status;

			pAppClassHandle = &cdcAppHandle;

			// Assign values to all the members in cdcAppHandle struct
			cdcAppHandle.pCdcObj = &cdcAppBuffer[0];
			.....
			.....
			status = CDC_Open(pAppClassHandle);
     

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

============================================================================
CDC_Open

Description
This function Opens the CDC module. It initializes CDC and Ctrl handles with the data given by the application.

NOTE: THIS FUNCTION CONFIGURES USB CDC MODULE IN HIGH SPEED MODE

Arguments

		    pAppClassHandle      Application handle to the CDC Class Obj
     

Return Value CSL_Status

  • CSL_SOK - Returned for success
  • CSL_ESYS_BADHANDLE - Invalid CDC handle

Pre Condition
None

Post Condition
Initializes CDC and Ctrl handles

Modifies
CDC and Ctrl handle data

Example

			CSL_CdcInitStructApp    cdcAppHandle;
			pCdcAppClassHandle      pAppClassHandle;
			Uint16                  cdcAppBuffer[420];
			CSL_Status              status;

			pAppClassHandle = &mscAppHandle;

			// Assign values to all the members in cdcAppHandle struct
			cdcAppHandle.pCdcObj = &cdcAppBuffer[0];
			.....
			.....
			status = CDC_Open(pAppClassHandle);
     

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

References CDC_Setup().

CSL_Status CDC_OpenFullspeed ( pCdcAppClassHandle  pAppClassHandle)

============================================================================
CDC_OpenFullspeed

Description
This function Opens the Cdc module for fullspeed mode operation. It initializes Cdc and Ctrl handles with the data given by the application

NOTE: THIS FUNCTION CONFIGURES USB CDC MODULE IN FULLSPEED MODE

Arguments

		    pAppClassHandle      Application handle to the CDC Class Obj
     

Return Value CSL_Status

  • CSL_SOK - Returned for success
  • CSL_ESYS_BADHANDLE - Invalid Cdc handle
  • CSL_ESYS_BADMEDIA - Media is Bad - Format needed
  • CSL_ESYS_MEDIA_NOTPRESENT - Media is not present

Pre Condition
None

Post Condition
Initializes Cdc and Ctrl handles

Modifies
Cdc and Ctrl handle data

Example

			CSL_CdcInitStructApp    cdcAppHandle;
			pCdcAppClassHandle      pAppClassHandle;
			Uint16                  cdcAppBuffer[420];
			CSL_Status              status;

			pAppClassHandle = &cdcAppHandle;

			// Assign values to all the members in cdcAppHandle struct
			cdcAppHandle.pCdcObj = &cdcAppBuffer[0];
			.....
			.....
			status = CDC_OpenFullspeed(pAppClassHandle);
     

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

============================================================================
CDC_OpenFullspeed

Description
This function Opens the Cdc module for fullspeed mode operation. It initializes Cdc and Ctrl handles with the data given by the application

NOTE: THIS FUNCTION CONFIGURES USB CDC MODULE IN FULLSPEED MODE

Arguments

		    pAppClassHandle      Application handle to the CDC Class Obj
     

Return Value CSL_Status

  • CSL_SOK - Returned for success
  • CSL_ESYS_BADHANDLE - Invalid Cdc handle

Pre Condition
None

Post Condition
Initializes Cdc and Ctrl handles

Modifies
Cdc and Ctrl handle data

Example

			CSL_CdcInitStructApp    cdcAppHandle;
			pCdcAppClassHandle      pAppClassHandle;
			Uint16                  cdcAppBuffer[420];
			CSL_Status              status;

			pAppClassHandle = &cdcAppHandle;

			// Assign values to all the members in cdcAppHandle struct
			cdcAppHandle.pCdcObj = &cdcAppBuffer[0];
			.....
			.....
			status = CDC_OpenFullspeed(pAppClassHandle);
     

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

References CDC_Setup(), CSL_USB_EP0_PACKET_SIZE, and USB_setFullSpeedMode().

Uint16 CDC_putData ( pUsbContext  pContext,
CSL_CdcInitStructApp cdcAppHandle,
Uint16 *  data,
Uint16  size 
)

============================================================================
CDC_putData

Description
This function sends out the data to the BULK IN

Arguments

			pContext		 Pointer to the USBContext structure
            hCdcClass        Handle to the CDC Class Obj
			data			the data to be transmitted
			size			the data size
     

Return Value - number of byte sent out

  • 0 - means the BULK IN is not ready for transmission
  • N > 0 - means the transmission is done and N byte data has been sent out

Pre Condition
CDC module should be opened using CDC_Open/CDC_OpenFullspeed function

Post Condition
Returns request processing status

Modifies
None

Example

			CSL_CdcInitStructApp    cdcAppHandle;
			CSL_CdcClassStruct      cdcClassStruct;
			CSL_Status              status;
			Uint16					uartData[80]
			Uint16					uartdataSize;

			// Assign values to all the members in cdcAppHandle struct
			cdcAppHandle.pCdcObj = &cdcClassStruct;
			.....
			.....
			status = CDC_Open(pAppClassHandle);
			....
			....
			// Echo the input from the host back to the host
			// Get data from the host
			uartDataSize = CDC_getData(pContext, &CDC_AppHandle, uartData);
			// Echo it back, if there is an input
			if (uartDataSize>0)
			{
				do 
				{
					// CDC_putData will return 0 if the TX is not ready for the transaction
					retNum = CDC_putData(pContext, &CDC_AppHandle, uartData, uartDataSize);
				} while (retNum==0);
			}
			....
			....
     

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

References CSL_USB_IN_TRANSFER, CSL_UsbContext::hEpObjArray, CSL_CdcInitStructApp::txBufferPtr, CSL_CdcInitStructApp::txWorkBufPtr, USB_bytesRemaining(), USB_isTransactionDone(), and USB_postTransaction().

static CSL_CdcRequestRet CDC_reqClearFeature ( CSL_UsbDevNum  devNum,
CSL_UsbSetupStruct usbSetup,
pUsbEpHandle  hInEp,
pUsbEpHandle  hOutEp,
void *  pCdc 
) [inline, static]

============================================================================
CDC_reqClearFeature

Description
This function handles the request to clear the feature set

Arguments

            devNum   - USB device number
            usbSetup - USB setup structure pointer
            hInEp    - USB IN endpoint handle
            hOutEp   - USB OUT endpoint handle
            pCdc     - Handle to the CDC Class Obj
     

Return Value

  • CSL_CDC_REQUEST_SEND_ACK - Send acknowledgement for request
  • CSL_CDC_REQUEST_STALL - Request stall signal (Error)

Pre Condition
CDC_lookupReqHandler should be called successfully

Post Condition
Clears the feature

Modifies
USB registers

Example

             CSL_CdcInitStructApp    cdcAppHandle;
             CSL_CdcObject           *pCdcHandle;
             CSL_CdcCtrlObject       *pCtrlHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  cdcAppBuffer[420];
             CSL_Status              status;
             Uint16                  request;

             // Assign values to all the members in cdcAppHandle struct
             cdcAppHandle.pCdcObj = &cdcAppBuffer[0];
             .....
             .....
             status = CDC_Open(&cdcAppHandle);
             ....
             ....
             pCtrlHandle->fpRequestHandler = CDC_lookupReqHandler(request,
                                                       pCtrlHandle->cdcReqTable);

             pCtrlHandle->fpRequestHandler(pCtrlHandle->devNum,
                                           &pCtrlHandle->usbSetup,hCtrlEpIn,hCtrlEpOut,pCDC);
     

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

References CSL_USB_FEATURE_ENDPOINT_STALL, CSL_USB_FEATURE_REMOTE_WAKEUP, USB_clearEndptStall(), USB_epNumToHandle(), USB_setRemoteWakeup(), CSL_UsbSetupStruct::wIndex, and CSL_UsbSetupStruct::wValue.

static CSL_CdcRequestRet CDC_reqGetConfiguration ( CSL_UsbDevNum  devNum,
CSL_UsbSetupStruct usbSetup,
pUsbEpHandle  hInEp,
pUsbEpHandle  hOutEp,
void *  pCdc 
) [inline, static]

============================================================================
CDC_reqGetConfiguration

Description
This function handles the request from host to get configuration

Arguments

            devNum   - USB device number
            usbSetup - USB setup structure pointer
            hInEp    - USB IN endpoint handle
            hOutEp   - USB OUT endpoint handle
            pCdc     - Handle to the CDC Class Obj
     

Return Value

  • CSL_CDC_REQUEST_GET_ACK - Get acknowledgement for request

Pre Condition
CDC_lookupReqHandler should be called successfully

Post Condition
Sends the configuration

Modifies
None

Example

             CSL_CdcInitStructApp    cdcAppHandle;
             CSL_CdcObject           *pCdcHandle;
             CSL_CdcCtrlObject       *pCtrlHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  cdcAppBuffer[420];
             CSL_Status              status;
             Uint16                  request;

             // Assign values to all the members in cdcAppHandle struct
             cdcAppHandle.pCdcObj = &cdcAppBuffer[0];
             .....
             .....
             status = CDC_Open(&cdcAppHandle);
             ....
             ....
             pCtrlHandle->fpRequestHandler = CDC_lookupReqHandler(request,
                                                       pCtrlHandle->cdcReqTable);

             pCtrlHandle->fpRequestHandler(pCtrlHandle->devNum,
                                           &pCtrlHandle->usbSetup,hCtrlEpIn,hCtrlEpOut,pCDC);
     

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

References CSL_USB_IOFLAG_NONE, CSL_USB_IOFLAG_NOSHORT, CSL_CdcClassStruct::ctrlHandle, CSL_CdcCtrlObject::curConfigStat, and USB_postTransaction().

static CSL_CdcRequestRet CDC_reqGetInterface ( CSL_UsbDevNum  devNum,
CSL_UsbSetupStruct usbSetup,
pUsbEpHandle  hInEp,
pUsbEpHandle  hOutEp,
void *  pCdc 
) [inline, static]

============================================================================
CDC_reqGetInterface

Description
This function handles the request from host to get interface unit number

Arguments

            devNum   - USB device number
            usbSetup - USB setup structure pointer
            hInEp    - USB IN endpoint handle
            hOutEp   - USB OUT endpoint handle
            pCdc     - Handle to the CDC Class Obj
     

Return Value

  • CSL_CDC_REQUEST_GET_ACK - Get acknowledgement for request\
  • CSL_CDC_REQUEST_STALL - Request stall signal (Error)

Pre Condition
CDC_lookupReqHandler should be called successfully

Post Condition
Sends interface info

Modifies
None

Example

             CSL_CdcInitStructApp    cdcAppHandle;
             CSL_CdcObject           *pCdcHandle;
             CSL_CdcCtrlObject       *pCtrlHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  cdcAppBuffer[420];
             CSL_Status              status;
             Uint16                  request;

             // Assign values to all the members in cdcAppHandle struct
             cdcAppHandle.pCdcObj = &cdcAppBuffer[0];
             .....
             .....
             status = CDC_Open(&cdcAppHandle);
             ....
             ....
             pCtrlHandle->fpRequestHandler = CDC_lookupReqHandler(request,
                                                       pCtrlHandle->cdcReqTable);

             pCtrlHandle->fpRequestHandler(pCtrlHandle->devNum,
                                           &pCtrlHandle->usbSetup,hCtrlEpIn,hCtrlEpOut,pCDC);
     

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

References CSL_USB_IOFLAG_NONE, CSL_CdcClassStruct::ctrlHandle, USB_postTransaction(), and CSL_UsbSetupStruct::wIndex.

static CSL_CdcRequestRet CDC_reqGetMaxLUN ( CSL_UsbDevNum  devNum,
CSL_UsbSetupStruct usbSetup,
pUsbEpHandle  hInEp,
pUsbEpHandle  hOutEp,
void *  pCdc 
) [inline, static]

============================================================================
CDC_reqGetMaxLUN

Description
This function handles the request from host to send maximum logical unit number

Arguments

            devNum   - USB device number
            usbSetup - USB setup structure pointer
            hInEp    - USB IN endpoint handle
            hOutEp   - USB OUT endpoint handle
            pCdc     - Handle to the CDC Class Obj
     

Return Value

  • CSL_CDC_REQUEST_GET_ACK - Get acknowledgement for request\
  • CSL_CDC_REQUEST_STALL - Request stall signal (Error)

Pre Condition
CDC_lookupReqHandler should be called successfully

Post Condition
Sends the max lun number

Modifies
None

Example

             CSL_CdcInitStructApp    cdcAppHandle;
             CSL_CdcObject           *pCdcHandle;
             CSL_CdcCtrlObject       *pCtrlHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  cdcAppBuffer[420];
             CSL_Status              status;
             Uint16                  request;

             // Assign values to all the members in cdcAppHandle struct
             cdcAppHandle.pCdcObj = &cdcAppBuffer[0];
             .....
             .....
             status = CDC_Open(&cdcAppHandle);
             ....
             ....
             pCtrlHandle->fpRequestHandler = CDC_lookupReqHandler(request,
                                                       pCtrlHandle->cdcReqTable);

             pCtrlHandle->fpRequestHandler(pCtrlHandle->devNum,
                                           &pCtrlHandle->usbSetup,hCtrlEpIn,hCtrlEpOut,pCDC);
     

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

References CSL_CdcClassStruct::cdcHandle, CSL_USB_IOFLAG_NONE, CSL_CdcClassStruct::ctrlHandle, USB_postTransaction(), CSL_UsbSetupStruct::wIndex, CSL_UsbSetupStruct::wLength, and CSL_UsbSetupStruct::wValue.

static CSL_CdcRequestRet CDC_reqGetStatus ( CSL_UsbDevNum  devNum,
CSL_UsbSetupStruct usbSetup,
pUsbEpHandle  hInEp,
pUsbEpHandle  hOutEp,
void *  pCdc 
) [inline, static]

============================================================================
CDC_reqGetStatus

Description
This function handles the get status request from host

Arguments

            devNum   - USB device number
            usbSetup - USB setup structure pointer
            hInEp    - USB IN endpoint handle
            hOutEp   - USB OUT endpoint handle
            pCdc     - Handle to the CDC Class Obj
     

Return Value

  • CSL_CDC_REQUEST_GET_ACK - Get acknowledgement for request
  • CSL_CDC_REQUEST_STALL - Request stall signal (Error)

Pre Condition
CDC_lookupReqHandler should be called successfully

Post Condition
Sends the status

Modifies
None

Example

             CSL_CdcInitStructApp    cdcAppHandle;
             CSL_CdcObject           *pCdcHandle;
             CSL_CdcCtrlObject       *pCtrlHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  cdcAppBuffer[420];
             CSL_Status              status;
             Uint16                  request;

             // Assign values to all the members in cdcAppHandle struct
             cdcAppHandle.pCdcObj = &cdcAppBuffer[0];
             .....
             .....
             status = CDC_Open(&cdcAppHandle);
             ....
             ....
             pCtrlHandle->fpRequestHandler = CDC_lookupReqHandler(request,
                                                       pCtrlHandle->cdcReqTable);

             pCtrlHandle->fpRequestHandler(pCtrlHandle->devNum,
                                           &pCtrlHandle->usbSetup,hCtrlEpIn,hCtrlEpOut,pCDC);
     

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

References CSL_UsbSetupStruct::bmRequestType, CSL_USB_IOFLAG_NONE, CSL_CdcClassStruct::ctrlHandle, USB_epNumToHandle(), USB_getEndptStall(), USB_getRemoteWakeupStat(), USB_postTransaction(), and CSL_UsbSetupStruct::wIndex.

static CSL_CdcRequestRet CDC_reqSetAddress ( CSL_UsbDevNum  devNum,
CSL_UsbSetupStruct usbSetup,
pUsbEpHandle  hInEp,
pUsbEpHandle  hOutEp,
void *  pCdc 
) [inline, static]

============================================================================
CDC_reqSetAddress

Description
This function handles the request to set the device address

Arguments

            devNum   - USB device number
            usbSetup - USB setup structure pointer
            hInEp    - USB IN endpoint handle
            hOutEp   - USB OUT endpoint handle
            pCdc     - Handle to the CDC Class Obj
     

Return Value

  • CSL_CDC_REQUEST_DONE - Request handled successfully

Pre Condition
CDC_lookupReqHandler should be called successfully

Post Condition
Sets the device address

Modifies
USB FADDR_POWER register

Example

             CSL_CdcInitStructApp    cdcAppHandle;
             CSL_CdcObject           *pCdcHandle;
             CSL_CdcCtrlObject       *pCtrlHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  cdcAppBuffer[420];
             CSL_Status              status;
             Uint16                  request;

             // Assign values to all the members in cdcAppHandle struct
             cdcAppHandle.pCdcObj = &cdcAppBuffer[0];
             .....
             .....
             status = CDC_Open(&cdcAppHandle);
             ....
             ....
             pCtrlHandle->fpRequestHandler = CDC_lookupReqHandler(request,
                                                       pCtrlHandle->cdcReqTable);

             pCtrlHandle->fpRequestHandler(pCtrlHandle->devNum,
                                           &pCtrlHandle->usbSetup,hCtrlEpIn,hCtrlEpOut,pCDC);
     

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

References USB_setDevAddr(), and CSL_UsbSetupStruct::wValue.

static CSL_CdcRequestRet CDC_reqSetConfiguration ( CSL_UsbDevNum  devNum,
CSL_UsbSetupStruct usbSetup,
pUsbEpHandle  hInEp,
pUsbEpHandle  hOutEp,
void *  pCdc 
) [inline, static]

============================================================================
CDC_reqSetConfiguration

Description
This function handles the request to set the device configuration

Arguments

            devNum   - USB device number
            usbSetup - USB setup structure pointer
            hInEp    - USB IN endpoint handle
            hOutEp   - USB OUT endpoint handle
            pCdc     - Handle to the CDC Class Obj
     

Return Value

  • CSL_CDC_REQUEST_SEND_ACK - Send acknowledgement for request
  • CSL_CDC_REQUEST_STALL - Request stall signal (Error)

Pre Condition
CDC_lookupReqHandler should be called successfully

Post Condition
Sets the configuration

Modifies
USB registers

Example

             CSL_CdcInitStructApp    cdcAppHandle;
             CSL_CdcObject           *pCdcHandle;
             CSL_CdcCtrlObject       *pCtrlHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  cdcAppBuffer[420];
             CSL_Status              status;
             Uint16                  request;

             // Assign values to all the members in cdcAppHandle struct
             cdcAppHandle.pCdcObj = &cdcAppBuffer[0];
             .....
             .....
             status = CDC_Open(&cdcAppHandle);
             ....
             ....
             pCtrlHandle->fpRequestHandler = CDC_lookupReqHandler(request,
                                                       pCtrlHandle->cdcReqTable);

             pCtrlHandle->fpRequestHandler(pCtrlHandle->devNum,
                                           &pCtrlHandle->usbSetup,hCtrlEpIn,hCtrlEpOut,pCDC);
     

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

References CSL_CdcClassStruct::ctrlHandle, CSL_CdcCtrlObject::curConfigStat, USB_setConfiguration(), and CSL_UsbSetupStruct::wValue.

static CSL_CdcRequestRet CDC_reqSetFeature ( CSL_UsbDevNum  devNum,
CSL_UsbSetupStruct usbSetup,
pUsbEpHandle  hInEp,
pUsbEpHandle  hOutEp,
void *  pCdc 
) [inline, static]

============================================================================
CDC_reqSetFeature

Description
This function handles the request from host to set feature

Arguments

            devNum   - USB device number
            usbSetup - USB setup structure pointer
            hInEp    - USB IN endpoint handle
            hOutEp   - USB OUT endpoint handle
            pCdc     - Handle to the CDC Class Obj
     

Return Value

  • CSL_CDC_REQUEST_GET_ACK - Get acknowledgement for request
  • CSL_CDC_REQUEST_STALL - Request stall signal (Error)

Pre Condition
CDC_lookupReqHandler should be called successfully

Post Condition
Sets the feature

Modifies
USB regiters

Example

             CSL_CdcInitStructApp    cdcAppHandle;
             CSL_CdcObject           *pCdcHandle;
             CSL_CdcCtrlObject       *pCtrlHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  cdcAppBuffer[420];
             CSL_Status              status;
             Uint16                  request;

             // Assign values to all the members in cdcAppHandle struct
             cdcAppHandle.pCdcObj = &cdcAppBuffer[0];
             .....
             .....
             status = CDC_Open(&cdcAppHandle);
             ....
             ....
             pCtrlHandle->fpRequestHandler = CDC_lookupReqHandler(request,
                                                       pCtrlHandle->cdcReqTable);

             pCtrlHandle->fpRequestHandler(pCtrlHandle->devNum,
                                           &pCtrlHandle->usbSetup,hCtrlEpIn,hCtrlEpOut,pCDC);
     

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

References CSL_USB_FEATURE_ENDPOINT_STALL, CSL_USB_FEATURE_REMOTE_WAKEUP, USB_epNumToHandle(), USB_setRemoteWakeup(), USB_stallEndpt(), CSL_UsbSetupStruct::wIndex, and CSL_UsbSetupStruct::wValue.

static CSL_CdcRequestRet CDC_reqSetInterface ( CSL_UsbDevNum  devNum,
CSL_UsbSetupStruct usbSetup,
pUsbEpHandle  hInEp,
pUsbEpHandle  hOutEp,
void *  pCdc 
) [inline, static]

============================================================================
CDC_reqSetInterface

Description
This function handles the request from host to set interface unit number

Arguments

            devNum   - USB device number
            usbSetup - USB setup structure pointer
            hInEp    - USB IN endpoint handle
            hOutEp   - USB OUT endpoint handle
            pCdc     - Handle to the CDC Class Obj
     

Return Value

  • CSL_CDC_REQUEST_SEND_ACK - Send acknowledgement for request
  • CSL_CDC_REQUEST_STALL - Request stall signal (Error)

Pre Condition
CDC_lookupReqHandler should be called successfully

Post Condition
Sends acknowledgement

Modifies
None

Example

             CSL_CdcInitStructApp    cdcAppHandle;
             CSL_CdcObject           *pCdcHandle;
             CSL_CdcCtrlObject       *pCtrlHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  cdcAppBuffer[420];
             CSL_Status              status;
             Uint16                  request;

             // Assign values to all the members in cdcAppHandle struct
             cdcAppHandle.pCdcObj = &cdcAppBuffer[0];
             .....
             .....
             status = CDC_Open(&cdcAppHandle);
             ....
             ....
             pCtrlHandle->fpRequestHandler = CDC_lookupReqHandler(request,
                                                       pCtrlHandle->cdcReqTable);

             pCtrlHandle->fpRequestHandler(pCtrlHandle->devNum,
                                           &pCtrlHandle->usbSetup,hCtrlEpIn,hCtrlEpOut,pCDC);
     

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

References USB_setConfiguration(), CSL_UsbSetupStruct::wIndex, and CSL_UsbSetupStruct::wValue.

static CSL_Status CDC_Setup ( pCdcAppClassHandle  pAppClassHandle,
Bool  usbSpeedCfg 
) [static]

============================================================================
CDC_Setup

Description
This function used to setup the Cdc and Ctrl handles. This is an internal function and is called from CDC_Open or CDC_OpenFullspeed functions.

Arguments

		    pAppClassHandle      Application handle to the CDC Class Obj
		    usbSpeedCfg          USB speed selection parameter
		                         0 - USB CDC operates in fullspeed mode
		                         1 - USB CDC operates in highspeed mode
     

Return Value CSL_Status

  • CSL_SOK - Returned for success
  • CSL_ESYS_BADHANDLE - Invalid Cdc handle
  • CSL_ESYS_BADMEDIA - Media is Bad - Format needed
  • CSL_ESYS_MEDIA_NOTPRESENT - Media is not present

Pre Condition
None

Post Condition
Initializes Cdc and Ctrl handles

Modifies
Cdc and Ctrl handle data

Example

			CSL_CdcInitStructApp    cdcAppHandle;
			pCdcAppClassHandle      pAppClassHandle;
			Uint16                  cdcAppBuffer[420];
			CSL_Status              status;

			pAppClassHandle = &cdcAppHandle;

			// Assign values to all the members in cdcAppHandle struct
			cdcAppHandle.pCdcObj = &cdcAppBuffer[0];
			.....
			.....
			// Setup USB for highspeed
			status = CDC_Setup(pAppClassHandle, TRUE);
     

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