FATFileSystem

Dependents:   SDFileSystem

Fork of FatFileSystem by mbed unsupported

Committer:
robt
Date:
Fri May 24 22:12:43 2013 +0000
Revision:
4:52a829edb754
Parent:
0:97df4125f18d
by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_unsupported 0:97df4125f18d 1 /* mbed Microcontroller Library - FATFileSystem
mbed_unsupported 0:97df4125f18d 2 * Copyright (c) 2008, sford
mbed_unsupported 0:97df4125f18d 3 */
mbed_unsupported 0:97df4125f18d 4
mbed_unsupported 0:97df4125f18d 5 /* Library: FATFileSystem.h
mbed_unsupported 0:97df4125f18d 6 * A library of stuff to make a fat filesystem on top of a block device
mbed_unsupported 0:97df4125f18d 7 */
mbed_unsupported 0:97df4125f18d 8
mbed_unsupported 0:97df4125f18d 9 #ifndef MBED_FATFILESYSTEM_H
mbed_unsupported 0:97df4125f18d 10 #define MBED_FATFILESYSTEM_H
mbed_unsupported 0:97df4125f18d 11
mbed_unsupported 0:97df4125f18d 12 #ifndef FFSDEBUG_ENABLED
mbed_unsupported 0:97df4125f18d 13 #define FFSDEBUG_ENABLED 0
mbed_unsupported 0:97df4125f18d 14 #endif
mbed_unsupported 0:97df4125f18d 15
mbed_unsupported 0:97df4125f18d 16 #if FFSDEBUG_ENABLED
mbed_unsupported 0:97df4125f18d 17 #define FFSDEBUG(FMT, ...) printf(FMT, ##__VA_ARGS__)
mbed_unsupported 0:97df4125f18d 18 #else
mbed_unsupported 0:97df4125f18d 19 #define FFSDEBUG(FMT, ...)
mbed_unsupported 0:97df4125f18d 20 #endif
mbed_unsupported 0:97df4125f18d 21
mbed_unsupported 0:97df4125f18d 22 #include "FileSystemLike.h"
mbed_unsupported 0:97df4125f18d 23 #include "FileHandle.h"
mbed_unsupported 0:97df4125f18d 24 #include "ff.h"
mbed_unsupported 0:97df4125f18d 25 #include "diskio.h"
mbed_unsupported 0:97df4125f18d 26
mbed_unsupported 0:97df4125f18d 27 namespace mbed {
mbed_unsupported 0:97df4125f18d 28 /* Class: FATFileSystem
mbed_unsupported 0:97df4125f18d 29 * The class itself
mbed_unsupported 0:97df4125f18d 30 */
mbed_unsupported 0:97df4125f18d 31 class FATFileSystem : public FileSystemLike {
mbed_unsupported 0:97df4125f18d 32 public:
mbed_unsupported 0:97df4125f18d 33
robt 4:52a829edb754 34 FATFileSystem(const char* n);
robt 4:52a829edb754 35 virtual ~FATFileSystem();
robt 4:52a829edb754 36
robt 4:52a829edb754 37 /* Function: open
mbed_unsupported 0:97df4125f18d 38 * open a file on the filesystem. never called directly
mbed_unsupported 0:97df4125f18d 39 */
robt 4:52a829edb754 40 virtual FileHandle *open(const char* name, int flags);
robt 4:52a829edb754 41 virtual int remove(const char *filename);
robt 4:52a829edb754 42 virtual int format();
mbed_unsupported 0:97df4125f18d 43 virtual DirHandle *opendir(const char *name);
mbed_unsupported 0:97df4125f18d 44 virtual int mkdir(const char *name, mode_t mode);
robt 4:52a829edb754 45
robt 4:52a829edb754 46 FATFS _fs; // Work area (file system object) for logical drive
robt 4:52a829edb754 47 static FATFileSystem *_ffs[_DRIVES]; // FATFileSystem objects, as parallel to FatFs drives array
robt 4:52a829edb754 48 int _fsid;
robt 4:52a829edb754 49
robt 4:52a829edb754 50 virtual int disk_initialize() { return 0; }
robt 4:52a829edb754 51 virtual int disk_status() { return 0; }
robt 4:52a829edb754 52 virtual int disk_read(char *buffer, int sector) = 0;
robt 4:52a829edb754 53 virtual int disk_write(const char *buffer, int sector) = 0;
robt 4:52a829edb754 54 virtual int disk_sync() { return 0; }
robt 4:52a829edb754 55 virtual int disk_sectors() = 0;
robt 4:52a829edb754 56
mbed_unsupported 0:97df4125f18d 57 };
robt 4:52a829edb754 58
mbed_unsupported 0:97df4125f18d 59 }
mbed_unsupported 0:97df4125f18d 60
mbed_unsupported 0:97df4125f18d 61 #endif