Revised to support both SD and USB file system

Dependents:   Multi-FileSystem Multi-FileSystem

Fork of MSCFileSystem by Chris Styles

Committer:
WiredHome
Date:
Mon Oct 17 00:57:08 2016 +0000
Revision:
10:4072b4b1c6f4
Parent:
8:c65b3b101292
Minor change in how a buffer was allocated in memory to not be hard-coded address.

Who changed what in which revision?

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