Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
fatfs/FATFileSystem.h@0:9ad20223a8fa, 2012-07-17 (annotated)
- Committer:
- nherriot
- Date:
- Tue Jul 17 15:40:56 2012 +0000
- Revision:
- 0:9ad20223a8fa
[mbed] converted /VodaDemoDoorControl/VodafoneK3770Lib
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| nherriot | 0:9ad20223a8fa | 1 | /* mbed Microcontroller Library - FATFileSystem |
| nherriot | 0:9ad20223a8fa | 2 | * Copyright (c) 2008, sford |
| nherriot | 0:9ad20223a8fa | 3 | */ |
| nherriot | 0:9ad20223a8fa | 4 | |
| nherriot | 0:9ad20223a8fa | 5 | /* Library: FATFileSystem.h |
| nherriot | 0:9ad20223a8fa | 6 | * A library of stuff to make a fat filesystem on top of a block device |
| nherriot | 0:9ad20223a8fa | 7 | */ |
| nherriot | 0:9ad20223a8fa | 8 | |
| nherriot | 0:9ad20223a8fa | 9 | #ifndef MBED_FATFILESYSTEM_H |
| nherriot | 0:9ad20223a8fa | 10 | #define MBED_FATFILESYSTEM_H |
| nherriot | 0:9ad20223a8fa | 11 | |
| nherriot | 0:9ad20223a8fa | 12 | #ifndef FFSDEBUG_ENABLED |
| nherriot | 0:9ad20223a8fa | 13 | #define FFSDEBUG_ENABLED 0 |
| nherriot | 0:9ad20223a8fa | 14 | #endif |
| nherriot | 0:9ad20223a8fa | 15 | |
| nherriot | 0:9ad20223a8fa | 16 | #if FFSDEBUG_ENABLED |
| nherriot | 0:9ad20223a8fa | 17 | #define FFSDEBUG(FMT, ...) printf(FMT, ##__VA_ARGS__) |
| nherriot | 0:9ad20223a8fa | 18 | #else |
| nherriot | 0:9ad20223a8fa | 19 | #define FFSDEBUG(FMT, ...) |
| nherriot | 0:9ad20223a8fa | 20 | #endif |
| nherriot | 0:9ad20223a8fa | 21 | |
| nherriot | 0:9ad20223a8fa | 22 | #include "FileSystemLike.h" |
| nherriot | 0:9ad20223a8fa | 23 | #include "FileHandle.h" |
| nherriot | 0:9ad20223a8fa | 24 | #include "ff.h" |
| nherriot | 0:9ad20223a8fa | 25 | #include "diskio.h" |
| nherriot | 0:9ad20223a8fa | 26 | |
| nherriot | 0:9ad20223a8fa | 27 | namespace mbed { |
| nherriot | 0:9ad20223a8fa | 28 | /* Class: FATFileSystem |
| nherriot | 0:9ad20223a8fa | 29 | * The class itself |
| nherriot | 0:9ad20223a8fa | 30 | */ |
| nherriot | 0:9ad20223a8fa | 31 | class FATFileSystem : public FileSystemLike { |
| nherriot | 0:9ad20223a8fa | 32 | public: |
| nherriot | 0:9ad20223a8fa | 33 | |
| nherriot | 0:9ad20223a8fa | 34 | FATFileSystem(const char* n); |
| nherriot | 0:9ad20223a8fa | 35 | virtual ~FATFileSystem(); |
| nherriot | 0:9ad20223a8fa | 36 | |
| nherriot | 0:9ad20223a8fa | 37 | /* Function: open |
| nherriot | 0:9ad20223a8fa | 38 | * open a file on the filesystem. never called directly |
| nherriot | 0:9ad20223a8fa | 39 | */ |
| nherriot | 0:9ad20223a8fa | 40 | virtual FileHandle *open(const char* name, int flags); |
| nherriot | 0:9ad20223a8fa | 41 | virtual int remove(const char *filename); |
| nherriot | 0:9ad20223a8fa | 42 | virtual int format(); |
| nherriot | 0:9ad20223a8fa | 43 | virtual DirHandle *opendir(const char *name); |
| nherriot | 0:9ad20223a8fa | 44 | virtual int mkdir(const char *name, mode_t mode); |
| nherriot | 0:9ad20223a8fa | 45 | |
| nherriot | 0:9ad20223a8fa | 46 | FATFS _fs; // Work area (file system object) for logical drive |
| nherriot | 0:9ad20223a8fa | 47 | static FATFileSystem *_ffs[_DRIVES]; // FATFileSystem objects, as parallel to FatFs drives array |
| nherriot | 0:9ad20223a8fa | 48 | int _fsid; |
| nherriot | 0:9ad20223a8fa | 49 | |
| nherriot | 0:9ad20223a8fa | 50 | virtual int disk_initialize() { return 0; } |
| nherriot | 0:9ad20223a8fa | 51 | virtual int disk_status() { return 0; } |
| nherriot | 0:9ad20223a8fa | 52 | virtual int disk_read(char *buffer, int sector) = 0; |
| nherriot | 0:9ad20223a8fa | 53 | virtual int disk_write(const char *buffer, int sector) = 0; |
| nherriot | 0:9ad20223a8fa | 54 | virtual int disk_sync() { return 0; } |
| nherriot | 0:9ad20223a8fa | 55 | virtual int disk_sectors() = 0; |
| nherriot | 0:9ad20223a8fa | 56 | |
| nherriot | 0:9ad20223a8fa | 57 | }; |
| nherriot | 0:9ad20223a8fa | 58 | |
| nherriot | 0:9ad20223a8fa | 59 | } |
| nherriot | 0:9ad20223a8fa | 60 | |
| nherriot | 0:9ad20223a8fa | 61 | #endif |