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 ourproject m3PI_TP_SETI ... more

Committer:
WiredHome
Date:
Thu Oct 10 23:56:41 2013 +0000
Revision:
0:7304356c0790
File System interface for USB.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
WiredHome 0:7304356c0790 1 /* USB Mass Storage device file system
WiredHome 0:7304356c0790 2 * Copyrigh (c) 2010, Igor Skochinsky
WiredHome 0:7304356c0790 3 * based on SDFileStorage
WiredHome 0:7304356c0790 4 * Copyright (c) 2008-2009, sford
WiredHome 0:7304356c0790 5 */
WiredHome 0:7304356c0790 6
WiredHome 0:7304356c0790 7 #ifndef MSCFILESYSTEM_H
WiredHome 0:7304356c0790 8 #define MSCFILESYSTEM_H
WiredHome 0:7304356c0790 9
WiredHome 0:7304356c0790 10 #include "mbed.h"
WiredHome 0:7304356c0790 11 #include "FATFileSystem.h"
WiredHome 0:7304356c0790 12
WiredHome 0:7304356c0790 13 /* Class: MSCFileSystem
WiredHome 0:7304356c0790 14 * Access the filesystem on an attached USB mass storage device (e.g. a memory stick)
WiredHome 0:7304356c0790 15 *
WiredHome 0:7304356c0790 16 * Example:
WiredHome 0:7304356c0790 17 * > #include "MSCFileSystem.h"
WiredHome 0:7304356c0790 18 * >
WiredHome 0:7304356c0790 19 * > MSCFileSystem msc("msc");
WiredHome 0:7304356c0790 20 * >
WiredHome 0:7304356c0790 21 * > int main() {
WiredHome 0:7304356c0790 22 * > FILE *fp = fopen("/msc/myfile.txt", "w");
WiredHome 0:7304356c0790 23 * > fprintf(fp, "Hello World!\n");
WiredHome 0:7304356c0790 24 * > fclose(fp);
WiredHome 0:7304356c0790 25 * > }
WiredHome 0:7304356c0790 26 */
WiredHome 0:7304356c0790 27 class MSCFileSystem : public FATFileSystem {
WiredHome 0:7304356c0790 28 public:
WiredHome 0:7304356c0790 29
WiredHome 0:7304356c0790 30 /* Constructor: MSCFileSystem
WiredHome 0:7304356c0790 31 * Create the File System for accessing a USB mass storage device
WiredHome 0:7304356c0790 32 *
WiredHome 0:7304356c0790 33 * Parameters:
WiredHome 0:7304356c0790 34 * name - The name used to access the filesystem
WiredHome 0:7304356c0790 35 */
WiredHome 0:7304356c0790 36 MSCFileSystem(const char* name);
WiredHome 0:7304356c0790 37 virtual int disk_initialize();
WiredHome 0:7304356c0790 38 virtual int disk_write(const char *buffer, int block_number);
WiredHome 0:7304356c0790 39 virtual int disk_read(char *buffer, int block_number);
WiredHome 0:7304356c0790 40 virtual int disk_status();
WiredHome 0:7304356c0790 41 virtual int disk_sync();
WiredHome 0:7304356c0790 42 virtual int disk_sectors();
WiredHome 0:7304356c0790 43
WiredHome 0:7304356c0790 44 protected:
WiredHome 0:7304356c0790 45
WiredHome 0:7304356c0790 46 int initialise_msc();
WiredHome 0:7304356c0790 47 uint32_t _numBlks;
WiredHome 0:7304356c0790 48 uint32_t _blkSize;
WiredHome 0:7304356c0790 49 };
WiredHome 0:7304356c0790 50
WiredHome 0:7304356c0790 51 #endif