USB Libraries Help > USB Device Libraries > USB MSD Device Library > Using the Library > How the Library Works > Data Transfer
MPLAB Harmony USB Stack
Data Transfer

The MSD Function Driver opens the media drivers for read/write operations when the function driver is initialized by the Device Layer. This happens when the Host sets a configuration containing MSD interfaces. The Open operation is complete in the MSD Function Driver Tasks routines (called by the Device Layer). 

The MSD Function Driver registers its own block operation event handler with the media drivers. Media Read and Write functions are called when the function driver receives a Sector Read or Sector Write request from the Host. The request will be tracked in the function driver Task routine. While the function driver waits for the media to complete the block operation, the function driver will NAK the data stage of the MSD data transfer request. 

The MSD Function Driver does not provide any events to the application. It is possible that the application may also open the media driver while they are already opened by the MSD Function Driver. If the application and the MSD Function Driver try to write to the same media driver, the result could be unpredictable. It is recommended that the application restrict write access to the media driver while the USB device is plugged into the Host. 

The application does not have to intervene in the functioning of the MSD Function Driver. Basically, the MSD Function Driver does provide any application callable functions.