2.8.4.2 USB_DEVICE_MSD_MEDIA_FUNCTIONS Structure

C

struct USB_DEVICE_MSD_MEDIA_FUNCTIONS {
  bool (* isAttached)(const DRV_HANDLE handle);
  DRV_HANDLE (* open)(const SYS_MODULE_INDEX index, const DRV_IO_INTENT intent);
  void (* close)(DRV_HANDLE hClient);
  SYS_MEDIA_GEOMETRY * (* geometryGet)(DRV_HANDLE hClient);
  void (* blockRead)(DRV_HANDLE handle, uintptr_t * blockOperationHandle, void * data, uint32_t blockStart, uint32_t nBlocks);
  void (* blockWrite)(DRV_HANDLE handle, uintptr_t * blockOperationHandle, void * data, uint32_t blockStart, uint32_t nBlocks);
  bool (* isWriteProtected)(DRV_HANDLE drvHandle);
  void (* blockEventHandlerSet)(const DRV_HANDLE drvHandle, const void * eventHandler, const uintptr_t context);
  void (* blockStartAddressSet)(const DRV_HANDLE drvHandle, const void * addressOfStartBlock);
};

Summary

Media Driver Function Pointer Data Structure

This structure contains function pointers, pointing to the media driver functions. The MSD function driver calls these functions at run time to access the media. This data structure should be specified during compilation and is a part of the MSD function driver initialization data structure. It is processed by the function driver when the function driver is initialized by the Device Layer.

Members

Members Description
bool (* isAttached)(const DRV_HANDLE handle); In case of pluggable media, such as SD Card, this function returns true when the media is inserted, initialized and ready to be used. In case of non-pluggable media, such as Internal Flash memory, this function can return true when the media is ready to be used. The MSD host may not detect the media until this function returns true. This function pointer cannot be NULL.
DRV_HANDLE (* open)(const SYS_MODULE_INDEX index, const DRV_IO_INTENT intent); The MSD Function Driver calls this function to obtain a handle and gain access to functionality of the specified instance of the media driver. The MSD function driver will attempt to open the driver with DRV_IO_INTENT_READWRITE and DRV_IO_INTENT_NONBLOCKING. The MSD host may not detect the media until the MSD function driver obtains a valid driver handle. The function driver will use this handle in all other functions to communicate with the media driver. This function pointer cannot be NULL.
void (* close)(DRV_HANDLE hClient); The MSD function driver calls this function when the function driver gets deinitialized as result of device detach or a change in configuration. The MSD function driver will open the media driver again to obtain a fresh driver handle when it gets initialized again. This function pointer cannot be NULL.
SYS_MEDIA_GEOMETRY * (* geometryGet)(DRV_HANDLE hClient); The MSD function driver calls this function when the function driver needs to know the storage capacity of the media. The MSD function driver uses the size of read region and number of read blocks to report the media capacity to the MSD host. This function pointer cannot be NULL.
void (* blockRead)(DRV_HANDLE handle, uintptr_t * blockOperationHandle, void * data, uint32_t blockStart, uint32_t nBlocks); The MSD function driver calls this function when it needs to read a block of data. This function pointer cannot be NULL.
void (* blockWrite)(DRV_HANDLE handle, uintptr_t * blockOperationHandle, void * data, uint32_t blockStart, uint32_t nBlocks); The MSD function driver calls this function when it needs to write a block of data. This function pointer can be NULL if the media is write protected.
bool (* isWriteProtected)(DRV_HANDLE drvHandle); The MSD function driver calls this function to find out if the media is write-protected. This function pointer cannot be NULL.
void (* blockEventHandlerSet)(const DRV_HANDLE drvHandle, const void * eventHandler, const uintptr_t context); The MSD function driver calls this function to register an block event call back function with the media driver. This event call back will be called when a block related operation has completed. This function pointer should not be NULL.
void (* blockStartAddressSet)(const DRV_HANDLE drvHandle, const void * addressOfStartBlock); If not NULL and if the blockStartAddress parameter in the USB_DEVICE_MSD_MEDIA_INIT_DATA data structure for this media is not 0, then the MSD function driver calls this function immediately after opening the media driver. For media such a NVM, where the storage media is a part of the program memory flash, this function sets the start of the storage area on the media. This function is not required for media such as SD Card.

Remarks

None.