A File System interface that incorporates both SD and USB support. It was difficult to find a ready-to-go library, but the right set of pieces from others, and a few modifications, created this.

Dependencies:   FatFileSystemCpp USBHostLite

Dependents:   m3PI_TP_POPS_II2015v0 m3PI_TP_POPS_II2015v0 m3PI_TP1_SETI2018 ourproject ... more

MSCFileSystem.h

Committer:
bouaziz
Date:
2013-11-10
Revision:
2:5bc5d2b70622
Parent:
0:7304356c0790

File content as of revision 2:5bc5d2b70622:

/* USB Mass Storage device file system
 * Copyrigh (c) 2010, Igor Skochinsky
 * based on SDFileStorage
 * Copyright (c) 2008-2009, sford
 */
 
#ifndef MSCFILESYSTEM_H
#define MSCFILESYSTEM_H

#include "mbed.h"
#include "FATFileSystem.h"

/* Class: MSCFileSystem
 *  Access the filesystem on an attached USB mass storage device (e.g. a memory stick)
 *
 * Example:
 * > #include "MSCFileSystem.h"
 * >
 * > MSCFileSystem msc("msc");
 * > 
 * > int main() {
 * >     FILE *fp = fopen("/msc/myfile.txt", "w");
 * >     fprintf(fp, "Hello World!\n");
 * >     fclose(fp);
 * > }
 */
class MSCFileSystem : public FATFileSystem {
public:

    /* Constructor: MSCFileSystem
     *  Create the File System for accessing a USB mass storage device
     *
     * Parameters:
     *  name - The name used to access the filesystem
     */
    MSCFileSystem(const char* name);
    virtual int disk_initialize();
    virtual int disk_write(const char *buffer, int block_number);
    virtual int disk_read(char *buffer, int block_number);    
    virtual int disk_status();
    virtual int disk_sync();
    virtual int disk_sectors();

protected:

    int initialise_msc();
    uint32_t _numBlks;
    uint32_t _blkSize;
};

#endif