- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Functions
csl_msc.c File Reference

USB MSC functional layer API source file. More...

`#include <string.h>`
`#include <csl_msc.h>`
`#include <csl_mscAux.h>`

## 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)

## Detailed Description

USB MSC functional layer API source file.

Path: \(CSLPATH)\ src

## Function Documentation

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);

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

References CSL_UsbDataStruct::bytes, CSL_MscCtrlObject::confDescr, CSL_MscCtrlObject::configDescrLnk, CSL_MSC_8BIT_SHIFT, CSL_MSC_BULKINEP_DESC0_DEFVAL, CSL_MSC_BULKINEP_DESC2_DEFVAL, CSL_MSC_BULKINEP_DESC3_DEFVAL, CSL_MSC_BULKINEP_DESC4_DEFVAL, CSL_MSC_BULKINEP_DESC_DEFLEN, CSL_MSC_BULKOUTEP_DESC0_DEFVAL, CSL_MSC_BULKOUTEP_DESC2_DEFVAL, CSL_MSC_BULKOUTEP_DESC3_DEFVAL, CSL_MSC_BULKOUTEP_DESC4_DEFVAL, CSL_MSC_BULKOUTEP_DESC_DEFLEN, CSL_MSC_CONF_DESC0_DEFVAL, CSL_MSC_CONF_DESC2_DEFVAL, CSL_MSC_CONF_DESC3_DEFVAL, CSL_MSC_CONF_DESC4_DEFVAL, CSL_MSC_CONF_DESC_DEFLEN, CSL_MSC_CONFIGURATION_DESCRIPTOR_TYPE, CSL_MSC_DEVICE_DESC0_DEFVAL, CSL_MSC_DEVICE_DESC2_DEFVAL, CSL_MSC_DEVICE_DESC3_DEFVAL, CSL_MSC_DEVICE_DESC4_DEFVAL, CSL_MSC_DEVICE_DESC5_DEFVAL, CSL_MSC_DEVICE_DESC6_DEFVAL, CSL_MSC_DEVICE_DESC7_DEFVAL, CSL_MSC_DEVICE_DESC8_DEFVAL, CSL_MSC_DEVICE_DESC9_DEFVAL, CSL_MSC_DEVICE_DESC_DEFLEN, CSL_MSC_DEVICE_DESCRIPTOR_TYPE, CSL_MSC_DEVICE_QUAL_DESC0_DEFVAL, CSL_MSC_DEVICE_QUAL_DESC2_DEFVAL, CSL_MSC_DEVICE_QUAL_DESC3_DEFVAL, CSL_MSC_DEVICE_QUAL_DESC4_DEFVAL, CSL_MSC_DEVICE_QUAL_DESC5_DEFVAL, CSL_MSC_DEVICE_QUAL_DESC_DEFLEN, CSL_MSC_DEVICE_QUAL_DESCRIPTOR_TYPE, CSL_MSC_ENDPOINT_DESCRIPTOR_TYPE, CSL_MSC_FS_CFG_DESC0_DEFVAL, CSL_MSC_FS_CFG_DESC10_DEFVAL, CSL_MSC_FS_CFG_DESC11_DEFVAL, CSL_MSC_FS_CFG_DESC12_DEFVAL, CSL_MSC_FS_CFG_DESC13_DEFVAL, CSL_MSC_FS_CFG_DESC14_DEFVAL, CSL_MSC_FS_CFG_DESC15_DEFVAL, CSL_MSC_FS_CFG_DESC16_DEFVAL, CSL_MSC_FS_CFG_DESC2_DEFVAL, CSL_MSC_FS_CFG_DESC3_DEFVAL, CSL_MSC_FS_CFG_DESC4_DEFVAL, CSL_MSC_FS_CFG_DESC6_DEFVAL, CSL_MSC_FS_CFG_DESC7_DEFVAL, CSL_MSC_FS_CFG_DESC8_DEFVAL, CSL_MSC_FS_CFG_DESC9_DEFVAL, CSL_MSC_HS_CFG_DESC0_DEFVAL, CSL_MSC_HS_CFG_DESC10_DEFVAL, CSL_MSC_HS_CFG_DESC11_DEFVAL, CSL_MSC_HS_CFG_DESC12_DEFVAL, CSL_MSC_HS_CFG_DESC13_DEFVAL, CSL_MSC_HS_CFG_DESC14_DEFVAL, CSL_MSC_HS_CFG_DESC15_DEFVAL, CSL_MSC_HS_CFG_DESC16_DEFVAL, CSL_MSC_HS_CFG_DESC2_DEFVAL, CSL_MSC_HS_CFG_DESC3_DEFVAL, CSL_MSC_HS_CFG_DESC4_DEFVAL, CSL_MSC_HS_CFG_DESC6_DEFVAL, CSL_MSC_HS_CFG_DESC7_DEFVAL, CSL_MSC_HS_CFG_DESC8_DEFVAL, CSL_MSC_HS_CFG_DESC9_DEFVAL, CSL_MSC_INTERFACE_DESC0_DEFVAL, CSL_MSC_INTERFACE_DESC2_DEFVAL, CSL_MSC_INTERFACE_DESC3_DEFVAL, CSL_MSC_INTERFACE_DESC4_DEFVAL, CSL_MSC_INTERFACE_DESC5_DEFVAL, CSL_MSC_INTERFACE_DESC_DEFLEN, CSL_MSC_INTERFACE_DESCRIPTOR_TYPE, CSL_MSC_LANGID0_DEFVAL, CSL_MSC_LANGID2_DEFVAL, CSL_MSC_LANGID3_DEFVAL, CSL_MSC_LANGID_DEFLEN, CSL_MSC_OTHERSPEED_CFG_DESCRIPTOR_TYPE, CSL_MSC_STRING_DESCRIPTOR_TYPE, CSL_MscCtrlObject::deviceDescr, CSL_MscCtrlObject::deviceQualDescr, CSL_MscCtrlObject::fullSpeedCfgDescr, CSL_MscCtrlObject::highSpeedCfgDescr, CSL_MscCtrlObject::massStorageBulkInEndptDescr, CSL_MscCtrlObject::massStorageBulkInEndptLnk, CSL_MscCtrlObject::massStorageBulkOutEndptDescr, CSL_MscCtrlObject::massStorageBulkOutEndptLnk, CSL_MscCtrlObject::massStorageIntDescr, CSL_MscCtrlObject::massStorageInterfcLnk, CSL_UsbDataStruct::pBuffer, CSL_MscCtrlObject::pCfgDescr, CSL_UsbDataStruct::pNextBuffer, CSL_MscCtrlObject::pOtherSpeedCfgDescr, CSL_MscCtrlObject::stringDescrLangid, USB_getMaxPower(), and CSL_MscCtrlObject::usbSpeedCfg.

Referenced by MSC_Setup().

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);

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

References CSL_MscObject::activityPresentFlag, CSL_MSC_CSW0_DEFVAL, CSL_MSC_CSW1_DEFVAL, CSL_MSC_CSW2_DEFVAL, CSL_MSC_MODESENSE_DATA0_DEFVAL, CSL_MSC_MODESENSE_DATA1_DEFVAL, CSL_MSC_MODESENSE_DATA2_DEFVAL, CSL_MSC_MODESENSE_DATA3_DEFVAL, CSL_MSC_MODESENSE_DATA4_DEFVAL, CSL_MSC_READ_CAPACITY0_DEFVAL, CSL_MSC_SENSE_DATA0_DEFVAL, CSL_MSC_SENSE_DATA1_DEFVAL, CSL_MSC_SENSE_DATA2_DEFVAL, CSL_MSC_SENSE_DATA3_DEFVAL, CSL_MSC_SENSE_DATA4_DEFVAL, CSL_MSC_SENSE_DATA5_DEFVAL, CSL_MscObject::csw, CSL_MscObject::modeSenseData, CSL_MscObject::readCapacity, CSL_MscObject::senseData, and CSL_MscObject::storageState.

Referenced by MSC_Setup().

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);

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

References CSL_MscInitStructApp::bulkHandler, CSL_MscObject::bulkInEpObj, CSL_MscObject::bulkOutEpObj, CSL_MSC_MEDIA_BAD, CSL_MSC_MEDIA_PRESENT, CSL_MSC_MEDIACCESS_BADMEDIA, CSL_MSC_MEDIACCESS_NOTPRESENT, CSL_MSC_MEDIACCESS_SUCCESS, CSL_USB_BULK, CSL_USB_CTRL, CSL_USB_EP0_PACKET_SIZE, CSL_USB_EP1_PACKET_SIZE_FS, CSL_USB_EP1_PACKET_SIZE_HS, CSL_USB_EVENT_EOT, CSL_USB_EVENT_RESET, CSL_USB_EVENT_RESUME, CSL_USB_EVENT_SETUP, CSL_USB_EVENT_SUSPEND, CSL_USB_IN_EP0, CSL_USB_IN_EP1, CSL_USB_OUT_EP0, CSL_USB_OUT_EP2, CSL_MscClassStruct::ctrlHandle, CSL_MscInitStructApp::ctrlHandler, CSL_MscCtrlObject::ctrlInEpObj, CSL_MscCtrlObject::ctrlOutEpObj, CSL_MscCtrlObject::curConfigStat, CSL_MscCtrlObject::deviceDescr, CSL_MscCtrlObject::devNum, CSL_MscObject::getMediaSize, CSL_MscInitStructApp::getMediaSizeApp, CSL_MscCtrlObject::hEpObjArray, CSL_MscObject::lbaBuffer, CSL_MscInitStructApp::lbaBufferApp, CSL_MscObject::lun, CSL_MscObject::mediaEject, CSL_MscInitStructApp::mediaEjectApp, CSL_MscObject::mediaGetPresentState, CSL_MscInitStructApp::mediaGetPresentStateApp, CSL_MscObject::mediaInit, CSL_MscInitStructApp::mediaInitApp, CSL_MscObject::mediaLockUnit, CSL_MscInitStructApp::mediaLockUnitApp, CSL_MscLogicalUnit::mediaSize, CSL_MscLogicalUnit::mediaState, MSC_initCtrlDesc(), MSC_initMscVal(), CSL_MscClassStruct::mscHandle, CSL_MscCtrlObject::mscReqTable, CSL_MscInitStructApp::mscReqTableApp, CSL_MscObject::noOfLun, CSL_MscInitStructApp::numLun, CSL_MscInitStructApp::pId, CSL_MscInitStructApp::pMscObj, CSL_MscObject::readMedia, CSL_MscInitStructApp::readMediaApp, CSL_MscCtrlObject::strDescr, CSL_MscInitStructApp::strDescrApp, CSL_MscCtrlObject::stringDescrLangid, CSL_MscCtrlObject::suspendFlag, USB_connectDev(), USB_initEndptObj(), USB_setParams(), CSL_MscCtrlObject::usbSpeedCfg, CSL_MscInitStructApp::vId, CSL_MscObject::writeMedia, and CSL_MscInitStructApp::writeMediaApp.

Referenced by MSC_Open(), and MSC_OpenFullspeed().