Christian Lerche
/
EA_DoorPlayer
EA BaseBoard, playing wav, PC see\'s SD-card through USB port.
ChaNFS/FATFileSystem.h@0:fef366d2ed20, 2011-11-22 (annotated)
- Committer:
- Lerche
- Date:
- Tue Nov 22 05:45:58 2011 +0000
- Revision:
- 0:fef366d2ed20
Thanks to those who provided EA_WavPlayer and USB_MSC
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Lerche | 0:fef366d2ed20 | 1 | /* mbed Microcontroller Library - FATFileSystem |
Lerche | 0:fef366d2ed20 | 2 | * Copyright (c) 2008, sford |
Lerche | 0:fef366d2ed20 | 3 | */ |
Lerche | 0:fef366d2ed20 | 4 | |
Lerche | 0:fef366d2ed20 | 5 | /* Library: FATFileSystem.h |
Lerche | 0:fef366d2ed20 | 6 | * A library of stuff to make a fat filesystem on top of a block device |
Lerche | 0:fef366d2ed20 | 7 | */ |
Lerche | 0:fef366d2ed20 | 8 | |
Lerche | 0:fef366d2ed20 | 9 | #ifndef MBED_FATFILESYSTEM_H |
Lerche | 0:fef366d2ed20 | 10 | #define MBED_FATFILESYSTEM_H |
Lerche | 0:fef366d2ed20 | 11 | |
Lerche | 0:fef366d2ed20 | 12 | #ifndef FFSDEBUG_ENABLED |
Lerche | 0:fef366d2ed20 | 13 | #define FFSDEBUG_ENABLED 0 |
Lerche | 0:fef366d2ed20 | 14 | #endif |
Lerche | 0:fef366d2ed20 | 15 | |
Lerche | 0:fef366d2ed20 | 16 | #if FFSDEBUG_ENABLED |
Lerche | 0:fef366d2ed20 | 17 | #define FFSDEBUG(FMT, ...) printf(FMT, ##__VA_ARGS__) |
Lerche | 0:fef366d2ed20 | 18 | #else |
Lerche | 0:fef366d2ed20 | 19 | #define FFSDEBUG(FMT, ...) |
Lerche | 0:fef366d2ed20 | 20 | #endif |
Lerche | 0:fef366d2ed20 | 21 | |
Lerche | 0:fef366d2ed20 | 22 | #include "FileSystemLike.h" |
Lerche | 0:fef366d2ed20 | 23 | #include "FileHandle.h" |
Lerche | 0:fef366d2ed20 | 24 | #include "ff.h" |
Lerche | 0:fef366d2ed20 | 25 | #include "diskio.h" |
Lerche | 0:fef366d2ed20 | 26 | |
Lerche | 0:fef366d2ed20 | 27 | namespace mbed { |
Lerche | 0:fef366d2ed20 | 28 | /* Class: FATFileSystem |
Lerche | 0:fef366d2ed20 | 29 | * The class itself |
Lerche | 0:fef366d2ed20 | 30 | */ |
Lerche | 0:fef366d2ed20 | 31 | class FATFileSystem : public FileSystemLike { |
Lerche | 0:fef366d2ed20 | 32 | public: |
Lerche | 0:fef366d2ed20 | 33 | |
Lerche | 0:fef366d2ed20 | 34 | FATFileSystem(const char* n); |
Lerche | 0:fef366d2ed20 | 35 | virtual ~FATFileSystem(); |
Lerche | 0:fef366d2ed20 | 36 | |
Lerche | 0:fef366d2ed20 | 37 | /* Function: open |
Lerche | 0:fef366d2ed20 | 38 | * open a file on the filesystem. never called directly |
Lerche | 0:fef366d2ed20 | 39 | */ |
Lerche | 0:fef366d2ed20 | 40 | virtual FileHandle *open(const char* name, int flags); |
Lerche | 0:fef366d2ed20 | 41 | virtual int remove(const char *filename); |
Lerche | 0:fef366d2ed20 | 42 | virtual int format(); |
Lerche | 0:fef366d2ed20 | 43 | virtual DirHandle *opendir(const char *name); |
Lerche | 0:fef366d2ed20 | 44 | virtual int mkdir(const char *name, mode_t mode); |
Lerche | 0:fef366d2ed20 | 45 | |
Lerche | 0:fef366d2ed20 | 46 | FATFS _fs; // Work area (file system object) for logical drive |
Lerche | 0:fef366d2ed20 | 47 | static FATFileSystem *_ffs[_DRIVES]; // FATFileSystem objects, as parallel to FatFs drives array |
Lerche | 0:fef366d2ed20 | 48 | int _fsid; |
Lerche | 0:fef366d2ed20 | 49 | |
Lerche | 0:fef366d2ed20 | 50 | virtual int disk_initialize() { return 0; } |
Lerche | 0:fef366d2ed20 | 51 | virtual int disk_status() { return 0; } |
Lerche | 0:fef366d2ed20 | 52 | virtual int disk_read(char *buffer, int sector) = 0; |
Lerche | 0:fef366d2ed20 | 53 | virtual int disk_write(const char *buffer, int sector) = 0; |
Lerche | 0:fef366d2ed20 | 54 | virtual int disk_sync() { return 0; } |
Lerche | 0:fef366d2ed20 | 55 | virtual int disk_sectors() = 0; |
Lerche | 0:fef366d2ed20 | 56 | |
Lerche | 0:fef366d2ed20 | 57 | }; |
Lerche | 0:fef366d2ed20 | 58 | |
Lerche | 0:fef366d2ed20 | 59 | } |
Lerche | 0:fef366d2ed20 | 60 | |
Lerche | 0:fef366d2ed20 | 61 | #endif |