PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
USB Host Middleware: Mass Storage

Data Structures

struct  cbw
 
struct  csw
 
struct  InquiryResponse
 
struct  read_capacity
 
struct  RequestSenseResponse
 
struct  StorageInfo
 
struct  inquiry_response
 
struct  ModeSenseResponse
 
struct  StorageReadWrite
 
struct  StorageWrite
 

Macros

#define USBMASSSTORAGE_FLAG_TRANSFERDONE   (1<<0)
 
#define USBMASSSTORAGE_FLAG_TRANSFERDONE_IN   (1<<1)
 
#define USBMASSSTORAGE_FLAG_TRANSFERDONE_OUT   (1<<2)
 
#define FORMAT_UNIT   0x04
 
#define INQUIRY_MASS_STORAGE   0x12
 
#define MODE_SELECT   0x55
 
#define MODE_SENSE   0x5A
 
#define PREVENT_ALLOW_MEDIUM_REMOVAL   0x1E
 
#define READ_MASS_STORAGE   0x28
 
#define READ_MASS_STORAGE_CAPACITY   0x25
 
#define READ_FORMAT_CAPACITIES   0x23
 
#define MASS_STORAGE_REQUEST_SENSE   0x03
 
#define REZERO   0x01
 
#define SEEK10   0x2B
 
#define SEND_DIAGNOSTIC   0x1D
 
#define START_STOP_UNIT   0x1B
 
#define TEST_UNIT_READY   0x00
 
#define VERIFY   0x2F
 
#define WRITE_MASS_STORAGE   0x2A
 
#define WRITE12   0xAA
 
#define WRITE_AND_VERIFY   0x2E
 
#define CBW_TAG   0x1A2B3C4D
 
#define LITTLEENDIAN   1
 
#define BIGENDIAN   2
 
#define ENDIANTYPE   BIGENDIAN
 
#define LENDIAN_BUFFER_TO_U32(pu8Buffer)
 
#define U32_TO_LENDIAN_BUFFER(pu8Buffer, u32Data)
 

Typedefs

typedef struct cbw cbw_t
 
typedef struct csw csw_t
 
typedef struct InquiryResponse InquiryResponse_t
 
typedef struct read_capacity read_capacity_t
 
typedef struct RequestSenseResponse RequestSenseResponse_t
 
typedef struct StorageInfo StorageInfo_t
 
typedef struct inquiry_response inquiry_response_t
 
typedef struct ModeSenseResponse ModeSenseResponse_t
 
typedef struct StorageReadWrite StorageReadWrite_t
 
typedef struct StorageWrite StorageWrite_t
 

Functions

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)
 
void UsbHostMassStorage_Init (void)
 
boolean_t UsbHostMassStorage_DeinitHandler (stc_usbn_t *pstcUsb)
 
boolean_t UsbHostMassStorage_InitHandler (stc_usbn_t *pstcUsb, uint8_t *pu8Configuration, uint32_t u32Length)
 
void UsbHostMassStorage_BulkInCompletion (stc_usbn_t *pstcUsbHandle)
 
void UsbHostMassStorage_BulkOutCompletion (stc_usbn_t *pstcUsbHandle)
 
void UsbHostMassStorage_InTransferDone (void)
 
void UsbHostMassStorage_OutTransferDone (void)
 
void UsbHostMassStorage_CheckForCompletion (volatile uint8_t *NAKDetected)
 
StorageInfo_t * UsbHostMassStorage_GetGlobalStorageInfo (void)
 
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)
 
void UsbHostMassStorage_GetEPStatus (uint8_t *InEpStatus, uint8_t *OutEpStatus)
 
int UsbHostMassStorage_TestUnitReady (StorageInfo_t *pstcStorageInfo)
 
void MassStorageWaitForSetupComplete (void)
 
boolean_t UsbHostMassStorage_DriverActive (void)
 

Detailed Description

Provided functions of USB Host Mass Storage module:

Storage API:

Other API:

Following procedures are used for the UsbHostClassSupervisor:

Used to connect USB hard drives to the MCU

Macro Definition Documentation

#define BIGENDIAN   2

Definition at line 133 of file UsbHostMassStorage.h.

#define CBW_TAG   0x1A2B3C4D
#define ENDIANTYPE   BIGENDIAN

Definition at line 134 of file UsbHostMassStorage.h.

#define FORMAT_UNIT   0x04

Definition at line 111 of file UsbHostMassStorage.h.

#define INQUIRY_MASS_STORAGE   0x12
#define LENDIAN_BUFFER_TO_U32 (   pu8Buffer)
Value:
(uint32_t)( (uint32_t)*(uint8_t*)(pu8Buffer) \
| ((((uint32_t)*(((uint8_t*)(pu8Buffer))+1)) << 8 ) & 0xFF00UL )\
| ((((uint32_t)*(((uint8_t*)(pu8Buffer))+2)) << 16 ) & 0xFF0000UL )\
| ((((uint32_t)*(((uint8_t*)(pu8Buffer))+3)) << 24 ) & 0xFF000000UL)\
)

Definition at line 136 of file UsbHostMassStorage.h.

Referenced by convBufferToCSW(), and convBufferToSenseResponse().

#define LITTLEENDIAN   1

Definition at line 132 of file UsbHostMassStorage.h.

#define MODE_SELECT   0x55

Definition at line 113 of file UsbHostMassStorage.h.

#define PREVENT_ALLOW_MEDIUM_REMOVAL   0x1E

Definition at line 115 of file UsbHostMassStorage.h.

#define READ_FORMAT_CAPACITIES   0x23

Definition at line 118 of file UsbHostMassStorage.h.

#define READ_MASS_STORAGE   0x28
#define READ_MASS_STORAGE_CAPACITY   0x25
#define REZERO   0x01

Definition at line 120 of file UsbHostMassStorage.h.

#define SEEK10   0x2B

Definition at line 121 of file UsbHostMassStorage.h.

#define SEND_DIAGNOSTIC   0x1D

Definition at line 122 of file UsbHostMassStorage.h.

Referenced by UsbHostMassStorage_SendCBW().

#define START_STOP_UNIT   0x1B

Definition at line 123 of file UsbHostMassStorage.h.

#define U32_TO_LENDIAN_BUFFER (   pu8Buffer,
  u32Data 
)
Value:
{ *((pu8Buffer)) =(uint8_t)((uint32_t)(u32Data) );\
*((pu8Buffer)+1)=(uint8_t)((uint32_t)(u32Data) >> 8);\
*((pu8Buffer)+2)=(uint8_t)((uint32_t)(u32Data) >> 16);\
*((pu8Buffer)+3)=(uint8_t)((uint32_t)(u32Data) >> 24);\
}

Definition at line 143 of file UsbHostMassStorage.h.

Referenced by convCBWtoBuffer().

#define USBMASSSTORAGE_FLAG_TRANSFERDONE   (1<<0)

Definition at line 107 of file UsbHostMassStorage.h.

#define USBMASSSTORAGE_FLAG_TRANSFERDONE_IN   (1<<1)
#define USBMASSSTORAGE_FLAG_TRANSFERDONE_OUT   (1<<2)
#define VERIFY   0x2F

Definition at line 125 of file UsbHostMassStorage.h.

#define WRITE12   0xAA

Definition at line 127 of file UsbHostMassStorage.h.

#define WRITE_AND_VERIFY   0x2E

Definition at line 128 of file UsbHostMassStorage.h.

Typedef Documentation

typedef struct cbw cbw_t
typedef struct csw csw_t
typedef struct StorageInfo StorageInfo_t
typedef struct StorageWrite StorageWrite_t

Function Documentation

void MassStorageWaitForSetupComplete ( void  )
void UsbHostMassStorage_BulkInCompletion ( stc_usbn_t *  pstcUsbHandle)

Definition at line 423 of file UsbHostMassStorage.c.

References StorageInfo::BYTES_TRANSFERRED, EndpointIN, StorageInfo::STATUS, and UsbHostMassStorage_InTransferDone().

Referenced by UsbHostMassStorage_Transmit_MSDC_Data().

Here is the call graph for this function:

Here is the caller graph for this function:

int16_t UsbHostMassStorage_BulkOnlyMSReset ( void  )

Definition at line 884 of file UsbHostMassStorage.c.

References stc_usb_request::bmRequestType, stc_usb_request::bRequest, pstcUsbHandle, SetupComplete(), WaitForSetupComplete(), stc_usb_request::wIndex, stc_usb_request::wLength, stc_usb_request::wValue, and ZERO_STRUCT.

Referenced by UsbHostMassStorage_ResetRecovery().

Here is the call graph for this function:

Here is the caller graph for this function:

void UsbHostMassStorage_BulkOutCompletion ( stc_usbn_t *  pstcUsbHandle)

Definition at line 431 of file UsbHostMassStorage.c.

References StorageInfo::BYTES_TRANSFERRED, EndpointOUT, StorageInfo::STATUS, and UsbHostMassStorage_OutTransferDone().

Referenced by UsbHostMassStorage_Transmit_MSDC_Data().

Here is the call graph for this function:

Here is the caller graph for this function:

int16_t UsbHostMassStorage_CheckCSW ( StorageInfo_t *  pstcStorageInfo)

Definition at line 861 of file UsbHostMassStorage.c.

References StorageInfo::BYTES_TRANSFERRED, CBW_TAG, StorageInfo::CSW_STATUS, csw::CSWDataResidue, csw::CSWSignatur, csw::CSWStatus, csw::CSWTag, cbw::dCBWDataTransferLength, and ErrorHandler().

Referenced by UsbHostMassStorage_StorageCommandSend().

Here is the call graph for this function:

Here is the caller graph for this function:

int16_t UsbHostMassStorage_ClearInEndpoint ( void  )

Definition at line 923 of file UsbHostMassStorage.c.

References EndpointIN, and pstcUsbHandle.

Referenced by ErrorHandler(), and UsbHostMassStorage_ResetRecovery().

Here is the caller graph for this function:

int16_t UsbHostMassStorage_ClearOutEndpoint ( void  )

Definition at line 940 of file UsbHostMassStorage.c.

References EndpointOUT, and pstcUsbHandle.

Referenced by ErrorHandler(), and UsbHostMassStorage_ResetRecovery().

Here is the caller graph for this function:

boolean_t UsbHostMassStorage_DeinitHandler ( stc_usbn_t *  pstcUsb)

Definition at line 404 of file UsbHostMassStorage.c.

References pstcUsbHandle, and TRUE.

boolean_t UsbHostMassStorage_DriverActive ( void  )

Definition at line 1019 of file UsbHostMassStorage.c.

References pstcUsbHandle.

int16_t UsbHostMassStorage_GetCSW ( StorageInfo_t *  pstcStorageInfo)

Definition at line 836 of file UsbHostMassStorage.c.

References StorageInfo::BUFFER_SIZE, convBufferToCSW(), StorageInfo::GET_CSW, UsbHostMassStorage_CheckForCompletion(), UsbHostMassStorage_Transmit_MSDC_Data(), and ZERO_STRUCT.

Referenced by UsbHostMassStorage_StorageCommandSend(), and UsbHostMassStorage_TestUnitReady().

Here is the call graph for this function:

Here is the caller graph for this function:

void UsbHostMassStorage_GetEPStatus ( uint8_t *  InEpStatus,
uint8_t *  OutEpStatus 
)
StorageInfo_t* UsbHostMassStorage_GetGlobalStorageInfo ( void  )
void UsbHostMassStorage_Init ( void  )
boolean_t UsbHostMassStorage_InitHandler ( stc_usbn_t *  pstcUsb,
uint8_t *  pu8Configuration,
uint32_t  u32Length 
)
void UsbHostMassStorage_InTransferDone ( void  )

Definition at line 439 of file UsbHostMassStorage.c.

References u8Status, and USBMASSSTORAGE_FLAG_TRANSFERDONE_IN.

Referenced by UsbHostMassStorage_BulkInCompletion().

Here is the caller graph for this function:

void UsbHostMassStorage_OutTransferDone ( void  )

Definition at line 444 of file UsbHostMassStorage.c.

References u8Status, and USBMASSSTORAGE_FLAG_TRANSFERDONE_OUT.

Referenced by UsbHostMassStorage_BulkOutCompletion().

Here is the caller graph for this function:

int16_t UsbHostMassStorage_ResetRecovery ( void  )

Definition at line 911 of file UsbHostMassStorage.c.

References UsbHostMassStorage_BulkOnlyMSReset(), UsbHostMassStorage_ClearInEndpoint(), UsbHostMassStorage_ClearOutEndpoint(), and UsbHostMassStorage_TestUnitReady().

Referenced by ErrorHandler().

Here is the call graph for this function:

Here is the caller graph for this function:

int16_t UsbHostMassStorage_StorageStatus ( void  )

Definition at line 897 of file UsbHostMassStorage.c.

References pstcUsbHandle.

Referenced by UsbHostMassStorage_StorageApiInit().

Here is the caller graph for this function:

int UsbHostMassStorage_TestUnitReady ( StorageInfo_t *  pstcStorageInfo)

Definition at line 957 of file UsbHostMassStorage.c.

References StorageInfo::STORAGE_CMD, TEST_UNIT_READY, UsbHostMassStorage_GetCSW(), UsbHostMassStorage_SendCBW(), and ZERO_STRUCT.

Referenced by UsbHostMassStorage_ResetRecovery().

Here is the call graph for this function:

Here is the caller graph for this function:

int16_t UsbHostMassStorage_Transmit_Data ( StorageInfo_t *  pstcStorageInfo)

Definition at line 827 of file UsbHostMassStorage.c.

References StorageInfo::BUFFER, StorageInfo::BUFFER_SIZE, cbw::dCBWDataTransferLength, and UsbHostMassStorage_Transmit_MSDC_Data().

Referenced by UsbHostMassStorage_StorageCommandSend().

Here is the call graph for this function:

Here is the caller graph for this function: