![]() |
Data Structures | |
struct | MSDBOT_CBW_TypeDef |
Bulk Only Transport (BOT) Command Block Wrapper (CBW) typedef. More... | |
struct | MSDBOT_CSW_TypeDef |
Bulk Only Transport (BOT) Command Status Wrapper (CSW) typedef. More... | |
struct | MSDD_CmdStatus_TypeDef |
Status info for one BOT CBW -> Data I/O -> CSW cycle. More... | |
struct | MSDSCSI_Inquiry_TypeDef |
SCSI Inquiry Command Descriptor Block (CDB) typedef. More... | |
struct | MSDSCSI_InquiryData_TypeDef |
SCSI Inquiry response data typedef. More... | |
struct | MSDSCSI_RequestSense_TypeDef |
SCSI Request Sense Command Descriptor Block (CDB) typedef. More... | |
struct | MSDSCSI_RequestSenseData_TypeDef |
SCSI Request Sense response data typedef. More... | |
struct | MSDSCSI_ReadCapacity_TypeDef |
SCSI Read Capacity Command Descriptor Block (CDB) typedef. More... | |
struct | MSDSCSI_ReadCapacityData_TypeDef |
SCSI Read Capacity response data typedef. More... | |
struct | MSDSCSI_Read10_TypeDef |
SCSI Read 10 Command Descriptor Block (CDB) typedef. More... | |
struct | MSDSCSI_Write10_TypeDef |
SCSI Write 10 Command Descriptor Block (CDB) typedef. More... | |
Defines | |
#define | MEDIA_BUFSIZ 4096 |
Intermediate media storage buffer size. | |
#define | SCSI_TESTUNIT_READY 0x00 |
SCSI Test Unit Ready command opcode. | |
#define | SCSI_REQUESTSENSE 0x03 |
SCSI Request Sense command opcode. | |
#define | SCSI_INQUIRY 0x12 |
SCSI Inquiry command opcode. | |
#define | SCSI_STARTSTOP_UNIT 0x1B |
SCSI Start Stop Unit command opcode. | |
#define | SCSI_READCAPACITY 0x25 |
SCSI Read Capacity command opcode. | |
#define | SCSI_READ10 0x28 |
SCSI Read (10) command opcode. | |
#define | SCSI_WRITE10 0x2A |
SCSI Write (10) command opcode. | |
#define | SCSI_READ10_LEN 10U |
SCSI Read (10) CBD length. | |
#define | SCSI_WRITE10_LEN 10U |
SCSI Write (10) CDB length. | |
#define | SCSI_INQUIRYDATA_LEN 36U |
SCSI Inquiry response data length. | |
#define | SCSI_REQUESTSENSE_LEN 6U |
SCSI Request Sense CDB length. | |
#define | SCSI_REQUESTSENSEDATA_LEN 18U |
SCSI Request Sense response data length. | |
#define | SCSI_READCAPACITY_LEN 10U |
SCSI Read Capacity CDB length. | |
#define | SCSI_READCAPACITYDATA_LEN 8U |
SCSI Read Capacity response data length. | |
Enumerations | |
enum | MSDBOT_Status_TypeDef { MSDBOT_STATUS_OK = 0, MSDBOT_INIT_ERROR = -1, MSDBOT_CMD_FAILED = -2, MSDBOT_XFER_ERROR = -3 } |
MSDBOT status enumerator. More... | |
Functions | |
bool | MSDD_Handler (void) |
Serve the MSD state machine. | |
void | MSDD_Init (int activityLedPort, uint32_t activityLedPin) |
Initialize MSD device. | |
bool | MSDH_Init (uint8_t *usbDeviceInfo, int usbDeviceInfoSize) |
Initialize an USB connected Mass Storage Device. | |
bool | MSDH_GetSectorCount (uint32_t *sectorCount) |
Get sectorcount from the device. | |
bool | MSDH_GetSectorSize (uint16_t *sectorSize) |
Get sectorsize from the device. | |
bool | MSDH_GetBlockSize (uint32_t *blockSize) |
Get blocksize from the device. | |
bool | MSDH_ReadSectors (uint32_t lba, uint16_t sectors, void *data) |
Read sectors from device. | |
bool | MSDH_WriteSectors (uint32_t lba, uint16_t sectors, const void *data) |
Write sectors to device. |
#define MEDIA_BUFSIZ 4096 |
#define SCSI_INQUIRYDATA_LEN 36U |
SCSI Inquiry response data length.
Definition at line 62 of file msdscsi.h.
Referenced by MSDD_Init(), MSDSCSI_Init(), and MSDSCSI_Inquiry().
#define SCSI_READ10_LEN 10U |
SCSI Read (10) CBD length.
Definition at line 60 of file msdscsi.h.
Referenced by MSDD_Init(), and MSDSCSI_Init().
#define SCSI_READCAPACITY 0x25 |
#define SCSI_READCAPACITY_LEN 10U |
#define SCSI_READCAPACITYDATA_LEN 8U |
SCSI Read Capacity response data length.
Definition at line 66 of file msdscsi.h.
Referenced by MSDD_Init(), MSDSCSI_Init(), and MSDSCSI_ReadCapacity().
#define SCSI_REQUESTSENSE 0x03 |
#define SCSI_REQUESTSENSE_LEN 6U |
#define SCSI_REQUESTSENSEDATA_LEN 18U |
SCSI Request Sense response data length.
Definition at line 64 of file msdscsi.h.
Referenced by MSDD_Init(), MSDSCSI_Init(), and MSDSCSI_RequestSense().
#define SCSI_STARTSTOP_UNIT 0x1B |
SCSI Start Stop Unit command opcode.
Definition at line 55 of file msdscsi.h.
Referenced by MSDD_Handler().
#define SCSI_TESTUNIT_READY 0x00 |
#define SCSI_WRITE10_LEN 10U |
SCSI Write (10) CDB length.
Definition at line 61 of file msdscsi.h.
Referenced by MSDD_Init(), and MSDSCSI_Init().
bool MSDD_Handler | ( | void | ) |
Serve the MSD state machine.
This function should be called on a regular basis from your main loop. It cannot be called from within an interrupt handler.
Definition at line 248 of file msdd.c.
References MSDBOT_CBW_TypeDef::CBWCB, and SCSI_STARTSTOP_UNIT.
void MSDD_Init | ( | int | activityLedPort, | |
uint32_t | activityLedPin | |||
) |
Initialize MSD device.
[in] | activityLedPort | Specify a GPIO port for a LED activity indicator (i.e. enum gpioPortX) Pass -1 if no indicator LED is available. |
[in] | activityLedPin | Pin number on activityLedPort for the LED activity indicator. |
Definition at line 198 of file msdd.c.
References SCSI_INQUIRYDATA_LEN, SCSI_READ10_LEN, SCSI_READCAPACITY_LEN, SCSI_READCAPACITYDATA_LEN, SCSI_REQUESTSENSE_LEN, SCSI_REQUESTSENSEDATA_LEN, and SCSI_WRITE10_LEN.
bool MSDH_GetBlockSize | ( | uint32_t * | blockSize | ) |
Get blocksize from the device.
[out] | blockSize | The block size of device storage memory. |
Definition at line 222 of file msdh.c.
References MSDSCSI_ReadCapacity().
bool MSDH_GetSectorCount | ( | uint32_t * | sectorCount | ) |
Get sectorcount from the device.
[out] | sectorCount | Number of sectors on the device. |
Definition at line 173 of file msdh.c.
References MSDSCSI_ReadCapacity().
bool MSDH_GetSectorSize | ( | uint16_t * | sectorSize | ) |
Get sectorsize from the device.
[out] | sectorSize | The size of device sectors. |
Definition at line 196 of file msdh.c.
References MSDSCSI_ReadCapacity().
bool MSDH_Init | ( | uint8_t * | usbDeviceInfo, | |
int | usbDeviceInfoSize | |||
) |
Initialize an USB connected Mass Storage Device.
Checks if the device is a valid MSD device. Will perform all necessary MSD initialization.
[in] | usbDeviceInfo | Pointer to USB enumeration information. usbDeviceInfo must have been initialized by a prior call to USBH_WaitForDeviceConnectionB(). |
[in] | usbDeviceInfoSize | The size of the usbDeviceInfo data buffer. |
Definition at line 77 of file msdh.c.
References MSDSCSI_Init(), MSDSCSI_Inquiry(), MSDSCSI_ReadCapacity(), MSDSCSI_RequestSense(), and MSDSCSI_TestUnitReady().
bool MSDH_ReadSectors | ( | uint32_t | lba, | |
uint16_t | sectors, | |||
void * | data | |||
) |
Read sectors from device.
[in] | lba | Sector address (LBA) of first sector to read. |
[in] | sectors | Number of sectors to read. |
[out] | data | Data buffer through which data is returned to caller. |
Definition at line 251 of file msdh.c.
References MSDSCSI_Read10().
bool MSDH_WriteSectors | ( | uint32_t | lba, | |
uint16_t | sectors, | |||
const void * | data | |||
) |
Write sectors to device.
[in] | lba | Sector address (LBA) of first sector to write. |
[in] | sectors | Number of sectors to write. |
[out] | data | Data buffer containing data to be written. |
Definition at line 272 of file msdh.c.
References MSDSCSI_Write10().