My firmware writes data to the SDCard (using MFS), and then I connect to Windows through USB -using the MSD driver to upload the data into a PC.
I didn't unmount MFS, I just connected partion manager directly to the USB (after I do a 512byte - 64 byte cache routine), because partion manager uses 512 byte blocks and USB uses 64 byte transfers.
I just write whatever data is passed to me, and read whatever is requested using addresses
*** Here is a snippet from my USB driver ********
case USB_MSC_DEVICE_READ_REQUEST :
/* copy data from storage device before sending it on USB Bus
(Called before calling send_data on BULK IN endpoints)*/
lba_data_ptr = (PTR_LBA_APP_STRUCT)val;
/* read data from mass storage device to driver buffer */
SDCard_Read_Blocks(lba_data_ptr->buff_ptr,(int32_t)lba_data_ptr->size, (int32_t)lba_data_ptr->offset);
break;
case USB_MSC_DEVICE_WRITE_REQUEST :
/* copy data from USb buffer to Storage device
(Called before after recv_data on BULK OUT endpoints)*/
lba_data_ptr = (PTR_LBA_APP_STRUCT)val;
/* read data from driver buffer to mass storage device */
SDCard_Write_Blocks(lba_data_ptr->buff_ptr,(int32_t)lba_data_ptr->size, (int32_t)lba_data_ptr->offset);
break;
***** Here is a snippet from the 512byte - 64 byte cache routine *******
/* I know that the api calls for number of bytes
but the driver expects number of blocks
so 1 is correct not 512*/
status =_io_read(partman_handle, sdCache.cache, 1) ;