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