![]() |
PDL for FM4
Version1.2
Peripheral Driverl Library for FM4
|
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 |
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
| #define BIGENDIAN 2 |
Definition at line 133 of file UsbHostMassStorage.h.
| #define CBW_TAG 0x1A2B3C4D |
Definition at line 130 of file UsbHostMassStorage.h.
Referenced by UsbHostMassStorage_CheckCSW(), and UsbHostMassStorage_SendCBW().
| #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 |
Definition at line 112 of file UsbHostMassStorage.h.
Referenced by UsbHostMassStorage_SendCBW(), UsbHostMassStorage_StorageApiInit(), and UsbHostMassStorage_Transmit_MSDC_Data().
| #define LENDIAN_BUFFER_TO_U32 | ( | pu8Buffer | ) |
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 MASS_STORAGE_REQUEST_SENSE 0x03 |
| #define MODE_SELECT 0x55 |
Definition at line 113 of file UsbHostMassStorage.h.
| #define MODE_SENSE 0x5A |
Definition at line 114 of file UsbHostMassStorage.h.
Referenced by UsbHostMassStorage_SendCBW(), UsbHostMassStorage_StorageApiModeSense(), and UsbHostMassStorage_Transmit_MSDC_Data().
| #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 |
Definition at line 116 of file UsbHostMassStorage.h.
Referenced by UsbHostMassStorage_SendCBW(), UsbHostMassStorage_StorageApiRead(), and UsbHostMassStorage_Transmit_MSDC_Data().
| #define READ_MASS_STORAGE_CAPACITY 0x25 |
Definition at line 117 of file UsbHostMassStorage.h.
Referenced by UsbHostMassStorage_SendCBW(), UsbHostMassStorage_StorageApiReadCapacity(), and UsbHostMassStorage_Transmit_MSDC_Data().
| #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 TEST_UNIT_READY 0x00 |
Definition at line 124 of file UsbHostMassStorage.h.
Referenced by UsbHostMassStorage_SendCBW(), UsbHostMassStorage_StorageApiInit(), UsbHostMassStorage_TestUnitReady(), and UsbHostMassStorage_Transmit_MSDC_Data().
| #define U32_TO_LENDIAN_BUFFER | ( | pu8Buffer, | |
| u32Data | |||
| ) |
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) |
Definition at line 108 of file UsbHostMassStorage.h.
Referenced by UsbHostMassStorage_CheckForCompletion(), UsbHostMassStorage_InTransferDone(), and UsbHostMassStorage_StorageCommandSend().
| #define USBMASSSTORAGE_FLAG_TRANSFERDONE_OUT (1<<2) |
Definition at line 109 of file UsbHostMassStorage.h.
Referenced by UsbHostMassStorage_CheckForCompletion(), UsbHostMassStorage_OutTransferDone(), and UsbHostMassStorage_StorageCommandSend().
| #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.
| #define WRITE_MASS_STORAGE 0x2A |
Definition at line 126 of file UsbHostMassStorage.h.
Referenced by UsbHostMassStorage_SendCBW(), UsbHostMassStorage_StorageApiWrite(), UsbHostMassStorage_StorageCommandSend(), and UsbHostMassStorage_Transmit_MSDC_Data().
| typedef struct inquiry_response inquiry_response_t |
| typedef struct InquiryResponse InquiryResponse_t |
| typedef struct ModeSenseResponse ModeSenseResponse_t |
| typedef struct read_capacity read_capacity_t |
| typedef struct RequestSenseResponse RequestSenseResponse_t |
| typedef struct StorageInfo StorageInfo_t |
| typedef struct StorageReadWrite StorageReadWrite_t |
| typedef struct StorageWrite StorageWrite_t |
| 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().


| 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().


| 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().


| 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().


| void UsbHostMassStorage_CheckForCompletion | ( | volatile uint8_t * | NAKDetected | ) |
Definition at line 574 of file UsbHostMassStorage.c.
References EndpointIN, EndpointOUT, pstcUsbHandle, TRUE, u8Status, USBMASSSTORAGE_FLAG_TRANSFERDONE_IN, and USBMASSSTORAGE_FLAG_TRANSFERDONE_OUT.
Referenced by UsbHostMassStorage_GetCSW(), UsbHostMassStorage_StorageApiInit(), UsbHostMassStorage_StorageApiModeSense(), UsbHostMassStorage_StorageApiRead(), UsbHostMassStorage_StorageApiReadCapacity(), UsbHostMassStorage_StorageApiWrite(), and UsbHostMassStorage_StorageCommandSend().

| int16_t UsbHostMassStorage_ClearInEndpoint | ( | void | ) |
Definition at line 923 of file UsbHostMassStorage.c.
References EndpointIN, and pstcUsbHandle.
Referenced by ErrorHandler(), and UsbHostMassStorage_ResetRecovery().

| int16_t UsbHostMassStorage_ClearOutEndpoint | ( | void | ) |
Definition at line 940 of file UsbHostMassStorage.c.
References EndpointOUT, and pstcUsbHandle.
Referenced by ErrorHandler(), and UsbHostMassStorage_ResetRecovery().

| 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().


| void UsbHostMassStorage_GetEPStatus | ( | uint8_t * | InEpStatus, |
| uint8_t * | OutEpStatus | ||
| ) |
| StorageInfo_t* UsbHostMassStorage_GetGlobalStorageInfo | ( | void | ) |
Definition at line 451 of file UsbHostMassStorage.c.
References stcGlobalStorageInfo.
Referenced by UsbHostMassStorage_StorageApiInit(), UsbHostMassStorage_StorageApiModeSense(), UsbHostMassStorage_StorageApiRead(), UsbHostMassStorage_StorageApiReadCapacity(), and UsbHostMassStorage_StorageApiWrite().

| void UsbHostMassStorage_Init | ( | void | ) |
| boolean_t UsbHostMassStorage_InitHandler | ( | stc_usbn_t * | pstcUsb, |
| uint8_t * | pu8Configuration, | ||
| uint32_t | u32Length | ||
| ) |
Definition at line 336 of file UsbHostMassStorage.c.
References EndpointIN, EndpointOUT, FALSE, pstcUsbHandle, TRUE, u16MaxPackageSizeIN, u16MaxPackageSizeOUT, u8EndpointIN, u8EndpointOUT, and USB_IN_DIRECTION.
| void UsbHostMassStorage_InTransferDone | ( | void | ) |
Definition at line 439 of file UsbHostMassStorage.c.
References u8Status, and USBMASSSTORAGE_FLAG_TRANSFERDONE_IN.
Referenced by UsbHostMassStorage_BulkInCompletion().

| void UsbHostMassStorage_OutTransferDone | ( | void | ) |
Definition at line 444 of file UsbHostMassStorage.c.
References u8Status, and USBMASSSTORAGE_FLAG_TRANSFERDONE_OUT.
Referenced by UsbHostMassStorage_BulkOutCompletion().

| 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().


| int16_t UsbHostMassStorage_SendCBW | ( | StorageInfo_t * | pstcStorageInfo | ) |
Definition at line 677 of file UsbHostMassStorage.c.
References cbw::bCBWCBLength, cbw::bCBWFlags, cbw::bCBWLUN, StorageInfo::BLOCK_CNT, StorageInfo::BLOCK_START, StorageInfo::BUFFER_SIZE, CBW_TAG, cbw::CBWCB, convCBWtoBuffer(), cbw::dCBWDataTransferLength, cbw::dCBWSignature, cbw::dCBWTag, INQUIRY_MASS_STORAGE, MASS_STORAGE_REQUEST_SENSE, MODE_SENSE, READ_MASS_STORAGE, READ_MASS_STORAGE_CAPACITY, StorageInfo::SEND_CBW, SEND_DIAGNOSTIC, StorageInfo::STORAGE_CMD, TEST_UNIT_READY, UsbHostMassStorage_Transmit_MSDC_Data(), WRITE_MASS_STORAGE, and ZERO_STRUCT.
Referenced by UsbHostMassStorage_StorageCommandSend(), and UsbHostMassStorage_TestUnitReady().


| int UsbHostMassStorage_StorageApiInit | ( | void | ) |
Definition at line 239 of file UsbHostMassStorage.c.
References StorageInfo::BUFFER, convBufferToInquiryResponse(), convBufferToSenseResponse(), StorageInfo::CSW_STATUS, INQUIRY_MASS_STORAGE, MASS_STORAGE_REQUEST_SENSE, RequestSenseResponse::SenseKey, StorageInfo::STORAGE_CMD, TEST_UNIT_READY, UsbHostMassStorage_CheckForCompletion(), UsbHostMassStorage_GetGlobalStorageInfo(), UsbHostMassStorage_StorageCommandSend(), UsbHostMassStorage_StorageStatus(), and ZERO_STRUCT.

| int UsbHostMassStorage_StorageApiModeSense | ( | void | ) |
Definition at line 312 of file UsbHostMassStorage.c.
References StorageInfo::BUFFER, convBufferToModeSenseResponse(), MODE_SENSE, StorageInfo::STORAGE_CMD, UsbHostMassStorage_CheckForCompletion(), UsbHostMassStorage_GetGlobalStorageInfo(), UsbHostMassStorage_StorageCommandSend(), ModeSenseResponse::WriteProtect, and ZERO_STRUCT.

| int UsbHostMassStorage_StorageApiRead | ( | BYTE * | buff, |
| DWORD | sector, | ||
| BYTE | count | ||
| ) |
Definition at line 124 of file UsbHostMassStorage.c.
References StorageInfo::BLOCK_CNT, StorageInfo::BLOCK_START, StorageInfo::BUFFER, convBufferToSenseResponse(), StorageInfo::CSW_STATUS, MASS_STORAGE_REQUEST_SENSE, READ_MASS_STORAGE, RequestSenseResponse::SenseKey, StorageInfo::STORAGE_CMD, UsbHostMassStorage_CheckForCompletion(), UsbHostMassStorage_GetGlobalStorageInfo(), UsbHostMassStorage_StorageCommandSend(), and ZERO_STRUCT.

| int UsbHostMassStorage_StorageApiReadCapacity | ( | void * | Buff | ) |
Definition at line 204 of file UsbHostMassStorage.c.
References StorageInfo::BUFFER, convBufferToSenseResponse(), StorageInfo::CSW_STATUS, MASS_STORAGE_REQUEST_SENSE, READ_MASS_STORAGE_CAPACITY, RequestSenseResponse::SenseKey, StorageInfo::STORAGE_CMD, UsbHostMassStorage_CheckForCompletion(), UsbHostMassStorage_GetGlobalStorageInfo(), UsbHostMassStorage_StorageCommandSend(), and ZERO_STRUCT.

| int UsbHostMassStorage_StorageApiWrite | ( | BYTE * | buff, |
| DWORD | sector, | ||
| BYTE | count | ||
| ) |
Definition at line 162 of file UsbHostMassStorage.c.
References StorageInfo::BLOCK_CNT, StorageInfo::BLOCK_START, StorageInfo::BUFFER, convBufferToSenseResponse(), StorageInfo::CSW_STATUS, MASS_STORAGE_REQUEST_SENSE, RequestSenseResponse::SenseKey, StorageInfo::STORAGE_CMD, UsbHostMassStorage_CheckForCompletion(), UsbHostMassStorage_GetGlobalStorageInfo(), UsbHostMassStorage_StorageCommandSend(), WRITE_MASS_STORAGE, and ZERO_STRUCT.

| int16_t UsbHostMassStorage_StorageCommandSend | ( | StorageInfo_t * | pstcStorageInfo | ) |
Definition at line 599 of file UsbHostMassStorage.c.
References cbw::dCBWDataTransferLength, ErrorHandler(), StorageInfo::STATUS, StorageInfo::STORAGE_CMD, u8Status, UsbHostMassStorage_CheckCSW(), UsbHostMassStorage_CheckForCompletion(), UsbHostMassStorage_GetCSW(), UsbHostMassStorage_SendCBW(), UsbHostMassStorage_Transmit_Data(), USBMASSSTORAGE_FLAG_TRANSFERDONE_IN, USBMASSSTORAGE_FLAG_TRANSFERDONE_OUT, and WRITE_MASS_STORAGE.
Referenced by UsbHostMassStorage_StorageApiInit(), UsbHostMassStorage_StorageApiModeSense(), UsbHostMassStorage_StorageApiRead(), UsbHostMassStorage_StorageApiReadCapacity(), and UsbHostMassStorage_StorageApiWrite().


| int16_t UsbHostMassStorage_StorageStatus | ( | void | ) |
Definition at line 897 of file UsbHostMassStorage.c.
References pstcUsbHandle.
Referenced by UsbHostMassStorage_StorageApiInit().

| 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().


| 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().


| int16_t UsbHostMassStorage_Transmit_MSDC_Data | ( | uint8_t * | pu8Buffer, |
| StorageInfo_t * | pstcStorageInfo | ||
| ) |
Definition at line 775 of file UsbHostMassStorage.c.
References StorageInfo::BUFFER_SIZE, EndpointIN, EndpointOUT, StorageInfo::GET_CSW, INQUIRY_MASS_STORAGE, MASS_STORAGE_REQUEST_SENSE, MODE_SENSE, pstcUsbHandle, READ_MASS_STORAGE, READ_MASS_STORAGE_CAPACITY, StorageInfo::SEND_CBW, StorageInfo::STORAGE_CMD, TEST_UNIT_READY, UsbHostMassStorage_BulkInCompletion(), UsbHostMassStorage_BulkOutCompletion(), and WRITE_MASS_STORAGE.
Referenced by UsbHostMassStorage_GetCSW(), UsbHostMassStorage_SendCBW(), and UsbHostMassStorage_Transmit_Data().

