Uses a more recent version of official mbed libraries than that of Neil Thiessen
Dependencies: FATFileSystem
Dependents: ThermalWake STM32F407VET6_SDCard STM32F407VET6_SD_HTTP_Server ZZ_SSL_Main_L476 ... more
Fork of SDFileSystem by
FATFileSystem/FATFileSystem.h@11:67ddc53e3983, 2014-08-14 (annotated)
- Committer:
- neilt6
- Date:
- Thu Aug 14 22:27:07 2014 +0000
- Revision:
- 11:67ddc53e3983
Major performance improvements with custom FATFileSystem
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
neilt6 | 11:67ddc53e3983 | 1 | /* mbed Microcontroller Library |
neilt6 | 11:67ddc53e3983 | 2 | * Copyright (c) 2006-2012 ARM Limited |
neilt6 | 11:67ddc53e3983 | 3 | * |
neilt6 | 11:67ddc53e3983 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
neilt6 | 11:67ddc53e3983 | 5 | * of this software and associated documentation files (the "Software"), to deal |
neilt6 | 11:67ddc53e3983 | 6 | * in the Software without restriction, including without limitation the rights |
neilt6 | 11:67ddc53e3983 | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
neilt6 | 11:67ddc53e3983 | 8 | * copies of the Software, and to permit persons to whom the Software is |
neilt6 | 11:67ddc53e3983 | 9 | * furnished to do so, subject to the following conditions: |
neilt6 | 11:67ddc53e3983 | 10 | * |
neilt6 | 11:67ddc53e3983 | 11 | * The above copyright notice and this permission notice shall be included in |
neilt6 | 11:67ddc53e3983 | 12 | * all copies or substantial portions of the Software. |
neilt6 | 11:67ddc53e3983 | 13 | * |
neilt6 | 11:67ddc53e3983 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
neilt6 | 11:67ddc53e3983 | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
neilt6 | 11:67ddc53e3983 | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
neilt6 | 11:67ddc53e3983 | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
neilt6 | 11:67ddc53e3983 | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
neilt6 | 11:67ddc53e3983 | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
neilt6 | 11:67ddc53e3983 | 20 | * SOFTWARE. |
neilt6 | 11:67ddc53e3983 | 21 | */ |
neilt6 | 11:67ddc53e3983 | 22 | #ifndef MBED_FATFILESYSTEM_H |
neilt6 | 11:67ddc53e3983 | 23 | #define MBED_FATFILESYSTEM_H |
neilt6 | 11:67ddc53e3983 | 24 | |
neilt6 | 11:67ddc53e3983 | 25 | #include "FileSystemLike.h" |
neilt6 | 11:67ddc53e3983 | 26 | #include "FileHandle.h" |
neilt6 | 11:67ddc53e3983 | 27 | #include "ff.h" |
neilt6 | 11:67ddc53e3983 | 28 | #include <stdint.h> |
neilt6 | 11:67ddc53e3983 | 29 | |
neilt6 | 11:67ddc53e3983 | 30 | using namespace mbed; |
neilt6 | 11:67ddc53e3983 | 31 | |
neilt6 | 11:67ddc53e3983 | 32 | /** |
neilt6 | 11:67ddc53e3983 | 33 | * FATFileSystem based on ChaN's Fat Filesystem library v0.8 |
neilt6 | 11:67ddc53e3983 | 34 | */ |
neilt6 | 11:67ddc53e3983 | 35 | class FATFileSystem : public FileSystemLike { |
neilt6 | 11:67ddc53e3983 | 36 | public: |
neilt6 | 11:67ddc53e3983 | 37 | |
neilt6 | 11:67ddc53e3983 | 38 | FATFileSystem(const char* n); |
neilt6 | 11:67ddc53e3983 | 39 | virtual ~FATFileSystem(); |
neilt6 | 11:67ddc53e3983 | 40 | |
neilt6 | 11:67ddc53e3983 | 41 | static FATFileSystem * _ffs[_VOLUMES]; // FATFileSystem objects, as parallel to FatFs drives array |
neilt6 | 11:67ddc53e3983 | 42 | FATFS _fs; // Work area (file system object) for logical drive |
neilt6 | 11:67ddc53e3983 | 43 | int _fsid; |
neilt6 | 11:67ddc53e3983 | 44 | |
neilt6 | 11:67ddc53e3983 | 45 | /** |
neilt6 | 11:67ddc53e3983 | 46 | * Opens a file on the filesystem |
neilt6 | 11:67ddc53e3983 | 47 | */ |
neilt6 | 11:67ddc53e3983 | 48 | virtual FileHandle *open(const char* name, int flags); |
neilt6 | 11:67ddc53e3983 | 49 | |
neilt6 | 11:67ddc53e3983 | 50 | /** |
neilt6 | 11:67ddc53e3983 | 51 | * Removes a file path |
neilt6 | 11:67ddc53e3983 | 52 | */ |
neilt6 | 11:67ddc53e3983 | 53 | virtual int remove(const char *filename); |
neilt6 | 11:67ddc53e3983 | 54 | |
neilt6 | 11:67ddc53e3983 | 55 | /** |
neilt6 | 11:67ddc53e3983 | 56 | * Formats a logical drive, FDISK artitioning rule, 512 bytes per cluster |
neilt6 | 11:67ddc53e3983 | 57 | */ |
neilt6 | 11:67ddc53e3983 | 58 | virtual int format(); |
neilt6 | 11:67ddc53e3983 | 59 | |
neilt6 | 11:67ddc53e3983 | 60 | /** |
neilt6 | 11:67ddc53e3983 | 61 | * Opens a directory on the filesystem |
neilt6 | 11:67ddc53e3983 | 62 | */ |
neilt6 | 11:67ddc53e3983 | 63 | virtual DirHandle *opendir(const char *name); |
neilt6 | 11:67ddc53e3983 | 64 | |
neilt6 | 11:67ddc53e3983 | 65 | /** |
neilt6 | 11:67ddc53e3983 | 66 | * Creates a directory path |
neilt6 | 11:67ddc53e3983 | 67 | */ |
neilt6 | 11:67ddc53e3983 | 68 | virtual int mkdir(const char *name, mode_t mode); |
neilt6 | 11:67ddc53e3983 | 69 | |
neilt6 | 11:67ddc53e3983 | 70 | /** |
neilt6 | 11:67ddc53e3983 | 71 | * Mounts the filesystem |
neilt6 | 11:67ddc53e3983 | 72 | */ |
neilt6 | 11:67ddc53e3983 | 73 | virtual int mount(); |
neilt6 | 11:67ddc53e3983 | 74 | |
neilt6 | 11:67ddc53e3983 | 75 | /** |
neilt6 | 11:67ddc53e3983 | 76 | * Unmounts the filesystem |
neilt6 | 11:67ddc53e3983 | 77 | */ |
neilt6 | 11:67ddc53e3983 | 78 | virtual int unmount(); |
neilt6 | 11:67ddc53e3983 | 79 | |
neilt6 | 11:67ddc53e3983 | 80 | virtual int disk_initialize() { return 0; } |
neilt6 | 11:67ddc53e3983 | 81 | virtual int disk_status() { return 0; } |
neilt6 | 11:67ddc53e3983 | 82 | virtual int disk_read(uint8_t * buffer, uint64_t sector, uint8_t count) = 0; |
neilt6 | 11:67ddc53e3983 | 83 | virtual int disk_write(const uint8_t * buffer, uint64_t sector, uint8_t count) = 0; |
neilt6 | 11:67ddc53e3983 | 84 | virtual int disk_sync() { return 0; } |
neilt6 | 11:67ddc53e3983 | 85 | virtual uint64_t disk_sectors() = 0; |
neilt6 | 11:67ddc53e3983 | 86 | |
neilt6 | 11:67ddc53e3983 | 87 | }; |
neilt6 | 11:67ddc53e3983 | 88 | |
neilt6 | 11:67ddc53e3983 | 89 | #endif |