PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
UsbHostMassStorage.c File Reference
Include dependency graph for UsbHostMassStorage.c:

Go to the source code of this file.

Functions

static void WaitForSetupComplete (void)
 
static void SetupComplete (stc_usbn_t *pstcUsb, uint8_t *pu8Buffer, uint32_t u32DataSize)
 
static void convBufferToSenseResponse (uint8_t *buffer, struct RequestSenseResponse *sr)
 
static void convBufferToModeSenseResponse (uint8_t *buffer, struct ModeSenseResponse *msr)
 
static void convBufferToInquiryResponse (uint8_t *buffer, InquiryResponse_t *ir)
 
static void convCBWtoBuffer (cbw_t *cbw, uint8_t *Buffer)
 
static int convBufferToCSW (uint8_t *buffer, int length, csw_t *csw)
 
int UsbHostMassStorage_StorageApiRead (BYTE *buff, DWORD sector, BYTE count)
 
int UsbHostMassStorage_StorageApiWrite (BYTE *buff, DWORD sector, BYTE count)
 
int UsbHostMassStorage_StorageApiReadCapacity (void(*Buff))
 
int UsbHostMassStorage_StorageApiInit (void)
 
int UsbHostMassStorage_StorageApiModeSense (void)
 
boolean_t UsbHostMassStorage_InitHandler (stc_usbn_t *pstcUsb, uint8_t *pu8Configuration, uint32_t u32Length)
 
boolean_t UsbHostMassStorage_DeinitHandler (stc_usbn_t *pstcUsb)
 
void UsbHostMassStorage_BulkInCompletion (stc_usbn_t *pstcUsbHandle)
 
void UsbHostMassStorage_BulkOutCompletion (stc_usbn_t *pstcUsbHandle)
 
void UsbHostMassStorage_InTransferDone (void)
 
void UsbHostMassStorage_OutTransferDone (void)
 
StorageInfo_t * UsbHostMassStorage_GetGlobalStorageInfo ()
 
static void ErrorHandler (uint16_t errCode, uint8_t *clrEponly)
 
void UsbHostMassStorage_CheckForCompletion (volatile uint8_t *NAKDetected)
 
int16_t UsbHostMassStorage_StorageCommandSend (StorageInfo_t *pstcStorageInfo)
 
int16_t UsbHostMassStorage_SendCBW (StorageInfo_t *pstcStorageInfo)
 
int16_t UsbHostMassStorage_Transmit_MSDC_Data (uint8_t *pu8Buffer, StorageInfo_t *pstcStorageInfo)
 
int16_t UsbHostMassStorage_Transmit_Data (StorageInfo_t *pstcStorageInfo)
 
int16_t UsbHostMassStorage_GetCSW (StorageInfo_t *pstcStorageInfo)
 
int16_t UsbHostMassStorage_CheckCSW (StorageInfo_t *pstcStorageInfo)
 
int16_t UsbHostMassStorage_BulkOnlyMSReset (void)
 
int16_t UsbHostMassStorage_StorageStatus (void)
 
int16_t UsbHostMassStorage_ResetRecovery (void)
 
int16_t UsbHostMassStorage_ClearInEndpoint (void)
 
int16_t UsbHostMassStorage_ClearOutEndpoint (void)
 
int UsbHostMassStorage_TestUnitReady (StorageInfo_t *pstcStorageInfo)
 
boolean_t UsbHostMassStorage_DriverActive (void)
 

Variables

static stc_host_endpoint_t * EndpointOUT
 
static stc_host_endpoint_t * EndpointIN
 
static uint8_t u8EndpointIN
 
static uint8_t u8EndpointOUT
 
static uint16_t u16MaxPackageSizeIN
 
static uint16_t u16MaxPackageSizeOUT
 
static volatile uint8_t u8Status = 0
 
static volatile boolean_t bSetupComplete = FALSE
 
StorageInfo_t stcGlobalStorageInfo
 
static StorageInfo_t * pstcStorageInfo
 
static stc_usb_request_t setup
 
static stc_usbn_t * pstcUsbHandle = NULL
 
read_capacity_t ReadCapacity
 
csw_t csw
 
cbw_t cbw
 
uint8_t CswBuffer [13]
 
uint8_t CbwBuffer [31]
 

Detailed Description

A detailed description is available at USB Host Mass Storage Module description

History:

  • 2010-03-30 1.0 MSc First version (works with 16FX)
  • 2011-08-11 1.1 MSc Several Bug fixes
  • 2011-08-24 1.2 MSc Timeout Bug fixes
  • 2013-10-14 1.3 MSc PDL support added

Definition in file UsbHostMassStorage.c.

Function Documentation

static int convBufferToCSW ( uint8_t *  buffer,
int  length,
csw_t *  csw 
)
static

Definition at line 527 of file UsbHostMassStorage.c.

References csw::CSWDataResidue, csw::CSWSignatur, csw::CSWStatus, csw::CSWTag, and LENDIAN_BUFFER_TO_U32.

Referenced by UsbHostMassStorage_GetCSW().

Here is the caller graph for this function:

static void convBufferToModeSenseResponse ( uint8_t *  buffer,
struct ModeSenseResponse *  msr 
)
static
static void convCBWtoBuffer ( cbw_t *  cbw,
uint8_t *  Buffer 
)
static

Definition at line 511 of file UsbHostMassStorage.c.

References cbw::bCBWCBLength, cbw::bCBWFlags, cbw::bCBWLUN, cbw::CBWCB, cbw::dCBWDataTransferLength, cbw::dCBWSignature, cbw::dCBWTag, and U32_TO_LENDIAN_BUFFER.

Referenced by UsbHostMassStorage_SendCBW().

Here is the caller graph for this function:

static void ErrorHandler ( uint16_t  errCode,
uint8_t *  clrEponly 
)
static

Definition at line 545 of file UsbHostMassStorage.c.

References bSetupComplete, EndpointIN, EndpointOUT, FALSE, UsbHostMassStorage_ClearInEndpoint(), UsbHostMassStorage_ClearOutEndpoint(), and UsbHostMassStorage_ResetRecovery().

Referenced by UsbHostMassStorage_CheckCSW(), and UsbHostMassStorage_StorageCommandSend().

Here is the call graph for this function:

Here is the caller graph for this function:

static void SetupComplete ( stc_usbn_t *  pstcUsb,
uint8_t *  pu8Buffer,
uint32_t  u32DataSize 
)
static

Definition at line 410 of file UsbHostMassStorage.c.

References bSetupComplete, and TRUE.

Referenced by UsbHostMassStorage_BulkOnlyMSReset().

Here is the caller graph for this function:

static void WaitForSetupComplete ( void  )
static

Definition at line 415 of file UsbHostMassStorage.c.

References bSetupComplete, and FALSE.

Referenced by UsbHostMassStorage_BulkOnlyMSReset().

Here is the caller graph for this function:

Variable Documentation

volatile boolean_t bSetupComplete = FALSE
static

Definition at line 86 of file UsbHostMassStorage.c.

Referenced by ErrorHandler(), SetupComplete(), and WaitForSetupComplete().

Definition at line 460 of file UsbHostMassStorage.c.

uint8_t CbwBuffer[31]

Definition at line 462 of file UsbHostMassStorage.c.

Definition at line 459 of file UsbHostMassStorage.c.

uint8_t CswBuffer[13]

Definition at line 461 of file UsbHostMassStorage.c.

StorageInfo_t* pstcStorageInfo
static

Definition at line 88 of file UsbHostMassStorage.c.

read_capacity_t ReadCapacity

Definition at line 458 of file UsbHostMassStorage.c.

stc_usb_request_t setup
static

Definition at line 89 of file UsbHostMassStorage.c.

StorageInfo_t stcGlobalStorageInfo

Definition at line 87 of file UsbHostMassStorage.c.

Referenced by UsbHostMassStorage_GetGlobalStorageInfo().

uint16_t u16MaxPackageSizeIN
static

Definition at line 84 of file UsbHostMassStorage.c.

Referenced by UsbHostMassStorage_InitHandler().

uint16_t u16MaxPackageSizeOUT
static

Definition at line 84 of file UsbHostMassStorage.c.

Referenced by UsbHostMassStorage_InitHandler().

uint8_t u8EndpointIN
static

Definition at line 83 of file UsbHostMassStorage.c.

Referenced by UsbHostMassStorage_InitHandler().

uint8_t u8EndpointOUT
static

Definition at line 83 of file UsbHostMassStorage.c.

Referenced by UsbHostMassStorage_InitHandler().