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