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