Functions
USB MSC Functions
MSC

Functions

CSL_Status MSC_Open (pMscAppClassHandle pAppClassHandle)
CSL_Status MSC_OpenFullspeed (pMscAppClassHandle pAppClassHandle)
static CSL_Status MSC_Setup (pMscAppClassHandle pAppClassHandle, Bool usbSpeedCfg)
CSL_Status MSC_Close (pMscAppClassHandle pAppClassHandle)
CSL_Status MSC_SetLunAttr (pMscAppClassHandle pAppClassHandle, CSL_MscLunAttribApp *lunHandle, Uint16 lunNum)
CSL_Status MSC_Ctrl (void *pMSC)
CSL_Status MSC_Bulk (void *pMSC)
Uint16 MSC_GetLunLockedStatus (void *pMSC, Uint16 lunNum)
Uint16 MSC_GetactivityFlagStatus (void *pMSC)
Uint16 MSC_GetsuspendFlagStatus (void *pMSC)
static CSL_Status MSC_initCtrlDesc (CSL_MscCtrlObject *pCtrlHandle)
static CSL_Status MSC_initMscVal (CSL_MscObject *pMscHandle)
CSL_Status MSC_HandleStateWaitForCBW (CSL_MscObject *pMscHandle, pUsbEpHandle hUsbOutEp, pUsbEpHandle hUsbInEp)
CSL_Status MSC_ExecuteRead (CSL_MscObject *pMscHandle, Uint16 lunNum, Uint16 first)
CSL_Status MSC_ExecuteWrite (CSL_MscObject *pMscHandle, Uint16 lunNum, Uint16 first)
CSL_Status MSC_HandleTestUnitReady (CSL_MscObject *pMscHandle, pUsbEpHandle hUsbInEp, Uint16 logicalUnit)
CSL_Status MSC_HandlePreventAllowMediaRemoval (CSL_MscObject *pMscHandle, pUsbEpHandle hUsbInEp, Uint16 logicalUnit)
CSL_Status MSC_HandleReadCapacity (CSL_MscObject *pMscHandle, pUsbEpHandle hUsbInEp, Uint16 logicalUnit)
CSL_MscRequestRet MSC_reqGetDescriptor (CSL_UsbDevNum devNum, CSL_UsbSetupStruct *usbSetup, pUsbEpHandle hInEp, pUsbEpHandle hOutEp, void *pMsc)
CSL_MscRequestRet MSC_reqBotMscReset (CSL_UsbDevNum devNum, CSL_UsbSetupStruct *usbSetup, pUsbEpHandle hInEp, pUsbEpHandle hOutEp, void *pMsc)
CSL_Status MSC_sendCswWithPhaseError (CSL_MscObject *pMscHandle, pUsbEpHandle hUsbInEp)
CSL_Status MSC_handleDataDirMisMatch (CSL_MscObject *pMscHandle, Uint16 dataDir)
static void MSC_SetSenseKeys (Uint16 *senseData, Uint16 senseKey, Uint16 addSenseKey)
static CSL_Status MSC_HandleStateReset (CSL_MscObject *pMscHandle, pUsbEpHandle hUsbOutEp)
static CSL_Status MSC_HandleStartStopUnit (CSL_MscObject *pMscHandle, pUsbEpHandle hUsbInEp, Uint16 lunNum)
static CSL_Status MSC_HandleStateSendCSW (CSL_MscObject *pMscHandle, pUsbEpHandle hUsbOutEp, pUsbEpHandle hUsbInEp)
static CSL_Status MSC_HandleStateSendData (CSL_MscObject *pMscHandle, pUsbEpHandle hUsbInEp)
static CSL_Status MSC_HandleStateSendStall (CSL_MscObject *pMscHandle, pUsbEpHandle hUsbInEp)
static CSL_Status MSC_HandleStateSendingShortPkt (CSL_MscObject *pMscHandle, pUsbEpHandle hUsbInEp)
static CSL_Status MSC_HandleModeSense6 (CSL_MscObject *pMscHandle, pUsbEpHandle hUsbInEp, Uint16 logicalUnit)
static CSL_Status MSC_HandleModeSense10 (CSL_MscObject *pMscHandle, pUsbEpHandle hUsbInEp, Uint16 logicalUnit)
static CSL_Status MSC_HandleInquiry (CSL_MscObject *pMscHandle, pUsbEpHandle hUsbInEp, Uint16 logicalUnit)
static CSL_Status MSC_HandleRequestSense (CSL_MscObject *pMscHandle, pUsbEpHandle hUsbInEp)
static CSL_Status MSC_HandleVerify10 (CSL_MscObject *pMscHandle, pUsbEpHandle hUsbInEp, Uint16 logicalUnit)
static CSL_MscRequestRet MSC_reqUnknown (CSL_UsbDevNum devNum, CSL_UsbSetupStruct *usbSetup, pUsbEpHandle hInEp, pUsbEpHandle hOutEp, void *pMsc)
static fpMSC_REQ_HANDLER MSC_lookupReqHandler (Uint16 request, CSL_MscRequestStruct *pUSB_ReqTable)
static CSL_MscRequestRet MSC_reqSetAddress (CSL_UsbDevNum devNum, CSL_UsbSetupStruct *usbSetup, pUsbEpHandle hInEp, pUsbEpHandle hOutEp, void *pMsc)
static CSL_MscRequestRet MSC_reqSetConfiguration (CSL_UsbDevNum devNum, CSL_UsbSetupStruct *usbSetup, pUsbEpHandle hInEp, pUsbEpHandle hOutEp, void *pMsc)
static CSL_MscRequestRet MSC_reqClearFeature (CSL_UsbDevNum devNum, CSL_UsbSetupStruct *usbSetup, pUsbEpHandle hInEp, pUsbEpHandle hOutEp, void *pMsc)
static CSL_MscRequestRet MSC_reqGetStatus (CSL_UsbDevNum devNum, CSL_UsbSetupStruct *usbSetup, pUsbEpHandle hInEp, pUsbEpHandle hOutEp, void *pMsc)
static CSL_MscRequestRet MSC_reqSetFeature (CSL_UsbDevNum devNum, CSL_UsbSetupStruct *usbSetup, pUsbEpHandle hInEp, pUsbEpHandle hOutEp, void *pMsc)
static CSL_MscRequestRet MSC_reqGetConfiguration (CSL_UsbDevNum devNum, CSL_UsbSetupStruct *usbSetup, pUsbEpHandle hInEp, pUsbEpHandle hOutEp, void *pMsc)
static CSL_MscRequestRet MSC_reqGetMaxLUN (CSL_UsbDevNum devNum, CSL_UsbSetupStruct *usbSetup, pUsbEpHandle hInEp, pUsbEpHandle hOutEp, void *pMsc)
static CSL_MscRequestRet MSC_reqGetInterface (CSL_UsbDevNum devNum, CSL_UsbSetupStruct *usbSetup, pUsbEpHandle hInEp, pUsbEpHandle hOutEp, void *pMsc)
static CSL_MscRequestRet MSC_reqSetInterface (CSL_UsbDevNum devNum, CSL_UsbSetupStruct *usbSetup, pUsbEpHandle hInEp, pUsbEpHandle hOutEp, void *pMsc)
static CSL_Status MSC_verifyCBW (CSL_MscObject *pMscHandle, pUsbEpHandle hUsbOutEp, pUsbEpHandle hUsbInEp)

Function Documentation

CSL_Status MSC_Bulk ( void *  pMSC)

============================================================================
MSC_Bulk

Description
This function handles all UBS traffic on the Bulk Endpoint This maintains the state of the MSC application. Provides Media Access Data to the low level USB module for transfer.

Arguments

            pMSC        Handle to the MSC Class Obj
     

Return Value CSL_Status

  • CSL_SOK - Returned for success
  • CSL_ESYS_BADHANDLE - Invalid Msc class handle
  • CSL_ESYS_INVPARAMS - Returned for invalid storage state

Pre Condition
MSC module should be opened using MSC_Open/MSC_OpenFullspeed function

Post Condition
Transfers data on bulk end points

Modifies
USB data buffeters

Example

			CSL_MscInitStructApp    mscAppHandle;
			pMscAppClassHandle      pAppClassHandle;
			Uint16                  mscAppBuffer[420];
			CSL_Status              status;

			pAppClassHandle = &mscAppHandle;

			// Assign values to all the members in mscAppHandle struct
			mscAppHandle.pMscObj = &mscAppBuffer[0];
			.....
			.....
			status = MSC_Open(pAppClassHandle);
			....
			....
			status = MSC_Bulk(pAppClassHandle->pMscObj);
     

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

References CSL_MscObject::bulkInEpObj, CSL_MscObject::bulkOutEpObj, CSL_MscObject::cbw, CSL_MSC_8BIT_SHIFT, CSL_MSC_CBW_6, CSL_MSC_STORAGE_STATE_READ, CSL_MSC_STORAGE_STATE_RESET, CSL_MSC_STORAGE_STATE_SENDING_CSW, CSL_MSC_STORAGE_STATE_SENDING_DATA, CSL_MSC_STORAGE_STATE_SENDING_SHORT_PKT, CSL_MSC_STORAGE_STATE_SENDING_STALL, CSL_MSC_STORAGE_STATE_WAIT_FOR_CBW, CSL_MSC_STORAGE_STATE_WRITE, CSL_USB_EVENT_RESET, MSC_ExecuteRead(), MSC_ExecuteWrite(), MSC_HandleStateReset(), MSC_HandleStateSendCSW(), MSC_HandleStateSendData(), MSC_HandleStateSendingShortPkt(), MSC_HandleStateSendStall(), MSC_HandleStateWaitForCBW(), CSL_MscClassStruct::mscHandle, CSL_MscObject::storageState, and USB_getEvents().

CSL_Status MSC_Close ( pMscAppClassHandle  pAppClassHandle)

============================================================================
MSC_Close

Description
This function Opens the Msc module.

Arguments

            pAppClassHandle       Application handle to the MSC Class Obj
     

Return Value CSL_Status

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

Pre Condition
MSC module should be opened using MSC_Open/MSC_OpenFullspeed function

Post Condition
Closes the Msc module

Modifies
Msc and Ctl handles

Example

			CSL_MscInitStructApp    mscAppHandle;
			pMscAppClassHandle      pAppClassHandle;
			Uint16                  mscAppBuffer[420];
			CSL_Status              status;

			pAppClassHandle = &mscAppHandle;

			// Assign values to all the members in mscAppHandle struct
			mscAppHandle.pMscObj = &mscAppBuffer[0];
			.....
			.....
			status = MSC_Open(pAppClassHandle);
			....
			....
			status = MSC_Close(pAppClassHandle);
     

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

References CSL_MscClassStruct::ctrlHandle, CSL_MscCtrlObject::devNum, CSL_MscInitStructApp::pMscObj, and USB_disconnectDev().

CSL_Status MSC_Ctrl ( void *  pMSC)

============================================================================
MSC_Ctrl

Description
This function handles all USB traffic on the Control Endpoint. Detects the events on the Control Endpoint and takes the appropriate action

Arguments

            pMSC        Handle to the MSC Class Obj
     

Return Value CSL_Status

  • CSL_SOK - Returned for success
  • CSL_ESYS_BADHANDLE - Invalid Msc class handle
  • CSL_MSC_INVALID_REQUEST_HANDLER - Invalid request class handler

Pre Condition
MSC module should be opened using MSC_Open/MSC_OpenFullspeed function

Post Condition
Control end point events are serviced

Modifies
USB Registers.

Example

			CSL_MscInitStructApp    mscAppHandle;
			pMscAppClassHandle      pAppClassHandle;
			Uint16                  mscAppBuffer[420];
			CSL_Status              status;

			pAppClassHandle = &mscAppHandle;

			// Assign values to all the members in mscAppHandle struct
			mscAppHandle.pMscObj = &mscAppBuffer[0];
			.....
			.....
			status = MSC_Open(pAppClassHandle);
			....
			....
            status = MSC_Ctrl(pAppClassHandle->pMscObj);
     

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

References CSL_UsbSetupStruct::bmRequestType, CSL_UsbSetupStruct::bRequest, CSL_MSC_8BIT_SHIFT, CSL_MSC_INVALID_REQUEST_HANDLER, CSL_USB_EVENT_RESET, CSL_USB_EVENT_RESUME, CSL_USB_EVENT_SETUP, CSL_USB_EVENT_SUSPEND, CSL_USB_IOFLAG_NONE, CSL_MscClassStruct::ctrlHandle, CSL_MscCtrlObject::ctrlInEpObj, CSL_MscCtrlObject::ctrlOutEpObj, CSL_MscCtrlObject::curConfigStat, CSL_MscCtrlObject::devNum, CSL_MscCtrlObject::fpRequestHandler, CSL_MscCtrlObject::hEpObjArray, MSC_lookupReqHandler(), MSC_reqUnknown(), CSL_MscCtrlObject::mscReqTable, CSL_UsbSetupStruct::newPacket, CSL_MscCtrlObject::suspendFlag, USB_abortAllTransaction(), USB_getEvents(), USB_getSetupPacket(), USB_postTransaction(), USB_setParams(), USB_stallEndpt(), and CSL_MscCtrlObject::usbSetup.

CSL_Status MSC_ExecuteRead ( CSL_MscObject pMscHandle,
Uint16  lunNum,
Uint16  first 
)

============================================================================
MSC_ExecuteRead

Description
This function executes the read operation. Data read from the storage media is sent to the host

Arguments

            pMscHandle      - Handle to Msc object
            lunNum          - Logical unit number
            first           - Flag to indicate first write operation
     

Return Value
Status returned by the MUSB module

Pre Condition
MSC module should be opened using MSC_Open/MSC_OpenFullspeed function

Post Condition
Writes the data to the media

Modifies
Data buffers

Example

             CSL_MscRequestRet       (*fpRequestHandler)(CSL_MSC_REQUEST_ARGS)
             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             CSL_MscCtrlObject       *pCtrlHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;
             Uint16                  request;
			 pMscAppClassHandle      pAppClassHandle;

			 pAppClassHandle = &mscAppHandle;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(pAppClassHandle);
             ....
             ....
             status = MSC_ExecuteRead(pMscHandle, lunNum, FALSE);
     

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

References CSL_MscObject::bulkInEpObj, CSL_MscObject::cbw, CSL_MscObject::cbwDataTransferLength, CSL_MSC_16BIT_MASK, CSL_MSC_16BIT_SHIFT, CSL_MSC_24BIT_SHIFT, CSL_MSC_8BIT_MASK, CSL_MSC_8BIT_SHIFT, CSL_MSC_CBW_10, CSL_MSC_CBW_11, CSL_MSC_CBW_6, CSL_MSC_CBW_8, CSL_MSC_CBW_9, CSL_MSC_CBW_DATADIR_IN, CSL_MSC_CBW_DIRBIT_MASK, CSL_MSC_CSW_4, CSL_MSC_CSW_5, CSL_MSC_CSW_6, CSL_MSC_CSW_STATUS_COMMAND_FAILED, CSL_MSC_CSW_STATUS_COMMAND_PASSED, CSL_MSC_MEDIA_BAD, CSL_MSC_MEDIA_PRESENT, CSL_MSC_MEDIACCESS_BADMEDIA, CSL_MSC_MEDIACCESS_NOTPRESENT, CSL_MSC_MEDIACCESS_OVERFLOW, CSL_MSC_MEDIACCESS_SUCCESS, CSL_MSC_SCSI_ASC_MEDIA_MANUALINTERVENTION_REQUIRED, CSL_MSC_SCSI_ASC_MEDIA_NOT_PRESENT, CSL_MSC_SCSI_ASC_MEDIA_OUTOFRANGE, CSL_MSC_SCSI_ASC_NO_ADDITIONAL_SENSE_INFORMATION, CSL_MSC_SCSI_SENSEKEY_ILLEGAL_REQUEST, CSL_MSC_SCSI_SENSEKEY_NO_SENSE, CSL_MSC_SCSI_SENSEKEY_NOT_READY, CSL_MSC_STORAGE_STATE_READ, CSL_MSC_STORAGE_STATE_SENDING_DATA, CSL_MSC_STORAGE_STATE_SENDING_STALL, CSL_USB_IOFLAG_NOSHORT, CSL_USB_IOFLAG_NOT, CSL_MscObject::csw, CSL_MscLogicalUnit::currLba, CSL_MscObject::lbaBuffer, CSL_MscLogicalUnit::lbaCnt, CSL_MscLogicalUnit::lbaSize, CSL_MscObject::lun, CSL_MscLogicalUnit::mediaState, MSC_handleDataDirMisMatch(), MSC_sendCswWithPhaseError(), MSC_SetSenseKeys(), CSL_MscObject::readMedia, CSL_MscObject::senseData, CSL_MscObject::storageState, USB_isTransactionDone(), USB_postTransaction(), and USB_stallEndpt().

Referenced by MSC_Bulk(), and MSC_HandleStateWaitForCBW().

CSL_Status MSC_ExecuteWrite ( CSL_MscObject pMscHandle,
Uint16  lunNum,
Uint16  first 
)

============================================================================
MSC_ExecuteWrite

Description
This function executes the write operation. Data sent by the host is is written to the storage media.

Arguments

            pMscHandle      - Handle to Msc object
            lunNum          - Logical unit number
            first           - Flag to indicate first write operation
     

Return Value
Status returned by the MUSB module

Pre Condition
MSC module should be opened using MSC_Open/MSC_OpenFullspeed function

Post Condition
Writes the data to the media

Modifies
Data buffers

Example

             CSL_MscRequestRet       (*fpRequestHandler)(CSL_MSC_REQUEST_ARGS)
             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             CSL_MscCtrlObject       *pCtrlHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;
             Uint16                  request;
			 pMscAppClassHandle      pAppClassHandle;

			 pAppClassHandle = &mscAppHandle;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(pAppClassHandle);
             ....
             ....
             status = MSC_ExecuteWrite(pMscHandle, lunNum, FALSE);
     

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

References CSL_MscObject::bulkInEpObj, CSL_MscObject::bulkOutEpObj, CSL_MscObject::cbw, CSL_MscObject::cbwDataTransferLength, CSL_MSC_16BIT_MASK, CSL_MSC_16BIT_SHIFT, CSL_MSC_24BIT_SHIFT, CSL_MSC_8BIT_MASK, CSL_MSC_8BIT_SHIFT, CSL_MSC_CBW_10, CSL_MSC_CBW_11, CSL_MSC_CBW_6, CSL_MSC_CBW_8, CSL_MSC_CBW_9, CSL_MSC_CBW_DATADIR_OUT, CSL_MSC_CBW_DIRBIT_MASK, CSL_MSC_CSW_4, CSL_MSC_CSW_5, CSL_MSC_CSW_6, CSL_MSC_CSW_DATA_SIZE, CSL_MSC_CSW_STATUS_COMMAND_FAILED, CSL_MSC_CSW_STATUS_COMMAND_PASSED, CSL_MSC_MEDIA_BAD, CSL_MSC_MEDIA_PRESENT, CSL_MSC_MEDIA_WRITEENABLE, CSL_MSC_MEDIA_WRITEPENDING, CSL_MSC_MEDIACCESS_BADMEDIA, CSL_MSC_MEDIACCESS_NOTPRESENT, CSL_MSC_MEDIACCESS_OVERFLOW, CSL_MSC_MEDIACCESS_SUCCESS, CSL_MSC_MEDIACCESS_WRITEPROTECT, CSL_MSC_SCSI_ASC_INVALID_COMMAND_OPERATION_CODE, CSL_MSC_SCSI_ASC_MEDIA_MANUALINTERVENTION_REQUIRED, CSL_MSC_SCSI_ASC_MEDIA_NOT_PRESENT, CSL_MSC_SCSI_ASC_MEDIA_OUTOFRANGE, CSL_MSC_SCSI_ASC_NO_ADDITIONAL_SENSE_INFORMATION, CSL_MSC_SCSI_ASC_WRITE_PROTECTED, CSL_MSC_SCSI_DATA_PROTECT, CSL_MSC_SCSI_SENSEKEY_ILLEGAL_REQUEST, CSL_MSC_SCSI_SENSEKEY_NO_SENSE, CSL_MSC_SCSI_SENSEKEY_NOT_READY, CSL_MSC_STORAGE_STATE_SENDING_CSW, CSL_MSC_STORAGE_STATE_WRITE, CSL_MSC_VERIFY_FAILED, CSL_MSC_VERIFY_PASSED, CSL_USB_IOFLAG_NONE, CSL_USB_IOFLAG_NOSHORT, CSL_MscObject::csw, CSL_MscLogicalUnit::currLba, CSL_MscObject::lbaBuffer, CSL_MscLogicalUnit::lbaCnt, CSL_MscLogicalUnit::lbaSize, CSL_MscObject::lun, CSL_MscLogicalUnit::mediaState, MSC_handleDataDirMisMatch(), MSC_sendCswWithPhaseError(), MSC_SetSenseKeys(), CSL_MscLogicalUnit::readwrite, CSL_MscObject::senseData, CSL_MscObject::storageState, USB_isTransactionDone(), USB_postTransaction(), CSL_MscLogicalUnit::verifyFlag, CSL_MscObject::writeMedia, and CSL_MscObject::writeToMedia.

Referenced by MSC_Bulk(), and MSC_HandleStateWaitForCBW().

Uint16 MSC_GetactivityFlagStatus ( void *  pMSC)

============================================================================
MSC_GetactivityFlagStatus

Description
This function gives the status of the activity Flag

Arguments

            pMSC        Handle to the MSC Class Obj
     

Return Value - Status of the activity flag

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

Pre Condition
MSC module should be opened using MSC_Open/MSC_OpenFullspeed function

Post Condition
Returns Activity flag status

Modifies
None

Example

			Uint16                  activityFlagStat;
			CSL_MscInitStructApp    mscAppHandle;
			pMscAppClassHandle      pAppClassHandle;
			Uint16                  mscAppBuffer[420];
			CSL_Status              status;

			pAppClassHandle = &mscAppHandle;

			// Assign values to all the members in mscAppHandle struct
			mscAppHandle.pMscObj = &mscAppBuffer[0];
			.....
			.....
			status = MSC_Open(pAppClassHandle);
			....
			....
			activityFlagStat = MSC_GetactivityFlagStatus(pAppClassHandle->pMscObj);
     

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

References CSL_MscObject::activityPresentFlag, and CSL_MscClassStruct::mscHandle.

Uint16 MSC_GetLunLockedStatus ( void *  pMSC,
Uint16  lunNum 
)

============================================================================
MSC_GetLunLockedStatus

Description
This function gets the Locked/Unlocked Status of the Lun.

Arguments

            pMSC        Handle to the MSC Class Obj
            lunNum      Logical Unit Number
     

Return Value - Lock/Unlock status of the Lun

  • '1' - if the lun is locked
  • '0' - if the lun is unlocked

Pre Condition
MSC module should be opened using MSC_Open/MSC_OpenFullspeed function

Post Condition
Returns the Locked/Unlocked status of Lun.

Modifies
None

Example

			Uint16                  lockStatus;
			CSL_MscInitStructApp    mscAppHandle;
			pMscAppClassHandle      pAppClassHandle;
			Uint16                  mscAppBuffer[420];
			CSL_Status              status;

			pAppClassHandle = &mscAppHandle;

			// Assign values to all the members in mscAppHandle struct
			mscAppHandle.pMscObj = &mscAppBuffer[0];
			.....
			.....
			status = MSC_Open(pAppClassHandle);
			....
			....
			lockStatus = MSC_GetLunLockedStatus(pAppClassHandle->pMscObj, 0);
     

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

References CSL_MSC_MEDIA_LOCKED, CSL_MscObject::lun, CSL_MscLogicalUnit::mediaState, and CSL_MscClassStruct::mscHandle.

Uint16 MSC_GetsuspendFlagStatus ( void *  pMSC)

============================================================================
MSC_GetsuspendFlagStatus

Description
This function gives the status of the suspend Flag

Arguments

            pMSC        Handle to the MSC Class Obj
     

Return Value - Status of the suspend flag

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

Pre Condition
MSC module should be opened using MSC_Open/MSC_OpenFullspeed function

Post Condition
Returns suspend flag status

Modifies
None

Example

			Uint16                  suspendFlagStat;
			CSL_MscInitStructApp    mscAppHandle;
			pMscAppClassHandle      pAppClassHandle;
			Uint16                  mscAppBuffer[420];
			CSL_Status              status;

			pAppClassHandle = &mscAppHandle;

			// Assign values to all the members in mscAppHandle struct
			mscAppHandle.pMscObj = &mscAppBuffer[0];
			.....
			.....
			status = MSC_Open(pAppClassHandle);
			....
			....
			suspendFlagStat = MSC_GetsuspendFlagStatus(pAppClassHandle->pMscObj);
     

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

References CSL_MscClassStruct::ctrlHandle, and CSL_MscCtrlObject::suspendFlag.

CSL_Status MSC_handleDataDirMisMatch ( CSL_MscObject pMscHandle,
Uint16  dataDir 
)

============================================================================
MSC_handleDataDirMisMatch

Description
Function to handle the data direction miss during USB data transfers. This function stalls the end points and updates the CSW status with phase error.

Arguments

            pMscHandle     - Handle to Msc class object
            dataDir        - Actual Data direction expected;
                             should be 0x80 for IN and 0x0 for OUT
     

Return Value
Status returned by the MUSB module

Pre Condition
Error detected during the data transfer

Post Condition
Stalls the IN/OUT end points

Modifies
CSW buffer

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             pUsbEpHandle            hUbOutEp;
             pUsbEpHandle            hUbInEp;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;
			 pMscAppClassHandle      pAppClassHandle;

			 pAppClassHandle = &mscAppHandle;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(pAppClassHandle);
             ....
             ....
             MSC_handleDataDirMisMatch(pMscHandle, CSL_MSC_CBW_DATADIR_IN);
     

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

References CSL_MscObject::bulkInEpObj, CSL_MscObject::bulkOutEpObj, CSL_MSC_CBW_DATADIR_IN, CSL_MSC_CSW_6, CSL_MSC_CSW_STATUS_PHASE_ERROR, CSL_MSC_STORAGE_STATE_SENDING_STALL, CSL_USB_IOFLAG_NOT, CSL_MscObject::csw, CSL_MscObject::lbaBuffer, CSL_MscObject::storageState, USB_postTransaction(), and USB_stallEndpt().

Referenced by MSC_ExecuteRead(), MSC_ExecuteWrite(), MSC_HandleInquiry(), MSC_HandleReadCapacity(), and MSC_HandleRequestSense().

static CSL_Status MSC_HandleInquiry ( CSL_MscObject pMscHandle,
pUsbEpHandle  hUsbInEp,
Uint16  logicalUnit 
) [inline, static]

============================================================================
MSC_HandleInquiry

Description
This function handles Inquiry command

Arguments

            pMscHandle      - Handle to Msc class object
            hUsbInEp        - In end point handle
            logicalUnit     - Logical unit number
     

Return Value
status returned by the MUSB module

Pre Condition
MSC module should be opened using MSC_Open/MSC_OpenFullspeed function

Post Condition
Changes the state to sending data

Modifies
storage state variable

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             MSC_HandleInquiry(pMscHandle, hUbInEp, lunNum);
     

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

References CSL_MscObject::cbw, CSL_MscObject::cbwDataTransferLength, CSL_MSC_16BIT_MASK, CSL_MSC_16BIT_SHIFT, CSL_MSC_CBW_6, CSL_MSC_CBW_DATADIR_IN, CSL_MSC_CBW_DIRBIT_MASK, CSL_MSC_CSW_4, CSL_MSC_CSW_5, CSL_MSC_CSW_6, CSL_MSC_CSW_STATUS_COMMAND_PASSED, CSL_MSC_STORAGE_STATE_SENDING_DATA, CSL_MSC_STORAGE_STATE_SENDING_SHORT_PKT, CSL_USB_IOFLAG_NOSHORT, CSL_MscObject::csw, CSL_MscObject::lun, MSC_handleDataDirMisMatch(), MSC_sendCswWithPhaseError(), CSL_MscLogicalUnit::scsiInquiryData, CSL_MscObject::storageState, and USB_postTransaction().

Referenced by MSC_HandleStateWaitForCBW().

static CSL_Status MSC_HandleModeSense10 ( CSL_MscObject pMscHandle,
pUsbEpHandle  hUsbInEp,
Uint16  logicalUnit 
) [inline, static]

============================================================================
MSC_HandleModeSense10

Description
This function handles the Mode Sense 10 Command

Arguments

            pMscHandle      - Handle to Msc class object
            hUsbInEp        - In end point handle
            logicalUnit     - Logical unit number
     

Return Value
status returned by the MUSB module

Pre Condition
MSC module should be opened using MSC_Open/MSC_OpenFullspeed function

Post Condition
Changes the state to sending data

Modifies
storage state variable

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             MSC_HandleModeSense6(pMscHandle, hUbInEp, lunNum);
     

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

References CSL_MscObject::bulkInEpObj, CSL_MscObject::bulkOutEpObj, CSL_MscObject::cbw, CSL_MscObject::cbwDataTransferLength, CSL_MSC_16BIT_MASK, CSL_MSC_16BIT_SHIFT, CSL_MSC_CBW_6, CSL_MSC_CBW_DATADIR_IN, CSL_MSC_CBW_DIRBIT_MASK, CSL_MSC_CSW_4, CSL_MSC_CSW_5, CSL_MSC_CSW_6, CSL_MSC_CSW_STATUS_COMMAND_PASSED, CSL_MSC_CSW_STATUS_PHASE_ERROR, CSL_MSC_STORAGE_STATE_SENDING_DATA, CSL_MSC_STORAGE_STATE_SENDING_STALL, CSL_USB_IOFLAG_NOSHORT, CSL_USB_IOFLAG_NOT, CSL_MscObject::csw, CSL_MscObject::lbaBuffer, CSL_MscObject::modeSenseData, MSC_sendCswWithPhaseError(), CSL_MscObject::storageState, USB_postTransaction(), and USB_stallEndpt().

Referenced by MSC_HandleStateWaitForCBW().

static CSL_Status MSC_HandleModeSense6 ( CSL_MscObject pMscHandle,
pUsbEpHandle  hUsbInEp,
Uint16  logicalUnit 
) [inline, static]

============================================================================
MSC_HandleModeSense6

Description
This function handles the Mode Sense 6 Command

Arguments

            pMscHandle      - Handle to Msc class object
            hUsbInEp        - In end point handle
            logicalUnit     - Logical unit number
     

Return Value
status returned by the MUSB module

Pre Condition
MSC module should be opened using MSC_Open/MSC_OpenFullspeed function

Post Condition
Changes the state to sending data

Modifies
storage state variable

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             MSC_HandleModeSense6(pMscHandle, hUbInEp, lunNum);
     

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

References CSL_MscObject::bulkInEpObj, CSL_MscObject::bulkOutEpObj, CSL_MscObject::cbw, CSL_MscObject::cbwDataTransferLength, CSL_MSC_16BIT_MASK, CSL_MSC_16BIT_SHIFT, CSL_MSC_CBW_6, CSL_MSC_CBW_DATADIR_IN, CSL_MSC_CBW_DIRBIT_MASK, CSL_MSC_CSW_4, CSL_MSC_CSW_5, CSL_MSC_CSW_6, CSL_MSC_CSW_STATUS_COMMAND_PASSED, CSL_MSC_CSW_STATUS_PHASE_ERROR, CSL_MSC_STORAGE_STATE_SENDING_DATA, CSL_MSC_STORAGE_STATE_SENDING_STALL, CSL_USB_IOFLAG_NOSHORT, CSL_USB_IOFLAG_NOT, CSL_MscObject::csw, CSL_MscObject::lbaBuffer, CSL_MscObject::modeSenseData, MSC_sendCswWithPhaseError(), CSL_MscObject::storageState, USB_postTransaction(), and USB_stallEndpt().

Referenced by MSC_HandleStateWaitForCBW().

CSL_Status MSC_HandlePreventAllowMediaRemoval ( CSL_MscObject pMscHandle,
pUsbEpHandle  hUsbInEp,
Uint16  logicalUnit 
)

============================================================================
MSC_HandlePreventAllowMediaRemoval

Description
This handles the Prevent Allow Media Removal SCSI Command

Arguments

            pMscHandle      - Handle to Msc class object
            hUsbInEp        - In end point handle
            logicalUnit     - Logical unit number
     

Return Value
status returned by the MUSB module

Pre Condition
MSC module should be opened using MSC_Open/MSC_OpenFullspeed function

Post Condition
Changes the state to sending CSW

Modifies
storage state variable

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             MSC_HandlePreventAllowMediaRemoval(pMscHandle, hUbInEp, lunNum);
     

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

References CSL_MscObject::bulkInEpObj, CSL_MscObject::bulkOutEpObj, CSL_MscObject::cbw, CSL_MscObject::cbwDataTransferLength, CSL_MSC_8BIT_SHIFT, CSL_MSC_CBW_9, CSL_MSC_CSW_6, CSL_MSC_CSW_DATA_SIZE, CSL_MSC_CSW_STATUS_COMMAND_FAILED, CSL_MSC_CSW_STATUS_COMMAND_PASSED, CSL_MSC_LOCK, CSL_MSC_MEDIA_BAD, CSL_MSC_MEDIA_LOCKED, CSL_MSC_MEDIA_PRESENT, CSL_MSC_MEDIACCESS_BADMEDIA, CSL_MSC_MEDIACCESS_SUCCESS, CSL_MSC_SCSI_ASC_INVALID_COMMAND_OPERATION_CODE, CSL_MSC_SCSI_ASC_MEDIA_NOT_PRESENT, CSL_MSC_SCSI_ASC_NO_ADDITIONAL_SENSE_INFORMATION, CSL_MSC_SCSI_SENSEKEY_ILLEGAL_REQUEST, CSL_MSC_SCSI_SENSEKEY_NO_SENSE, CSL_MSC_SCSI_SENSEKEY_NOT_READY, CSL_MSC_STORAGE_STATE_SENDING_CSW, CSL_MSC_STORAGE_STATE_SENDING_STALL, CSL_MSC_UNLOCK, CSL_USB_IOFLAG_NONE, CSL_USB_IOFLAG_NOT, CSL_MscObject::csw, CSL_MscObject::lbaBuffer, CSL_MscObject::lun, CSL_MscObject::mediaGetPresentState, CSL_MscObject::mediaLockUnit, CSL_MscLogicalUnit::mediaState, MSC_SetSenseKeys(), CSL_MscLogicalUnit::removeable, CSL_MscObject::senseData, CSL_MscObject::storageState, USB_postTransaction(), and USB_stallEndpt().

Referenced by MSC_HandleStateWaitForCBW().

CSL_Status MSC_HandleReadCapacity ( CSL_MscObject pMscHandle,
pUsbEpHandle  hUsbInEp,
Uint16  logicalUnit 
)

============================================================================
MSC_HandleReadCapacity

Description
This handles the Read Capacity SCSI Command

Arguments

            pMscHandle      - Handle to Msc class object
            hUsbInEp        - In end point handle
            logicalUnit     - Logical unit number
     

Return Value
status returned by the MUSB module

Pre Condition
MSC module should be opened using MSC_Open/MSC_OpenFullspeed function

Post Condition
Changes the state to sending data

Modifies
storage state variable

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             MSC_HandleReadCapacity(pMscHandle, hUbInEp, lunNum);
     

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

References CSL_MscObject::cbw, CSL_MscObject::cbwDataTransferLength, CSL_MSC_16BIT_MASK, CSL_MSC_16BIT_SHIFT, CSL_MSC_8BIT_SHIFT, CSL_MSC_CBW_6, CSL_MSC_CBW_DATADIR_IN, CSL_MSC_CBW_DIRBIT_MASK, CSL_MSC_CSW_4, CSL_MSC_CSW_5, CSL_MSC_CSW_6, CSL_MSC_CSW_STATUS_COMMAND_FAILED, CSL_MSC_CSW_STATUS_COMMAND_PASSED, CSL_MSC_MEDIA_BAD, CSL_MSC_MEDIA_PRESENT, CSL_MSC_MEDIACCESS_BADMEDIA, CSL_MSC_MEDIACCESS_NOTPRESENT, CSL_MSC_MEDIACCESS_SUCCESS, CSL_MSC_RC_1, CSL_MSC_RC_2, CSL_MSC_RC_3, CSL_MSC_RC_4, CSL_MSC_SCSI_ASC_MEDIA_NOT_PRESENT, CSL_MSC_SCSI_ASC_NO_ADDITIONAL_SENSE_INFORMATION, CSL_MSC_SCSI_SENSEKEY_NO_SENSE, CSL_MSC_SCSI_SENSEKEY_NOT_READY, CSL_MSC_STORAGE_STATE_SENDING_DATA, CSL_USB_IOFLAG_NOSHORT, CSL_MscObject::csw, CSL_MscLogicalUnit::lbaSize, CSL_MscObject::lun, CSL_MscObject::mediaGetPresentState, CSL_MscLogicalUnit::mediaSize, CSL_MscLogicalUnit::mediaState, MSC_handleDataDirMisMatch(), MSC_sendCswWithPhaseError(), MSC_SetSenseKeys(), CSL_MscObject::readCapacity, CSL_MscObject::senseData, CSL_MscObject::storageState, and USB_postTransaction().

Referenced by MSC_HandleStateWaitForCBW().

static CSL_Status MSC_HandleRequestSense ( CSL_MscObject pMscHandle,
pUsbEpHandle  hUsbInEp 
) [inline, static]

============================================================================
MSC_HandleRequestSense

Description
This handles the Request Sense SCSI Command

Arguments

            pMscHandle      - Handle to Msc class object
            hUsbInEp        - In end point handle
     

Return Value
status returned by the MUSB module

Pre Condition
MSC module should be opened using MSC_Open/MSC_OpenFullspeed function

Post Condition
Changes the state to sending data

Modifies
storage state variable

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             pUsbEpHandle            hUbOutEp;
             pUsbEpHandle            hUbInEp;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             MSC_HandleRequestSense(pMscHandle, hUbInEp);
     

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

References CSL_MscObject::cbw, CSL_MscObject::cbwDataTransferLength, CSL_MSC_16BIT_MASK, CSL_MSC_16BIT_SHIFT, CSL_MSC_CBW_6, CSL_MSC_CBW_DATADIR_IN, CSL_MSC_CBW_DIRBIT_MASK, CSL_MSC_CSW_4, CSL_MSC_CSW_5, CSL_MSC_CSW_6, CSL_MSC_CSW_STATUS_COMMAND_PASSED, CSL_MSC_STORAGE_STATE_SENDING_DATA, CSL_MSC_STORAGE_STATE_SENDING_SHORT_PKT, CSL_USB_IOFLAG_NOSHORT, CSL_MscObject::csw, MSC_handleDataDirMisMatch(), MSC_sendCswWithPhaseError(), CSL_MscObject::senseData, CSL_MscObject::storageState, and USB_postTransaction().

Referenced by MSC_HandleStateWaitForCBW().

static CSL_Status MSC_HandleStartStopUnit ( CSL_MscObject pMscHandle,
pUsbEpHandle  hUsbInEp,
Uint16  lunNum 
) [inline, static]

============================================================================
MSC_HandleStartStopUnit

Description
Starts or stops the Unit

Arguments

            pMscHandle      - Handle to Msc class object
            hUsbInEp        - In end point handle
            lunNum          - Logical unit number
     

Return Value
status returned by the MUSB module

Pre Condition
MSC module should be opened using MSC_Open/MSC_OpenFullspeed function

Post Condition
Changes the state to sending CSW

Modifies
storage state variable

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             MSC_HandleStartStopUnit(pMscHandle, hUbInEp, lunNum);
     

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

References CSL_MscObject::bulkInEpObj, CSL_MscObject::bulkOutEpObj, CSL_MscObject::cbw, CSL_MscObject::cbwDataTransferLength, CSL_MSC_8BIT_SHIFT, CSL_MSC_CBW_9, CSL_MSC_CSW_6, CSL_MSC_CSW_STATUS_COMMAND_FAILED, CSL_MSC_CSW_STATUS_COMMAND_PASSED, CSL_MSC_MEDIA_BAD, CSL_MSC_MEDIA_LOCKED, CSL_MSC_MEDIA_PRESENT, CSL_MSC_MEDIACCESS_SUCCESS, CSL_MSC_SCSI_ASC_INVALID_COMMAND_OPERATION_CODE, CSL_MSC_SCSI_ASC_MEDIA_REMOVAL_PREVENTED, CSL_MSC_SCSI_ASC_NO_ADDITIONAL_SENSE_INFORMATION, CSL_MSC_SCSI_SENSEKEY_ILLEGAL_REQUEST, CSL_MSC_SCSI_SENSEKEY_NO_SENSE, CSL_MSC_SCSI_SENSEKEY_UNIT_ATTENTION, CSL_MSC_STORAGE_STATE_SENDING_CSW, CSL_MSC_STORAGE_STATE_SENDING_STALL, CSL_USB_IOFLAG_NONE, CSL_USB_IOFLAG_NOT, CSL_MscObject::csw, CSL_MscObject::lbaBuffer, CSL_MscObject::lun, CSL_MscObject::mediaEject, CSL_MscLogicalUnit::mediaState, MSC_SetSenseKeys(), CSL_MscObject::senseData, CSL_MscObject::storageState, USB_postTransaction(), and USB_stallEndpt().

Referenced by MSC_HandleStateWaitForCBW().

static CSL_Status MSC_HandleStateReset ( CSL_MscObject pMscHandle,
pUsbEpHandle  hUsbOutEp 
) [inline, static]

============================================================================
MSC_HandleStateReset

Description
Handles the reset condition

Arguments

            pMscHandle      - Handle to Msc class object
            hUsbOutEp       - Out end point handle
     

Return Value
status returned by the MUSB module

Pre Condition
MSC module should be opened using MSC_Open/MSC_OpenFullspeed function

Post Condition
Changes the state to wait for CBW

Modifies
Storage state variable

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             MSC_HandleStateReset(pMscHandle, hUbOutEp);
     

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

References CSL_MscObject::cbw, CSL_MSC_STATE_RESET_DATA_SIZE, CSL_MSC_STORAGE_STATE_WAIT_FOR_CBW, CSL_USB_IOFLAG_NONE, CSL_MscObject::storageState, USB_abortTransaction(), and USB_postTransaction().

Referenced by MSC_Bulk(), and MSC_reqBotMscReset().

static CSL_Status MSC_HandleStateSendCSW ( CSL_MscObject pMscHandle,
pUsbEpHandle  hUsbOutEp,
pUsbEpHandle  hUsbInEp 
) [inline, static]

============================================================================
MSC_HandleStateSendCSW

Description
Handles send CSW state

Arguments

            pMscHandle      - Handle to Msc class object
            hUsbOutEp       - Out end point handle
            hUsbInEp        - In end point handle
     

Return Value
status returned by the MUSB module

Pre Condition
MSC module should be opened using MSC_Open/MSC_OpenFullspeed function

Post Condition
Changes the state to wait for CBW

Modifies
storage state variable

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             pUsbEpHandle            hUbOutEp;
             pUsbEpHandle            hUbInEp;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             MSC_HandleStateSendCSW(pMscHandle, hUbOutEp, hUbInEp);
     

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

References CSL_MscObject::activityPresentFlag, CSL_MscObject::cbw, CSL_MSC_CBW_DATA_SIZE, CSL_MSC_STORAGE_STATE_WAIT_FOR_CBW, CSL_USB_IOFLAG_NONE, CSL_MscObject::storageState, USB_isTransactionDone(), and USB_postTransaction().

Referenced by MSC_Bulk().

static CSL_Status MSC_HandleStateSendData ( CSL_MscObject pMscHandle,
pUsbEpHandle  hUsbInEp 
) [inline, static]

============================================================================
MSC_HandleStateSendData

Description
Sends the command status word to the host device

Arguments

            pMscHandle      - Handle to Msc class object
            hUsbInEp        - In end point handle
     

Return Value
status returned by the MUSB module

Pre Condition
MSC module should be opened using MSC_Open/MSC_OpenFullspeed function

Post Condition
Changes the state to sending CSW

Modifies
storage state variable

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             pUsbEpHandle            hUbOutEp;
             pUsbEpHandle            hUbInEp;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             MSC_HandleStateSendData(pMscHandle, hUbInEp);
     

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

References CSL_MSC_CSW_DATA_SIZE, CSL_MSC_STORAGE_STATE_SENDING_CSW, CSL_USB_IOFLAG_NONE, CSL_MscObject::csw, CSL_MscObject::storageState, USB_isTransactionDone(), and USB_postTransaction().

Referenced by MSC_Bulk().

static CSL_Status MSC_HandleStateSendingShortPkt ( CSL_MscObject pMscHandle,
pUsbEpHandle  hUsbInEp 
) [inline, static]

============================================================================
MSC_HandleStateSendingShortPkt

Description
Handles sending short packet storage state

Arguments

            pMscHandle      - Handle to Msc class object
            hUsbInEp        - In end point handle
     

Return Value
status returned by the MUSB module

Pre Condition
MSC module should be opened using MSC_Open/MSC_OpenFullspeed function

Post Condition
Changes the state to sending stall

Modifies
storage state variable

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             pUsbEpHandle            hUbOutEp;
             pUsbEpHandle            hUbInEp;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             MSC_HandleStateSendingShortPkt(pMscHandle, hUbInEp);
     

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

References CSL_MSC_STORAGE_STATE_SENDING_STALL, CSL_USB_IOFLAG_NOT, CSL_MscObject::csw, CSL_MscObject::storageState, USB_postTransaction(), and USB_stallEndpt().

Referenced by MSC_Bulk().

static CSL_Status MSC_HandleStateSendStall ( CSL_MscObject pMscHandle,
pUsbEpHandle  hUsbInEp 
) [inline, static]

============================================================================
MSC_HandleStateSendStall

Description
Sends the stall signal to the host

Arguments

            pMscHandle      - Handle to Msc class object
            hUsbInEp        - In end point handle
     

Return Value
status returned by the MUSB module

Pre Condition
MSC module should be opened using MSC_Open/MSC_OpenFullspeed function

Post Condition
Changes the state to sending CSW

Modifies
storage state variable

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             pUsbEpHandle            hUbOutEp;
             pUsbEpHandle            hUbInEp;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             MSC_HandleStateSendStall(pMscHandle, hUbInEp);
     

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

References CSL_MSC_CSW_DATA_SIZE, CSL_MSC_STORAGE_STATE_SENDING_CSW, CSL_USB_IOFLAG_NONE, CSL_MscObject::csw, CSL_MscObject::storageState, USB_isTransactionDone(), and USB_postTransaction().

Referenced by MSC_Bulk().

CSL_Status MSC_HandleStateWaitForCBW ( CSL_MscObject pMscHandle,
pUsbEpHandle  hUsbOutEp,
pUsbEpHandle  hUsbInEp 
)

============================================================================
MSC_HandleStateWaitForCBW

Description
Handles the Wait for CBW state

Arguments

            pMscHandle      - Handle to Msc class object
            hUsbOutEp       - Out end point handle
            hUsbInEp        - In end point handle
     

Return Value
status returned by the MUSB module

Pre Condition
MSC module should be opened using MSC_Open/MSC_OpenFullspeed function

Post Condition
Changes the state to sending data or stall

Modifies
storage state variable

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             pUsbEpHandle            hUbOutEp;
             pUsbEpHandle            hUbInEp;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;
			 pMscAppClassHandle      pAppClassHandle;

			 pAppClassHandle = &mscAppHandle;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(pAppClassHandle);
             ....
             ....
             MSC_HandleStateWaitForCBW(pMscHandle, hUbOutEp, hUbInEp);
     

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

References CSL_MscObject::activityPresentFlag, CSL_MscObject::cbw, CSL_MscObject::cbwDataTransferLength, CSL_MSC_16BIT_MASK, CSL_MSC_16BIT_SHIFT, CSL_MSC_8BIT_SHIFT, CSL_MSC_CBW_2, CSL_MSC_CBW_3, CSL_MSC_CBW_4, CSL_MSC_CBW_5, CSL_MSC_CBW_6, CSL_MSC_CBW_7, CSL_MSC_CSW_2, CSL_MSC_CSW_3, CSL_MSC_CSW_4, CSL_MSC_CSW_5, CSL_MSC_CSW_6, CSL_MSC_CSW_DATA_SIZE, CSL_MSC_CSW_STATUS_COMMAND_FAILED, CSL_MSC_SCSI_ASC_INVALID_COMMAND_OPERATION_CODE, CSL_MSC_SCSI_COMMAND_INQUIRY, CSL_MSC_SCSI_COMMAND_MODE_SENSE_10, CSL_MSC_SCSI_COMMAND_MODE_SENSE_6, CSL_MSC_SCSI_COMMAND_PREVENT_ALLOW_MEDIA_REMOVAL, CSL_MSC_SCSI_COMMAND_READ_10, CSL_MSC_SCSI_COMMAND_READ_CAPACITY, CSL_MSC_SCSI_COMMAND_REQUEST_SENSE, CSL_MSC_SCSI_COMMAND_START_STOP_UNIT, CSL_MSC_SCSI_COMMAND_TEST_UNIT_READY, CSL_MSC_SCSI_COMMAND_VERIFY_10, CSL_MSC_SCSI_COMMAND_WRITE_10, CSL_MSC_SCSI_SENSEKEY_ILLEGAL_REQUEST, CSL_MSC_STORAGE_STATE_SENDING_CSW, CSL_MSC_STORAGE_STATE_SENDING_SHORT_PKT, CSL_MSC_STORAGE_STATE_SENDING_STALL, CSL_USB_IOFLAG_NONE, CSL_USB_IOFLAG_NOSHORT, CSL_USB_IOFLAG_NOT, CSL_MscObject::csw, MSC_ExecuteRead(), MSC_ExecuteWrite(), MSC_HandleInquiry(), MSC_HandleModeSense10(), MSC_HandleModeSense6(), MSC_HandlePreventAllowMediaRemoval(), MSC_HandleReadCapacity(), MSC_HandleRequestSense(), MSC_HandleStartStopUnit(), MSC_HandleTestUnitReady(), MSC_HandleVerify10(), MSC_SetSenseKeys(), MSC_verifyCBW(), CSL_MscObject::senseData, CSL_MscObject::storageState, USB_isTransactionDone(), USB_postTransaction(), and USB_stallEndpt().

Referenced by MSC_Bulk().

CSL_Status MSC_HandleTestUnitReady ( CSL_MscObject pMscHandle,
pUsbEpHandle  hUsbInEp,
Uint16  logicalUnit 
)

============================================================================
MSC_HandleTestUnitReady

Description
This handles the Test Unit Ready SCSI Command

Arguments

            pMscHandle      - Handle to Msc class object
            hUsbInEp        - In end point handle
            logicalUnit     - Logical unit number
     

Return Value
status returned by the MUSB module

Pre Condition
MSC module should be opened using MSC_Open/MSC_OpenFullspeed function

Post Condition
Changes the state to sending CSW

Modifies
storage state variable

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             MSC_HandleTestUnitReady(pMscHandle, hUbInEp, lunNum);
     

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

References CSL_MscObject::bulkInEpObj, CSL_MscObject::bulkOutEpObj, CSL_MscObject::cbwDataTransferLength, CSL_MSC_CSW_6, CSL_MSC_CSW_DATA_SIZE, CSL_MSC_CSW_STATUS_COMMAND_FAILED, CSL_MSC_CSW_STATUS_COMMAND_PASSED, CSL_MSC_MEDIA_BAD, CSL_MSC_MEDIA_PRESENT, CSL_MSC_MEDIACCESS_BADMEDIA, CSL_MSC_MEDIACCESS_NOTPRESENT, CSL_MSC_MEDIACCESS_SUCCESS, CSL_MSC_SCSI_ASC_MEDIA_MAY_HAVE_CHANGED, CSL_MSC_SCSI_ASC_MEDIA_NOT_PRESENT, CSL_MSC_SCSI_ASC_NO_ADDITIONAL_SENSE_INFORMATION, CSL_MSC_SCSI_SENSEKEY_NO_SENSE, CSL_MSC_SCSI_SENSEKEY_NOT_READY, CSL_MSC_SCSI_SENSEKEY_UNIT_ATTENTION, CSL_MSC_STORAGE_STATE_SENDING_CSW, CSL_MSC_STORAGE_STATE_SENDING_STALL, CSL_USB_IOFLAG_NOSHORT, CSL_USB_IOFLAG_NOT, CSL_MscObject::csw, CSL_MscObject::getMediaSize, CSL_MscObject::lbaBuffer, CSL_MscObject::lun, CSL_MscObject::mediaGetPresentState, CSL_MscObject::mediaInit, CSL_MscLogicalUnit::mediaSize, CSL_MscLogicalUnit::mediaState, MSC_SetSenseKeys(), CSL_MscObject::senseData, CSL_MscObject::storageState, USB_postTransaction(), and USB_stallEndpt().

Referenced by MSC_HandleStateWaitForCBW().

static CSL_Status MSC_HandleVerify10 ( CSL_MscObject pMscHandle,
pUsbEpHandle  hUsbInEp,
Uint16  logicalUnit 
) [inline, static]

============================================================================
MSC_HandleVerify10

Description
This handles the Verify 10 SCSI Command

Arguments

            pMscHandle      - Handle to Msc class object
            hUsbInEp        - In end point handle
            logicalUnit     - Logical unit number
     

Return Value
Status returned by the MUSB module

Pre Condition
MSC module should be opened using MSC_Open/MSC_OpenFullspeed function

Post Condition
Changes the state to sending CSW

Modifies
storage state variable

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             MSC_HandleVerify10(pMscHandle, hUbInEp, lunNum);
     

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

References CSL_MscObject::bulkInEpObj, CSL_MscObject::bulkOutEpObj, CSL_MscObject::cbw, CSL_MscObject::cbwDataTransferLength, CSL_MSC_8BIT_HIGH_MASK, CSL_MSC_8BIT_MASK, CSL_MSC_8BIT_SHIFT, CSL_MSC_CBW_11, CSL_MSC_CSW_6, CSL_MSC_CSW_DATA_SIZE, CSL_MSC_CSW_STATUS_COMMAND_FAILED, CSL_MSC_CSW_STATUS_COMMAND_PASSED, CSL_MSC_SCSI_ASC_MISCOMPARE_VERIFY, CSL_MSC_SCSI_SENSEKEY_MISCOMPARE, CSL_MSC_STORAGE_STATE_SENDING_CSW, CSL_MSC_STORAGE_STATE_SENDING_STALL, CSL_MSC_VERIFY_PASSED, CSL_USB_IOFLAG_NOSHORT, CSL_USB_IOFLAG_NOT, CSL_MscObject::csw, CSL_MscObject::lbaBuffer, CSL_MscObject::lun, MSC_SetSenseKeys(), CSL_MscObject::senseData, CSL_MscObject::storageState, USB_postTransaction(), USB_stallEndpt(), and CSL_MscLogicalUnit::verifyFlag.

Referenced by MSC_HandleStateWaitForCBW().

static CSL_Status MSC_initCtrlDesc ( CSL_MscCtrlObject pCtrlHandle) [static]

============================================================================
MSC_initCtrlDesc

Description
This function initializes the control object

Arguments

            pCtrlHandle        Handle to the CTL Object
     

Return Value CSL_Status

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

Pre Condition
None

Post Condition
Initializes control object

Modifies
Control object structure

Example

            CSL_MscCtrlObject    ctrlObj;
            CSL_Status           status;

            status = MSC_initCtrlDesc(&ctrlObj);

     

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

static CSL_Status MSC_initMscVal ( CSL_MscObject pMscHandle) [static]

============================================================================
MSC_initMscVal

Description
This function initializes the MSC object

Arguments

            pMscHandle        Handle to the Msc Object
     

Return Value CSL_Status

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

Pre Condition
None

Post Condition
Initializes MSC object

Modifies
MSC object structure

Example

            CSL_MscObject    mscObj;
            CSL_Status       status;

            status = MSC_initMscVal(&mscObj);

     

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

static fpMSC_REQ_HANDLER MSC_lookupReqHandler ( Uint16  request,
CSL_MscRequestStruct pUSB_ReqTable 
) [inline, static]

============================================================================
MSC_lookupReqHandler

Description
This functions maps the request sent by host to the Msc request table and returns the corresponding request handler address

Arguments

            request        -  Request sent by the host
            pUSB_ReqTable  -  Request table structure pointer
     

Return Value
Request handler pointer

Pre Condition
Request table should be initialized and MSC_Open/MSC_OpenFullspeed function should be called successfully

Post Condition
Returns the request handler pointer

Modifies
None

Example

             CSL_MscRequestRet       (*fpRequestHandler)(CSL_MSC_REQUEST_ARGS)
             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             CSL_MscCtrlObject       *pCtrlHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;
             Uint16                  request;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             pCtrlHandle->fpRequestHandler = MSC_lookupReqHandler(request,
                                                       pCtrlHandle->mscReqTable);
     

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

References CSL_MscRequestStruct::fpRequestHandler, and MSC_reqUnknown().

Referenced by MSC_Ctrl().

CSL_Status MSC_Open ( pMscAppClassHandle  pAppClassHandle)

============================================================================
MSC_Open

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

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

Arguments

		    pAppClassHandle      Application handle to the MSC Class Obj
     

Return Value CSL_Status

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

Pre Condition
None

Post Condition
Initializes Msc and Ctrl handles

Modifies
Msc and Ctrl handle data

Example

			CSL_MscInitStructApp    mscAppHandle;
			pMscAppClassHandle      pAppClassHandle;
			Uint16                  mscAppBuffer[420];
			CSL_Status              status;

			pAppClassHandle = &mscAppHandle;

			// Assign values to all the members in mscAppHandle struct
			mscAppHandle.pMscObj = &mscAppBuffer[0];
			.....
			.....
			status = MSC_Open(pAppClassHandle);
     

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

References MSC_Setup().

CSL_Status MSC_OpenFullspeed ( pMscAppClassHandle  pAppClassHandle)

============================================================================
MSC_OpenFullspeed

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

NOTE: THIS FUNCTION CONFIGURES USB MSC MODULE IN FULLSPEED MODE

Arguments

		    pAppClassHandle      Application handle to the MSC Class Obj
     

Return Value CSL_Status

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

Pre Condition
None

Post Condition
Initializes Msc and Ctrl handles

Modifies
Msc and Ctrl handle data

Example

			CSL_MscInitStructApp    mscAppHandle;
			pMscAppClassHandle      pAppClassHandle;
			Uint16                  mscAppBuffer[420];
			CSL_Status              status;

			pAppClassHandle = &mscAppHandle;

			// Assign values to all the members in mscAppHandle struct
			mscAppHandle.pMscObj = &mscAppBuffer[0];
			.....
			.....
			status = MSC_OpenFullspeed(pAppClassHandle);
     

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

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

CSL_MscRequestRet MSC_reqBotMscReset ( CSL_UsbDevNum  devNum,
CSL_UsbSetupStruct usbSetup,
pUsbEpHandle  hInEp,
pUsbEpHandle  hOutEp,
void *  pMsc 
)

============================================================================
MSC_reqBotMscReset

Description
This function handles the Bulk Only Mass storage Reset request from host

Arguments

         devNum   - USB device instance number
         usbSetup - USB setup packet structure
         hInEp    - USB IN end point handle
         hOutEp   - USB OUT end point handle
         pMsc     - Pointer to the MSC Class Obj structure

     

Return Value

  • CSL_MSC_REQUEST_GET_ACK - Get acknowledgement for request
  • CSL_MSC_REQUEST_STALL - Request stall signal (Error)

Pre Condition
MSC_lookupReqHandler should be called successfully

Post Condition
Resets storage state

Modifies
None

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             CSL_MscCtrlObject       *pCtrlHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;
             Uint16                  request;

             Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             pCtrlHandle->fpRequestHandler = MSC_lookupReqHandler(request,
                                                       pCtrlHandle->mscReqTable);

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

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

References CSL_MscObject::bulkInEpObj, CSL_MscObject::bulkOutEpObj, CSL_MSC_STORAGE_STATE_RESET, MSC_HandleStateReset(), CSL_MscClassStruct::mscHandle, CSL_MscObject::storageState, and USB_abortTransaction().

static CSL_MscRequestRet MSC_reqClearFeature ( CSL_UsbDevNum  devNum,
CSL_UsbSetupStruct usbSetup,
pUsbEpHandle  hInEp,
pUsbEpHandle  hOutEp,
void *  pMsc 
) [inline, static]

============================================================================
MSC_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
            pMsc     - Handle to the MSC Class Obj
     

Return Value

  • CSL_MSC_REQUEST_SEND_ACK - Send acknowledgement for request
  • CSL_MSC_REQUEST_STALL - Request stall signal (Error)

Pre Condition
MSC_lookupReqHandler should be called successfully

Post Condition
Clears the feature

Modifies
USB registers

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             CSL_MscCtrlObject       *pCtrlHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;
             Uint16                  request;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             pCtrlHandle->fpRequestHandler = MSC_lookupReqHandler(request,
                                                       pCtrlHandle->mscReqTable);

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

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

References CSL_MSC_8BIT_MASK, 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_MscRequestRet MSC_reqGetConfiguration ( CSL_UsbDevNum  devNum,
CSL_UsbSetupStruct usbSetup,
pUsbEpHandle  hInEp,
pUsbEpHandle  hOutEp,
void *  pMsc 
) [inline, static]

============================================================================
MSC_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
            pMsc     - Handle to the MSC Class Obj
     

Return Value

  • CSL_MSC_REQUEST_GET_ACK - Get acknowledgement for request

Pre Condition
MSC_lookupReqHandler should be called successfully

Post Condition
Sends the configuration

Modifies
None

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             CSL_MscCtrlObject       *pCtrlHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;
             Uint16                  request;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             pCtrlHandle->fpRequestHandler = MSC_lookupReqHandler(request,
                                                       pCtrlHandle->mscReqTable);

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

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

References CSL_USB_IOFLAG_NONE, CSL_USB_IOFLAG_NOSHORT, CSL_MscCtrlObject::ctrlBuffer, CSL_MscClassStruct::ctrlHandle, CSL_MscCtrlObject::curConfigStat, and USB_postTransaction().

CSL_MscRequestRet MSC_reqGetDescriptor ( CSL_UsbDevNum  devNum,
CSL_UsbSetupStruct usbSetup,
pUsbEpHandle  hInEp,
pUsbEpHandle  hOutEp,
void *  pMsc 
)

============================================================================
MSC_reqGetDescriptor

Description
This function handles the request from host to get the descriptor

Arguments

            CSL_MSC_REQUEST_ARGS    - MSC request arguments
     

Return Value

  • CSL_MSC_REQUEST_GET_ACK - Get acknowledgement for request\
  • CSL_MSC_REQUEST_STALL - Request stall signal (Error)

Pre Condition
MSC_lookupReqHandler should be called successfully

Post Condition
Sends the descriptor

Modifies
None

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             CSL_MscCtrlObject       *pCtrlHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;
             Uint16                  request;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             pCtrlHandle->fpRequestHandler = MSC_lookupReqHandler(request,
                                                       pCtrlHandle->mscReqTable);

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

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

References CSL_MSC_8BIT_MASK, CSL_MSC_8BIT_SHIFT, CSL_MSC_UNICODE_SIZE, CSL_USB_CONFIGURATION_DESCRIPTOR_TYPE, CSL_USB_DEVICE_DESCRIPTOR_TYPE, CSL_USB_DEVICE_QUAL_DESCRIPTOR_TYPE, CSL_USB_IOFLAG_CAT, CSL_USB_IOFLAG_LNK, CSL_USB_IOFLAG_NONE, CSL_USB_IOFLAG_NOSHORT, CSL_USB_OTHERSPEED_CFG_DESCRIPTOR_TYPE, CSL_USB_STRING_DESCRIPTOR_TYPE, CSL_MscClassStruct::ctrlHandle, CSL_MscCtrlObject::deviceDescr, CSL_MscCtrlObject::deviceQualDescr, CSL_MscCtrlObject::pCfgDescr, CSL_MscCtrlObject::pOtherSpeedCfgDescr, CSL_MscCtrlObject::strDescr, CSL_MscCtrlObject::stringDescrLangid, USB_postTransaction(), CSL_UsbSetupStruct::wLength, and CSL_UsbSetupStruct::wValue.

static CSL_MscRequestRet MSC_reqGetInterface ( CSL_UsbDevNum  devNum,
CSL_UsbSetupStruct usbSetup,
pUsbEpHandle  hInEp,
pUsbEpHandle  hOutEp,
void *  pMsc 
) [inline, static]

============================================================================
MSC_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
            pMsc     - Handle to the MSC Class Obj
     

Return Value

  • CSL_MSC_REQUEST_GET_ACK - Get acknowledgement for request\
  • CSL_MSC_REQUEST_STALL - Request stall signal (Error)

Pre Condition
MSC_lookupReqHandler should be called successfully

Post Condition
Sends interface info

Modifies
None

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             CSL_MscCtrlObject       *pCtrlHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;
             Uint16                  request;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             pCtrlHandle->fpRequestHandler = MSC_lookupReqHandler(request,
                                                       pCtrlHandle->mscReqTable);

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

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

References CSL_USB_IOFLAG_NONE, CSL_MscCtrlObject::ctrlBuffer, CSL_MscClassStruct::ctrlHandle, USB_postTransaction(), and CSL_UsbSetupStruct::wIndex.

static CSL_MscRequestRet MSC_reqGetMaxLUN ( CSL_UsbDevNum  devNum,
CSL_UsbSetupStruct usbSetup,
pUsbEpHandle  hInEp,
pUsbEpHandle  hOutEp,
void *  pMsc 
) [inline, static]

============================================================================
MSC_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
            pMsc     - Handle to the MSC Class Obj
     

Return Value

  • CSL_MSC_REQUEST_GET_ACK - Get acknowledgement for request\
  • CSL_MSC_REQUEST_STALL - Request stall signal (Error)

Pre Condition
MSC_lookupReqHandler should be called successfully

Post Condition
Sends the max lun number

Modifies
None

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             CSL_MscCtrlObject       *pCtrlHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;
             Uint16                  request;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             pCtrlHandle->fpRequestHandler = MSC_lookupReqHandler(request,
                                                       pCtrlHandle->mscReqTable);

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

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

References CSL_USB_IOFLAG_NONE, CSL_MscCtrlObject::ctrlBuffer, CSL_MscClassStruct::ctrlHandle, CSL_MscClassStruct::mscHandle, CSL_MscObject::noOfLun, USB_postTransaction(), CSL_UsbSetupStruct::wIndex, CSL_UsbSetupStruct::wLength, and CSL_UsbSetupStruct::wValue.

static CSL_MscRequestRet MSC_reqGetStatus ( CSL_UsbDevNum  devNum,
CSL_UsbSetupStruct usbSetup,
pUsbEpHandle  hInEp,
pUsbEpHandle  hOutEp,
void *  pMsc 
) [inline, static]

============================================================================
MSC_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
            pMsc     - Handle to the MSC Class Obj
     

Return Value

  • CSL_MSC_REQUEST_GET_ACK - Get acknowledgement for request
  • CSL_MSC_REQUEST_STALL - Request stall signal (Error)

Pre Condition
MSC_lookupReqHandler should be called successfully

Post Condition
Sends the status

Modifies
None

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             CSL_MscCtrlObject       *pCtrlHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;
             Uint16                  request;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             pCtrlHandle->fpRequestHandler = MSC_lookupReqHandler(request,
                                                       pCtrlHandle->mscReqTable);

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

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

References CSL_UsbSetupStruct::bmRequestType, CSL_MSC_CURRDEV_STAT, CSL_MSC_REQUEST_TYPE_BASE, CSL_MSC_REQUEST_TYPE_DEVICE_STATUS, CSL_MSC_REQUEST_TYPE_EP_STATUS, CSL_MSC_REQUEST_TYPE_INTERFACE_STATUS, CSL_USB_IOFLAG_NONE, CSL_MscCtrlObject::ctrlBuffer, CSL_MscClassStruct::ctrlHandle, USB_epNumToHandle(), USB_getEndptStall(), USB_getRemoteWakeupStat(), USB_postTransaction(), and CSL_UsbSetupStruct::wIndex.

static CSL_MscRequestRet MSC_reqSetAddress ( CSL_UsbDevNum  devNum,
CSL_UsbSetupStruct usbSetup,
pUsbEpHandle  hInEp,
pUsbEpHandle  hOutEp,
void *  pMsc 
) [inline, static]

============================================================================
MSC_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
            pMsc     - Handle to the MSC Class Obj
     

Return Value

  • CSL_MSC_REQUEST_DONE - Request handled successfully

Pre Condition
MSC_lookupReqHandler should be called successfully

Post Condition
Sets the device address

Modifies
USB FADDR_POWER register

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             CSL_MscCtrlObject       *pCtrlHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;
             Uint16                  request;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             pCtrlHandle->fpRequestHandler = MSC_lookupReqHandler(request,
                                                       pCtrlHandle->mscReqTable);

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

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

References USB_setDevAddr(), and CSL_UsbSetupStruct::wValue.

static CSL_MscRequestRet MSC_reqSetConfiguration ( CSL_UsbDevNum  devNum,
CSL_UsbSetupStruct usbSetup,
pUsbEpHandle  hInEp,
pUsbEpHandle  hOutEp,
void *  pMsc 
) [inline, static]

============================================================================
MSC_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
            pMsc     - Handle to the MSC Class Obj
     

Return Value

  • CSL_MSC_REQUEST_SEND_ACK - Send acknowledgement for request
  • CSL_MSC_REQUEST_STALL - Request stall signal (Error)

Pre Condition
MSC_lookupReqHandler should be called successfully

Post Condition
Sets the configuration

Modifies
USB registers

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             CSL_MscCtrlObject       *pCtrlHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;
             Uint16                  request;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             pCtrlHandle->fpRequestHandler = MSC_lookupReqHandler(request,
                                                       pCtrlHandle->mscReqTable);

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

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

References CSL_MscClassStruct::ctrlHandle, CSL_MscCtrlObject::curConfigStat, USB_setConfiguration(), and CSL_UsbSetupStruct::wValue.

static CSL_MscRequestRet MSC_reqSetFeature ( CSL_UsbDevNum  devNum,
CSL_UsbSetupStruct usbSetup,
pUsbEpHandle  hInEp,
pUsbEpHandle  hOutEp,
void *  pMsc 
) [inline, static]

============================================================================
MSC_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
            pMsc     - Handle to the MSC Class Obj
     

Return Value

  • CSL_MSC_REQUEST_GET_ACK - Get acknowledgement for request
  • CSL_MSC_REQUEST_STALL - Request stall signal (Error)

Pre Condition
MSC_lookupReqHandler should be called successfully

Post Condition
Sets the feature

Modifies
USB regiters

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             CSL_MscCtrlObject       *pCtrlHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;
             Uint16                  request;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             pCtrlHandle->fpRequestHandler = MSC_lookupReqHandler(request,
                                                       pCtrlHandle->mscReqTable);

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

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

References CSL_MSC_8BIT_MASK, 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_MscRequestRet MSC_reqSetInterface ( CSL_UsbDevNum  devNum,
CSL_UsbSetupStruct usbSetup,
pUsbEpHandle  hInEp,
pUsbEpHandle  hOutEp,
void *  pMsc 
) [inline, static]

============================================================================
MSC_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
            pMsc     - Handle to the MSC Class Obj
     

Return Value

  • CSL_MSC_REQUEST_SEND_ACK - Send acknowledgement for request
  • CSL_MSC_REQUEST_STALL - Request stall signal (Error)

Pre Condition
MSC_lookupReqHandler should be called successfully

Post Condition
Sends acknowledgement

Modifies
None

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             CSL_MscCtrlObject       *pCtrlHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;
             Uint16                  request;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             pCtrlHandle->fpRequestHandler = MSC_lookupReqHandler(request,
                                                       pCtrlHandle->mscReqTable);

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

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

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

static CSL_MscRequestRet MSC_reqUnknown ( CSL_UsbDevNum  devNum,
CSL_UsbSetupStruct usbSetup,
pUsbEpHandle  hInEp,
pUsbEpHandle  hOutEp,
void *  pMsc 
) [inline, static]

============================================================================
MSC_reqUnknown

Description
This function handles the case where the request sent by the host is unknown unit number

Arguments

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

Return Value

  • CSL_MSC_REQUEST_STALL - Request stall signal (Error)

Pre Condition
MSC_lookupReqHandler should be called successfully

Post Condition
Sends acknowledgement

Modifies
None

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             CSL_MscCtrlObject       *pCtrlHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;
             Uint16                  request;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             pCtrlHandle->fpRequestHandler = MSC_lookupReqHandler(request,
                                                       pCtrlHandle->mscReqTable);

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

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

Referenced by MSC_Ctrl(), and MSC_lookupReqHandler().

CSL_Status MSC_sendCswWithPhaseError ( CSL_MscObject pMscHandle,
pUsbEpHandle  hUsbInEp 
)

============================================================================
MSC_sendCswWithPhaseError

Description
This function sends CSW with phase error. This function is used to handle different error conditions by the SCSI commands.

Arguments

            pMscHandle      - Handle to Msc class object
            hUsbInEp        - In end point handle
     

Return Value
status returned by the MUSB module

Pre Condition
Error detected during the data transfer

Post Condition
Sends CSW with phase error

Modifies
CSW buffer

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             pUsbEpHandle            hUbOutEp;
             pUsbEpHandle            hUbInEp;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;
			 pMscAppClassHandle      pAppClassHandle;

			 pAppClassHandle = &mscAppHandle;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(pAppClassHandle);
             ....
             ....
             MSC_sendCswWithPhaseError(pMscHandle, hUbInEp);
     

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

References CSL_MscObject::cbwDataTransferLength, CSL_MSC_16BIT_MASK, CSL_MSC_16BIT_SHIFT, CSL_MSC_CSW_4, CSL_MSC_CSW_5, CSL_MSC_CSW_6, CSL_MSC_CSW_DATA_SIZE, CSL_MSC_CSW_STATUS_PHASE_ERROR, CSL_MSC_STORAGE_STATE_SENDING_CSW, CSL_USB_IOFLAG_NOSHORT, CSL_MscObject::csw, CSL_MscObject::storageState, and USB_postTransaction().

Referenced by MSC_ExecuteRead(), MSC_ExecuteWrite(), MSC_HandleInquiry(), MSC_HandleModeSense10(), MSC_HandleModeSense6(), MSC_HandleReadCapacity(), and MSC_HandleRequestSense().

CSL_Status MSC_SetLunAttr ( pMscAppClassHandle  pAppClassHandle,
CSL_MscLunAttribApp lunHandle,
Uint16  lunNum 
)

============================================================================
MSC_SetLunAttr

Description
This function initializes the logical unit data structures.

Arguments

            pAppClassHandle      Handle of the MSC User Application Object
            lunHandle            Handle to the application Lun Object
            lunNum               Logical Unit Number
     

Return Value CSL_Status

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

Pre Condition
MSC module should be opened using MSC_Open/MSC_OpenFullspeed function

Post Condition
Initializes the logical unit

Modifies
Logical unit data structures

Example

			CSL_MscInitStructApp    mscAppHandle;
			pMscAppClassHandle      pAppClassHandle;
			Uint16                  mscAppBuffer[420];
			CSL_Status              status;
			CSL_MscLunAttribApp     lunObj;

			pAppClassHandle = &mscAppHandle;

			// Assign values to all the members in mscAppHandle struct
			mscAppHandle.pMscObj = &mscAppBuffer[0];
			.....
			.....
			status = MSC_Open(pAppClassHandle);
			....
			....
			//Assign values to Lun Object structure
			lunObj.removeableApp = 0;
			lunObj.lbaSizeApp    = 512;
			....
			....
			status = MSC_SetLunAttr(&mscAppHandle, &lunObj, 0);
     

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

References CSL_MSC_VERIFY_PASSED, CSL_SCSI_DATA0_DEFVAL, CSL_SCSI_DATA1_DEFVAL, CSL_SCSI_DATA2_DEFVAL, CSL_SCSI_DATA30_DEFVAL, CSL_SCSI_DATA31_DEFVAL, CSL_SCSI_DATA32_DEFVAL, CSL_SCSI_DATA3_DEFVAL, CSL_SCSI_DATA4_DEFVAL, CSL_SCSI_DATA5_DEFVAL, CSL_SCSI_DATA_NULL_VAL, CSL_SCSI_DATA_SIZE1, CSL_SCSI_DATA_SIZE2, CSL_SCSI_DATA_SIZE3, CSL_SCSI_DATA_SIZE4, CSL_MscLogicalUnit::lbaSize, CSL_MscLunAttribApp::lbaSizeApp, CSL_MscObject::lun, CSL_MscLogicalUnit::mediaSize, CSL_MscLunAttribApp::mediaSizeApp, CSL_MscLogicalUnit::mediaState, CSL_MscClassStruct::mscHandle, CSL_MscInitStructApp::pMscObj, CSL_MscLogicalUnit::readwrite, CSL_MscLunAttribApp::readwriteApp, CSL_MscLogicalUnit::removeable, CSL_MscLunAttribApp::removeableApp, CSL_MscLunAttribApp::scsiInquiryConfData, CSL_MscLogicalUnit::scsiInquiryData, and CSL_MscLogicalUnit::verifyFlag.

static void MSC_SetSenseKeys ( Uint16 *  senseData,
Uint16  senseKey,
Uint16  addSenseKey 
) [inline, static]

============================================================================
MSC_SetSenseKeys

Description
This function sets the sense key data

Arguments

            senseData      - Sense key data array
            senseKey       - Sense key data
            addSenseKey    - Sense key additional data
     

Return Value
None

Pre Condition
MSC module should be opened using MSC_Open/MSC_OpenFullspeed function

Post Condition
Sets sense key data

Modifies
SEnse key data array

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             pUsbEpHandle            hUbOutEp;
             Uint16                  lunNum;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(&mscAppHandle);
             ....
             ....
             MSC_SetSenseKeys(pMscHandle->senseData,
                              CSL_MSC_SCSI_SENSEKEY_ILLEGAL_REQUEST,
                              CSL_MSC_SCSI_ASC_INVALID_COMMAND_OPERATION_CODE);
     

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

References CSL_MSC_SSD_2, and CSL_MSC_SSD_7.

Referenced by MSC_ExecuteRead(), MSC_ExecuteWrite(), MSC_HandlePreventAllowMediaRemoval(), MSC_HandleReadCapacity(), MSC_HandleStartStopUnit(), MSC_HandleStateWaitForCBW(), MSC_HandleTestUnitReady(), and MSC_HandleVerify10().

static CSL_Status MSC_Setup ( pMscAppClassHandle  pAppClassHandle,
Bool  usbSpeedCfg 
) [static]

============================================================================
MSC_Setup

Description
This function used to setup the Msc and Ctrl handles. This is an internal function and is called from MSC_Open or MSC_OpenFullspeed functions.

Arguments

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

Return Value CSL_Status

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

Pre Condition
None

Post Condition
Initializes Msc and Ctrl handles

Modifies
Msc and Ctrl handle data

Example

			CSL_MscInitStructApp    mscAppHandle;
			pMscAppClassHandle      pAppClassHandle;
			Uint16                  mscAppBuffer[420];
			CSL_Status              status;

			pAppClassHandle = &mscAppHandle;

			// Assign values to all the members in mscAppHandle struct
			mscAppHandle.pMscObj = &mscAppBuffer[0];
			.....
			.....
			// Setup USB for highspeed
			status = MSC_Setup(pAppClassHandle, TRUE);
     

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

static CSL_Status MSC_verifyCBW ( CSL_MscObject pMscHandle,
pUsbEpHandle  hUsbOutEp,
pUsbEpHandle  hUsbInEp 
) [inline, static]

============================================================================
MSC_verifyCBW

Description
Verifies the CBW received from host

Arguments

            pMscHandle      - Handle to Msc class object
            hUsbOutEp       - Out end point handle
            hUsbInEp        - In end point handle
     

Return Value CSL_Status
CSL_SOK - CBW is valid
CSL_ESYS_FAIL - CBW is invalid

Pre Condition
MSC_Open should be called successfully

Post Condition
None

Modifies
None

Example

             CSL_MscInitStructApp    mscAppHandle;
             CSL_MscObject           *pMscHandle;
             pUsbEpHandle            hUbOutEp;
             pUsbEpHandle            hUbInEp;
             Uint16                  mscAppBuffer[420];
             CSL_Status              status;
			 pMscAppClassHandle      pAppClassHandle;

			 pAppClassHandle = &mscAppHandle;

             // Assign values to all the members in mscAppHandle struct
             mscAppHandle.pMscObj = &mscAppBuffer[0];
             .....
             .....
             status = MSC_Open(pAppClassHandle);
             ....
             ....
             MSC_verifyCBW(pMscHandle, hUbOutEp, hUbInEp);
     

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

References CSL_MscObject::cbw, CSL_MSC_16BIT_SHIFT, CSL_MSC_8BIT_SHIFT, CSL_MSC_CBW_0, CSL_MSC_CBW_1, CSL_MSC_CBW_6, CSL_MSC_CBW_DATA_SIZE, CSL_MSC_CBW_SIGNATURE, CSL_MscObject::noOfLun, and USB_getDataCountReadFromFifo().

Referenced by MSC_HandleStateWaitForCBW().