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