![]() |
Data Structures | |
struct | MSDParseData |
struct | MSCbw |
struct | MSCsw |
struct | _MSDConfigurationDescriptors |
struct | _MSDConfigurationDescriptorsOTG |
struct | MSDTransfer |
struct | MSDCommandState |
struct | MSDDriver |
struct | PMSDIOFifo |
FIFO buffer for READ/WRITE (disk) operation of a mass storage device. More... | |
struct | MSDLun |
LUN structure. More... | |
struct | _SBCInquiry |
struct | _SBCInquiryData |
struct | _SBCRead10 |
struct | SBCReadCapacity10 |
struct | SBCReadCapacity10Data |
struct | SBCRequestSense |
struct | SBCRequestSenseData |
struct | _SBCTestUnitReady |
SBCTestUnitReady Data structure for the TEST UNIT READY command. More... | |
struct | SBCWrite10 |
struct | _SBCMediumRemoval |
struct | _SBCModeSense6 |
struct | _SBCModeParameterHeader6 |
struct | _SBCInformationalExceptionsControl |
struct | _SBCReadWriteErrorRecovery |
union | SBCCommand |
Modules | |
MSD Device Descriptor IDs | |
USBD General Configure | |
USB MassStorage Configure | |
MSD Subclass Codes | |
MSD Protocol Codes | |
MSD CBW Definitions | |
MSD CSW Definitions | |
MSD Driver Possible states | |
MSD Driver Result Codes | |
MSD Driver Action Cases | |
MSD Driver Xfr Directions | |
SBC Operation Codes | |
SBC Periph. Qualifiers | |
SBC Periph. Types | |
SBC Sense Response Codes | |
SBC Sense Keys | |
SBC Sense Additional | |
MSD Endian Macros | |
SBC Command States | |
Defines | |
#define | MIN(a, b) ((a < b) ? a : b) |
#define | MIN(a, b) ((a < b) ? a : b) |
#define | DEFAULT_LUN_BLOCK_SIZE 512 |
#define | MSD_BULK_ONLY_RESET 0xFF |
#define | MSD_GET_MAX_LUN 0xFE |
#define | MSDIO_IDLE 0 |
#define | MSDIO_START 1 |
#define | MSDIO_WAIT 2 |
#define | MSDIO_NEXT 3 |
#define | MSDIO_PAUSE 4 |
#define | MSDIO_ABORT 5 |
#define | MSDIO_DONE 6 |
#define | MSDIO_ERROR 7 |
#define | MSDIO_READ10_CHUNK_SIZE (128 * 512) |
#define | MSDIO_WRITE10_CHUNK_SIZE (128 * 512) |
#define | MSDIOFifo_IncNdx(ndx, sectSize, bufSize) |
#define | MED_STATUS_SUCCESS 0x00 |
#define | MED_STATE_READY 0x00 |
#define | MED_STATE_BUSY 0x01 |
#define | LUN_STATUS_SUCCESS 0x00 |
#define | LUN_STATUS_ERROR 0x02 |
#define | LUN_NOT_PRESENT 0x00 |
#define | LUN_EJECTED 0x01 |
#define | LUN_CHANGED 0x10 |
#define | LUN_TRANS_READY LUN_CHANGED |
#define | LUN_READY 0x11 |
#define | SBC_SPC_VERSION_4 0x06 |
Version value for the SBC-3 specification. | |
#define | SBC_TPGS_NONE 0x0 |
Values for the TPGS field returned in INQUIRY data. | |
#define | SBC_TPGS_ASYMMETRIC 0x1 |
#define | SBC_TPGS_SYMMETRIC 0x2 |
#define | SBC_TPGS_BOTH 0x3 |
#define | SBC_VERSION_DESCRIPTOR_SBC_3 0x04C0 |
Version descriptor value for the SBC-3 specification. | |
#define | SBC_MEDIUM_TYPE_DIRECT_ACCESS_BLOCK_DEVICE 0x00 |
MEDIUM TYPE field value for direct-access block devices. | |
#define | SBC_MRIE_NO_REPORTING 0x00 |
MRIE field values. | |
#define | SBC_MRIE_ASYNCHRONOUS 0x01 |
#define | SBC_MRIE_GENERATE_UNIT_ATTENTION 0x02 |
#define | SBC_MRIE_COND_GENERATE_RECOVERED_ERROR 0x03 |
#define | SBC_MRIE_UNCOND_GENERATE_RECOVERED_ERROR 0x04 |
#define | SBC_MRIE_GENERATE_NO_SENSE 0x05 |
#define | SBC_MRIE_ON_REQUEST 0x06 |
#define | SBC_PAGE_READ_WRITE_ERROR_RECOVERY 0x01 |
Supported mode pages. | |
#define | SBC_PAGE_INFORMATIONAL_EXCEPTIONS_CONTROL 0x1C |
#define | SBC_PAGE_RETURN_ALL 0x3F |
#define | SBC_PAGE_VENDOR_SPECIFIC 0x00 |
Typedefs | |
typedef void(* | fMEDCallback )(void *pArg, uint8_t bStatus, uint32_t dwTransferred, uint32_t dwRemaining) |
typedef void(* | MSDLunDataMonitorFunction )(uint8_t flowDirection, uint32_t dataLength, uint32_t fifoNullCount, uint32_t fifoFullCount) |
Functions | |
void | MSDDriver_Initialize (const USBDDriverDescriptors *pDescriptors, MSDLun *pLuns, unsigned char numLuns) |
void | MSDDriver_ConfigurationChangeHandler (uint8_t cfgnum) |
void | MSDDriver_RequestHandler (const USBGenericRequest *request) |
void | MSDD_StateMachine (MSDDriver *pMsdDriver) |
COMPILER_ALIGNED (32) | |
void | MSDFunction_Initialize (USBDDriver *pUsbd, uint8_t bInterfaceNb, MSDLun *pLuns, uint8_t numLuns) |
void | MSDFunction_Configure (USBGenericDescriptor *pDescriptors, uint16_t wLength) |
uint32_t | MSDFunction_RequestHandler (const USBGenericRequest *request) |
void | MSDFunction_StateMachine (void) |
void | MSDIOFifo_Init (MSDIOFifo *pFifo, void *pBuffer, unsigned int bufferSize) |
Initializes a MSDIOFifo instance. | |
void | LUN_Init (MSDLun *lun, void *media, uint8_t *ioBuffer, uint32_t ioBufferSize, uint32_t baseAddress, uint32_t size, uint16_t blockSize, uint8_t protected, void(*dataMonitor)(uint8_t flowDirection, uint32_tdataLength, uint32_tfifoNullCount, uint32_tfifoFullCount)) |
Initializes a LUN instance. Must be invoked at least once even no Media is linked. | |
uint32_t | LUN_Eject (MSDLun *lun) |
Eject the media from a LUN. | |
uint32_t | LUN_Write (MSDLun *lun, uint32_t blockAddress, void *data, uint32_t length, TransferCallback callback, void *argument) |
Writes data on the a LUN starting at the specified block address. | |
uint32_t | LUN_Read (MSDLun *lun, uint32_t blockAddress, void *data, uint32_t length, TransferCallback callback, void *argument) |
Reads data from a LUN, starting at the specified block address. | |
void | SBC_UpdateSenseData (SBCRequestSenseData *requestSenseData, unsigned char senseKey, unsigned char additionalSenseCode, unsigned char additionalSenseCodeQualifier) |
Updates the sense data of a LUN with the given key and codes. | |
unsigned char | SBC_GetCommandInformation (void *command, unsigned int *length, unsigned char *type, MSDLun *lun) |
Return information about the transfer length and direction expected by the device for a particular command. | |
unsigned char | SBC_ProcessCommand (MSDLun *lun, MSDCommandState *commandState) |
Processes a SBC command by dispatching it to a subfunction. | |
struct _MSDConfigurationDescriptors | __attribute__ ((__packed__)) SBCTestUnitReady |
SBCTestUnitReady Data structure for the TEST UNIT READY command. | |
void | MSDDriver_Initialize (const USBDDriverDescriptors *pDescriptors, MSDLun *luns, uint8_t numLuns) |
uint8_t | MED_IsMappedRDSupported (void *pMed) |
uint8_t | MED_IsMappedWRSupported (void *pMed) |
uint32_t | MED_GetMappedAddress (void *pMed, uint32_t dwBlk) |
uint8_t | MED_IsBusy (void *pMed) |
uint8_t | MED_IsProtected (void *pMed) |
uint8_t | MED_GetState (void *pMed) |
uint32_t | MED_GetBlockSize (void *pMed) |
uint32_t | MED_GetSize (void *pMed) |
uint8_t | MED_Write (void *pMed, uint32_t dwAddr, void *pData, uint32_t dwLen, fMEDCallback fCallback, void *pArg) |
uint8_t | MED_Read (void *pMed, uint32_t dwAddr, void *pData, uint32_t dwLen, fMEDCallback fCallback, void *pArg) |
uint8_t | MED_Flush (void *pMed) |
Variables | |
const USBDDriverDescriptors | msdDriverDescriptors |
const USBDDriverDescriptors | msdDriverDescriptors |
Implement a single interface device with single MS function in.
Implements Massstorage Function for USB device.
#define DEFAULT_LUN_BLOCK_SIZE 512 |
#define LUN_TRANS_READY LUN_CHANGED |
#define MIN | ( | a, | ||
b | ||||
) | ((a < b) ? a : b) |
Returns the minimum between two values.
Definition at line 94 of file USBDDriverDescriptors.c.
#define MIN | ( | a, | ||
b | ||||
) | ((a < b) ? a : b) |
Returns the minimum between two values.
Definition at line 73 of file USBDDriverDescriptors.c.
#define MSD_BULK_ONLY_RESET 0xFF |
#define MSD_GET_MAX_LUN 0xFE |
#define MSDIO_ABORT 5 |
Abort, to abort the process
Definition at line 57 of file MSDIOFifo.h.
#define MSDIO_DONE 6 |
Done, finish without error
Definition at line 59 of file MSDIOFifo.h.
#define MSDIO_ERROR 7 |
Error, any error happens
Definition at line 61 of file MSDIOFifo.h.
#define MSDIO_IDLE 0 |
Idle state, do nothing
Definition at line 47 of file MSDIOFifo.h.
#define MSDIO_NEXT 3 |
Next, to check if the next block can be performed
Definition at line 53 of file MSDIOFifo.h.
#define MSDIO_PAUSE 4 |
Pause, to pause the process for buffer full or null
Definition at line 55 of file MSDIOFifo.h.
#define MSDIO_READ10_CHUNK_SIZE (128 * 512) |
FIFO offset before USB transmit start FIFO trunk size (in each transfer, large amount of data)
Definition at line 69 of file MSDIOFifo.h.
#define MSDIO_START 1 |
Start, to start IO operation
Definition at line 49 of file MSDIOFifo.h.
#define MSDIO_WAIT 2 |
Wait, waiting for IO operation done
Definition at line 51 of file MSDIOFifo.h.
#define MSDIOFifo_IncNdx | ( | ndx, | ||
sectSize, | ||||
bufSize | ||||
) |
if ((ndx) >= (bufSize) - (sectSize)) (ndx) = 0; \ else (ndx) += (sectSize)
Definition at line 128 of file MSDIOFifo.h.
#define SBC_MEDIUM_TYPE_DIRECT_ACCESS_BLOCK_DEVICE 0x00 |
#define SBC_MRIE_NO_REPORTING 0x00 |
#define SBC_PAGE_READ_WRITE_ERROR_RECOVERY 0x01 |
#define SBC_SPC_VERSION_4 0x06 |
#define SBC_TPGS_NONE 0x0 |
#define SBC_VERSION_DESCRIPTOR_SBC_3 0x04C0 |
typedef void(* MSDLunDataMonitorFunction)(uint8_t flowDirection, uint32_t dataLength, uint32_t fifoNullCount, uint32_t fifoFullCount) |
Mass storage device data flow monitor function type
flowDirection | 1 - device to host (READ10) 0 - host to device (WRITE10) | |
dataLength | Length of data transferred in bytes. | |
fifoNullCount | Times that FIFO is NULL to wait | |
fifoFullCount | Times that FIFO is filled to wait |
struct _MSDConfigurationDescriptors __attribute__ | ( | (__packed__) | ) |
SBCTestUnitReady Data structure for the TEST UNIT READY command.
COMPILER_ALIGNED | ( | 32 | ) |
MSD Driver instance for device function
Definition at line 66 of file MSDFunction.c.
uint32_t LUN_Eject | ( | MSDLun * | lun | ) |
Eject the media from a LUN.
lun | Pointer to the MSDLun instance to initialize |
void LUN_Init | ( | MSDLun * | lun, | |
void * | media, | |||
uint8_t * | ioBuffer, | |||
uint32_t | ioBufferSize, | |||
uint32_t | baseAddress, | |||
uint32_t | size, | |||
uint16_t | blockSize, | |||
uint8_t | protected, | |||
void(*)(uint8_t flowDirection, uint32_tdataLength, uint32_tfifoNullCount, uint32_tfifoFullCount) | dataMonitor | |||
) |
Initializes a LUN instance. Must be invoked at least once even no Media is linked.
lun | Pointer to the MSDLun instance to initialize | |
media | Media on which the LUN is constructed, set to 0 to disconnect the Media or initialize an ejected LUN. | |
ioBuffer | Pointer to a buffer used for read/write operation and which must be blockSize bytes long. | |
ioBufferSize | Size of the allocated IO buffer. | |
baseAddress | Base address of the LUN in number of media blocks | |
size | Total size of the LUN in number of media blocks | |
blockSize | One block of the LUN in number of media blocks | |
protected | The LUN area is forced to readonly even the media is writable | |
dataMonitor | Pointer to a Monitor Function to analyze the flow of this LUN. |
uint32_t LUN_Read | ( | MSDLun * | lun, | |
uint32_t | blockAddress, | |||
void * | data, | |||
uint32_t | length, | |||
TransferCallback | callback, | |||
void * | argument | |||
) |
Reads data from a LUN, starting at the specified block address.
lun | Pointer to a MSDLun instance | |
blockAddress | First block address to read | |
data | Pointer to a data buffer in which to store the data | |
length | Number of blocks to read | |
callback | Optional callback to invoke when the read finishes | |
argument | Optional callback argument. |
uint32_t LUN_Write | ( | MSDLun * | lun, | |
uint32_t | blockAddress, | |||
void * | data, | |||
uint32_t | length, | |||
TransferCallback | callback, | |||
void * | argument | |||
) |
Writes data on the a LUN starting at the specified block address.
lun | Pointer to a MSDLun instance | |
blockAddress | First block address to write | |
data | Pointer to the data to write | |
length | Number of blocks to write | |
callback | Optional callback to invoke when the write finishes | |
argument | Optional callback argument. |
void MSDD_StateMachine | ( | MSDDriver * | pMsdDriver | ) |
State machine for the MSD device driver
pMsdDriver | Pointer to a MSDDriver instance |
void MSDDriver_ConfigurationChangeHandler | ( | uint8_t | cfgnum | ) |
Invoked when the configuration of the device changes. Resets the mass storage driver.
pMsdDriver | Pointer to MSDDriver instance. | |
cfgnum | New configuration number. |
void MSDDriver_Initialize | ( | const USBDDriverDescriptors * | pDescriptors, | |
MSDLun * | pLuns, | |||
unsigned char | numLuns | |||
) |
Initializes the MSD driver and the associated USB driver.
pDescriptors | Pointer to Descriptors list for MSD Device. | |
pLuns | Pointer to a list of LUNs | |
numLuns | Number of LUN in list |
Definition at line 66 of file MSDDriver.c.
void MSDDriver_RequestHandler | ( | const USBGenericRequest * | request | ) |
Handler for incoming SETUP requests on default Control endpoint 0.
Standard requests are forwarded to the USBDDriver_RequestHandler method.
pMsdDriver | Pointer to MSDDriver instance. | |
request | Pointer to a USBGenericRequest instance |
void MSDFunction_Configure | ( | USBGenericDescriptor * | pDescriptors, | |
uint16_t | wLength | |||
) |
Invoked when the configuration of the device changes. Pass endpoints and resets the mass storage function. Pointer to the descriptors for function configure. Length of descriptors in number of bytes.
void MSDFunction_Initialize | ( | USBDDriver * | pUsbd, | |
uint8_t | bInterfaceNb, | |||
MSDLun * | pLuns, | |||
uint8_t | numLuns | |||
) |
Initializes the MSD driver and the associated USB driver.
pUsbd | Pointer to USBDDriver instance. | |
bInterfaceNb | Interface number for the function. | |
pLuns | Pointer to a list of LUNs | |
numLuns | Number of LUN in list |
uint32_t MSDFunction_RequestHandler | ( | const USBGenericRequest * | request | ) |
Handler for incoming SETUP requests on default Control endpoint 0.
Standard requests are forwarded to the USBDDriver_RequestHandler method.
pMsdDriver | Pointer to MSDDriver instance. | |
request | Pointer to a USBGenericRequest instance |
void MSDFunction_StateMachine | ( | void | ) |
State machine for the MSD driver
void MSDIOFifo_Init | ( | MSDIOFifo * | pFifo, | |
void * | pBuffer, | |||
unsigned int | bufferSize | |||
) |
unsigned char SBC_GetCommandInformation | ( | void * | command, | |
unsigned int * | length, | |||
unsigned char * | type, | |||
MSDLun * | lun | |||
) |
Return information about the transfer length and direction expected by the device for a particular command.
command | Pointer to a buffer holding the command to evaluate | |
length | Expected length of the data transfer | |
type | Expected direction of data transfer | |
lun | Pointer to the LUN affected by the command |
unsigned char SBC_ProcessCommand | ( | MSDLun * | lun, | |
MSDCommandState * | commandState | |||
) |
Processes a SBC command by dispatching it to a subfunction.
lun | Pointer to the affected LUN | |
commandState | Pointer to the current command state |
void SBC_UpdateSenseData | ( | SBCRequestSenseData * | requestSenseData, | |
unsigned char | senseKey, | |||
unsigned char | additionalSenseCode, | |||
unsigned char | additionalSenseCodeQualifier | |||
) |
Updates the sense data of a LUN with the given key and codes.
requestSenseData | Pointer to the sense data to update | |
senseKey | Sense key | |
additionalSenseCode | Additional sense code | |
additionalSenseCodeQualifier | Additional sense code qualifier |
{ &deviceDescriptor, (USBConfigurationDescriptor *) &configurationDescriptorsFS, &qualifierDescriptor, (USBConfigurationDescriptor *) &otherSpeedDescriptorsFS, 0, (USBConfigurationDescriptor *) &configurationDescriptorsHS, &qualifierDescriptor, (USBConfigurationDescriptor *) &otherSpeedDescriptorsHS, stringDescriptors, 4 }
List of the standard descriptors used by the Mass Storage driver.
Definition at line 420 of file USBDDriverDescriptors.c.
{ &deviceDescriptor, (USBConfigurationDescriptor *) &configurationDescriptorsFS, &qualifierDescriptor, (USBConfigurationDescriptor *) &otherSpeedDescriptorsFS, 0, (USBConfigurationDescriptor *) &configurationDescriptorsHS, &qualifierDescriptor, (USBConfigurationDescriptor *) &otherSpeedDescriptorsHS, stringDescriptors, 4 }
List of the standard descriptors used by the Mass Storage driver.
Definition at line 398 of file USBDDriverDescriptors.c.